Skip to content

Conversation

@ondrejmirtes
Copy link
Member

Supersedes #750

/cc @staabm This isn't yet ready for prime-time. For one, I don't think that some extension types are called with the reordered arguments. Let's take dynamic method return type extensions for example:

		foreach (TypeUtils::getDirectClassNames($typeWithMethod) as $className) {
			if ($methodCall instanceof MethodCall) {
				foreach ($this->dynamicReturnTypeExtensionRegistry->getDynamicMethodReturnTypeExtensionsForClass($className) as $dynamicMethodReturnTypeExtension) {
					if (!$dynamicMethodReturnTypeExtension->isMethodSupported($methodReflection)) {
						continue;
					}

					$resolvedType = $dynamicMethodReturnTypeExtension->getTypeFromMethodCall($methodReflection, $methodCall, $this);
					if ($resolvedType === null) {
						continue;
					}

					$resolvedTypes[] = $resolvedType;
				}
			} else {
				foreach ($this->dynamicReturnTypeExtensionRegistry->getDynamicStaticMethodReturnTypeExtensionsForClass($className) as $dynamicStaticMethodReturnTypeExtension) {
					if (!$dynamicStaticMethodReturnTypeExtension->isStaticMethodSupported($methodReflection)) {
						continue;
					}

					$resolvedType = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall(
						$methodReflection,
						$methodCall,
						$this,
					);
					if ($resolvedType === null) {
						continue;
					}

					$resolvedTypes[] = $resolvedType;
				}
			}
		}

No indication of usage of NamedArgumentsHelper.

Additionally, it looks like that in some cases, the arguments are not indexed from zero. Which can be seen from these errors:

1230) PHPStan\Analyser\LegacyNodeScopeResolverTest::testPhp74Functions with data set #26 ('non-empty-array<int, string>', '$mbStrSplitConstantStringWith...coding')
Undefined array key 0

/Users/ondrej/Development/phpstan/src/Type/Php/StrSplitFunctionReturnTypeExtension.php:87

Would you be able to bring this over the finish line? Thanks.

@ondrejmirtes ondrejmirtes mentioned this pull request May 11, 2022
6 tasks
@staabm
Copy link
Contributor

staabm commented May 11, 2022

I will see what I can do. will report back.

@ondrejmirtes
Copy link
Member Author

Just rebased the branch, it should fix some errors.

@staabm
Copy link
Contributor

staabm commented May 12, 2022

working on fixes to be pushed into this PR in #1305

@staabm staabm mentioned this pull request May 12, 2022
@ondrejmirtes ondrejmirtes marked this pull request as ready for review May 12, 2022 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants