diff --git a/mbstring/mbstring.php b/mbstring/mbstring.php index 561d466aa..3e8aa28e3 100644 --- a/mbstring/mbstring.php +++ b/mbstring/mbstring.php @@ -199,7 +199,7 @@ function mb_substitute_character(string|int|null $substitute_character = null): *

* @return bool true on success or false on failure. */ -#[PhpStormStubsElementAvailable(to: '7.4')] +#[PhpStormStubsElementAvailable(from: '5.3', to: '7.4')] function mb_parse_str(string $string, &$result): bool {} /** @@ -213,7 +213,7 @@ function mb_parse_str(string $string, &$result): bool {} *

* @return bool true on success or false on failure. */ -#[PhpStormStubsElementAvailable('8.0')] +#[PhpStormStubsElementAvailable(from: '8.0')] function mb_parse_str(string $string, &$result): bool {} /** diff --git a/runTests.sh b/runTests.sh new file mode 100755 index 000000000..fa3d3a1dd --- /dev/null +++ b/runTests.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +echo "Installing composer packages..." +docker-compose -f docker-compose.yml run test_runner composer install -d /opt/project/phpstorm-stubs --ignore-platform-reqs +phpVersions=("7.1" "7.2" "7.3" "7.4" "8.0" "8.1") +for i in "${phpVersions[@]}" +do + export PHP_VERSION=$i + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + cd "$SCRIPT_DIR" || exit + echo "Building docker container for PHP_$i..." + docker-compose -f docker-compose.yml build >/dev/null + echo "Dumping reflection data to file $SCRIPT_DIR/ReflectionData.json for PHP_$i..." + docker-compose -f docker-compose.yml run -e PHP_VERSION="$i" php_under_test /usr/local/bin/php /opt/project/phpstorm-stubs/tests/Tools/dump-reflection-to-file.php + echo "Running tests agains PHP_$i..." + docker-compose -f docker-compose.yml run -e PHP_VERSION="$i" test_runner /opt/project/phpstorm-stubs/vendor/bin/phpunit --configuration /opt/project/phpstorm-stubs/phpunit.xml --testsuite PHP_"$i" + echo "Removing file $SCRIPT_DIR/ReflectionData.json with reflection data for PHP_$i..." + rm -f "$SCRIPT_DIR/ReflectionData.json" +done diff --git a/tests/BaseClassesTest.php b/tests/BaseClassesTest.php index 6af683371..dff53d2f4 100644 --- a/tests/BaseClassesTest.php +++ b/tests/BaseClassesTest.php @@ -53,11 +53,7 @@ public function testClassesMethodsExist(PHPClass|PHPInterface $class, PHPMethod } else { $stubClass = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($className); } - static::assertArrayHasKey( - $method->name, - $stubClass->methods, - "Missing method $className::$method->name" - ); + static::assertNotEmpty($stubClass->getMethod($method->name), "Missing method $className::$method->name"); } /** @@ -155,7 +151,7 @@ function ($parameter) { public function testClassInterfaces(PHPClass $class) { $className = $class->name; - $stubClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name, null, false); + $stubClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name, shouldSuitCurrentPhpVersion: false); foreach ($class->interfaces as $interface) { static::assertContains( $interface, @@ -173,13 +169,9 @@ public function testClassProperties(PHPClass $class, PHPProperty $property) { $className = $class->name; $stubClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name); - static::assertArrayHasKey( - $property->name, - $stubClass->properties, - "Missing property $property->access " + static::assertNotEmpty($stubClass->getProperty($property->name), "Missing property $property->access " . implode('|', $property->typesFromSignature) . - "$className::$$property->name" - ); + "$className::$$property->name"); } /** @@ -256,10 +248,10 @@ public function testClassesExist(PHPClass|PHPInterface $class): void { $className = $class->name; if ($class instanceof PHPClass) { - $stubClasses = PhpStormStubsSingleton::getPhpStormStubs()->getClasses(); + $stubClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($className); } else { - $stubClasses = PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); + $stubClass = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($className); } - static::assertArrayHasKey($className, $stubClasses, "Missing class $className: class $className {}"); + static::assertNotEmpty($className, "Missing class $className: class $className {}"); } } diff --git a/tests/BaseConstantsTest.php b/tests/BaseConstantsTest.php index 7c3453314..bd9b22095 100644 --- a/tests/BaseConstantsTest.php +++ b/tests/BaseConstantsTest.php @@ -20,10 +20,9 @@ public function testConstants(PHPConst $constant): void { $constantName = $constant->name; $constantValue = $constant->value; - $stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getConstants(); - static::assertArrayHasKey( - $constantName, - $stubConstants, + $stubConstant = PhpStormStubsSingleton::getPhpStormStubs()->getConstant($constantName); + static::assertNotEmpty( + $stubConstant, "Missing constant: const $constantName = $constantValue\n" ); } @@ -37,13 +36,12 @@ public function testClassConstants(PHPClass|PHPInterface $class, PHPConst $const $constantName = $constant->name; $constantValue = $constant->value; if ($class instanceof PHPClass) { - $stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name)->constants; + $stubConstant = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name)->getConstant($constantName); } else { - $stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($class->name)->constants; + $stubConstant = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($class->name)->getConstant($constantName); } - static::assertArrayHasKey( - $constantName, - $stubConstants, + static::assertNotEmpty( + $stubConstant, "Missing constant: const $constantName = $constantValue\n" ); } diff --git a/tests/BaseFunctionsTest.php b/tests/BaseFunctionsTest.php index 11acf45cf..a9e3607b3 100644 --- a/tests/BaseFunctionsTest.php +++ b/tests/BaseFunctionsTest.php @@ -19,26 +19,26 @@ class BaseFunctionsTest extends BaseStubsTest { /** * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionFunctionsProvider::allFunctionsProvider - * @throws Exception + * @throws Exception|RuntimeException */ public function testFunctionsExist(PHPFunction $function): void { $functionName = $function->name; - $stubFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); + $stubFunction = PhpStormStubsSingleton::getPhpStormStubs()->getFunction($functionName); $params = BaseStubsTest::getParameterRepresentation($function); - static::assertArrayHasKey($functionName, $stubFunctions, "Missing function: function $functionName($params){}"); + static::assertNotEmpty($stubFunction, "Missing function: function $functionName($params){}"); } /** * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionFunctionsProvider::functionsForDeprecationTestsProvider + * @throws RuntimeException */ public function testFunctionsDeprecation(PHPFunction $function) { $functionName = $function->name; - $stubFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); - $phpstormFunction = $stubFunctions[$functionName]; + $stubFunction = PhpStormStubsSingleton::getPhpStormStubs()->getFunction($functionName); static::assertFalse( - $function->is_deprecated && $phpstormFunction->is_deprecated !== true, + $function->is_deprecated && $stubFunction->is_deprecated !== true, "Function $functionName is not deprecated in stubs" ); } @@ -50,10 +50,9 @@ public function testFunctionsDeprecation(PHPFunction $function) public function testFunctionsParametersAmount(PHPFunction $function) { $functionName = $function->name; - $stubFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); - $phpstormFunction = $stubFunctions[$functionName]; + $stubFunction = PhpStormStubsSingleton::getPhpStormStubs()->getFunction($functionName); $filteredStubParameters = array_filter( - $phpstormFunction->parameters, + $stubFunction->parameters, fn ($parameter) => BasePHPElement::entitySuitsCurrentPhpVersion($parameter) ); $uniqueParameterNames = array_unique(array_map(fn (PHPParameter $parameter) => $parameter->name, $filteredStubParameters)); @@ -63,7 +62,7 @@ public function testFunctionsParametersAmount(PHPFunction $function) $uniqueParameterNames, "Parameter number mismatch for function $functionName. Expected: " . BaseStubsTest::getParameterRepresentation($function) . "\n" . - 'Actual: ' . BaseStubsTest::getParameterRepresentation($phpstormFunction) + 'Actual: ' . BaseStubsTest::getParameterRepresentation($stubFunction) ); } diff --git a/tests/BaseStubsTest.php b/tests/BaseStubsTest.php index 2172b5255..16bc67dba 100644 --- a/tests/BaseStubsTest.php +++ b/tests/BaseStubsTest.php @@ -42,12 +42,7 @@ public static function getStringRepresentationOfDefaultParameterValue(mixed $def if ($defaultValue instanceof ConstFetch) { $defaultValueName = (string)$defaultValue->name; if ($defaultValueName !== 'false' && $defaultValueName !== 'true' && $defaultValueName !== 'null') { - $constants = array_filter( - PhpStormStubsSingleton::getPhpStormStubs()->getConstants(), - fn (PHPConst $const) => $const->name === (string)$defaultValue->name - ); - /** @var PHPConst $constant */ - $constant = array_pop($constants); + $constant = PhpStormStubsSingleton::getPhpStormStubs()->getConstant($defaultValueName); $value = $constant->value; } else { $value = $defaultValueName; @@ -87,9 +82,7 @@ public static function getStringRepresentationOfDefaultParameterValue(mixed $def if ((string)$defaultValue->name === 'class') { $value = (string)$defaultValue->class; } else { - $constants = array_filter($parentClass->constants, fn (PHPConst $const) => $const->name === (string)$defaultValue->name); - /** @var PHPConst $constant */ - $constant = array_pop($constants); + $constant = $parentClass->getConstant((string)$defaultValue->name);; $value = $constant->value; } } else { @@ -127,7 +120,7 @@ protected static function getDuplicatedFunctions(array $filtered): array $duplicatedFunctions = array_filter($filtered, function (PHPFunction $value, int|string $key) { $duplicatesOfFunction = self::getAllDuplicatesOfFunction($value->name); $functionVersions[] = ParserUtils::getAvailableInVersions( - PhpStormStubsSingleton::getPhpStormStubs()->getFunction($value->name) + PhpStormStubsSingleton::getPhpStormStubs()->getFunction($value->name, shouldSuitCurrentPhpVersion: false) ); array_push($functionVersions, ...array_values(array_map( fn (PHPFunction $function) => ParserUtils::getAvailableInVersions($function), diff --git a/tests/Model/PHPMethod.php b/tests/Model/PHPMethod.php index ebb0767ef..77af96f5f 100644 --- a/tests/Model/PHPMethod.php +++ b/tests/Model/PHPMethod.php @@ -8,7 +8,6 @@ use ReflectionMethod; use RuntimeException; use stdClass; -use StubTests\Parsers\ParserUtils; class PHPMethod extends PHPFunction { @@ -77,7 +76,7 @@ public function readObjectFromStubNode($node) $index = 0; foreach ($node->getParams() as $parameter) { $parsedParameter = (new PHPParameter())->readObjectFromStubNode($parameter); - if (in_array(doubleval(getenv('PHP_VERSION')), ParserUtils::getAvailableInVersions($parsedParameter))) { + if (self::entitySuitsCurrentPhpVersion($parsedParameter)) { $parsedParameter->indexInSignature = $index; $this->parameters[] = $parsedParameter; $index++; diff --git a/tests/Model/PHPProperty.php b/tests/Model/PHPProperty.php index 6fd85446b..4083bf77c 100644 --- a/tests/Model/PHPProperty.php +++ b/tests/Model/PHPProperty.php @@ -13,7 +13,7 @@ class PHPProperty extends BasePHPElement /** @var string[] */ public $typesFromSignature = []; - /** @var string[] */ + /** @var string[][] */ public $typesFromAttribute = []; /** @var string[] */ public $typesFromPhpDoc = []; diff --git a/tests/Model/StubsContainer.php b/tests/Model/StubsContainer.php index a4fb38988..5f03bf516 100644 --- a/tests/Model/StubsContainer.php +++ b/tests/Model/StubsContainer.php @@ -89,22 +89,27 @@ public function getFunctions(): array /** * @param string $name * @param string|null $sourceFilePath + * @param bool $shouldSuitCurrentPhpVersion * @return PHPFunction|null * @throws RuntimeException */ - public function getFunction(string $name, ?string $sourceFilePath = null): ?PHPFunction + public function getFunction(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPFunction { - $functions = array_filter($this->functions, function (PHPFunction $function) use ($name): bool { - return $function->name === $name && $function->duplicateOtherElement === false - && BasePHPElement::entitySuitsCurrentPhpVersion($function); + $functions = array_filter($this->functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $name): bool { + return $function->name === $name && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); }); + if (count($functions) > 1) { + $functions = array_filter($functions, function (PHPFunction $function): bool { + return $function->duplicateOtherElement === false; + }); + } if (count($functions) === 1) { return array_pop($functions); } else { if ($sourceFilePath !== null) { - $functions = array_filter($functions, function (PHPFunction $function) use ($sourceFilePath) { + $functions = array_filter($functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { return $function->sourceFilePath === $sourceFilePath - && BasePHPElement::entitySuitsCurrentPhpVersion($function); + && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); }); } if (count($functions) > 1) { @@ -146,23 +151,23 @@ public function getClasses(): array /** * @param string $name * @param string|null $sourceFilePath - * @param bool $shouldSuiteCurrentPhpVersion + * @param bool $shouldSuitCurrentPhpVersion * @return PHPClass|null * @throws RuntimeException */ - public function getClass(string $name, ?string $sourceFilePath = null, bool $shouldSuiteCurrentPhpVersion = true): ?PHPClass + public function getClass(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPClass { - $classes = array_filter($this->classes, function (PHPClass $class) use ($shouldSuiteCurrentPhpVersion, $name): bool { + $classes = array_filter($this->classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $name): bool { return $class->name === $name && - (!$shouldSuiteCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); + (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); }); if (count($classes) === 1) { return array_pop($classes); } else { if ($sourceFilePath !== null) { - $classes = array_filter($classes, function (PHPClass $class) use ($shouldSuiteCurrentPhpVersion, $sourceFilePath) { + $classes = array_filter($classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { return $class->sourceFilePath === $sourceFilePath && - (!$shouldSuiteCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); + (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); }); } if (count($classes) > 1) { diff --git a/tests/Parsers/ParserUtils.php b/tests/Parsers/ParserUtils.php index cbc58664b..cb29b1230 100644 --- a/tests/Parsers/ParserUtils.php +++ b/tests/Parsers/ParserUtils.php @@ -129,7 +129,7 @@ private static function getLatestAvailableVersionFromPhpDoc(BasePHPElement $elem */ private static function getSinceVersionsFromParentClass(PHPMethod|PHPConst $element): array { - $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($element->parentName, shouldSuiteCurrentPhpVersion: false); + $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($element->parentName, shouldSuitCurrentPhpVersion: false); if ($parentClass === null) { $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($element->parentName, shouldSuitCurrentPhpVersion: false); } @@ -144,7 +144,7 @@ private static function getSinceVersionsFromParentClass(PHPMethod|PHPConst $elem */ public static function getLatestAvailableVersionsFromParentClass(PHPMethod|PHPConst $element): array { - $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($element->parentName, shouldSuiteCurrentPhpVersion: false); + $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($element->parentName, shouldSuitCurrentPhpVersion: false); if ($parentClass === null) { $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($element->parentName, shouldSuitCurrentPhpVersion: false); } diff --git a/tests/StubsConstantsAndParametersValuesTest.php b/tests/StubsConstantsAndParametersValuesTest.php index 65a3bb0e3..018da3130 100644 --- a/tests/StubsConstantsAndParametersValuesTest.php +++ b/tests/StubsConstantsAndParametersValuesTest.php @@ -22,12 +22,12 @@ public function testConstantsValues(PHPConst $constant): void { $constantName = $constant->name; $constantValue = $constant->value; - $stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getConstants(); + $stubConstant = PhpStormStubsSingleton::getPhpStormStubs()->getConstant($constantName); self::assertEquals( $constantValue, - $stubConstants[$constantName]->value, + $stubConstant->value, "Constant value mismatch: const $constantName \n - Expected value: $constantValue but was {$stubConstants[$constantName]->value}" + Expected value: $constantValue but was $stubConstant->value" ); } diff --git a/tests/StubsReflectionClassesTest.php b/tests/StubsReflectionClassesTest.php index 4b45e384c..711fdad4a 100644 --- a/tests/StubsReflectionClassesTest.php +++ b/tests/StubsReflectionClassesTest.php @@ -5,7 +5,6 @@ use PHPUnit\Framework\Exception; use RuntimeException; -use StubTests\Model\PHPMethod; use StubTests\TestData\Providers\PhpStormStubsSingleton; /** @@ -18,10 +17,7 @@ class StubsReflectionClassesTest extends BaseStubsTest */ public function testReflectionFunctionAbstractGetReturnTypeMethod() { - $getReturnTypeMethods = array_filter(PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionFunctionAbstract') - ->methods, fn (PHPMethod $method) => $method->name === 'getReturnType'); - /** @var PHPMethod $getReturnTypeMethod */ - $getReturnTypeMethod = array_pop($getReturnTypeMethods); + $getReturnTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionFunctionAbstract')->getMethod('getReturnType'); $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getReturnTypeMethod->returnTypesFromAttribute + $getReturnTypeMethod->returnTypesFromSignature + $getReturnTypeMethod->returnTypesFromPhpDoc, false)); self::assertContains( @@ -46,10 +42,7 @@ public function testReflectionFunctionAbstractGetReturnTypeMethod() */ public function testReflectionPropertyGetTypeMethod() { - $getTypeMethods = array_filter(PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionProperty') - ->methods, fn (PHPMethod $method) => $method->name === 'getType'); - /** @var PHPMethod $getTypeMethod */ - $getTypeMethod = array_pop($getTypeMethods); + $getTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionProperty')->getMethod('getType'); $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getTypeMethod->returnTypesFromAttribute + $getTypeMethod->returnTypesFromSignature + $getTypeMethod->returnTypesFromPhpDoc, false)); self::assertContains( @@ -69,10 +62,7 @@ public function testReflectionPropertyGetTypeMethod() */ public function testReflectionParameterGetTypeMethod() { - $getTypeMethods = array_filter(PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionParameter') - ->methods, fn (PHPMethod $method) => $method->name === 'getType'); - /** @var PHPMethod $getTypeMethod */ - $getTypeMethod = array_pop($getTypeMethods); + $getTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionParameter')->getMethod('getType'); $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getTypeMethod->returnTypesFromAttribute + $getTypeMethod->returnTypesFromSignature + $getTypeMethod->returnTypesFromPhpDoc, false)); self::assertContains( diff --git a/tests/StubsTypeHintsTest.php b/tests/StubsTypeHintsTest.php index 8bfb6e2e5..489c40f74 100644 --- a/tests/StubsTypeHintsTest.php +++ b/tests/StubsTypeHintsTest.php @@ -10,10 +10,8 @@ use StubTests\Model\PHPInterface; use StubTests\Model\PHPMethod; use StubTests\Model\PHPParameter; -use StubTests\Model\PhpVersions; use StubTests\Model\StubProblemType; use StubTests\Parsers\ParserUtils; -use StubTests\TestData\Providers\EntitiesFilter; use StubTests\TestData\Providers\PhpStormStubsSingleton; use StubTests\TestData\Providers\ReflectionStubsSingleton; @@ -26,13 +24,7 @@ class StubsTypeHintsTest extends BaseStubsTest public function testFunctionsReturnTypeHints(PHPFunction $function) { $functionName = $function->name; - $allEqualStubFunctions = EntitiesFilter::getFiltered( - PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(), - fn (PHPFunction $stubFunction) => $stubFunction->name !== $functionName || - !in_array(PhpVersions::getLatest(), ParserUtils::getAvailableInVersions($stubFunction)) - ); - /** @var PHPFunction $stubFunction */ - $stubFunction = array_pop($allEqualStubFunctions); + $stubFunction = PhpStormStubsSingleton::getPhpStormStubs()->getFunction($functionName); $unifiedStubsReturnTypes = []; $unifiedStubsAttributesReturnTypes = []; $unifiedReflectionReturnTypes = []; @@ -260,12 +252,7 @@ public static function testMethodDoesNotHaveUnionReturnTypeHint(PHPMethod $stubM */ public function testMethodScalarTypeHintsInParametersMatchReflection(PHPClass|PHPInterface $class, PHPMethod $stubMethod, PHPParameter $stubParameter) { - $reflectionMethods = array_filter( - ReflectionStubsSingleton::getReflectionStubs()->getClass($class->name)->methods, - fn (PHPMethod $method) => $method->name === $stubMethod->name - ); - /** @var PHPMethod $reflectionMethod */ - $reflectionMethod = array_pop($reflectionMethods); + $reflectionMethod = ReflectionStubsSingleton::getReflectionStubs()->getClass($class->name)->getMethod($stubMethod->name); $reflectionParameters = array_filter($reflectionMethod->parameters, fn (PHPParameter $parameter) => $parameter->name === $stubParameter->name); $reflectionParameter = array_pop($reflectionParameters); self::compareTypeHintsWithReflection($reflectionParameter, $stubParameter, $stubMethod->name); @@ -277,12 +264,7 @@ public function testMethodScalarTypeHintsInParametersMatchReflection(PHPClass|PH */ public function testMethodNullableTypeHintsInParametersMatchReflection(PHPClass|PHPInterface $class, PHPMethod $stubMethod, PHPParameter $stubParameter) { - $reflectionMethods = array_filter( - ReflectionStubsSingleton::getReflectionStubs()->getClass($class->name)->methods, - fn (PHPMethod $method) => $method->name === $stubMethod->name - ); - /** @var PHPMethod $reflectionMethod */ - $reflectionMethod = array_pop($reflectionMethods); + $reflectionMethod = ReflectionStubsSingleton::getReflectionStubs()->getClass($class->name)->getMethod($stubMethod->name); $reflectionParameters = array_filter($reflectionMethod->parameters, fn (PHPParameter $parameter) => $parameter->name === $stubParameter->name); $reflectionParameter = array_pop($reflectionParameters); self::compareTypeHintsWithReflection($reflectionParameter, $stubParameter, $stubMethod->name); @@ -294,12 +276,7 @@ public function testMethodNullableTypeHintsInParametersMatchReflection(PHPClass| */ public function testMethodUnionTypeHintsInParametersMatchReflection(PHPClass|PHPInterface $class, PHPMethod $stubMethod, PHPParameter $stubParameter) { - $reflectionMethods = array_filter( - ReflectionStubsSingleton::getReflectionStubs()->getClass($class->name)->methods, - fn (PHPMethod $method) => $method->name === $stubMethod->name - ); - /** @var PHPMethod $reflectionMethod */ - $reflectionMethod = array_pop($reflectionMethods); + $reflectionMethod = ReflectionStubsSingleton::getReflectionStubs()->getClass($class->name)->getMethod($stubMethod->name); $reflectionParameters = array_filter($reflectionMethod->parameters, fn (PHPParameter $parameter) => $parameter->name === $stubParameter->name); $reflectionParameter = array_pop($reflectionParameters); self::compareTypeHintsWithReflection($reflectionParameter, $stubParameter, $stubMethod->name); diff --git a/tests/TestData/mutedProblems.json b/tests/TestData/mutedProblems.json index 461365c9b..af4043872 100644 --- a/tests/TestData/mutedProblems.json +++ b/tests/TestData/mutedProblems.json @@ -760,17 +760,6 @@ } ] }, - { - "name": "mb_parse_str", - "problems": [ - { - "description": "has duplicate in stubs", - "versions": [ - "ALL" - ] - } - ] - }, { "name": "session_set_cookie_params", "problems": [