@@ -14,86 +14,86 @@ |
||
14 | 14 | |
15 | 15 | class EntitiesFilter |
16 | 16 | { |
17 | - /** |
|
18 | - * @param BasePHPElement[] $entities |
|
19 | - * @return BasePHPElement[] |
|
20 | - */ |
|
21 | - public static function getFiltered(array $entities, callable $additionalFilter = null, int ...$problemTypes): array |
|
22 | - { |
|
23 | - $resultArray = []; |
|
24 | - $hasProblem = false; |
|
25 | - foreach ($entities as $key => $entity) { |
|
26 | - foreach ($problemTypes as $problemType) { |
|
27 | - if ($entity->hasMutedProblem($problemType)) { |
|
28 | - $hasProblem = true; |
|
29 | - } |
|
30 | - } |
|
31 | - if ($entity->hasMutedProblem(StubProblemType::STUB_IS_MISSED) || |
|
32 | - $additionalFilter !== null && $additionalFilter($entity) === true) { |
|
33 | - $hasProblem = true; |
|
34 | - } |
|
35 | - if ($hasProblem) { |
|
36 | - $hasProblem = false; |
|
37 | - } else { |
|
38 | - $resultArray[$key] = $entity; |
|
39 | - } |
|
40 | - } |
|
17 | + /** |
|
18 | + * @param BasePHPElement[] $entities |
|
19 | + * @return BasePHPElement[] |
|
20 | + */ |
|
21 | + public static function getFiltered(array $entities, callable $additionalFilter = null, int ...$problemTypes): array |
|
22 | + { |
|
23 | + $resultArray = []; |
|
24 | + $hasProblem = false; |
|
25 | + foreach ($entities as $key => $entity) { |
|
26 | + foreach ($problemTypes as $problemType) { |
|
27 | + if ($entity->hasMutedProblem($problemType)) { |
|
28 | + $hasProblem = true; |
|
29 | + } |
|
30 | + } |
|
31 | + if ($entity->hasMutedProblem(StubProblemType::STUB_IS_MISSED) || |
|
32 | + $additionalFilter !== null && $additionalFilter($entity) === true) { |
|
33 | + $hasProblem = true; |
|
34 | + } |
|
35 | + if ($hasProblem) { |
|
36 | + $hasProblem = false; |
|
37 | + } else { |
|
38 | + $resultArray[$key] = $entity; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - return $resultArray; |
|
43 | - } |
|
42 | + return $resultArray; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return PHPFunction[] |
|
47 | - * @throws RuntimeException |
|
48 | - */ |
|
49 | - public static function getFilteredFunctions(PHPInterface|PHPClass $class = null, bool $shouldSuitCurrentPhpVersion = true): array |
|
50 | - { |
|
51 | - if ($class === null) { |
|
52 | - $allFunctions = ReflectionStubsSingleton::getReflectionStubs()->getFunctions(); |
|
53 | - } else { |
|
54 | - $allFunctions = $class->methods; |
|
55 | - } |
|
56 | - /** @var PHPFunction[] $resultArray */ |
|
57 | - $resultArray = []; |
|
58 | - $allFunctions = array_filter( |
|
59 | - $allFunctions, |
|
60 | - fn ($function) => !$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function) |
|
61 | - ); |
|
62 | - foreach (self::getFiltered($allFunctions, null, StubProblemType::HAS_DUPLICATION, StubProblemType::FUNCTION_PARAMETER_MISMATCH) as $function) { |
|
63 | - $resultArray[] = $function; |
|
64 | - } |
|
65 | - return $resultArray; |
|
66 | - } |
|
45 | + /** |
|
46 | + * @return PHPFunction[] |
|
47 | + * @throws RuntimeException |
|
48 | + */ |
|
49 | + public static function getFilteredFunctions(PHPInterface|PHPClass $class = null, bool $shouldSuitCurrentPhpVersion = true): array |
|
50 | + { |
|
51 | + if ($class === null) { |
|
52 | + $allFunctions = ReflectionStubsSingleton::getReflectionStubs()->getFunctions(); |
|
53 | + } else { |
|
54 | + $allFunctions = $class->methods; |
|
55 | + } |
|
56 | + /** @var PHPFunction[] $resultArray */ |
|
57 | + $resultArray = []; |
|
58 | + $allFunctions = array_filter( |
|
59 | + $allFunctions, |
|
60 | + fn ($function) => !$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function) |
|
61 | + ); |
|
62 | + foreach (self::getFiltered($allFunctions, null, StubProblemType::HAS_DUPLICATION, StubProblemType::FUNCTION_PARAMETER_MISMATCH) as $function) { |
|
63 | + $resultArray[] = $function; |
|
64 | + } |
|
65 | + return $resultArray; |
|
66 | + } |
|
67 | 67 | |
68 | - public static function getFilteredParameters(PHPFunction $function, callable $additionalFilter = null, int ...$problemType): array |
|
69 | - { |
|
70 | - /** @var PHPParameter[] $resultArray */ |
|
71 | - $resultArray = []; |
|
72 | - foreach (self::getFiltered( |
|
73 | - $function->parameters, |
|
74 | - $additionalFilter, |
|
75 | - StubProblemType::FUNCTION_PARAMETER_MISMATCH, |
|
76 | - ...$problemType |
|
77 | - ) as $parameter) { |
|
78 | - $resultArray[] = $parameter; |
|
79 | - } |
|
80 | - return $resultArray; |
|
81 | - } |
|
68 | + public static function getFilteredParameters(PHPFunction $function, callable $additionalFilter = null, int ...$problemType): array |
|
69 | + { |
|
70 | + /** @var PHPParameter[] $resultArray */ |
|
71 | + $resultArray = []; |
|
72 | + foreach (self::getFiltered( |
|
73 | + $function->parameters, |
|
74 | + $additionalFilter, |
|
75 | + StubProblemType::FUNCTION_PARAMETER_MISMATCH, |
|
76 | + ...$problemType |
|
77 | + ) as $parameter) { |
|
78 | + $resultArray[] = $parameter; |
|
79 | + } |
|
80 | + return $resultArray; |
|
81 | + } |
|
82 | 82 | |
83 | - public static function getFilterFunctionForAllowedTypeHintsInLanguageLevel(float $languageVersion): callable |
|
84 | - { |
|
85 | - return function (PHPClass|PHPInterface $stubClass, PHPMethod $stubMethod, ?float $firstSinceVersion) use ($languageVersion) { |
|
86 | - $reflectionClass = ReflectionStubsSingleton::getReflectionStubs()->getClass($stubClass->name); |
|
87 | - $reflectionMethod = null; |
|
88 | - if ($reflectionClass !== null) { |
|
89 | - $reflectionMethods = array_filter( |
|
90 | - $reflectionClass->methods, |
|
91 | - fn (PHPMethod $method) => $stubMethod->name === $method->name |
|
92 | - ); |
|
93 | - $reflectionMethod = array_pop($reflectionMethods); |
|
94 | - } |
|
95 | - return $reflectionMethod !== null && ($stubMethod->isFinal || $stubClass->isFinal || $firstSinceVersion !== null && |
|
96 | - $firstSinceVersion > $languageVersion); |
|
97 | - }; |
|
98 | - } |
|
83 | + public static function getFilterFunctionForAllowedTypeHintsInLanguageLevel(float $languageVersion): callable |
|
84 | + { |
|
85 | + return function (PHPClass|PHPInterface $stubClass, PHPMethod $stubMethod, ?float $firstSinceVersion) use ($languageVersion) { |
|
86 | + $reflectionClass = ReflectionStubsSingleton::getReflectionStubs()->getClass($stubClass->name); |
|
87 | + $reflectionMethod = null; |
|
88 | + if ($reflectionClass !== null) { |
|
89 | + $reflectionMethods = array_filter( |
|
90 | + $reflectionClass->methods, |
|
91 | + fn (PHPMethod $method) => $stubMethod->name === $method->name |
|
92 | + ); |
|
93 | + $reflectionMethod = array_pop($reflectionMethods); |
|
94 | + } |
|
95 | + return $reflectionMethod !== null && ($stubMethod->isFinal || $stubClass->isFinal || $firstSinceVersion !== null && |
|
96 | + $firstSinceVersion > $languageVersion); |
|
97 | + }; |
|
98 | + } |
|
99 | 99 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return PHPFunction[] |
47 | 47 | * @throws RuntimeException |
48 | 48 | */ |
49 | - public static function getFilteredFunctions(PHPInterface|PHPClass $class = null, bool $shouldSuitCurrentPhpVersion = true): array |
|
49 | + public static function getFilteredFunctions(PHPInterface | PHPClass $class = null, bool $shouldSuitCurrentPhpVersion = true): array |
|
50 | 50 | { |
51 | 51 | if ($class === null) { |
52 | 52 | $allFunctions = ReflectionStubsSingleton::getReflectionStubs()->getFunctions(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | public static function getFilterFunctionForAllowedTypeHintsInLanguageLevel(float $languageVersion): callable |
84 | 84 | { |
85 | - return function (PHPClass|PHPInterface $stubClass, PHPMethod $stubMethod, ?float $firstSinceVersion) use ($languageVersion) { |
|
85 | + return function(PHPClass | PHPInterface $stubClass, PHPMethod $stubMethod, ?float $firstSinceVersion) use ($languageVersion) { |
|
86 | 86 | $reflectionClass = ReflectionStubsSingleton::getReflectionStubs()->getClass($stubClass->name); |
87 | 87 | $reflectionMethod = null; |
88 | 88 | if ($reflectionClass !== null) { |
@@ -12,8 +12,7 @@ |
||
12 | 12 | use StubTests\Model\PHPParameter; |
13 | 13 | use StubTests\Model\StubProblemType; |
14 | 14 | |
15 | -class EntitiesFilter |
|
16 | -{ |
|
15 | +class EntitiesFilter { |
|
17 | 16 | /** |
18 | 17 | * @param BasePHPElement[] $entities |
19 | 18 | * @return BasePHPElement[] |
@@ -15,86 +15,86 @@ |
||
15 | 15 | |
16 | 16 | class StubsParametersProvider |
17 | 17 | { |
18 | - /** |
|
19 | - * @throws RuntimeException |
|
20 | - */ |
|
21 | - public static function parametersForScalarTypeHintTestsProvider(): ?Generator |
|
22 | - { |
|
23 | - $filterFunction = self::getFilterFunctionForLanguageLevel(7); |
|
24 | - return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::PARAMETER_HAS_SCALAR_TYPEHINT); |
|
25 | - } |
|
18 | + /** |
|
19 | + * @throws RuntimeException |
|
20 | + */ |
|
21 | + public static function parametersForScalarTypeHintTestsProvider(): ?Generator |
|
22 | + { |
|
23 | + $filterFunction = self::getFilterFunctionForLanguageLevel(7); |
|
24 | + return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::PARAMETER_HAS_SCALAR_TYPEHINT); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @throws RuntimeException |
|
29 | - */ |
|
30 | - public static function parametersForNullableTypeHintTestsProvider(): ?Generator |
|
31 | - { |
|
32 | - $filterFunction = self::getFilterFunctionForLanguageLevel(7.1); |
|
33 | - return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::HAS_NULLABLE_TYPEHINT); |
|
34 | - } |
|
27 | + /** |
|
28 | + * @throws RuntimeException |
|
29 | + */ |
|
30 | + public static function parametersForNullableTypeHintTestsProvider(): ?Generator |
|
31 | + { |
|
32 | + $filterFunction = self::getFilterFunctionForLanguageLevel(7.1); |
|
33 | + return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::HAS_NULLABLE_TYPEHINT); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @throws RuntimeException |
|
38 | - */ |
|
39 | - public static function parametersForUnionTypeHintTestsProvider(): ?Generator |
|
40 | - { |
|
41 | - $filterFunction = self::getFilterFunctionForLanguageLevel(8); |
|
42 | - return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::HAS_UNION_TYPEHINT); |
|
43 | - } |
|
36 | + /** |
|
37 | + * @throws RuntimeException |
|
38 | + */ |
|
39 | + public static function parametersForUnionTypeHintTestsProvider(): ?Generator |
|
40 | + { |
|
41 | + $filterFunction = self::getFilterFunctionForLanguageLevel(8); |
|
42 | + return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::HAS_UNION_TYPEHINT); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @throws RuntimeException |
|
47 | - */ |
|
48 | - public static function parametersForAllowedScalarTypeHintTestsProvider(): ?Generator |
|
49 | - { |
|
50 | - $filterFunction = EntitiesFilter::getFilterFunctionForAllowedTypeHintsInLanguageLevel(7); |
|
51 | - return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::PARAMETER_TYPE_MISMATCH); |
|
52 | - } |
|
45 | + /** |
|
46 | + * @throws RuntimeException |
|
47 | + */ |
|
48 | + public static function parametersForAllowedScalarTypeHintTestsProvider(): ?Generator |
|
49 | + { |
|
50 | + $filterFunction = EntitiesFilter::getFilterFunctionForAllowedTypeHintsInLanguageLevel(7); |
|
51 | + return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::PARAMETER_TYPE_MISMATCH); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @throws RuntimeException |
|
56 | - */ |
|
57 | - public static function parametersForAllowedNullableTypeHintTestsProvider(): ?Generator |
|
58 | - { |
|
59 | - $filterFunction = EntitiesFilter::getFilterFunctionForAllowedTypeHintsInLanguageLevel(7.1); |
|
60 | - return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::PARAMETER_TYPE_MISMATCH); |
|
61 | - } |
|
54 | + /** |
|
55 | + * @throws RuntimeException |
|
56 | + */ |
|
57 | + public static function parametersForAllowedNullableTypeHintTestsProvider(): ?Generator |
|
58 | + { |
|
59 | + $filterFunction = EntitiesFilter::getFilterFunctionForAllowedTypeHintsInLanguageLevel(7.1); |
|
60 | + return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::PARAMETER_TYPE_MISMATCH); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @throws RuntimeException |
|
65 | - */ |
|
66 | - public static function parametersForAllowedUnionTypeHintTestsProvider(): ?Generator |
|
67 | - { |
|
68 | - $filterFunction = EntitiesFilter::getFilterFunctionForAllowedTypeHintsInLanguageLevel(8); |
|
69 | - return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::HAS_UNION_TYPEHINT); |
|
70 | - } |
|
63 | + /** |
|
64 | + * @throws RuntimeException |
|
65 | + */ |
|
66 | + public static function parametersForAllowedUnionTypeHintTestsProvider(): ?Generator |
|
67 | + { |
|
68 | + $filterFunction = EntitiesFilter::getFilterFunctionForAllowedTypeHintsInLanguageLevel(8); |
|
69 | + return self::yieldFilteredMethodParameters($filterFunction, StubProblemType::HAS_UNION_TYPEHINT); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @throws RuntimeException |
|
74 | - */ |
|
75 | - private static function yieldFilteredMethodParameters(callable $filterFunction, int ...$problemTypes): ?Generator |
|
76 | - { |
|
77 | - $coreClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getCoreClasses() + |
|
78 | - PhpStormStubsSingleton::getPhpStormStubs()->getCoreInterfaces(); |
|
79 | - foreach (EntitiesFilter::getFiltered($coreClassesAndInterfaces) as $class) { |
|
80 | - foreach (EntitiesFilter::getFilteredFunctions($class, false) as $method) { |
|
81 | - foreach (EntitiesFilter::getFilteredParameters($method, null, ...$problemTypes) as $parameter) { |
|
82 | - if (!empty($parameter->availableVersionsRangeFromAttribute)) { |
|
83 | - $firstSinceVersion = max(ParserUtils::getDeclaredSinceVersion($method), min($parameter->availableVersionsRangeFromAttribute)); |
|
84 | - } else { |
|
85 | - $firstSinceVersion = ParserUtils::getDeclaredSinceVersion($method); |
|
86 | - } |
|
87 | - if ($filterFunction($class, $method, $firstSinceVersion) === true) { |
|
88 | - yield "method $class->name::$method->name($parameter->name)" => [$class, $method, $parameter]; |
|
89 | - } |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
93 | - } |
|
72 | + /** |
|
73 | + * @throws RuntimeException |
|
74 | + */ |
|
75 | + private static function yieldFilteredMethodParameters(callable $filterFunction, int ...$problemTypes): ?Generator |
|
76 | + { |
|
77 | + $coreClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getCoreClasses() + |
|
78 | + PhpStormStubsSingleton::getPhpStormStubs()->getCoreInterfaces(); |
|
79 | + foreach (EntitiesFilter::getFiltered($coreClassesAndInterfaces) as $class) { |
|
80 | + foreach (EntitiesFilter::getFilteredFunctions($class, false) as $method) { |
|
81 | + foreach (EntitiesFilter::getFilteredParameters($method, null, ...$problemTypes) as $parameter) { |
|
82 | + if (!empty($parameter->availableVersionsRangeFromAttribute)) { |
|
83 | + $firstSinceVersion = max(ParserUtils::getDeclaredSinceVersion($method), min($parameter->availableVersionsRangeFromAttribute)); |
|
84 | + } else { |
|
85 | + $firstSinceVersion = ParserUtils::getDeclaredSinceVersion($method); |
|
86 | + } |
|
87 | + if ($filterFunction($class, $method, $firstSinceVersion) === true) { |
|
88 | + yield "method $class->name::$method->name($parameter->name)" => [$class, $method, $parameter]; |
|
89 | + } |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable |
|
96 | - { |
|
97 | - return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
98 | - !$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion; |
|
99 | - } |
|
95 | + private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable |
|
96 | + { |
|
97 | + return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
98 | + !$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion; |
|
99 | + } |
|
100 | 100 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | |
95 | 95 | private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable |
96 | 96 | { |
97 | - return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
97 | + return fn (PHPClass | PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
98 | 98 | !$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion; |
99 | 99 | } |
100 | 100 | } |
@@ -13,8 +13,7 @@ |
||
13 | 13 | use StubTests\TestData\Providers\EntitiesFilter; |
14 | 14 | use StubTests\TestData\Providers\PhpStormStubsSingleton; |
15 | 15 | |
16 | -class StubsParametersProvider |
|
17 | -{ |
|
16 | +class StubsParametersProvider { |
|
18 | 17 | /** |
19 | 18 | * @throws RuntimeException |
20 | 19 | */ |
@@ -16,108 +16,108 @@ |
||
16 | 16 | |
17 | 17 | class StubMethodsProvider |
18 | 18 | { |
19 | - public static function allMethodsProvider(): ?Generator |
|
20 | - { |
|
21 | - $classesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
22 | - PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
23 | - foreach ($classesAndInterfaces as $className => $class) { |
|
24 | - foreach ($class->methods as $methodName => $method) { |
|
25 | - yield "method $className::$methodName" => [$method]; |
|
26 | - } |
|
27 | - } |
|
28 | - } |
|
19 | + public static function allMethodsProvider(): ?Generator |
|
20 | + { |
|
21 | + $classesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
22 | + PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
23 | + foreach ($classesAndInterfaces as $className => $class) { |
|
24 | + foreach ($class->methods as $methodName => $method) { |
|
25 | + yield "method $className::$methodName" => [$method]; |
|
26 | + } |
|
27 | + } |
|
28 | + } |
|
29 | 29 | |
30 | - public static function allFunctionAndMethodsWithReturnTypeHintsProvider(): ?Generator |
|
31 | - { |
|
32 | - $coreClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
33 | - PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
34 | - $allFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); |
|
35 | - $filteredMethods = []; |
|
36 | - foreach (EntitiesFilter::getFiltered($coreClassesAndInterfaces) as $class) { |
|
37 | - $filteredMethods = EntitiesFilter::getFiltered( |
|
38 | - $class->methods, |
|
39 | - fn (PHPMethod $method) => empty($method->returnTypesFromSignature) || empty($method->returnTypesFromPhpDoc) |
|
40 | - || $method->parentName === '___PHPSTORM_HELPERS\object', |
|
41 | - StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE |
|
42 | - ); |
|
43 | - } |
|
44 | - $filteredMethods += EntitiesFilter::getFiltered( |
|
45 | - $allFunctions, |
|
46 | - fn (PHPFunction $function) => empty($function->returnTypesFromSignature) || empty($function->returnTypesFromPhpDoc), |
|
47 | - StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE |
|
48 | - ); |
|
49 | - foreach ($filteredMethods as $methodName => $method) { |
|
50 | - if ($method instanceof PHPMethod) { |
|
51 | - yield "method $method->parentName::$methodName" => [$method]; |
|
52 | - } else { |
|
53 | - yield "function $methodName" => [$method]; |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
30 | + public static function allFunctionAndMethodsWithReturnTypeHintsProvider(): ?Generator |
|
31 | + { |
|
32 | + $coreClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
33 | + PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
34 | + $allFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); |
|
35 | + $filteredMethods = []; |
|
36 | + foreach (EntitiesFilter::getFiltered($coreClassesAndInterfaces) as $class) { |
|
37 | + $filteredMethods = EntitiesFilter::getFiltered( |
|
38 | + $class->methods, |
|
39 | + fn (PHPMethod $method) => empty($method->returnTypesFromSignature) || empty($method->returnTypesFromPhpDoc) |
|
40 | + || $method->parentName === '___PHPSTORM_HELPERS\object', |
|
41 | + StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE |
|
42 | + ); |
|
43 | + } |
|
44 | + $filteredMethods += EntitiesFilter::getFiltered( |
|
45 | + $allFunctions, |
|
46 | + fn (PHPFunction $function) => empty($function->returnTypesFromSignature) || empty($function->returnTypesFromPhpDoc), |
|
47 | + StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE |
|
48 | + ); |
|
49 | + foreach ($filteredMethods as $methodName => $method) { |
|
50 | + if ($method instanceof PHPMethod) { |
|
51 | + yield "method $method->parentName::$methodName" => [$method]; |
|
52 | + } else { |
|
53 | + yield "function $methodName" => [$method]; |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @throws RuntimeException |
|
60 | - */ |
|
61 | - public static function methodsForReturnTypeHintTestsProvider(): ?Generator |
|
62 | - { |
|
63 | - $filterFunction = self::getFilterFunctionForLanguageLevel(7); |
|
64 | - return self::yieldFilteredMethods( |
|
65 | - $filterFunction, |
|
66 | - StubProblemType::FUNCTION_HAS_RETURN_TYPEHINT, |
|
67 | - StubProblemType::WRONG_RETURN_TYPEHINT |
|
68 | - ); |
|
69 | - } |
|
58 | + /** |
|
59 | + * @throws RuntimeException |
|
60 | + */ |
|
61 | + public static function methodsForReturnTypeHintTestsProvider(): ?Generator |
|
62 | + { |
|
63 | + $filterFunction = self::getFilterFunctionForLanguageLevel(7); |
|
64 | + return self::yieldFilteredMethods( |
|
65 | + $filterFunction, |
|
66 | + StubProblemType::FUNCTION_HAS_RETURN_TYPEHINT, |
|
67 | + StubProblemType::WRONG_RETURN_TYPEHINT |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @throws RuntimeException |
|
73 | - */ |
|
74 | - public static function methodsForNullableReturnTypeHintTestsProvider(): ?Generator |
|
75 | - { |
|
76 | - $filterFunction = self::getFilterFunctionForLanguageLevel(7.1); |
|
77 | - return self::yieldFilteredMethods( |
|
78 | - $filterFunction, |
|
79 | - StubProblemType::HAS_NULLABLE_TYPEHINT, |
|
80 | - StubProblemType::WRONG_RETURN_TYPEHINT |
|
81 | - ); |
|
82 | - } |
|
71 | + /** |
|
72 | + * @throws RuntimeException |
|
73 | + */ |
|
74 | + public static function methodsForNullableReturnTypeHintTestsProvider(): ?Generator |
|
75 | + { |
|
76 | + $filterFunction = self::getFilterFunctionForLanguageLevel(7.1); |
|
77 | + return self::yieldFilteredMethods( |
|
78 | + $filterFunction, |
|
79 | + StubProblemType::HAS_NULLABLE_TYPEHINT, |
|
80 | + StubProblemType::WRONG_RETURN_TYPEHINT |
|
81 | + ); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @throws RuntimeException |
|
86 | - */ |
|
87 | - public static function methodsForUnionReturnTypeHintTestsProvider(): ?Generator |
|
88 | - { |
|
89 | - $filterFunction = self::getFilterFunctionForLanguageLevel(8); |
|
90 | - return self::yieldFilteredMethods( |
|
91 | - $filterFunction, |
|
92 | - StubProblemType::HAS_UNION_TYPEHINT, |
|
93 | - StubProblemType::WRONG_RETURN_TYPEHINT |
|
94 | - ); |
|
95 | - } |
|
84 | + /** |
|
85 | + * @throws RuntimeException |
|
86 | + */ |
|
87 | + public static function methodsForUnionReturnTypeHintTestsProvider(): ?Generator |
|
88 | + { |
|
89 | + $filterFunction = self::getFilterFunctionForLanguageLevel(8); |
|
90 | + return self::yieldFilteredMethods( |
|
91 | + $filterFunction, |
|
92 | + StubProblemType::HAS_UNION_TYPEHINT, |
|
93 | + StubProblemType::WRONG_RETURN_TYPEHINT |
|
94 | + ); |
|
95 | + } |
|
96 | 96 | |
97 | - private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable |
|
98 | - { |
|
99 | - return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
100 | - !$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion && !$method->isReturnTypeTentative; |
|
101 | - } |
|
97 | + private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable |
|
98 | + { |
|
99 | + return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
100 | + !$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion && !$method->isReturnTypeTentative; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @throws RuntimeException |
|
105 | - */ |
|
106 | - private static function yieldFilteredMethods(callable $filterFunction, int ...$problemTypes): ?Generator |
|
107 | - { |
|
108 | - $coreClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getCoreClasses() + |
|
109 | - PhpStormStubsSingleton::getPhpStormStubs()->getCoreInterfaces(); |
|
110 | - foreach (EntitiesFilter::getFiltered($coreClassesAndInterfaces) as $className => $class) { |
|
111 | - foreach (EntitiesFilter::getFiltered( |
|
112 | - $class->methods, |
|
113 | - fn (PHPMethod $method) => $method->parentName === '___PHPSTORM_HELPERS\object', |
|
114 | - ...$problemTypes |
|
115 | - ) as $methodName => $method) { |
|
116 | - $firstSinceVersion = ParserUtils::getDeclaredSinceVersion($method); |
|
117 | - if ($filterFunction($class, $method, $firstSinceVersion) === true) { |
|
118 | - yield "method $className::$methodName" => [$method]; |
|
119 | - } |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
103 | + /** |
|
104 | + * @throws RuntimeException |
|
105 | + */ |
|
106 | + private static function yieldFilteredMethods(callable $filterFunction, int ...$problemTypes): ?Generator |
|
107 | + { |
|
108 | + $coreClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getCoreClasses() + |
|
109 | + PhpStormStubsSingleton::getPhpStormStubs()->getCoreInterfaces(); |
|
110 | + foreach (EntitiesFilter::getFiltered($coreClassesAndInterfaces) as $className => $class) { |
|
111 | + foreach (EntitiesFilter::getFiltered( |
|
112 | + $class->methods, |
|
113 | + fn (PHPMethod $method) => $method->parentName === '___PHPSTORM_HELPERS\object', |
|
114 | + ...$problemTypes |
|
115 | + ) as $methodName => $method) { |
|
116 | + $firstSinceVersion = ParserUtils::getDeclaredSinceVersion($method); |
|
117 | + if ($filterFunction($class, $method, $firstSinceVersion) === true) { |
|
118 | + yield "method $className::$methodName" => [$method]; |
|
119 | + } |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | 123 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | |
97 | 97 | private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable |
98 | 98 | { |
99 | - return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
99 | + return fn (PHPClass | PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal && |
|
100 | 100 | !$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion && !$method->isReturnTypeTentative; |
101 | 101 | } |
102 | 102 |
@@ -14,8 +14,7 @@ |
||
14 | 14 | use StubTests\TestData\Providers\EntitiesFilter; |
15 | 15 | use StubTests\TestData\Providers\PhpStormStubsSingleton; |
16 | 16 | |
17 | -class StubMethodsProvider |
|
18 | -{ |
|
17 | +class StubMethodsProvider { |
|
19 | 18 | public static function allMethodsProvider(): ?Generator |
20 | 19 | { |
21 | 20 | $classesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
@@ -13,41 +13,41 @@ |
||
13 | 13 | |
14 | 14 | class StubsTestDataProviders |
15 | 15 | { |
16 | - public static function allFunctionsProvider(): ?Generator |
|
17 | - { |
|
18 | - foreach (PhpStormStubsSingleton::getPhpStormStubs()->getFunctions() as $functionName => $function) { |
|
19 | - yield "function $functionName" => [$function]; |
|
20 | - } |
|
21 | - } |
|
16 | + public static function allFunctionsProvider(): ?Generator |
|
17 | + { |
|
18 | + foreach (PhpStormStubsSingleton::getPhpStormStubs()->getFunctions() as $functionName => $function) { |
|
19 | + yield "function $functionName" => [$function]; |
|
20 | + } |
|
21 | + } |
|
22 | 22 | |
23 | - public static function allClassesProvider(): ?Generator |
|
24 | - { |
|
25 | - $allClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
26 | - PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
27 | - foreach ($allClassesAndInterfaces as $class) { |
|
28 | - yield "class $class->sourceFilePath/$class->name" => [$class]; |
|
29 | - } |
|
30 | - } |
|
23 | + public static function allClassesProvider(): ?Generator |
|
24 | + { |
|
25 | + $allClassesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
26 | + PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
27 | + foreach ($allClassesAndInterfaces as $class) { |
|
28 | + yield "class $class->sourceFilePath/$class->name" => [$class]; |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | - public static function coreFunctionsProvider(): ?Generator |
|
33 | - { |
|
34 | - $allFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); |
|
35 | - $coreFunctions = array_filter($allFunctions, fn (PHPFunction $function): bool => $function->stubBelongsToCore === true); |
|
36 | - foreach ($coreFunctions as $coreFunction) { |
|
37 | - yield "function $coreFunction->name" => [$coreFunction]; |
|
38 | - } |
|
39 | - } |
|
32 | + public static function coreFunctionsProvider(): ?Generator |
|
33 | + { |
|
34 | + $allFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(); |
|
35 | + $coreFunctions = array_filter($allFunctions, fn (PHPFunction $function): bool => $function->stubBelongsToCore === true); |
|
36 | + foreach ($coreFunctions as $coreFunction) { |
|
37 | + yield "function $coreFunction->name" => [$coreFunction]; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - public static function stubsDirectoriesProvider(): ?Generator |
|
42 | - { |
|
43 | - $stubsDirectory = dirname(__DIR__, 4); |
|
44 | - /** @var SplFileInfo $directory */ |
|
45 | - foreach (new DirectoryIterator($stubsDirectory) as $directory) { |
|
46 | - $directoryName = $directory->getBasename(); |
|
47 | - if ($directory->isDot() || !$directory->isDir() || in_array($directoryName, ['tests', 'meta', 'vendor'], true) || str_starts_with($directoryName, '.')) { |
|
48 | - continue; |
|
49 | - } |
|
50 | - yield "directory $directoryName" => [$directoryName]; |
|
51 | - } |
|
52 | - } |
|
41 | + public static function stubsDirectoriesProvider(): ?Generator |
|
42 | + { |
|
43 | + $stubsDirectory = dirname(__DIR__, 4); |
|
44 | + /** @var SplFileInfo $directory */ |
|
45 | + foreach (new DirectoryIterator($stubsDirectory) as $directory) { |
|
46 | + $directoryName = $directory->getBasename(); |
|
47 | + if ($directory->isDot() || !$directory->isDir() || in_array($directoryName, ['tests', 'meta', 'vendor'], true) || str_starts_with($directoryName, '.')) { |
|
48 | + continue; |
|
49 | + } |
|
50 | + yield "directory $directoryName" => [$directoryName]; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
@@ -11,8 +11,7 @@ |
||
11 | 11 | use function dirname; |
12 | 12 | use function in_array; |
13 | 13 | |
14 | -class StubsTestDataProviders |
|
15 | -{ |
|
14 | +class StubsTestDataProviders { |
|
16 | 15 | public static function allFunctionsProvider(): ?Generator |
17 | 16 | { |
18 | 17 | foreach (PhpStormStubsSingleton::getPhpStormStubs()->getFunctions() as $functionName => $function) { |
@@ -8,21 +8,21 @@ |
||
8 | 8 | |
9 | 9 | class StubConstantsProvider |
10 | 10 | { |
11 | - public static function classConstantProvider(): ?Generator |
|
12 | - { |
|
13 | - $classesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
14 | - PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
15 | - foreach ($classesAndInterfaces as $class) { |
|
16 | - foreach ($class->constants as $constant) { |
|
17 | - yield "constant $class->sourceFilePath/$class->name::$constant->name" => [$class, $constant]; |
|
18 | - } |
|
19 | - } |
|
20 | - } |
|
11 | + public static function classConstantProvider(): ?Generator |
|
12 | + { |
|
13 | + $classesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
|
14 | + PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces(); |
|
15 | + foreach ($classesAndInterfaces as $class) { |
|
16 | + foreach ($class->constants as $constant) { |
|
17 | + yield "constant $class->sourceFilePath/$class->name::$constant->name" => [$class, $constant]; |
|
18 | + } |
|
19 | + } |
|
20 | + } |
|
21 | 21 | |
22 | - public static function globalConstantProvider(): ?Generator |
|
23 | - { |
|
24 | - foreach (PhpStormStubsSingleton::getPhpStormStubs()->getConstants() as $constantName => $constant) { |
|
25 | - yield "constant $constantName" => [$constant]; |
|
26 | - } |
|
27 | - } |
|
22 | + public static function globalConstantProvider(): ?Generator |
|
23 | + { |
|
24 | + foreach (PhpStormStubsSingleton::getPhpStormStubs()->getConstants() as $constantName => $constant) { |
|
25 | + yield "constant $constantName" => [$constant]; |
|
26 | + } |
|
27 | + } |
|
28 | 28 | } |
@@ -6,8 +6,7 @@ |
||
6 | 6 | use Generator; |
7 | 7 | use StubTests\TestData\Providers\PhpStormStubsSingleton; |
8 | 8 | |
9 | -class StubConstantsProvider |
|
10 | -{ |
|
9 | +class StubConstantsProvider { |
|
11 | 10 | public static function classConstantProvider(): ?Generator |
12 | 11 | { |
13 | 12 | $classesAndInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getClasses() + |
@@ -7,216 +7,216 @@ |
||
7 | 7 | |
8 | 8 | class PhpCoreStubsProvider |
9 | 9 | { |
10 | - public static array $StubDirectoryMap = [ |
|
11 | - 'CORE' => [ |
|
12 | - 'Core', |
|
13 | - 'date', |
|
14 | - 'filter', |
|
15 | - 'fpm', |
|
16 | - 'hash', |
|
17 | - 'meta', |
|
18 | - 'pcre', |
|
19 | - 'Phar', |
|
20 | - 'Reflection', |
|
21 | - 'regex', |
|
22 | - 'session', |
|
23 | - 'SPL', |
|
24 | - 'standard', |
|
25 | - 'superglobals', |
|
26 | - 'tokenizer' |
|
27 | - ], |
|
28 | - 'BUNDLED' => [ |
|
29 | - 'apache', |
|
30 | - 'bcmath', |
|
31 | - 'calendar', |
|
32 | - 'ctype', |
|
33 | - 'dba', |
|
34 | - 'exif', |
|
35 | - 'fileinfo', |
|
36 | - 'ftp', |
|
37 | - 'gd', |
|
38 | - 'iconv', |
|
39 | - 'intl', |
|
40 | - 'json', |
|
41 | - 'mbstring', |
|
42 | - 'pcntl', |
|
43 | - 'PDO', |
|
44 | - 'posix', |
|
45 | - 'shmop', |
|
46 | - 'sockets', |
|
47 | - 'sqlite3', |
|
48 | - 'sysvmsg', |
|
49 | - 'sysvsem', |
|
50 | - 'sysvshm', |
|
51 | - 'xmlrpc', |
|
52 | - 'zlib' |
|
53 | - ], |
|
54 | - 'EXTERNAL' => [ |
|
55 | - 'aerospike', |
|
56 | - 'bz2', |
|
57 | - 'curl', |
|
58 | - 'dom', |
|
59 | - 'enchant', |
|
60 | - 'gettext', |
|
61 | - 'gmp', |
|
62 | - 'imap', |
|
63 | - 'interbase', |
|
64 | - 'ldap', |
|
65 | - 'libxml', |
|
66 | - 'mcrypt', |
|
67 | - 'mssql', |
|
68 | - 'mysql', |
|
69 | - 'mysqli', |
|
70 | - 'oci8', |
|
71 | - 'odbc', |
|
72 | - 'openssl', |
|
73 | - 'pdo_ibm', |
|
74 | - 'pdo_mysql', |
|
75 | - 'pdo_pgsql', |
|
76 | - 'pdo_sqlite', |
|
77 | - 'pgsql', |
|
78 | - 'pspell', |
|
79 | - 'readline', |
|
80 | - 'recode', |
|
81 | - 'SimpleXML', |
|
82 | - 'snmp', |
|
83 | - 'soap', |
|
84 | - 'sodium', |
|
85 | - 'sybase', |
|
86 | - 'tidy', |
|
87 | - 'wddx', |
|
88 | - 'xml', |
|
89 | - 'xmlreader', |
|
90 | - 'xmlwriter', |
|
91 | - 'xsl', |
|
92 | - 'Zend OPcache', |
|
93 | - 'zip' |
|
94 | - ], |
|
95 | - 'PECL' => [ |
|
96 | - 'apcu', |
|
97 | - 'ast', |
|
98 | - 'crypto', |
|
99 | - 'cubrid', |
|
100 | - 'decimal', |
|
101 | - 'ds', |
|
102 | - 'event', |
|
103 | - 'expect', |
|
104 | - 'gearman', |
|
105 | - 'geoip', |
|
106 | - 'gmagick', |
|
107 | - 'http', |
|
108 | - 'ibm_db2', |
|
109 | - 'imagick', |
|
110 | - 'inotify', |
|
111 | - 'leveldb', |
|
112 | - 'libevent', |
|
113 | - 'LuaSandbox', |
|
114 | - 'lzf', |
|
115 | - 'mailparse', |
|
116 | - 'memcache', |
|
117 | - 'memcached', |
|
118 | - 'ming', |
|
119 | - 'mongo', |
|
120 | - 'mongodb', |
|
121 | - 'msgpack', |
|
122 | - 'mysql_xdevapi', |
|
123 | - 'ncurses', |
|
124 | - 'oauth', |
|
125 | - 'parallel', |
|
126 | - 'Parle', |
|
127 | - 'pcov', |
|
128 | - 'pdflib', |
|
129 | - 'pq', |
|
130 | - 'pthreads', |
|
131 | - 'radius', |
|
132 | - 'rdkafka', |
|
133 | - 'rpminfo', |
|
134 | - 'solr', |
|
135 | - 'SplType', |
|
136 | - 'SQLite', |
|
137 | - 'sqlsrv', |
|
138 | - 'ssh2', |
|
139 | - 'stats', |
|
140 | - 'stomp', |
|
141 | - 'svn', |
|
142 | - 'sync', |
|
143 | - 'uopz', |
|
144 | - 'uuid', |
|
145 | - 'uv', |
|
146 | - 'winbinder', |
|
147 | - 'wincache', |
|
148 | - 'xdiff', |
|
149 | - 'xhprof', |
|
150 | - 'xxtea', |
|
151 | - 'yaf', |
|
152 | - 'yaml', |
|
153 | - 'yar', |
|
154 | - 'zookeeper', |
|
155 | - 'zstd' |
|
156 | - ], |
|
157 | - 'OTHERS' => [ |
|
158 | - 'amqp', |
|
159 | - 'blackfire', |
|
160 | - 'cassandra', |
|
161 | - 'com_dotnet', |
|
162 | - 'couchbase', |
|
163 | - 'couchbase_v2', |
|
164 | - 'dio', |
|
165 | - 'Ev', |
|
166 | - 'fann', |
|
167 | - 'FFI', |
|
168 | - 'ffmpeg', |
|
169 | - 'geos', |
|
170 | - 'gnupg', |
|
171 | - 'grpc', |
|
172 | - 'igbinary', |
|
173 | - 'judy', |
|
174 | - 'libsodium', |
|
175 | - 'libvirt-php', |
|
176 | - 'lua', |
|
177 | - 'mapscript', |
|
178 | - 'meminfo', |
|
179 | - 'mosquitto-php', |
|
180 | - 'mqseries', |
|
181 | - 'newrelic', |
|
182 | - 'phpdbg', |
|
183 | - 'rar', |
|
184 | - 'redis', |
|
185 | - 'rrd', |
|
186 | - 'SaxonC', |
|
187 | - 'suhosin', |
|
188 | - 'svm', |
|
189 | - 'v8js', |
|
190 | - 'win32service', |
|
191 | - 'xcache', |
|
192 | - 'xdebug', |
|
193 | - 'xlswriter', |
|
194 | - 'zend', |
|
195 | - 'ZendCache', |
|
196 | - 'ZendDebugger', |
|
197 | - 'ZendUtils', |
|
198 | - 'zmq' |
|
199 | - ] |
|
200 | - ]; |
|
10 | + public static array $StubDirectoryMap = [ |
|
11 | + 'CORE' => [ |
|
12 | + 'Core', |
|
13 | + 'date', |
|
14 | + 'filter', |
|
15 | + 'fpm', |
|
16 | + 'hash', |
|
17 | + 'meta', |
|
18 | + 'pcre', |
|
19 | + 'Phar', |
|
20 | + 'Reflection', |
|
21 | + 'regex', |
|
22 | + 'session', |
|
23 | + 'SPL', |
|
24 | + 'standard', |
|
25 | + 'superglobals', |
|
26 | + 'tokenizer' |
|
27 | + ], |
|
28 | + 'BUNDLED' => [ |
|
29 | + 'apache', |
|
30 | + 'bcmath', |
|
31 | + 'calendar', |
|
32 | + 'ctype', |
|
33 | + 'dba', |
|
34 | + 'exif', |
|
35 | + 'fileinfo', |
|
36 | + 'ftp', |
|
37 | + 'gd', |
|
38 | + 'iconv', |
|
39 | + 'intl', |
|
40 | + 'json', |
|
41 | + 'mbstring', |
|
42 | + 'pcntl', |
|
43 | + 'PDO', |
|
44 | + 'posix', |
|
45 | + 'shmop', |
|
46 | + 'sockets', |
|
47 | + 'sqlite3', |
|
48 | + 'sysvmsg', |
|
49 | + 'sysvsem', |
|
50 | + 'sysvshm', |
|
51 | + 'xmlrpc', |
|
52 | + 'zlib' |
|
53 | + ], |
|
54 | + 'EXTERNAL' => [ |
|
55 | + 'aerospike', |
|
56 | + 'bz2', |
|
57 | + 'curl', |
|
58 | + 'dom', |
|
59 | + 'enchant', |
|
60 | + 'gettext', |
|
61 | + 'gmp', |
|
62 | + 'imap', |
|
63 | + 'interbase', |
|
64 | + 'ldap', |
|
65 | + 'libxml', |
|
66 | + 'mcrypt', |
|
67 | + 'mssql', |
|
68 | + 'mysql', |
|
69 | + 'mysqli', |
|
70 | + 'oci8', |
|
71 | + 'odbc', |
|
72 | + 'openssl', |
|
73 | + 'pdo_ibm', |
|
74 | + 'pdo_mysql', |
|
75 | + 'pdo_pgsql', |
|
76 | + 'pdo_sqlite', |
|
77 | + 'pgsql', |
|
78 | + 'pspell', |
|
79 | + 'readline', |
|
80 | + 'recode', |
|
81 | + 'SimpleXML', |
|
82 | + 'snmp', |
|
83 | + 'soap', |
|
84 | + 'sodium', |
|
85 | + 'sybase', |
|
86 | + 'tidy', |
|
87 | + 'wddx', |
|
88 | + 'xml', |
|
89 | + 'xmlreader', |
|
90 | + 'xmlwriter', |
|
91 | + 'xsl', |
|
92 | + 'Zend OPcache', |
|
93 | + 'zip' |
|
94 | + ], |
|
95 | + 'PECL' => [ |
|
96 | + 'apcu', |
|
97 | + 'ast', |
|
98 | + 'crypto', |
|
99 | + 'cubrid', |
|
100 | + 'decimal', |
|
101 | + 'ds', |
|
102 | + 'event', |
|
103 | + 'expect', |
|
104 | + 'gearman', |
|
105 | + 'geoip', |
|
106 | + 'gmagick', |
|
107 | + 'http', |
|
108 | + 'ibm_db2', |
|
109 | + 'imagick', |
|
110 | + 'inotify', |
|
111 | + 'leveldb', |
|
112 | + 'libevent', |
|
113 | + 'LuaSandbox', |
|
114 | + 'lzf', |
|
115 | + 'mailparse', |
|
116 | + 'memcache', |
|
117 | + 'memcached', |
|
118 | + 'ming', |
|
119 | + 'mongo', |
|
120 | + 'mongodb', |
|
121 | + 'msgpack', |
|
122 | + 'mysql_xdevapi', |
|
123 | + 'ncurses', |
|
124 | + 'oauth', |
|
125 | + 'parallel', |
|
126 | + 'Parle', |
|
127 | + 'pcov', |
|
128 | + 'pdflib', |
|
129 | + 'pq', |
|
130 | + 'pthreads', |
|
131 | + 'radius', |
|
132 | + 'rdkafka', |
|
133 | + 'rpminfo', |
|
134 | + 'solr', |
|
135 | + 'SplType', |
|
136 | + 'SQLite', |
|
137 | + 'sqlsrv', |
|
138 | + 'ssh2', |
|
139 | + 'stats', |
|
140 | + 'stomp', |
|
141 | + 'svn', |
|
142 | + 'sync', |
|
143 | + 'uopz', |
|
144 | + 'uuid', |
|
145 | + 'uv', |
|
146 | + 'winbinder', |
|
147 | + 'wincache', |
|
148 | + 'xdiff', |
|
149 | + 'xhprof', |
|
150 | + 'xxtea', |
|
151 | + 'yaf', |
|
152 | + 'yaml', |
|
153 | + 'yar', |
|
154 | + 'zookeeper', |
|
155 | + 'zstd' |
|
156 | + ], |
|
157 | + 'OTHERS' => [ |
|
158 | + 'amqp', |
|
159 | + 'blackfire', |
|
160 | + 'cassandra', |
|
161 | + 'com_dotnet', |
|
162 | + 'couchbase', |
|
163 | + 'couchbase_v2', |
|
164 | + 'dio', |
|
165 | + 'Ev', |
|
166 | + 'fann', |
|
167 | + 'FFI', |
|
168 | + 'ffmpeg', |
|
169 | + 'geos', |
|
170 | + 'gnupg', |
|
171 | + 'grpc', |
|
172 | + 'igbinary', |
|
173 | + 'judy', |
|
174 | + 'libsodium', |
|
175 | + 'libvirt-php', |
|
176 | + 'lua', |
|
177 | + 'mapscript', |
|
178 | + 'meminfo', |
|
179 | + 'mosquitto-php', |
|
180 | + 'mqseries', |
|
181 | + 'newrelic', |
|
182 | + 'phpdbg', |
|
183 | + 'rar', |
|
184 | + 'redis', |
|
185 | + 'rrd', |
|
186 | + 'SaxonC', |
|
187 | + 'suhosin', |
|
188 | + 'svm', |
|
189 | + 'v8js', |
|
190 | + 'win32service', |
|
191 | + 'xcache', |
|
192 | + 'xdebug', |
|
193 | + 'xlswriter', |
|
194 | + 'zend', |
|
195 | + 'ZendCache', |
|
196 | + 'ZendDebugger', |
|
197 | + 'ZendUtils', |
|
198 | + 'zmq' |
|
199 | + ] |
|
200 | + ]; |
|
201 | 201 | |
202 | - /** |
|
203 | - * @return string[] |
|
204 | - */ |
|
205 | - public static function getCoreStubsDirectories(): array |
|
206 | - { |
|
207 | - $coreStubs = [self::$StubDirectoryMap['CORE']]; |
|
208 | - $coreStubs[] = self::$StubDirectoryMap['BUNDLED']; |
|
209 | - $coreStubs[] = self::$StubDirectoryMap['EXTERNAL']; |
|
210 | - return CommonUtils::flattenArray($coreStubs, false); |
|
211 | - } |
|
202 | + /** |
|
203 | + * @return string[] |
|
204 | + */ |
|
205 | + public static function getCoreStubsDirectories(): array |
|
206 | + { |
|
207 | + $coreStubs = [self::$StubDirectoryMap['CORE']]; |
|
208 | + $coreStubs[] = self::$StubDirectoryMap['BUNDLED']; |
|
209 | + $coreStubs[] = self::$StubDirectoryMap['EXTERNAL']; |
|
210 | + return CommonUtils::flattenArray($coreStubs, false); |
|
211 | + } |
|
212 | 212 | |
213 | - /** |
|
214 | - * @return string[] |
|
215 | - */ |
|
216 | - public static function getNonCoreStubsDirectories(): array |
|
217 | - { |
|
218 | - $coreStubs = [self::$StubDirectoryMap['PECL']]; |
|
219 | - $coreStubs[] = self::$StubDirectoryMap['OTHERS']; |
|
220 | - return CommonUtils::flattenArray($coreStubs, false); |
|
221 | - } |
|
213 | + /** |
|
214 | + * @return string[] |
|
215 | + */ |
|
216 | + public static function getNonCoreStubsDirectories(): array |
|
217 | + { |
|
218 | + $coreStubs = [self::$StubDirectoryMap['PECL']]; |
|
219 | + $coreStubs[] = self::$StubDirectoryMap['OTHERS']; |
|
220 | + return CommonUtils::flattenArray($coreStubs, false); |
|
221 | + } |
|
222 | 222 | } |
@@ -5,8 +5,7 @@ |
||
5 | 5 | |
6 | 6 | use StubTests\Model\CommonUtils; |
7 | 7 | |
8 | -class PhpCoreStubsProvider |
|
9 | -{ |
|
8 | +class PhpCoreStubsProvider { |
|
10 | 9 | public static array $StubDirectoryMap = [ |
11 | 10 | 'CORE' => [ |
12 | 11 | 'Core', |
@@ -12,68 +12,68 @@ |
||
12 | 12 | */ |
13 | 13 | class StubsReflectionClassesTest extends BaseStubsTest |
14 | 14 | { |
15 | - /** |
|
16 | - * @throws Exception|RuntimeException |
|
17 | - */ |
|
18 | - public function testReflectionFunctionAbstractGetReturnTypeMethod() |
|
19 | - { |
|
20 | - $getReturnTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionFunctionAbstract')->getMethod('getReturnType'); |
|
21 | - $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getReturnTypeMethod->returnTypesFromAttribute + |
|
22 | - $getReturnTypeMethod->returnTypesFromSignature + $getReturnTypeMethod->returnTypesFromPhpDoc, false)); |
|
23 | - self::assertContains( |
|
24 | - 'ReflectionNamedType', |
|
25 | - $allReturnTypes, |
|
26 | - 'method ReflectionFunctionAbstract::getReturnType should have ReflectionNamedType in return types for php 7.1+' |
|
27 | - ); |
|
28 | - self::assertContains( |
|
29 | - 'ReflectionUnionType', |
|
30 | - $allReturnTypes, |
|
31 | - 'method ReflectionFunctionAbstract::getReturnType should have ReflectionUnionType in return types for php 8.0+' |
|
32 | - ); |
|
33 | - self::assertContains( |
|
34 | - 'ReflectionType', |
|
35 | - $allReturnTypes, |
|
36 | - 'method ReflectionFunctionAbstract::getReturnType should have ReflectionType in return types for php 7.0' |
|
37 | - ); |
|
38 | - } |
|
15 | + /** |
|
16 | + * @throws Exception|RuntimeException |
|
17 | + */ |
|
18 | + public function testReflectionFunctionAbstractGetReturnTypeMethod() |
|
19 | + { |
|
20 | + $getReturnTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionFunctionAbstract')->getMethod('getReturnType'); |
|
21 | + $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getReturnTypeMethod->returnTypesFromAttribute + |
|
22 | + $getReturnTypeMethod->returnTypesFromSignature + $getReturnTypeMethod->returnTypesFromPhpDoc, false)); |
|
23 | + self::assertContains( |
|
24 | + 'ReflectionNamedType', |
|
25 | + $allReturnTypes, |
|
26 | + 'method ReflectionFunctionAbstract::getReturnType should have ReflectionNamedType in return types for php 7.1+' |
|
27 | + ); |
|
28 | + self::assertContains( |
|
29 | + 'ReflectionUnionType', |
|
30 | + $allReturnTypes, |
|
31 | + 'method ReflectionFunctionAbstract::getReturnType should have ReflectionUnionType in return types for php 8.0+' |
|
32 | + ); |
|
33 | + self::assertContains( |
|
34 | + 'ReflectionType', |
|
35 | + $allReturnTypes, |
|
36 | + 'method ReflectionFunctionAbstract::getReturnType should have ReflectionType in return types for php 7.0' |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @throws Exception|RuntimeException |
|
42 | - */ |
|
43 | - public function testReflectionPropertyGetTypeMethod() |
|
44 | - { |
|
45 | - $getTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionProperty')->getMethod('getType'); |
|
46 | - $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getTypeMethod->returnTypesFromAttribute + |
|
47 | - $getTypeMethod->returnTypesFromSignature + $getTypeMethod->returnTypesFromPhpDoc, false)); |
|
48 | - self::assertContains( |
|
49 | - 'ReflectionNamedType', |
|
50 | - $allReturnTypes, |
|
51 | - 'method ReflectionProperty::getType should have ReflectionNamedType in return types for php 7.1+' |
|
52 | - ); |
|
53 | - self::assertContains( |
|
54 | - 'ReflectionUnionType', |
|
55 | - $allReturnTypes, |
|
56 | - 'method ReflectionProperty::getType should have ReflectionUnionType in return types for php 8.0+' |
|
57 | - ); |
|
58 | - } |
|
40 | + /** |
|
41 | + * @throws Exception|RuntimeException |
|
42 | + */ |
|
43 | + public function testReflectionPropertyGetTypeMethod() |
|
44 | + { |
|
45 | + $getTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionProperty')->getMethod('getType'); |
|
46 | + $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getTypeMethod->returnTypesFromAttribute + |
|
47 | + $getTypeMethod->returnTypesFromSignature + $getTypeMethod->returnTypesFromPhpDoc, false)); |
|
48 | + self::assertContains( |
|
49 | + 'ReflectionNamedType', |
|
50 | + $allReturnTypes, |
|
51 | + 'method ReflectionProperty::getType should have ReflectionNamedType in return types for php 7.1+' |
|
52 | + ); |
|
53 | + self::assertContains( |
|
54 | + 'ReflectionUnionType', |
|
55 | + $allReturnTypes, |
|
56 | + 'method ReflectionProperty::getType should have ReflectionUnionType in return types for php 8.0+' |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @throws Exception|RuntimeException |
|
62 | - */ |
|
63 | - public function testReflectionParameterGetTypeMethod() |
|
64 | - { |
|
65 | - $getTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionParameter')->getMethod('getType'); |
|
66 | - $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getTypeMethod->returnTypesFromAttribute + |
|
67 | - $getTypeMethod->returnTypesFromSignature + $getTypeMethod->returnTypesFromPhpDoc, false)); |
|
68 | - self::assertContains( |
|
69 | - 'ReflectionNamedType', |
|
70 | - $allReturnTypes, |
|
71 | - 'method ReflectionParameter::getType should have ReflectionNamedType in return types' |
|
72 | - ); |
|
73 | - self::assertContains( |
|
74 | - 'ReflectionUnionType', |
|
75 | - $allReturnTypes, |
|
76 | - 'method ReflectionParameter::getType should have ReflectionUnionType in return types' |
|
77 | - ); |
|
78 | - } |
|
60 | + /** |
|
61 | + * @throws Exception|RuntimeException |
|
62 | + */ |
|
63 | + public function testReflectionParameterGetTypeMethod() |
|
64 | + { |
|
65 | + $getTypeMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass('ReflectionParameter')->getMethod('getType'); |
|
66 | + $allReturnTypes = array_unique(Model\CommonUtils::flattenArray($getTypeMethod->returnTypesFromAttribute + |
|
67 | + $getTypeMethod->returnTypesFromSignature + $getTypeMethod->returnTypesFromPhpDoc, false)); |
|
68 | + self::assertContains( |
|
69 | + 'ReflectionNamedType', |
|
70 | + $allReturnTypes, |
|
71 | + 'method ReflectionParameter::getType should have ReflectionNamedType in return types' |
|
72 | + ); |
|
73 | + self::assertContains( |
|
74 | + 'ReflectionUnionType', |
|
75 | + $allReturnTypes, |
|
76 | + 'method ReflectionParameter::getType should have ReflectionUnionType in return types' |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | } |
@@ -10,8 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * Class to test typehints of some Reflection* classes as reflection for these classes returns null. |
12 | 12 | */ |
13 | -class StubsReflectionClassesTest extends BaseStubsTest |
|
14 | -{ |
|
13 | +class StubsReflectionClassesTest extends BaseStubsTest { |
|
15 | 14 | /** |
16 | 15 | * @throws Exception|RuntimeException |
17 | 16 | */ |
@@ -8,17 +8,17 @@ |
||
8 | 8 | |
9 | 9 | class StubsStructureTest extends BaseStubsTest |
10 | 10 | { |
11 | - /** |
|
12 | - * @dataProvider \StubTests\TestData\Providers\Stubs\StubsTestDataProviders::stubsDirectoriesProvider |
|
13 | - */ |
|
14 | - public function testStubsDirectoryExistInMap($directory) |
|
15 | - { |
|
16 | - self::assertContains( |
|
17 | - $directory, |
|
18 | - iterator_to_array(new RecursiveIteratorIterator( |
|
19 | - new RecursiveArrayIterator(PhpCoreStubsProvider::$StubDirectoryMap) |
|
20 | - ), false), |
|
21 | - "Stubs directories provider doesn't contain '$directory'. Please add '$directory' to 'PhpCoreStubsProvider::\%StubDirectoryMap'" |
|
22 | - ); |
|
23 | - } |
|
11 | + /** |
|
12 | + * @dataProvider \StubTests\TestData\Providers\Stubs\StubsTestDataProviders::stubsDirectoriesProvider |
|
13 | + */ |
|
14 | + public function testStubsDirectoryExistInMap($directory) |
|
15 | + { |
|
16 | + self::assertContains( |
|
17 | + $directory, |
|
18 | + iterator_to_array(new RecursiveIteratorIterator( |
|
19 | + new RecursiveArrayIterator(PhpCoreStubsProvider::$StubDirectoryMap) |
|
20 | + ), false), |
|
21 | + "Stubs directories provider doesn't contain '$directory'. Please add '$directory' to 'PhpCoreStubsProvider::\%StubDirectoryMap'" |
|
22 | + ); |
|
23 | + } |
|
24 | 24 | } |
@@ -6,8 +6,7 @@ |
||
6 | 6 | use RecursiveIteratorIterator; |
7 | 7 | use StubTests\TestData\Providers\Stubs\PhpCoreStubsProvider; |
8 | 8 | |
9 | -class StubsStructureTest extends BaseStubsTest |
|
10 | -{ |
|
9 | +class StubsStructureTest extends BaseStubsTest { |
|
11 | 10 | /** |
12 | 11 | * @dataProvider \StubTests\TestData\Providers\Stubs\StubsTestDataProviders::stubsDirectoriesProvider |
13 | 12 | */ |
@@ -11,65 +11,65 @@ |
||
11 | 11 | |
12 | 12 | class StubsPhp81Tests extends BaseStubsTest |
13 | 13 | { |
14 | - /** |
|
15 | - * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionPropertiesProvider::classReadonlyPropertiesProvider |
|
16 | - * @throws RuntimeException |
|
17 | - */ |
|
18 | - public function testPropertyReadonly(PHPClass $class, PHPProperty $property) |
|
19 | - { |
|
20 | - $className = $class->name; |
|
21 | - $stubProperty = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name)->getProperty($property->name); |
|
22 | - static::assertEquals( |
|
23 | - $property->isReadonly, |
|
24 | - $stubProperty->isReadonly, |
|
25 | - "Property $className::$property->name readonly modifier is incorrect" |
|
26 | - ); |
|
27 | - } |
|
14 | + /** |
|
15 | + * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionPropertiesProvider::classReadonlyPropertiesProvider |
|
16 | + * @throws RuntimeException |
|
17 | + */ |
|
18 | + public function testPropertyReadonly(PHPClass $class, PHPProperty $property) |
|
19 | + { |
|
20 | + $className = $class->name; |
|
21 | + $stubProperty = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name)->getProperty($property->name); |
|
22 | + static::assertEquals( |
|
23 | + $property->isReadonly, |
|
24 | + $stubProperty->isReadonly, |
|
25 | + "Property $className::$property->name readonly modifier is incorrect" |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionMethodsProvider::classMethodsWithTentitiveReturnTypeProvider |
|
31 | - * @throws RuntimeException |
|
32 | - */ |
|
33 | - public function testTentativeReturnTypeHints(PHPClass|PHPInterface $class, PHPMethod $method) |
|
34 | - { |
|
35 | - $functionName = $method->name; |
|
36 | - if ($class instanceof PHPClass) { |
|
37 | - $stubMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name)->getMethod($functionName); |
|
38 | - } else { |
|
39 | - $stubMethod = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($class->name)->getMethod($functionName); |
|
40 | - } |
|
41 | - $unifiedStubsReturnTypes = []; |
|
42 | - $unifiedStubsAttributesReturnTypes = []; |
|
43 | - $unifiedReflectionReturnTypes = []; |
|
44 | - self::convertNullableTypesToUnion($method->returnTypesFromSignature, $unifiedReflectionReturnTypes); |
|
45 | - if (!empty($stubMethod->returnTypesFromSignature)) { |
|
46 | - self::convertNullableTypesToUnion($stubMethod->returnTypesFromSignature, $unifiedStubsReturnTypes); |
|
47 | - } else { |
|
48 | - foreach ($stubMethod->returnTypesFromAttribute as $languageVersion => $listOfTypes) { |
|
49 | - $unifiedStubsAttributesReturnTypes[$languageVersion] = []; |
|
50 | - self::convertNullableTypesToUnion($listOfTypes, $unifiedStubsAttributesReturnTypes[$languageVersion]); |
|
51 | - } |
|
52 | - } |
|
53 | - $conditionToCompareWithSignature = BaseStubsTest::isReflectionTypesMatchSignature( |
|
54 | - $unifiedReflectionReturnTypes, |
|
55 | - $unifiedStubsReturnTypes |
|
56 | - ); |
|
57 | - $typesFromAttribute = []; |
|
58 | - if (!empty($unifiedStubsAttributesReturnTypes)) { |
|
59 | - $typesFromAttribute = !empty($unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')]) ? |
|
60 | - $unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')] : |
|
61 | - $unifiedStubsAttributesReturnTypes['default']; |
|
62 | - } |
|
63 | - $conditionToCompareWithAttribute = BaseStubsTest::isReflectionTypesExistInAttributes($unifiedReflectionReturnTypes, $typesFromAttribute); |
|
64 | - $testCondition = $conditionToCompareWithSignature || $conditionToCompareWithAttribute; |
|
65 | - self::assertTrue( |
|
66 | - $testCondition, |
|
67 | - "Method $class->name::$functionName has invalid return type. Reflection method has return type " . |
|
68 | - implode('|', $method->returnTypesFromSignature) . |
|
69 | - ' but stubs has return type ' . implode('|', $stubMethod->returnTypesFromSignature) . |
|
70 | - ' in signature and attribute has types ' . implode('|', $typesFromAttribute) |
|
71 | - ); |
|
72 | - self::assertTrue($stubMethod->isReturnTypeTentative, "Reflection method $class->name::$functionName has " . |
|
73 | - "tentative return type but stub's method isn't declared as tentative"); |
|
74 | - } |
|
29 | + /** |
|
30 | + * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionMethodsProvider::classMethodsWithTentitiveReturnTypeProvider |
|
31 | + * @throws RuntimeException |
|
32 | + */ |
|
33 | + public function testTentativeReturnTypeHints(PHPClass|PHPInterface $class, PHPMethod $method) |
|
34 | + { |
|
35 | + $functionName = $method->name; |
|
36 | + if ($class instanceof PHPClass) { |
|
37 | + $stubMethod = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class->name)->getMethod($functionName); |
|
38 | + } else { |
|
39 | + $stubMethod = PhpStormStubsSingleton::getPhpStormStubs()->getInterface($class->name)->getMethod($functionName); |
|
40 | + } |
|
41 | + $unifiedStubsReturnTypes = []; |
|
42 | + $unifiedStubsAttributesReturnTypes = []; |
|
43 | + $unifiedReflectionReturnTypes = []; |
|
44 | + self::convertNullableTypesToUnion($method->returnTypesFromSignature, $unifiedReflectionReturnTypes); |
|
45 | + if (!empty($stubMethod->returnTypesFromSignature)) { |
|
46 | + self::convertNullableTypesToUnion($stubMethod->returnTypesFromSignature, $unifiedStubsReturnTypes); |
|
47 | + } else { |
|
48 | + foreach ($stubMethod->returnTypesFromAttribute as $languageVersion => $listOfTypes) { |
|
49 | + $unifiedStubsAttributesReturnTypes[$languageVersion] = []; |
|
50 | + self::convertNullableTypesToUnion($listOfTypes, $unifiedStubsAttributesReturnTypes[$languageVersion]); |
|
51 | + } |
|
52 | + } |
|
53 | + $conditionToCompareWithSignature = BaseStubsTest::isReflectionTypesMatchSignature( |
|
54 | + $unifiedReflectionReturnTypes, |
|
55 | + $unifiedStubsReturnTypes |
|
56 | + ); |
|
57 | + $typesFromAttribute = []; |
|
58 | + if (!empty($unifiedStubsAttributesReturnTypes)) { |
|
59 | + $typesFromAttribute = !empty($unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')]) ? |
|
60 | + $unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')] : |
|
61 | + $unifiedStubsAttributesReturnTypes['default']; |
|
62 | + } |
|
63 | + $conditionToCompareWithAttribute = BaseStubsTest::isReflectionTypesExistInAttributes($unifiedReflectionReturnTypes, $typesFromAttribute); |
|
64 | + $testCondition = $conditionToCompareWithSignature || $conditionToCompareWithAttribute; |
|
65 | + self::assertTrue( |
|
66 | + $testCondition, |
|
67 | + "Method $class->name::$functionName has invalid return type. Reflection method has return type " . |
|
68 | + implode('|', $method->returnTypesFromSignature) . |
|
69 | + ' but stubs has return type ' . implode('|', $stubMethod->returnTypesFromSignature) . |
|
70 | + ' in signature and attribute has types ' . implode('|', $typesFromAttribute) |
|
71 | + ); |
|
72 | + self::assertTrue($stubMethod->isReturnTypeTentative, "Reflection method $class->name::$functionName has " . |
|
73 | + "tentative return type but stub's method isn't declared as tentative"); |
|
74 | + } |
|
75 | 75 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionMethodsProvider::classMethodsWithTentitiveReturnTypeProvider |
31 | 31 | * @throws RuntimeException |
32 | 32 | */ |
33 | - public function testTentativeReturnTypeHints(PHPClass|PHPInterface $class, PHPMethod $method) |
|
33 | + public function testTentativeReturnTypeHints(PHPClass | PHPInterface $class, PHPMethod $method) |
|
34 | 34 | { |
35 | 35 | $functionName = $method->name; |
36 | 36 | if ($class instanceof PHPClass) { |
@@ -57,19 +57,18 @@ discard block |
||
57 | 57 | $typesFromAttribute = []; |
58 | 58 | if (!empty($unifiedStubsAttributesReturnTypes)) { |
59 | 59 | $typesFromAttribute = !empty($unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')]) ? |
60 | - $unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')] : |
|
61 | - $unifiedStubsAttributesReturnTypes['default']; |
|
60 | + $unifiedStubsAttributesReturnTypes[getenv('PHP_VERSION')] : $unifiedStubsAttributesReturnTypes['default']; |
|
62 | 61 | } |
63 | 62 | $conditionToCompareWithAttribute = BaseStubsTest::isReflectionTypesExistInAttributes($unifiedReflectionReturnTypes, $typesFromAttribute); |
64 | 63 | $testCondition = $conditionToCompareWithSignature || $conditionToCompareWithAttribute; |
65 | 64 | self::assertTrue( |
66 | 65 | $testCondition, |
67 | - "Method $class->name::$functionName has invalid return type. Reflection method has return type " . |
|
68 | - implode('|', $method->returnTypesFromSignature) . |
|
69 | - ' but stubs has return type ' . implode('|', $stubMethod->returnTypesFromSignature) . |
|
70 | - ' in signature and attribute has types ' . implode('|', $typesFromAttribute) |
|
66 | + "Method $class->name::$functionName has invalid return type. Reflection method has return type ". |
|
67 | + implode('|', $method->returnTypesFromSignature). |
|
68 | + ' but stubs has return type '.implode('|', $stubMethod->returnTypesFromSignature). |
|
69 | + ' in signature and attribute has types '.implode('|', $typesFromAttribute) |
|
71 | 70 | ); |
72 | - self::assertTrue($stubMethod->isReturnTypeTentative, "Reflection method $class->name::$functionName has " . |
|
71 | + self::assertTrue($stubMethod->isReturnTypeTentative, "Reflection method $class->name::$functionName has ". |
|
73 | 72 | "tentative return type but stub's method isn't declared as tentative"); |
74 | 73 | } |
75 | 74 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | use StubTests\Model\PHPProperty; |
10 | 10 | use StubTests\TestData\Providers\PhpStormStubsSingleton; |
11 | 11 | |
12 | -class StubsPhp81Tests extends BaseStubsTest |
|
13 | -{ |
|
12 | +class StubsPhp81Tests extends BaseStubsTest { |
|
14 | 13 | /** |
15 | 14 | * @dataProvider \StubTests\TestData\Providers\Reflection\ReflectionPropertiesProvider::classReadonlyPropertiesProvider |
16 | 15 | * @throws RuntimeException |