diff --git a/Makefile b/Makefile index e935b2ad1f9..9d5cff7a01a 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ lint: --exclude tests/PHPStan/Rules/Properties/data/intersection-types.php \ --exclude tests/PHPStan/Rules/Classes/data/first-class-instantiation-callable.php \ --exclude tests/PHPStan/Rules/Classes/data/instantiation-callable.php \ + --exclude tests/PHPStan/Rules/Classes/data/instantiation-partial-function-application.php \ --exclude tests/PHPStan/Rules/Classes/data/bug-9402.php \ --exclude tests/PHPStan/Rules/Constants/data/class-as-class-constant.php \ --exclude tests/PHPStan/Rules/Constants/data/value-assigned-to-class-constant-native-type.php \ diff --git a/build/collision-detector.json b/build/collision-detector.json index 7ac9a60bd96..9f285d628c9 100644 --- a/build/collision-detector.json +++ b/build/collision-detector.json @@ -29,6 +29,13 @@ "../tests/PHPStan/Rules/DeadCode/data/partial-function-application-bound-args.php", "../tests/PHPStan/Rules/Exceptions/data/dead-catch-partial-function-application.php", "../tests/PHPStan/Rules/Functions/data/partial-function-application-bound-args.php", - "../tests/PHPStan/Rules/Pure/data/partial-function-application-pure.php" + "../tests/PHPStan/Rules/Pure/data/partial-function-application-pure.php", + "../tests/PHPStan/Analyser/nsrt/partial-function-application-signature.php", + "../tests/PHPStan/Rules/Functions/data/partial-function-application-closure-calls.php", + "../tests/PHPStan/Rules/Functions/data/partial-function-application-arguments.php", + "../tests/PHPStan/Rules/Methods/data/partial-function-application-method-arguments.php", + "../tests/PHPStan/Rules/Functions/data/partial-function-application-callbacks.php", + "../tests/PHPStan/Analyser/nsrt/partial-function-application-replay.php", + "../tests/PHPStan/Rules/Classes/data/instantiation-partial-function-application.php" ] } diff --git a/build/stubs/PhpParserExpr.stub b/build/stubs/PhpParserExpr.stub index 636d8cf5b42..01f47088491 100644 --- a/build/stubs/PhpParserExpr.stub +++ b/build/stubs/PhpParserExpr.stub @@ -5,6 +5,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node; use PhpParser\NodeAbstract; use PhpParser\Node\Arg; +use PhpParser\Node\ArgPlaceholder; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; use PhpParser\Node\VariadicPlaceholder; @@ -13,38 +14,38 @@ use PhpParser\Node\FunctionLike; abstract class CallLike extends Expr { /** * Return raw arguments, which may be actual Args, or VariadicPlaceholders for first-class - * callables. + * callables, or ArgPlaceholders for partial function application. * - * @return list + * @return list */ abstract public function getRawArgs(): array; /** - * Assert that this is not a first-class callable and return only ordinary Args. + * Assert that this is not a partial function application and return only ordinary Args. * * @return list */ public function getArgs(): array { - assert(!$this->isFirstClassCallable()); + assert(!$this->isPartialFunctionApplication()); return $this->getRawArgs(); } } class FuncCall extends CallLike { - /** @var list Arguments */ + /** @var list Arguments */ public array $args; /** * Constructs a function call node. * * @param Node\Name|Expr $name Function name - * @param list $args Arguments + * @param list $args Arguments * @param array $attributes Additional attributes */ public function __construct(Node $name, array $args = [], array $attributes = []) {} } class MethodCall extends CallLike { - /** @var list Arguments */ + /** @var list Arguments */ public array $args; /** @@ -52,28 +53,28 @@ class MethodCall extends CallLike { * * @param Expr $var Variable holding object * @param string|Identifier|Expr $name Method name - * @param list $args Arguments + * @param list $args Arguments * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {} } class New_ extends CallLike { - /** @var list Arguments */ + /** @var list Arguments */ public array $args; /** * Constructs a function call node. * * @param Node\Name|Expr|Node\Stmt\Class_ $class Class name (or class node for anonymous classes) - * @param list $args Arguments + * @param list $args Arguments * @param array $attributes Additional attributes */ public function __construct(Node $class, array $args = [], array $attributes = []) {} } class NullsafeMethodCall extends CallLike { - /** @var list Arguments */ + /** @var list Arguments */ public array $args; /** @@ -81,14 +82,14 @@ class NullsafeMethodCall extends CallLike { * * @param Expr $var Variable holding object * @param string|Identifier|Expr $name Method name - * @param list $args Arguments + * @param list $args Arguments * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {} } class StaticCall extends CallLike { - /** @var list Arguments */ + /** @var list Arguments */ public array $args; /** @@ -96,7 +97,7 @@ class StaticCall extends CallLike { * * @param Node\Name|Expr $class Class name * @param string|Identifier|Expr $name Method name - * @param list $args Arguments + * @param list $args Arguments * @param array $attributes Additional attributes */ public function __construct(Node $class, $name, array $args = [], array $attributes = []) {} diff --git a/e2e/result-cache-first-class-callable/dep.patch b/e2e/result-cache-first-class-callable/dep.patch new file mode 100644 index 00000000000..cf5bc0b5248 --- /dev/null +++ b/e2e/result-cache-first-class-callable/dep.patch @@ -0,0 +1,28 @@ +--- src/Dep.php ++++ src/Dep.php +@@ -5,21 +5,21 @@ + class Dep + { + +- public function m(): string ++ public function m(): int + { +- return 'a'; ++ return 1; + } + +- public static function s(): string ++ public static function s(): int + { +- return 'a'; ++ return 1; + } + + } + +-function f(): string ++function f(): int + { +- return 'a'; ++ return 1; + } diff --git a/e2e/result-cache-first-class-callable/phpstan.neon b/e2e/result-cache-first-class-callable/phpstan.neon new file mode 100644 index 00000000000..1618e38b360 --- /dev/null +++ b/e2e/result-cache-first-class-callable/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 8 + phpVersion: 80100 + tmpDir: tmp + paths: + - src diff --git a/e2e/result-cache-first-class-callable/result-cache-first-class-callable_test.sh b/e2e/result-cache-first-class-callable/result-cache-first-class-callable_test.sh new file mode 100755 index 00000000000..c597ae39035 --- /dev/null +++ b/e2e/result-cache-first-class-callable/result-cache-first-class-callable_test.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# @tags result-cache + +function set_up() { + e2e::set_up +} + +function tear_down() { + e2e::tear_down +} + +function test_result_cache_first_class_callable() { + OUTPUT=$(../../bin/phpstan analyse -vv --error-format raw 2>&1) && CODE=0 || CODE=$? + echo "$OUTPUT" + assert_same "0" "$CODE" + # The signature of a first-class callable is the signature of its target, so a + # file creating one from a function, a method or a static method of Dep.php + # depends on Dep.php. Unrelated.php does not. + patch -b src/Dep.php < dep.patch + INFO=$(../../bin/phpstan result-cache-info --json) + echo "$INFO" + assert_equals 'true' "$(echo "$INFO" | jq --raw-output '.resultCacheUsed')" + assert_equals '4' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../../bin/phpstan analyse --error-format raw 2>&1) && CODE=0 || CODE=$? + echo "$OUTPUT" + assert_same "1" "$CODE" + assert_contains 'FunctionFcc.php:9:Function ResultCacheE2EFirstClassCallable\functionFcc() should return string but returns int.' "$OUTPUT" + assert_contains 'MethodFcc.php:9:Function ResultCacheE2EFirstClassCallable\methodFcc() should return string but returns int.' "$OUTPUT" + assert_contains 'StaticMethodFcc.php:9:Function ResultCacheE2EFirstClassCallable\staticMethodFcc() should return string but returns int.' "$OUTPUT" +} diff --git a/e2e/result-cache-first-class-callable/src/Dep.php b/e2e/result-cache-first-class-callable/src/Dep.php new file mode 100644 index 00000000000..702109565de --- /dev/null +++ b/e2e/result-cache-first-class-callable/src/Dep.php @@ -0,0 +1,23 @@ +m(...); + + return $f(); +} diff --git a/e2e/result-cache-first-class-callable/src/StaticMethodFcc.php b/e2e/result-cache-first-class-callable/src/StaticMethodFcc.php new file mode 100644 index 00000000000..02984713a67 --- /dev/null +++ b/e2e/result-cache-first-class-callable/src/StaticMethodFcc.php @@ -0,0 +1,10 @@ +getDefaultValue(); if ($defaultValue === null) { if (!$parameter->isVariadic()) { - throw new ShouldNotHappenException(sprintf('An optional parameter $%s must have a default value', $parameter->getName())); + // like an optional parameter combined from variants that do not all have it + return null; } $defaultValue = new ConstantArrayType([], []); } diff --git a/src/Analyser/ExprHandler/FuncCallHandler.php b/src/Analyser/ExprHandler/FuncCallHandler.php index 008e549a016..2f2a8b76c82 100644 --- a/src/Analyser/ExprHandler/FuncCallHandler.php +++ b/src/Analyser/ExprHandler/FuncCallHandler.php @@ -22,6 +22,7 @@ use PHPStan\Analyser\ExpressionResultFactory; use PHPStan\Analyser\ExpressionResultStorage; use PHPStan\Analyser\ExprHandler; +use PHPStan\Analyser\ExprHandler\Helper\ClosureOriginCallReplay; use PHPStan\Analyser\ExprHandler\Helper\ClosureTypeResolver; use PHPStan\Analyser\ExprHandler\Helper\DefaultNarrowingHelper; use PHPStan\Analyser\ExprHandler\Helper\DynamicReturnTypeStoragePrimer; @@ -600,7 +601,12 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex $argsResult->getDependencies(), $this->getDependencies($beforeScope, $functionReflection, $nameResult, $preliminaryResult), ); - return $preliminaryResult->finalize($scope, $hasYield, $isAlwaysTerminating, $throwPoints, $impurePoints, $variableFlow, $dependencies); + $result = $preliminaryResult->finalize($scope, $hasYield, $isAlwaysTerminating, $throwPoints, $impurePoints, $variableFlow, $dependencies); + if ($nameResult === null) { + return $result; + } + + return ClosureOriginCallReplay::replay($nodeScopeResolver, $this->expressionResultFactory, $expr, $nameResult, $nameType, $scopeBeforeArgs, $storage, $result); } /** @@ -863,12 +869,6 @@ private function resolveReturnType(NodeScopeResolver $nodeScopeResolver, Mutatin /** @var non-empty-string $name */ $name = $expr->name->value; $functionName = new Name($name); - } elseif ( - $expr->name instanceof FuncCall - && $expr->name->name instanceof Name - && $expr->name->isFirstClassCallable() - ) { - $functionName = $expr->name->name; } $normalizedNode = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $expr); diff --git a/src/Analyser/ExprHandler/Helper/ClosureOriginCallReplay.php b/src/Analyser/ExprHandler/Helper/ClosureOriginCallReplay.php new file mode 100644 index 00000000000..4c078aa48bc --- /dev/null +++ b/src/Analyser/ExprHandler/Helper/ClosureOriginCallReplay.php @@ -0,0 +1,131 @@ +getTypes() : [$calleeType]; + /** @var list $origins */ + $origins = []; + $calls = []; + foreach ($members as $member) { + if (!$member instanceof ClosureType) { + return $result; + } + $origin = $member->getOrigin(); + if ($origin === null) { + return $result; + } + foreach ($origins as $seen) { + if ($seen->equals($origin)) { + continue 2; + } + } + $call = $origin->createCall($expr, $member); + if ($call === null) { + return $result; + } + $origins[] = $origin; + $calls[] = $call; + } + if ($calls === []) { + return $result; + } + + // the arguments are already processed: the replayed calls read their + // stored results, walking from the same position + $replayed = []; + foreach ($calls as $call) { + $replayed[] = $nodeScopeResolver->processExprOnDemand($call, $scopeBeforeArgs, $storage->duplicate()); + } + + $scope = $replayed[0]->getScope(); + $isAlwaysTerminating = $replayed[0]->isAlwaysTerminating(); + // the callee's throw points depend on the arguments (json_decode()'s flags), + // the closure's are the ones of any call + $throwPoints = [...$nameResult->getThrowPoints(), ...$replayed[0]->getThrowPoints()]; + foreach (array_slice($replayed, 1) as $replayedResult) { + $scope = $scope->mergeWith($replayedResult->getScope()); + $isAlwaysTerminating = $isAlwaysTerminating && $replayedResult->isAlwaysTerminating(); + $throwPoints = [...$throwPoints, ...$replayedResult->getThrowPoints()]; + } + + // positional: simple-downgrader resolves named arguments only on $this->property->method() calls + return $expressionResultFactory->create( + $scope, + $result->getBeforeScope(), + $expr, + $result->hasYield(), + $result->isAlwaysTerminating() || $isAlwaysTerminating, + $throwPoints, + $result->getImpurePoints(), + static fn (bool $nativeTypesPromoted): Type => TypeCombinator::union(...array_map( + static fn (ExpressionResult $replayedResult): Type => $replayedResult->getKeepVoidType($nativeTypesPromoted), + $replayed, + )), + static function (TypeSpecifierContext $context, bool $nativeTypesPromoted) use ($replayed): SpecifiedTypes { + $specifiedTypes = $replayed[0]->getSpecifiedTypes($context, $nativeTypesPromoted); + foreach (array_slice($replayed, 1) as $replayedResult) { + $specifiedTypes = $specifiedTypes->intersectWith($replayedResult->getSpecifiedTypes($context, $nativeTypesPromoted)); + } + + return $specifiedTypes; + }, + false, + null, + null, + null, + static fn (Type $type, TypeSpecifierContext $context, bool $nativeTypesPromoted): SpecifiedTypes => $result->getCreatedTypes($type, $context, $nativeTypesPromoted) ?? new SpecifiedTypes(), + null, + null, + $result->getArgsResult(), + $result->getVariableFlow(), + $result->getDependencies(), + ); + } + +} diff --git a/src/Analyser/ExprHandler/Virtual/FunctionCallableNodeHandler.php b/src/Analyser/ExprHandler/Virtual/FunctionCallableNodeHandler.php index d454a9b55f6..20aca1ca69e 100644 --- a/src/Analyser/ExprHandler/Virtual/FunctionCallableNodeHandler.php +++ b/src/Analyser/ExprHandler/Virtual/FunctionCallableNodeHandler.php @@ -24,6 +24,7 @@ use PHPStan\Node\FunctionCallableNode; use PHPStan\Reflection\InitializerExprContext; use PHPStan\Reflection\InitializerExprTypeResolver; +use PHPStan\Reflection\PartialFunctionApplicationParameters; use PHPStan\Reflection\ReflectionProvider; use PHPStan\ShouldNotHappenException; use PHPStan\Turbo\ShadowedByTurboExtension; @@ -150,10 +151,6 @@ private function getDependencies(MutatingScope $scope, FunctionCallableNode $exp private function resolveType(MutatingScope $scope, FunctionCallableNode $expr, ?ExpressionResult $nameResult): Type { $originalNode = $expr->getOriginalNode(); - if (!$originalNode->isFirstClassCallable()) { - // the signature of a partial function application is not inferred yet - return new ObjectType(Closure::class); - } if ($originalNode->name instanceof Expr) { // $originalNode->name is the same node as $expr->getName(), processed // in processExpr exactly in this branch - read its ExpressionResult @@ -161,7 +158,8 @@ private function resolveType(MutatingScope $scope, FunctionCallableNode $expr, ? throw new ShouldNotHappenException(); } $callableType = $nameResult->getTypeOnScope($scope, $scope->nativeTypesPromoted); - if (self::isClosureObject($callableType)) { + $isFirstClassCallable = $originalNode->isFirstClassCallable(); + if ($isFirstClassCallable && self::isClosureObject($callableType)) { // the first-class callable of a closure object is the object itself return $callableType; } @@ -173,10 +171,17 @@ private function resolveType(MutatingScope $scope, FunctionCallableNode $expr, ? null, $callableType->getCallableParametersAcceptors($scope), $scope->nativeTypesPromoted, + $isFirstClassCallable ? null : $originalNode->getRawArgs(), + $isFirstClassCallable ? [] : PartialFunctionApplicationParameters::getBoundArgTypes($scope, $originalNode), ); } - return $this->initializerExprTypeResolver->getFirstClassCallableType($originalNode, InitializerExprContext::fromScope($scope), $scope->nativeTypesPromoted); + return $this->initializerExprTypeResolver->getFirstClassCallableType( + $originalNode, + InitializerExprContext::fromScope($scope), + $scope->nativeTypesPromoted, + $originalNode->isFirstClassCallable() ? null : PartialFunctionApplicationParameters::getBoundArgTypes($scope, $originalNode), + ); } private static function isClosureObject(Type $type): bool diff --git a/src/Analyser/ExprHandler/Virtual/MethodCallableNodeHandler.php b/src/Analyser/ExprHandler/Virtual/MethodCallableNodeHandler.php index 3e09dad7691..a6d9a5f3faa 100644 --- a/src/Analyser/ExprHandler/Virtual/MethodCallableNodeHandler.php +++ b/src/Analyser/ExprHandler/Virtual/MethodCallableNodeHandler.php @@ -23,7 +23,9 @@ use PHPStan\DependencyInjection\AutowiredService; use PHPStan\Node\MethodCallableNode; use PHPStan\Reflection\InitializerExprTypeResolver; +use PHPStan\Reflection\PartialFunctionApplicationParameters; use PHPStan\Turbo\ShadowedByTurboExtension; +use PHPStan\Type\ClosureOrigin; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; use function array_merge; @@ -145,10 +147,6 @@ private function resolveType(MutatingScope $scope, MethodCallableNode $expr, Exp if (!$originalNode->name instanceof Identifier) { return new ObjectType(Closure::class); } - if (!$originalNode->isFirstClassCallable()) { - // the signature of a partial function application is not inferred yet - return new ObjectType(Closure::class); - } // $originalNode->var is the same node as $expr->getVar(), processed in // processExpr - read its ExpressionResult instead of Scope::getType() @@ -162,6 +160,9 @@ private function resolveType(MutatingScope $scope, MethodCallableNode $expr, Exp $method, $method->getVariants(), $scope->nativeTypesPromoted, + $originalNode->isFirstClassCallable() ? null : $originalNode->getRawArgs(), + $originalNode->isFirstClassCallable() ? [] : PartialFunctionApplicationParameters::getBoundArgTypes($scope, $originalNode), + ClosureOrigin::forMethod($varType, $originalNode->name->toString(), false), ); } diff --git a/src/Analyser/ExprHandler/Virtual/StaticMethodCallableNodeHandler.php b/src/Analyser/ExprHandler/Virtual/StaticMethodCallableNodeHandler.php index e8b84371f33..9d6ee3e47ba 100644 --- a/src/Analyser/ExprHandler/Virtual/StaticMethodCallableNodeHandler.php +++ b/src/Analyser/ExprHandler/Virtual/StaticMethodCallableNodeHandler.php @@ -23,6 +23,7 @@ use PHPStan\Node\StaticMethodCallableNode; use PHPStan\Reflection\InitializerExprContext; use PHPStan\Reflection\InitializerExprTypeResolver; +use PHPStan\Reflection\PartialFunctionApplicationParameters; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Turbo\ShadowedByTurboExtension; use PHPStan\Type\Type; @@ -103,7 +104,12 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex isAlwaysTerminating: $isAlwaysTerminating, throwPoints: $throwPoints, impurePoints: $impurePoints, - typeCallback: fn (bool $nativeTypesPromoted): Type => $this->initializerExprTypeResolver->getFirstClassCallableType($expr->getOriginalNode(), InitializerExprContext::fromScope($beforeScope), $nativeTypesPromoted), + typeCallback: fn (bool $nativeTypesPromoted): Type => $this->initializerExprTypeResolver->getFirstClassCallableType( + $expr->getOriginalNode(), + InitializerExprContext::fromScope($beforeScope), + $nativeTypesPromoted, + $expr->getOriginalNode()->isFirstClassCallable() ? null : PartialFunctionApplicationParameters::getBoundArgTypes($nativeTypesPromoted ? $beforeScope->doNotTreatPhpDocTypesAsCertain() : $beforeScope, $expr->getOriginalNode()), + ), specifyTypesCallback: fn (TypeSpecifierContext $context, bool $nativeTypesPromoted) => $this->defaultNarrowingHelper->specifyDefaultTypes($expr, $context), ); diff --git a/src/Node/FunctionCallableNode.php b/src/Node/FunctionCallableNode.php index ac74cc15545..6c70cb03d6a 100644 --- a/src/Node/FunctionCallableNode.php +++ b/src/Node/FunctionCallableNode.php @@ -3,8 +3,11 @@ namespace PHPStan\Node; use Override; +use PhpParser\Node\Arg; +use PhpParser\Node\ArgPlaceholder; use PhpParser\Node\Expr; use PhpParser\Node\Name; +use PhpParser\Node\VariadicPlaceholder; use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Turbo\ReferencedByTurboExtension; @@ -36,6 +39,16 @@ public function getOriginalNode(): Expr\FuncCall return $this->originalNode; } + /** + * The arguments of the call: bound arguments, `?` placeholders and the `...` placeholder. + * + * @return array + */ + public function getArgs(): array + { + return $this->originalNode->getRawArgs(); + } + #[Override] public function getType(): string { diff --git a/src/Node/MethodCallableNode.php b/src/Node/MethodCallableNode.php index 037605111c2..fa530142186 100644 --- a/src/Node/MethodCallableNode.php +++ b/src/Node/MethodCallableNode.php @@ -3,8 +3,11 @@ namespace PHPStan\Node; use Override; +use PhpParser\Node\Arg; +use PhpParser\Node\ArgPlaceholder; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; +use PhpParser\Node\VariadicPlaceholder; use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Turbo\ReferencedByTurboExtension; @@ -45,6 +48,16 @@ public function getOriginalNode(): Expr\MethodCall return $this->originalNode; } + /** + * The arguments of the call: bound arguments, `?` placeholders and the `...` placeholder. + * + * @return array + */ + public function getArgs(): array + { + return $this->originalNode->getRawArgs(); + } + #[Override] public function getType(): string { diff --git a/src/Node/StaticMethodCallableNode.php b/src/Node/StaticMethodCallableNode.php index 02573a06baf..b8287fc3d21 100644 --- a/src/Node/StaticMethodCallableNode.php +++ b/src/Node/StaticMethodCallableNode.php @@ -3,9 +3,12 @@ namespace PHPStan\Node; use Override; +use PhpParser\Node\Arg; +use PhpParser\Node\ArgPlaceholder; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; use PhpParser\Node\Name; +use PhpParser\Node\VariadicPlaceholder; use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Turbo\ReferencedByTurboExtension; @@ -49,6 +52,16 @@ public function getOriginalNode(): Expr\StaticCall return $this->originalNode; } + /** + * The arguments of the call: bound arguments, `?` placeholders and the `...` placeholder. + * + * @return array + */ + public function getArgs(): array + { + return $this->originalNode->getRawArgs(); + } + #[Override] public function getType(): string { diff --git a/src/Reflection/InitializerExprTypeResolver.php b/src/Reflection/InitializerExprTypeResolver.php index be6369d447d..ee7767ab88d 100644 --- a/src/Reflection/InitializerExprTypeResolver.php +++ b/src/Reflection/InitializerExprTypeResolver.php @@ -4,6 +4,7 @@ use Closure; use PhpParser\Node\Arg; +use PhpParser\Node\ArgPlaceholder; use PhpParser\Node\ComplexType; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp; @@ -27,6 +28,7 @@ use PhpParser\Node\Scalar\MagicConst\File; use PhpParser\Node\Scalar\MagicConst\Line; use PhpParser\Node\Scalar\String_; +use PhpParser\Node\VariadicPlaceholder; use PHPStan\Analyser\ConstantResolver; use PHPStan\Analyser\OutOfClassScope; use PHPStan\Analyser\ValueDependencyCollector; @@ -52,6 +54,7 @@ use PHPStan\Type\BooleanType; use PHPStan\Type\CallableAssertionsHelper; use PHPStan\Type\ClassStringType; +use PHPStan\Type\ClosureOrigin; use PHPStan\Type\ClosureType; use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantArrayTypeBuilder; @@ -788,11 +791,24 @@ private function isParameterValueNullable(Param $parameter): bool return false; } - public function getFirstClassCallableType(Expr\CallLike $expr, InitializerExprContext $context, bool $nativeTypesPromoted): Type + /** + * @param array|null $boundArgTypes the types of the bound arguments of a partial function application, + * keyed like its raw arguments; null to resolve them as constant expressions + */ + public function getFirstClassCallableType(Expr\CallLike $expr, InitializerExprContext $context, bool $nativeTypesPromoted, ?array $boundArgTypes = null): Type { + $partialApplicationArgs = null; if (!$expr->isFirstClassCallable()) { - // the signature of a partial function application is not inferred yet - return new ObjectType(Closure::class); + $partialApplicationArgs = $expr->getRawArgs(); + if ($boundArgTypes === null) { + $boundArgTypes = []; + foreach ($partialApplicationArgs as $i => $arg) { + if (!$arg instanceof Arg) { + continue; + } + $boundArgTypes[$i] = $this->getType($arg->value, $context); + } + } } if ($expr instanceof FuncCall) { @@ -803,6 +819,9 @@ public function getFirstClassCallableType(Expr\CallLike $expr, InitializerExprCo $function, $function->getVariants(), $nativeTypesPromoted, + $partialApplicationArgs, + $boundArgTypes ?? [], + ClosureOrigin::forFunction($function->getName()), ); } @@ -841,6 +860,9 @@ public function getFirstClassCallableType(Expr\CallLike $expr, InitializerExprCo $method, $method->getVariants(), $nativeTypesPromoted, + $partialApplicationArgs, + $boundArgTypes ?? [], + ClosureOrigin::forMethod($classType, $methodName, true), ); } @@ -853,13 +875,28 @@ public function getFirstClassCallableType(Expr\CallLike $expr, InitializerExprCo /** * @param ParametersAcceptor[] $variants + * @param array|null $partialApplicationArgs the arguments of a partial function application, null for a first-class callable + * @param array $boundArgTypes the types of the bound arguments of a partial function application, keyed like $partialApplicationArgs + * @param ClosureOrigin|null $origin the callee, whose call a call of the closure replays */ public function createFirstClassCallable( FunctionReflection|ExtendedMethodReflection|null $function, array $variants, bool $nativeTypesPromoted, + ?array $partialApplicationArgs = null, + array $boundArgTypes = [], + ?ClosureOrigin $origin = null, ): Type { + if ($origin !== null && $partialApplicationArgs !== null) { + $origin = $origin->withPartialApplication($partialApplicationArgs, $boundArgTypes); + } + + if ($partialApplicationArgs !== null && PartialFunctionApplicationParameters::leavesUnknownDefaultValue($variants, $partialApplicationArgs)) { + // creating the closure throws + return new ObjectType(Closure::class); + } + // variants of multi-variant built-ins carry functionMap parameter names, // but the closure accepts the native names as named arguments $namedArgumentNames = []; @@ -879,19 +916,6 @@ public function createFirstClassCallable( $returnType = $nativeTypesPromoted ? $variant->getNativeReturnType() : $returnType; } - $templateTags = []; - foreach ($variant->getTemplateTypeMap()->getTypes() as $templateType) { - if (!$templateType instanceof TemplateType) { - continue; - } - $templateTags[$templateType->getName()] = new TemplateTag( - $templateType->getName(), - $templateType->getBound(), - $templateType->getDefault(), - $templateType->getVariance(), - ); - } - $throwPoints = []; $impurePoints = []; $acceptsNamedArguments = TrinaryLogic::createYes(); @@ -929,12 +953,49 @@ public function createFirstClassCallable( $acceptsNamedArguments = $function->acceptsNamedArguments(); $mustUseReturnValue = $function->mustUseReturnValue(); + // binding an object to the closure of a static method, or to a partial + // application of a function, fails; a function's first-class callable can be bound + if ($function instanceof ExtendedMethodReflection ? $function->isStatic() : $partialApplicationArgs !== null) { + $isStaticClosure = TrinaryLogic::createYes(); + } } $parameters = $variant->getParameters(); if (count($namedArgumentNames) > 0) { $parameters = self::renameParameters($parameters, $namedArgumentNames); } + $isVariadic = $variant->isVariadic(); + $templateTypeMap = $variant->getTemplateTypeMap(); + $variantOrigin = $origin; + if ($partialApplicationArgs !== null) { + $partialApplication = PartialFunctionApplicationParameters::apply($parameters, $isVariadic, $partialApplicationArgs, $boundArgTypes, $returnType, $templateTypeMap); + if ($partialApplication === null) { + // creating the closure from this variant throws + continue; + } + [$parameters, $isVariadic, $returnType, $templateTypeMap, $boundParameterNames] = $partialApplication; + $magicMethodParameterNames = PartialFunctionApplicationParameters::getMagicMethodParameterNames($function, $partialApplicationArgs); + if ($magicMethodParameterNames === null) { + continue; + } + $parameters = self::renameParameters($parameters, $magicMethodParameterNames); + if ($variantOrigin !== null) { + $variantOrigin = $variantOrigin->withBoundParameterNames($boundParameterNames); + } + } + + $templateTags = []; + foreach ($templateTypeMap->getTypes() as $templateType) { + if (!$templateType instanceof TemplateType) { + continue; + } + $templateTags[$templateType->getName()] = new TemplateTag( + $templateType->getName(), + $templateType->getBound(), + $templateType->getDefault(), + $templateType->getVariance(), + ); + } if ($function !== null) { $assertions = $function->getAsserts(); } elseif ($variant instanceof CallableParametersAcceptor) { @@ -950,8 +1011,8 @@ public function createFirstClassCallable( $closureTypes[] = new ClosureType( $parameters, $returnType, - $variant->isVariadic(), - $variant->getTemplateTypeMap(), + $isVariadic, + $templateTypeMap, $variant->getResolvedTemplateTypeMap(), $variant instanceof ExtendedParametersAcceptor ? $variant->getCallSiteVarianceMap() : TemplateTypeVarianceMap::createEmpty(), $templateTags, @@ -961,9 +1022,14 @@ public function createFirstClassCallable( mustUseReturnValue: $mustUseReturnValue, assertions: $assertions, isStatic: $isStaticClosure, + origin: $variantOrigin, ); } + if ($partialApplicationArgs !== null && count($closureTypes) === 0) { + return new ObjectType(Closure::class); + } + return TypeCombinator::union(...$closureTypes); } diff --git a/src/Reflection/ParameterReflection.php b/src/Reflection/ParameterReflection.php index bebd231c945..33708f06a61 100644 --- a/src/Reflection/ParameterReflection.php +++ b/src/Reflection/ParameterReflection.php @@ -30,6 +30,10 @@ public function passedByReference(): PassedByReference; public function isVariadic(): bool; + /** + * An ErrorType for a parameter of a built-in function whose default PHP does not know, + * like mt_rand()'s $min: it must be passed explicitly when a later parameter is. + */ public function getDefaultValue(): ?Type; } diff --git a/src/Reflection/PartialFunctionApplicationParameters.php b/src/Reflection/PartialFunctionApplicationParameters.php new file mode 100644 index 00000000000..07d12dae6f8 --- /dev/null +++ b/src/Reflection/PartialFunctionApplicationParameters.php @@ -0,0 +1,524 @@ + $parameters + * @param bool $isVariadic whether the callee takes more arguments than its parameters, like one calling func_get_args() + * @param array $args + * @param array $boundArgTypes the types of the bound arguments, keyed like $args + * @return array{list, bool, Type, TemplateTypeMap, list}|null null when creating the closure throws + */ + public static function apply(array $parameters, bool $isVariadic, array $args, array $boundArgTypes, Type $returnType, TemplateTypeMap $templateTypeMap): ?array + { + $mapped = self::map($parameters, $isVariadic, $args); + if ($mapped === null) { + return null; + } + [$closureParameters, $isVariadic, $bound] = $mapped; + $boundNames = []; + foreach ($bound as [$parameter, $argIndex]) { + if (!$parameter->isVariadic()) { + $boundNames[] = $parameter->getName(); + continue; + } + $arg = $args[$argIndex]; + if (!$arg instanceof Arg || $arg->name === null) { + continue; + } + $boundNames[] = $arg->name->toString(); + } + if ($templateTypeMap->isEmpty()) { + return [$closureParameters, $isVariadic, $returnType, $templateTypeMap, $boundNames]; + } + + $inferred = TemplateTypeMap::createEmpty(); + foreach ($bound as [$parameter, $argIndex]) { + if (!isset($boundArgTypes[$argIndex])) { + continue; + } + $inferred = $inferred->union($parameter->getType()->inferTemplateTypes($boundArgTypes[$argIndex])); + } + if ($inferred->isEmpty()) { + return [$closureParameters, $isVariadic, $returnType, $templateTypeMap, $boundNames]; + } + + $inClosureParameters = []; + foreach ($closureParameters as $parameter) { + TypeTraverser::map($parameter->getType(), static function (Type $type, callable $traverse) use ($templateTypeMap, &$inClosureParameters): Type { + if (self::isOwnTemplate($type, $templateTypeMap)) { + $inClosureParameters[$type->getName()] = true; + } + + return $traverse($type); + }); + } + + $returnType = TypeTraverser::map($returnType, static function (Type $type, callable $traverse) use ($templateTypeMap, $inferred, $inClosureParameters): Type { + if (!self::isOwnTemplate($type, $templateTypeMap)) { + return $traverse($type); + } + $inferredType = $inferred->getType($type->getName()); + if ($inferredType === null) { + return $type; + } + if (isset($inClosureParameters[$type->getName()])) { + return TypeCombinator::union($type, $inferredType); + } + + return $inferredType; + }); + + $closureTemplateTypes = []; + foreach ($templateTypeMap->getTypes() as $name => $templateType) { + if (!isset($inClosureParameters[$name]) && $inferred->hasType($name)) { + continue; + } + $closureTemplateTypes[$name] = $templateType; + } + + return [$closureParameters, $isVariadic, $returnType, new TemplateTypeMap($closureTemplateTypes), $boundNames]; + } + + /** + * PHP calls a method it does not declare through __call() or __callStatic(), so the + * closure of its partial application is one of that trampoline, (mixed ...$arguments): + * the placeholders become $arguments0, $arguments1..., and a named one throws. + * + * @param array $args + * @return list|null the names of the closure's first parameters, the ones of its + * positional placeholders; null when creating the closure throws + */ + public static function getMagicMethodParameterNames(FunctionReflection|MethodReflection|null $function, array $args): ?array + { + if (!self::isMagicMethod($function)) { + return []; + } + + $names = []; + foreach ($args as $arg) { + if (!$arg instanceof ArgPlaceholder) { + continue; + } + if ($arg->name !== null) { + return null; + } + $names[] = 'arguments' . count($names); + } + + return $names; + } + + /** @phpstan-assert-if-true MethodReflection $function */ + public static function isMagicMethod(FunctionReflection|MethodReflection|null $function): bool + { + return $function instanceof MethodReflection + && !$function->getDeclaringClass()->hasNativeMethod($function->getName()); + } + + /** + * @phpstan-assert-if-true TemplateType $type + */ + private static function isOwnTemplate(Type $type, TemplateTypeMap $templateTypeMap): bool + { + if (!$type instanceof TemplateType) { + return false; + } + $templateType = $templateTypeMap->getType($type->getName()); + + return $templateType instanceof TemplateType && $templateType->getScope()->equals($type->getScope()); + } + + /** + * @param list $parameters + * @param array $args + * @return array{list, bool, list}|null the closure's parameters, + * whether it is variadic and the parameters the bound arguments go to, null when creating the closure throws + */ + private static function map(array $parameters, bool $isVariadic, array $args): ?array + { + $variadicParameter = null; + $declared = $parameters; + if (count($parameters) > 0 && $parameters[count($parameters) - 1]->isVariadic()) { + $variadicParameter = $parameters[count($parameters) - 1]; + unset($declared[count($parameters) - 1]); + } + + $indexesByName = []; + foreach ($declared as $i => $parameter) { + $indexesByName[$parameter->getName()] = $i; + } + + $positional = []; + $named = []; + $covered = []; + $hasVariadicPlaceholder = false; + $position = 0; + $variadicPlaceholders = 0; + $seenNamed = false; + $bound = []; + foreach ($args as $argIndex => $arg) { + if ($hasVariadicPlaceholder) { + // the variadic placeholder must be last and may only appear once + return null; + } + if ($arg instanceof VariadicPlaceholder) { + $hasVariadicPlaceholder = true; + continue; + } + + if ($arg instanceof Arg && $arg->unpack) { + // cannot combine partial application and unpacking + return null; + } + + $isPlaceholder = $arg instanceof ArgPlaceholder; + $name = $arg->name; + if ($name === null) { + if ($seenNamed) { + // positional argument after a named one + return null; + } + if (isset($declared[$position])) { + $covered[$position] = true; + if ($isPlaceholder) { + $positional[] = self::required($declared[$position], $declared[$position]->getName()); + } else { + $bound[] = [$declared[$position], $argIndex]; + } + } elseif ($variadicParameter !== null) { + if ($isPlaceholder) { + $positional[] = self::required($variadicParameter, $variadicParameter->getName() . $variadicPlaceholders); + $variadicPlaceholders++; + } else { + $bound[] = [$variadicParameter, $argIndex]; + } + } else { + // too many arguments + return null; + } + $position++; + continue; + } + + $seenNamed = true; + $nameString = $name->toString(); + if (!array_key_exists($nameString, $indexesByName)) { + if ($isPlaceholder || $variadicParameter === null) { + // a named placeholder for an unknown or variadic parameter, + // or an unknown named argument without a variadic to collect it + return null; + } + $bound[] = [$variadicParameter, $argIndex]; + continue; + } + + $index = $indexesByName[$nameString]; + if (isset($covered[$index])) { + // overwrites a previous argument or placeholder + return null; + } + $covered[$index] = true; + if (!$isPlaceholder) { + $bound[] = [$declared[$index], $argIndex]; + continue; + } + + $named[] = self::required($declared[$index], $nameString); + } + + $lastCovered = $covered === [] ? -1 : max(array_keys($covered)); + foreach ($declared as $i => $parameter) { + if (isset($covered[$i]) || !$parameter->getDefaultValue() instanceof ErrorType) { + continue; + } + if ($hasVariadicPlaceholder || ($i < $lastCovered && $parameter->isOptional())) { + // PHP refuses to fill in a default it does not know + return null; + } + } + + $closureParameters = [...$positional, ...$named]; + if (!$hasVariadicPlaceholder) { + foreach ($declared as $i => $parameter) { + if (!isset($covered[$i]) && !$parameter->isOptional()) { + // too few arguments + return null; + } + } + + return [$closureParameters, false, $bound]; + } + + foreach ($declared as $i => $parameter) { + if (isset($covered[$i])) { + continue; + } + $closureParameters[] = $parameter; + } + if ($variadicParameter !== null) { + $closureParameters[] = $variadicParameter; + } + + // the variadic placeholder forwards the extra arguments to the callee + return [$closureParameters, $isVariadic, $bound]; + } + + /** + * @return array the types of the bound arguments, keyed like the raw arguments + */ + public static function getBoundArgTypes(Scope $scope, CallLike $call): array + { + $types = []; + foreach ($call->getRawArgs() as $i => $arg) { + if (!$arg instanceof Arg) { + continue; + } + $types[$i] = $scope->getType($arg->value); + } + + return $types; + } + + /** + * The variant whose partial application the arguments fit. When several fit, + * they are combined; when none does, all of them are. + * + * @param array $args + * @param list $variants + * @param list|null $namedArgumentsVariants + */ + public static function selectVariant(array $args, array $variants, ?array $namedArgumentsVariants): ParametersAcceptor + { + if ($namedArgumentsVariants !== null) { + foreach ($args as $arg) { + if (!$arg instanceof VariadicPlaceholder && $arg->name !== null) { + $variants = $namedArgumentsVariants; + break; + } + } + } + + foreach ($variants as $variant) { + if (self::leavesUnknownDefaultValue([$variant], $args)) { + return $variant; + } + } + + if (count($variants) === 1) { + return $variants[0]; + } + + $fitting = []; + foreach ($variants as $variant) { + if (self::map($variant->getParameters(), $variant->isVariadic(), $args) === null) { + continue; + } + $fitting[] = $variant; + } + + if (count($fitting) === 1) { + return $fitting[0]; + } + + if (count($fitting) === 0) { + $closestVariant = self::selectVariantClosestToArgumentsCount($args, $variants); + if ($closestVariant !== null) { + return $closestVariant; + } + } + + return ParametersAcceptorSelector::combineAcceptors(count($fitting) > 0 ? $fitting : $variants); + } + + /** + * The variants of a built-in describe one real signature, so when ... leaves out a parameter + * whose default PHP does not know in any of them, like $value of ReflectionProperty::setValue(?, ...), + * creating the closure throws whichever variant the arguments fit. + * + * @param ParametersAcceptor[] $variants + * @param array $args + */ + public static function leavesUnknownDefaultValue(array $variants, array $args): bool + { + $positionalCount = 0; + $names = []; + $hasVariadicPlaceholder = false; + foreach ($args as $arg) { + if ($arg instanceof VariadicPlaceholder) { + $hasVariadicPlaceholder = true; + continue; + } + if ($arg->name !== null) { + $names[$arg->name->toString()] = true; + continue; + } + $positionalCount++; + } + if (!$hasVariadicPlaceholder) { + return false; + } + + foreach ($variants as $variant) { + foreach ($variant->getParameters() as $i => $parameter) { + if ( + $i >= $positionalCount + && !$parameter->isVariadic() + && !array_key_exists($parameter->getName(), $names) + && $parameter->getDefaultValue() instanceof ErrorType + ) { + return true; + } + } + } + + return false; + } + + /** + * Combining the variants () and ($min, $max) of mt_rand() would accept mt_rand(?), + * so like a call, a count of positional arguments that the combined variants + * accept but no variant does is checked against the variant closest to it. + * + * @param array $args + * @param list $variants + */ + private static function selectVariantClosestToArgumentsCount(array $args, array $variants): ?ParametersAcceptor + { + $argsCount = 0; + $hasVariadicPlaceholder = false; + foreach ($args as $arg) { + if ($hasVariadicPlaceholder || ($arg instanceof Arg && $arg->unpack) || (!$arg instanceof VariadicPlaceholder && $arg->name !== null)) { + return null; + } + if ($arg instanceof VariadicPlaceholder) { + $hasVariadicPlaceholder = true; + continue; + } + $argsCount++; + } + + $closestVariant = null; + $closestDistance = null; + $combinedMinCount = null; + $combinedMaxCount = 0; + foreach ($variants as $variant) { + $minCount = 0; + foreach ($variant->getParameters() as $parameter) { + if ($parameter->isOptional()) { + continue; + } + $minCount++; + } + $maxCount = $variant->isVariadic() ? null : count($variant->getParameters()); + $combinedMinCount = min($combinedMinCount ?? $minCount, $minCount); + $combinedMaxCount = $maxCount === null || $combinedMaxCount === null ? null : max($combinedMaxCount, $maxCount); + + // the variadic placeholder fills in the parameters left + $isInsufficient = !$hasVariadicPlaceholder && $argsCount < $minCount; + if (!$isInsufficient && ($maxCount === null || $argsCount <= $maxCount)) { + // the count fits, the arguments do not for another reason + return null; + } + + $distance = $isInsufficient ? $minCount - $argsCount : $argsCount - $maxCount; + if ($closestDistance !== null && ($distance > $closestDistance || ($distance === $closestDistance && !$isInsufficient))) { + continue; + } + + $closestVariant = $variant; + $closestDistance = $distance; + } + + if ( + (!$hasVariadicPlaceholder && $argsCount < $combinedMinCount) + || ($combinedMaxCount !== null && $argsCount > $combinedMaxCount) + ) { + return null; + } + + return $closestVariant; + } + + private static function required(ParameterReflection $parameter, string $name): ParameterReflection + { + if ($parameter instanceof ExtendedParameterReflection) { + return new ExtendedDummyParameter( + $name, + $parameter->getType(), + false, + $parameter->passedByReference(), + false, + null, + $parameter->getNativeType(), + $parameter->getPhpDocType(), + $parameter->getOutType(), + $parameter->isImmediatelyInvokedCallable(), + $parameter->getClosureThisType(), + $parameter->getAttributes(), + $parameter->getAllowedConstants(), + $parameter->isPureUnlessCallableIsImpureParameter(), + $parameter->isPureUnlessParameterPassedParameter(), + ); + } + + return new DummyParameter( + $name, + $parameter->getType(), + false, + $parameter->passedByReference(), + false, + null, + ); + } + +} diff --git a/src/Reflection/Php/ClosureCallMethodReflection.php b/src/Reflection/Php/ClosureCallMethodReflection.php index a65a321a4c4..cae15b9d9ea 100644 --- a/src/Reflection/Php/ClosureCallMethodReflection.php +++ b/src/Reflection/Php/ClosureCallMethodReflection.php @@ -28,6 +28,7 @@ final class ClosureCallMethodReflection implements ExtendedMethodReflection public function __construct( private ExtendedMethodReflection $nativeMethodReflection, private ClosureType $closureType, + private bool $takesNewThis = true, ) { } @@ -70,16 +71,16 @@ public function getPrototype(): ClassMemberReflection public function getVariants(): array { $parameters = $this->closureType->getParameters(); - $newThis = new NativeParameterReflection( - 'newThis', - optional: false, - type: new ObjectWithoutClassType(), - passedByReference: PassedByReference::createNo(), - variadic: false, - defaultValue: null, - ); - - array_unshift($parameters, $newThis); + if ($this->takesNewThis) { + array_unshift($parameters, new NativeParameterReflection( + 'newThis', + optional: false, + type: new ObjectWithoutClassType(), + passedByReference: PassedByReference::createNo(), + variadic: false, + defaultValue: null, + )); + } return [ new ExtendedFunctionVariant( diff --git a/src/Reflection/Php/ClosureCallUnresolvedMethodPrototypeReflection.php b/src/Reflection/Php/ClosureCallUnresolvedMethodPrototypeReflection.php index 58ef40513d9..91073ba2b32 100644 --- a/src/Reflection/Php/ClosureCallUnresolvedMethodPrototypeReflection.php +++ b/src/Reflection/Php/ClosureCallUnresolvedMethodPrototypeReflection.php @@ -12,13 +12,16 @@ final class ClosureCallUnresolvedMethodPrototypeReflection implements UnresolvedMethodPrototypeReflection { - public function __construct(private UnresolvedMethodPrototypeReflection $prototype, private ClosureType $closure) + /** + * @param bool $takesNewThis whether the method takes the object to bind first, like call() and unlike __invoke() + */ + public function __construct(private UnresolvedMethodPrototypeReflection $prototype, private ClosureType $closure, private bool $takesNewThis = true) { } public function doNotResolveTemplateTypeMapToBounds(): UnresolvedMethodPrototypeReflection { - return new self($this->prototype->doNotResolveTemplateTypeMapToBounds(), $this->closure); + return new self($this->prototype->doNotResolveTemplateTypeMapToBounds(), $this->closure, $this->takesNewThis); } public function getNakedMethod(): ExtendedMethodReflection @@ -28,12 +31,12 @@ public function getNakedMethod(): ExtendedMethodReflection public function getTransformedMethod(): ExtendedMethodReflection { - return new ClosureCallMethodReflection($this->prototype->getTransformedMethod(), $this->closure); + return new ClosureCallMethodReflection($this->prototype->getTransformedMethod(), $this->closure, $this->takesNewThis); } public function withCalledOnType(Type $type): UnresolvedMethodPrototypeReflection { - return new self($this->prototype->withCalledOnType($type), $this->closure); + return new self($this->prototype->withCalledOnType($type), $this->closure, $this->takesNewThis); } } diff --git a/src/Reflection/SignatureMap/Php8SignatureMapProvider.php b/src/Reflection/SignatureMap/Php8SignatureMapProvider.php index 6468bdd6f40..34e69363775 100644 --- a/src/Reflection/SignatureMap/Php8SignatureMapProvider.php +++ b/src/Reflection/SignatureMap/Php8SignatureMapProvider.php @@ -20,6 +20,7 @@ use PHPStan\Reflection\PassedByReference; use PHPStan\Reflection\ReflectionProvider\ReflectionProviderProvider; use PHPStan\ShouldNotHappenException; +use PHPStan\Type\ErrorType; use PHPStan\Type\FileTypeMapper; use PHPStan\Type\MixedType; use PHPStan\Type\ParserNodeTypeToPHPStanType; @@ -377,65 +378,51 @@ private function getMergedSignatures(FunctionSignature $nativeSignature, array $ return ['positional' => [], 'named' => null]; } - $nativeParams = $nativeSignature->getParameters(); - $namedArgumentsVariants = []; - $allParamNamesMatchNative = true; - foreach ($functionMapSignatures['positional'] as $functionMapSignature) { - $isPrevParamVariadic = false; - $hasMiddleVariadicParam = false; - // avoid weird functions like array_diff_uassoc - foreach ($functionMapSignature->getParameters() as $i => $functionParam) { - $nativeParam = $nativeParams[$i] ?? null; - $allParamNamesMatchNative = $allParamNamesMatchNative && $nativeParam !== null && $functionParam->getName() === $nativeParam->getName(); - $hasMiddleVariadicParam = $hasMiddleVariadicParam || $isPrevParamVariadic; - $isPrevParamVariadic = $functionParam->isVariadic() || ( - $nativeParam !== null - ? $nativeParam->isVariadic() - : false - ); - } + return [ + 'positional' => array_map(fn (FunctionSignature $signature): FunctionSignature => $this->withUnknownDefaultValues($nativeSignature, $signature), $functionMapSignatures['positional']), + // PHP resolves named arguments against the one signature php-src stubs declare + 'named' => [$nativeSignature], + ]; + } - if ($hasMiddleVariadicParam) { + /** + * A parameter of a function map variant like mt_rand(int $min, int $max) keeps the unknown default + * of the parameter it stands for, also over a default the PhpStorm stubs make up for it, + * so that combining the variants knows that $min must be passed explicitly before $max. + */ + private function withUnknownDefaultValues(FunctionSignature $nativeSignature, FunctionSignature $signature): FunctionSignature + { + $nativeParameters = $nativeSignature->getParameters(); + $parameters = []; + foreach ($signature->getParameters() as $i => $parameter) { + $nativeParameter = $nativeParameters[$i] ?? null; + if ( + $nativeParameter === null + || $nativeParameter->getName() !== $parameter->getName() + || !$nativeParameter->getDefaultValue() instanceof ErrorType + ) { + $parameters[] = $parameter; continue; } - $parameters = []; - foreach ($functionMapSignature->getParameters() as $i => $functionParam) { - if (!array_key_exists($i, $nativeParams)) { - continue 2; - } - - // it seems that variadic parameters cannot be named in native functions/methods. - $nativeParam = $nativeParams[$i]; - if ($nativeParam->isVariadic()) { - break; - } - - $parameters[] = new ParameterSignature( - $nativeParam->getName(), - $functionParam->isOptional(), - $functionParam->getType(), - $functionParam->getNativeType(), - $functionParam->passedByReference(), - $functionParam->isVariadic(), - $functionParam->getDefaultValue() ?? $nativeParam->getDefaultValue(), - $functionParam->getOutType() ?? $nativeParam->getOutType(), - ); - } - - $namedArgumentsVariants[] = new FunctionSignature( - $parameters, - $functionMapSignature->getReturnType(), - $functionMapSignature->getNativeReturnType(), - $functionMapSignature->isVariadic(), + $parameters[] = new ParameterSignature( + $parameter->getName(), + $parameter->isOptional(), + $parameter->getType(), + $parameter->getNativeType(), + $parameter->passedByReference(), + $parameter->isVariadic(), + $nativeParameter->getDefaultValue(), + $parameter->getOutType(), ); } - if ($allParamNamesMatchNative || count($namedArgumentsVariants) === 0) { - $namedArgumentsVariants = null; - } - - return ['positional' => $functionMapSignatures['positional'], 'named' => $namedArgumentsVariants]; + return new FunctionSignature( + $parameters, + $signature->getReturnType(), + $signature->getNativeReturnType(), + $signature->isVariadic(), + ); } private function mergeSignatures(FunctionSignature $nativeSignature, FunctionSignature $functionMapSignature): FunctionSignature @@ -570,6 +557,17 @@ private function getSignature( } } + $defaultValue = null; + if ($param->default instanceof ConstFetch && $param->default->name->toString() === 'UNKNOWN') { + // see ParameterReflection::getDefaultValue() + $defaultValue = new ErrorType(); + } elseif ($param->default !== null) { + $defaultValue = $this->initializerExprTypeResolver->getType( + $param->default, + InitializerExprContext::fromStubParameter($className, $stubFile, $function), + ); + } + $parameters[] = new ParameterSignature( $name->name, $param->default !== null || $param->variadic, @@ -577,10 +575,7 @@ private function getSignature( $parameterType, $param->byRef ? PassedByReference::createCreatesNewVariable() : PassedByReference::createNo(), $param->variadic, - $param->default !== null ? $this->initializerExprTypeResolver->getType( - $param->default, - InitializerExprContext::fromStubParameter($className, $stubFile, $function), - ) : null, + $defaultValue, null, ); diff --git a/src/Rules/FunctionCallParametersCheck.php b/src/Rules/FunctionCallParametersCheck.php index 13af1483c79..c5a44e7d254 100644 --- a/src/Rules/FunctionCallParametersCheck.php +++ b/src/Rules/FunctionCallParametersCheck.php @@ -16,9 +16,12 @@ use PHPStan\Reflection\ConstantReflection; use PHPStan\Reflection\ExtendedParameterReflection; use PHPStan\Reflection\FunctionReflection; +use PHPStan\Reflection\GenericParametersAcceptorResolver; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ParameterReflection; use PHPStan\Reflection\ParametersAcceptor; +use PHPStan\Reflection\ParametersAcceptorSelector; +use PHPStan\Reflection\PartialFunctionApplicationParameters; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Reflection\ResolvedFunctionVariant; use PHPStan\Rules\Methods\NamedArgumentParameterMethodCallsCollector; @@ -40,6 +43,7 @@ use PHPStan\Type\VerbosityLevel; use function array_fill; use function array_key_exists; +use function array_keys; use function array_last; use function array_merge; use function count; @@ -52,6 +56,7 @@ use function lcfirst; use function max; use function sprintf; +use function ucfirst; #[AutowiredService] final class FunctionCallParametersCheck @@ -85,6 +90,7 @@ public function __construct( /** * @param 'attribute'|'callable'|'method'|'staticMethod'|'function'|'new' $nodeType * @param array{class-string, string}|null $renamedNamedArgumentParameterData + * @param list $namedCallVariants positional variants of a callee whose named arguments resolve against its php-src signature * @return list */ public function check( @@ -114,6 +120,7 @@ public function check( string $bitmaskNotAllowedMessage, ?array $renamedNamedArgumentParameterData, FunctionReflection|MethodReflection|null $calleeReflection = null, + array $namedCallVariants = [], ): array { if ($funcCall instanceof Node\Expr\MethodCall || $funcCall instanceof Node\Expr\StaticCall || $funcCall instanceof Node\Expr\FuncCall) { @@ -150,14 +157,38 @@ public function check( $functionParametersMaxCount = -1; } - /** @var array $arguments */ + /** @var array $arguments */ $arguments = []; - /** @var array $args */ - $args = $funcCall->getArgs(); + $isPartialApplication = $funcCall->isPartialFunctionApplication(); + $args = $isPartialApplication ? $funcCall->getRawArgs() : $funcCall->getArgs(); $hasNamedArguments = false; $hasUnpackedArgument = false; + $hasVariadicPlaceholder = false; $errors = []; foreach ($args as $arg) { + if ($hasVariadicPlaceholder) { + // reported by checkPartialApplicationSyntax() + break; + } + if ($arg instanceof Node\VariadicPlaceholder) { + $hasVariadicPlaceholder = true; + continue; + } + if ($arg instanceof Node\ArgPlaceholder) { + $argumentName = null; + if ($arg->name !== null) { + $hasNamedArguments = true; + $argumentName = $arg->name->toString(); + } + $arguments[] = [$arg, null, false, $argumentName, $arg->getStartLine()]; + continue; + } + + if ($isPartialApplication && $arg->unpack) { + // reported by checkPartialApplicationSyntax() + continue; + } + $argumentName = null; if ($arg->name !== null) { $hasNamedArguments = true; @@ -285,6 +316,7 @@ public function check( ->build(); } + $argumentsCount = null; if (!$hasNamedArguments) { $invokedParametersCount = count($arguments); foreach ($arguments as [2 => $unpack]) { @@ -293,10 +325,18 @@ public function check( break; } } + $argumentsCount = [$invokedParametersCount, $functionParametersMinCount, $functionParametersMaxCount]; + } elseif (!$isPartialApplication) { + $argumentsCount = self::getNamedArgumentsCount($arguments, $parametersAcceptor, $namedCallVariants); + } + if ($argumentsCount !== null) { + [$invokedParametersCount, $functionParametersMinCount, $functionParametersMaxCount] = $argumentsCount; if ( - $invokedParametersCount < $functionParametersMinCount - || ($this->checkExtraArguments && $invokedParametersCount > $functionParametersMaxCount) + // ... of a partial application fills in the parameters left + ($invokedParametersCount < $functionParametersMinCount && !$hasVariadicPlaceholder) + // a partial application with too many arguments throws when it is created + || (($this->checkExtraArguments || $isPartialApplication) && $functionParametersMaxCount !== -1 && $invokedParametersCount > $functionParametersMaxCount) ) { if ($functionParametersMinCount === $functionParametersMaxCount) { $errors[] = RuleErrorBuilder::message(sprintf( @@ -332,6 +372,7 @@ public function check( if ( !$funcCall instanceof Node\Expr\New_ + && !$isPartialApplication && !$scope->isInFirstLevelStatement() && $scope->getKeepVoidType($funcCall)->isVoid()->yes() ) { @@ -341,7 +382,7 @@ public function check( ->build(); } - [$addedErrors, $argumentsWithParameters] = $this->processArguments($parametersAcceptor, $funcCallLine, $isBuiltin, $arguments, $hasNamedArguments, $missingParameterMessage, $unknownParameterMessage); + [$addedErrors, $argumentsWithParameters] = $this->processArguments($parametersAcceptor, $funcCallLine, $isBuiltin, $arguments, $hasNamedArguments, !$hasVariadicPlaceholder, $missingParameterMessage, $unknownParameterMessage); foreach ($addedErrors as $error) { $errors[] = $error; } @@ -352,6 +393,11 @@ public function check( $positionalArgumentsFix = null; foreach ($argumentsWithParameters as $i => [$argumentValue, $argumentValueType, $unpack, $argumentName, $argumentLine, $parameter, $originalParameter]) { + if ($argumentValue instanceof Node\ArgPlaceholder) { + // a placeholder has no value, it becomes a parameter of the closure + continue; + } + if ($this->checkArgumentTypes && $unpack) { $iterableTypeResult = $this->ruleLevelHelper->findTypeToCheck( $scope, @@ -462,7 +508,7 @@ public function check( // only the parameter of a resolved generic acceptor has an original // type to tell an unresolvable type this call made from a declared one - $unresolvableParameterType = $originalParameter !== null ? $this->unresolvableTypeHelper->getUnresolvableType($parameterType) : null; + $unresolvableParameterType = $originalParameter !== null && !$isPartialApplication ? $this->unresolvableTypeHelper->getUnresolvableType($parameterType) : null; if ( $unresolvableParameterType !== null && $this->unresolvableTypeHelper->getUnresolvableType($originalParameter->getType()) === null @@ -631,7 +677,7 @@ public function check( ))->identifier('argument.byRef')->line($argumentLine)->build(); } - if ($this->checkMissingTypehints && $parametersAcceptor instanceof ResolvedFunctionVariant) { + if ($this->checkMissingTypehints && !$isPartialApplication && $parametersAcceptor instanceof ResolvedFunctionVariant) { $originalParametersAcceptor = $parametersAcceptor->getOriginalParametersAcceptor(); $resolvedTypes = $parametersAcceptor->getResolvedTemplateTypeMap()->getTypes(); if (!$isBuiltin && count($resolvedTypes) > 0) { @@ -716,8 +762,148 @@ static function (Type $type, callable $traverse) use (&$returnTemplateTypes): Ty } /** - * @param array $arguments - * @return array{list, array} + * The placements of placeholders PHP refuses to compile, whatever the callee is. + * + * @return list + */ + public function checkPartialApplicationSyntax(Node\Expr\CallLike $call): array + { + $errors = []; + $hasVariadicPlaceholder = false; + foreach ($call->getRawArgs() as $arg) { + if ($hasVariadicPlaceholder) { + // PHP judges the argument right after the variadic placeholder + if ($arg instanceof Node\VariadicPlaceholder) { + $errorBuilder = RuleErrorBuilder::message('Variadic placeholder may only appear once.') + ->identifier('argument.duplicateVariadicPlaceholder'); + } else { + $errorBuilder = RuleErrorBuilder::message('Variadic placeholder must be last.') + ->identifier('argument.variadicPlaceholderNotLast'); + } + $errors[] = $errorBuilder + ->line($arg->getStartLine()) + ->nonIgnorable() + ->build(); + break; + } + if ($arg instanceof Node\VariadicPlaceholder) { + $hasVariadicPlaceholder = true; + continue; + } + if (!$arg instanceof Node\Arg || !$arg->unpack) { + continue; + } + + $errors[] = RuleErrorBuilder::message('Cannot combine partial application and unpacking.') + ->identifier('argument.unpackInPartialApplication') + ->line($arg->getStartLine()) + ->nonIgnorable() + ->build(); + } + + return $errors; + } + + /** + * Checks the bound arguments and placeholders of a partial function application + * against the callee: PHP throws when such a closure is created from arguments + * that do not fit. + * + * @param 'callable'|'method'|'staticMethod'|'function' $nodeType + * @param string $calleeDescription like "function foo" or "method Foo::bar()", escaped for sprintf() + * @return list + */ + public function checkPartialApplication( + ParametersAcceptor $parametersAcceptor, + Scope&NodeCallbackInvoker&CollectedDataEmitter $scope, + bool $isBuiltin, + Node\Expr\FuncCall|Node\Expr\MethodCall|Node\Expr\StaticCall $call, + string $nodeType, + TrinaryLogic $acceptsNamedArguments, + string $calleeDescription, + FunctionReflection|MethodReflection|null $calleeReflection, + ): array + { + if (PartialFunctionApplicationParameters::isMagicMethod($calleeReflection)) { + // the __call() trampoline it calls only has a variadic parameter + $errors = []; + foreach ($call->getRawArgs() as $arg) { + if (!$arg instanceof Node\ArgPlaceholder || $arg->name === null) { + continue; + } + $errors[] = RuleErrorBuilder::message(sprintf('Cannot use named placeholder for unknown or variadic parameter $%s.', $arg->name->toString())) + ->identifier('argument.unknown') + ->line($arg->getStartLine()) + ->build(); + } + if ($errors !== []) { + return $errors; + } + } + + // templates are resolved from the bound arguments, as in a call; + // the ones only the placeholders determine stay unresolved + $argTypes = []; + $position = 0; + foreach ($call->getRawArgs() as $arg) { + if ($arg instanceof Node\VariadicPlaceholder) { + break; + } + if ($arg instanceof Node\ArgPlaceholder) { + if ($arg->name === null) { + $position++; + } + continue; + } + if ($arg->unpack) { + continue; + } + if ($arg->name !== null) { + $argTypes[$arg->name->toString()] = $scope->getType($arg->value); + continue; + } + $argTypes[$position++] = $scope->getType($arg->value); + } + if (!$parametersAcceptor->getTemplateTypeMap()->isEmpty()) { + $parametersAcceptor = GenericParametersAcceptorResolver::resolve($argTypes, $parametersAcceptor); + } + + $applied = ucfirst($calleeDescription) . ' partially applied with'; + + return $this->check( + $parametersAcceptor, + $scope, + $isBuiltin, + $call, + $nodeType, + $acceptsNamedArguments, + $applied . ' %d argument, %d required.', + $applied . ' %d arguments, %d required.', + $applied . ' %d argument, at least %d required.', + $applied . ' %d arguments, at least %d required.', + $applied . ' %d argument, %d-%d required.', + $applied . ' %d arguments, %d-%d required.', + '%s of ' . $calleeDescription . ' expects %s, %s given.', + 'Result of ' . $calleeDescription . ' (void) is used.', + '%s of ' . $calleeDescription . ' is passed by reference, so it expects variables only.', + 'Unable to resolve the template type %s in partial application of ' . $calleeDescription, + 'Missing parameter $%s in partial application of ' . $calleeDescription . '.', + 'Unknown parameter $%s in partial application of ' . $calleeDescription . '.', + 'Return type of partial application of ' . $calleeDescription . ' contains unresolvable type.', + '%s of ' . $calleeDescription . ' contains unresolvable type.', + $applied . ' %s, but it\'s not allowed because of @no-named-arguments.', + 'Constant %s is not allowed for %s of ' . $calleeDescription . '.', + 'Constants %s cannot be combined for %s of ' . $calleeDescription . '.', + 'Combining constants with | is not allowed for %s of ' . $calleeDescription . '.', + null, + $calleeReflection, + ); + } + + /** + * @param array $arguments + * @param bool $checkMissingParameters false when ... of a partial application fills in the parameters left + * @return array{list, array} */ private function processArguments( ParametersAcceptor $parametersAcceptor, @@ -725,6 +911,7 @@ private function processArguments( bool $isBuiltin, array $arguments, bool $hasNamedArguments, + bool $checkMissingParameters, string $missingParameterMessage, string $unknownParameterMessage, ): array @@ -772,6 +959,17 @@ private function processArguments( $parameter = $parameters[$i]; $originalParameter = $originalParameters[$i]; } + } elseif ( + $argumentValue instanceof Node\ArgPlaceholder + && (!array_key_exists($argumentName, $parametersByName) || $parametersByName[$argumentName]->isVariadic()) + ) { + $namedArgumentAlreadyOccurred = true; + $errors[] = RuleErrorBuilder::message(sprintf('Cannot use named placeholder for unknown or variadic parameter $%s.', $argumentName)) + ->identifier('argument.unknown') + ->line($argumentLine) + ->build(); + $newArguments[$i] = [$argumentValue, $argumentValueType, $unpack, $argumentName, $argumentLine, null, null]; + continue; } elseif (array_key_exists($argumentName, $parametersByName)) { $namedArgumentAlreadyOccurred = true; $parameter = $parametersByName[$argumentName]; @@ -828,7 +1026,31 @@ private function processArguments( unset($unusedParametersByName[$parameter->getName()]); } - if ($hasNamedArguments) { + // PHP refuses to fill in a default it does not know: for a parameter + // skipped by a later named argument, or left to ... of a partial application + $lastPassedPosition = -1; + foreach ($parameters as $i => $parameter) { + if ($parameter->isVariadic() || array_key_exists($parameter->getName(), $unusedParametersByName)) { + continue; + } + $lastPassedPosition = $i; + } + foreach ($parameters as $i => $parameter) { + if ( + !array_key_exists($parameter->getName(), $unusedParametersByName) + || !$parameter->getDefaultValue() instanceof ErrorType + || ($checkMissingParameters && (!$hasNamedArguments || !$parameter->isOptional() || $i > $lastPassedPosition)) + ) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf('Argument #%d ($%s) must be passed explicitly, because the default value is not known.', $i + 1, $parameter->getName())) + ->identifier('argument.unknownDefaultValue') + ->line($line) + ->build(); + } + + if ($hasNamedArguments && $checkMissingParameters) { foreach ($unusedParametersByName as $parameter) { if ($parameter->isOptional()) { continue; @@ -1101,6 +1323,78 @@ public static function getVariantForArgumentsCount(array $args, array $variants, return null; } + return self::getClosestVariant($argsCount, $variants); + } + + /** + * PHP resolves named arguments against the one signature php-src stubs declare, + * passes the default of each parameter they skip, and then the function checks + * the number of arguments like for a positional call: mt_rand(min: 1) throws. + * So the count is checked against the variants like a positional call's. + * + * @param array $arguments + * @param list $variants + * @return array{int, int, int}|null the arguments count and the minimum and maximum (-1 when variadic) to report it against, null when a variant accepts it + */ + private static function getNamedArgumentsCount(array $arguments, ParametersAcceptor $namedArgumentsVariant, array $variants): ?array + { + if (count($variants) < 2) { + return null; + } + + $positionsByName = []; + foreach ($namedArgumentsVariant->getParameters() as $i => $parameter) { + if ($parameter->isVariadic()) { + continue; + } + $positionsByName[$parameter->getName()] = $i; + } + + $passedPositions = []; + foreach ($arguments as $i => [, , $unpack, $argumentName]) { + if ($unpack) { + return null; + } + if ($argumentName === null) { + $passedPositions[$i] = true; + continue; + } + if (!array_key_exists($argumentName, $positionsByName)) { + // reported as an unknown parameter + return null; + } + $passedPositions[$positionsByName[$argumentName]] = true; + } + + $argsCount = $passedPositions === [] ? 0 : max(array_keys($passedPositions)) + 1; + foreach ($namedArgumentsVariant->getParameters() as $i => $parameter) { + if ($i >= $argsCount) { + break; + } + if (!array_key_exists($i, $passedPositions) && $parameter->getDefaultValue() instanceof ErrorType) { + // PHP throws before the function checks the count + return null; + } + } + + $combinedVariant = ParametersAcceptorSelector::combineAcceptors($variants); + $variant = self::acceptsArgumentsCount($combinedVariant, $argsCount) + ? self::getClosestVariant($argsCount, $variants) + : $combinedVariant; + if ($variant === null) { + return null; + } + + [$minCount, $maxCount] = self::getArgumentsCountRange($variant); + + return [$argsCount, $minCount, $maxCount ?? -1]; + } + + /** + * @param list $variants + */ + private static function getClosestVariant(int $argsCount, array $variants): ?ParametersAcceptor + { $closestVariant = null; $closestDistance = null; foreach ($variants as $variant) { diff --git a/src/Rules/Functions/CallCallablesRule.php b/src/Rules/Functions/CallCallablesRule.php index 2d25ffeef72..4d1227726b8 100644 --- a/src/Rules/Functions/CallCallablesRule.php +++ b/src/Rules/Functions/CallCallablesRule.php @@ -10,8 +10,11 @@ use PHPStan\DependencyInjection\AutowiredParameter; use PHPStan\DependencyInjection\RegisteredRule; use PHPStan\Internal\SprintfHelper; +use PHPStan\Node\Expr\TypeExpr; use PHPStan\Reflection\InaccessibleMethod; +use PHPStan\Reflection\ParametersAcceptor; use PHPStan\Reflection\ParametersAcceptorSelector; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; @@ -20,9 +23,11 @@ use PHPStan\Type\ClosureType; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; +use PHPStan\Type\UnionType; use PHPStan\Type\VerbosityLevel; use function array_merge; use function count; +use function in_array; use function sprintf; use function ucfirst; @@ -36,6 +41,7 @@ final class CallCallablesRule implements Rule public function __construct( private FunctionCallParametersCheck $check, private RuleLevelHelper $ruleLevelHelper, + private ReflectionProvider $reflectionProvider, #[AutowiredParameter] private bool $reportMaybes, ) @@ -104,13 +110,24 @@ public function processNode( ))->identifier('callable.inaccessibleMethod')->build(); } + $namedArgumentsVariants = $this->getCalleeNamedArgumentsVariants($type, $node, $scope); $parametersAcceptor = ParametersAcceptorSelector::selectFromArgs( $scope, $node->getArgs(), $parametersAcceptors, - null, + $namedArgumentsVariants, ); + foreach ($node->getArgs() as $arg) { + if ($arg->name === null || !self::isBoundByPartialApplication($type, $arg->name->toString())) { + continue; + } + $messages[] = RuleErrorBuilder::message(sprintf('Argument for parameter $%s has already been bound by the partial function application.', $arg->name->toString())) + ->identifier('argument.duplicate') + ->line($arg->getStartLine()) + ->build(); + } + if ($type instanceof ClosureType) { $callableDescription = 'closure'; } else { @@ -146,8 +163,79 @@ public function processNode( 'Combining constants with | is not allowed for %s of ' . $callableDescription . '.', null, null, + $namedArgumentsVariants !== null ? $parametersAcceptors : [], ), ); } + /** + * A first-class callable of a multi-variant built-in is a union of closures, one per variant, + * but PHP resolves named arguments against the one signature of its callee. + * + * @return list|null + */ + private function getCalleeNamedArgumentsVariants(Type $type, Node\Expr\FuncCall $node, Scope $scope): ?array + { + $members = $type instanceof UnionType ? $type->getTypes() : [$type]; + $origin = null; + foreach ($members as $member) { + if (!$member instanceof ClosureType) { + return null; + } + $memberOrigin = $member->getOrigin(); + if ($memberOrigin === null || !$memberOrigin->isFirstClassCallable()) { + return null; + } + if ($origin !== null && !$origin->equals($memberOrigin)) { + return null; + } + $origin = $memberOrigin; + } + if ($origin === null) { + return null; + } + + $call = $origin->createCall($node, $members[0]); + if ($call instanceof Node\Expr\FuncCall && $call->name instanceof Node\Name) { + if (!$this->reflectionProvider->hasFunction($call->name, $scope)) { + return null; + } + + return $this->reflectionProvider->getFunction($call->name, $scope)->getNamedArgumentsVariants(); + } + if ($call instanceof Node\Expr\MethodCall) { + $calledOn = $call->var; + } elseif ($call instanceof Node\Expr\StaticCall) { + $calledOn = $call->class; + } else { + return null; + } + if (!$calledOn instanceof TypeExpr || !$call->name instanceof Node\Identifier) { + return null; + } + + return $scope->getMethodReflection($calledOn->getExprType(), $call->name->toString())?->getNamedArgumentsVariants(); + } + + /** + * Whether every closure the type can be is a variadic one a partial function application + * created with the parameter bound - its call then throws "Named parameter overwrites + * previous argument". A closure that is not variadic reports the name as unknown instead. + */ + private static function isBoundByPartialApplication(Type $type, string $name): bool + { + $members = $type instanceof UnionType ? $type->getTypes() : [$type]; + foreach ($members as $member) { + if (!$member instanceof ClosureType || !$member->isVariadic()) { + return false; + } + $origin = $member->getOrigin(); + if ($origin === null || !in_array($name, $origin->getBoundParameterNames(), true)) { + return false; + } + } + + return true; + } + } diff --git a/src/Rules/Functions/CallToFunctionParametersRule.php b/src/Rules/Functions/CallToFunctionParametersRule.php index dca5ec06e86..3e9b133c5a0 100644 --- a/src/Rules/Functions/CallToFunctionParametersRule.php +++ b/src/Rules/Functions/CallToFunctionParametersRule.php @@ -77,6 +77,7 @@ public function processNode(Node $node, Scope&NodeCallbackInvoker&CollectedDataE 'Combining constants with | is not allowed for %s of function ' . $functionName . '.', null, $function, + $function->getNamedArgumentsVariants() !== null ? $function->getVariants() : [], ); } diff --git a/src/Rules/Functions/FunctionCallableRule.php b/src/Rules/Functions/FunctionCallableRule.php index fdcecaebeaa..13cedad8e63 100644 --- a/src/Rules/Functions/FunctionCallableRule.php +++ b/src/Rules/Functions/FunctionCallableRule.php @@ -3,18 +3,26 @@ namespace PHPStan\Rules\Functions; use PhpParser\Node; +use PHPStan\Analyser\CollectedDataEmitter; +use PHPStan\Analyser\NodeCallbackInvoker; use PHPStan\Analyser\NullsafeOperatorHelper; use PHPStan\Analyser\Scope; use PHPStan\DependencyInjection\AutowiredParameter; use PHPStan\DependencyInjection\RegisteredRule; +use PHPStan\Internal\SprintfHelper; use PHPStan\Node\FunctionCallableNode; +use PHPStan\Reflection\PartialFunctionApplicationParameters; use PHPStan\Reflection\ReflectionProvider; +use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\TrinaryLogic; +use PHPStan\Type\ClosureType; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; use PHPStan\Type\VerbosityLevel; +use function array_merge; use function in_array; use function sprintf; use function strtolower; @@ -43,6 +51,7 @@ final class FunctionCallableRule implements Rule public function __construct( private ReflectionProvider $reflectionProvider, private RuleLevelHelper $ruleLevelHelper, + private FunctionCallParametersCheck $parametersCheck, #[AutowiredParameter] private bool $checkFunctionNameCase, #[AutowiredParameter] @@ -56,7 +65,7 @@ public function getNodeType(): string return FunctionCallableNode::class; } - public function processNode(Node $node, Scope $scope): array + public function processNode(Node $node, Scope&NodeCallbackInvoker&CollectedDataEmitter $scope): array { if (!$node->getOriginalNode()->isFirstClassCallable()) { if (!$scope->getPhpVersion()->supportsPartialFunctionApplication()->yes()) { @@ -67,6 +76,11 @@ public function processNode(Node $node, Scope $scope): array ->build(), ]; } + // compile errors, even when the callee is unknown + $syntaxErrors = $this->parametersCheck->checkPartialApplicationSyntax($node->getOriginalNode()); + if ($syntaxErrors !== []) { + return $syntaxErrors; + } } elseif (!$scope->getPhpVersion()->supportsFirstClassCallables()->yes()) { return [ RuleErrorBuilder::message('First-class callables are supported only on PHP 8.1 and later.') @@ -99,11 +113,26 @@ public function processNode(Node $node, Scope $scope): array if (in_array(strtolower($function->getName()), self::DYNAMIC_CALL_FORBIDDEN_FUNCTIONS, true)) { $errors[] = RuleErrorBuilder::message(sprintf( - 'Cannot create callable from %s(), it cannot be called dynamically.', + $node->getOriginalNode()->isFirstClassCallable() + ? 'Calling the callable created from %s() throws, it cannot be called dynamically.' + : 'Cannot create callable from %s(), it cannot be called dynamically.', $function->getName(), ))->identifier('callable.notSupported')->build(); } + if (!$node->getOriginalNode()->isFirstClassCallable()) { + $errors = array_merge($errors, $this->parametersCheck->checkPartialApplication( + PartialFunctionApplicationParameters::selectVariant($node->getArgs(), $function->getVariants(), $function->getNamedArgumentsVariants()), + $scope, + $function->isBuiltin(), + $node->getOriginalNode(), + 'function', + $function->acceptsNamedArguments(), + 'function ' . SprintfHelper::escapeFormatString($function->getName()), + $function, + )); + } + return $errors; } @@ -145,7 +174,26 @@ public function processNode(Node $node, Scope $scope): array ]; } - return []; + if ($node->getOriginalNode()->isFirstClassCallable() || !$isCallable->yes()) { + return []; + } + + $parametersAcceptors = $type->getCallableParametersAcceptors($scope); + $acceptsNamedArguments = TrinaryLogic::createYes(); + foreach ($parametersAcceptors as $parametersAcceptor) { + $acceptsNamedArguments = $acceptsNamedArguments->and($parametersAcceptor->acceptsNamedArguments()); + } + + return $this->parametersCheck->checkPartialApplication( + PartialFunctionApplicationParameters::selectVariant($node->getArgs(), $parametersAcceptors, null), + $scope, + false, + $node->getOriginalNode(), + 'callable', + $acceptsNamedArguments, + $type instanceof ClosureType ? 'closure' : sprintf('callable %s', SprintfHelper::escapeFormatString($type->describe(VerbosityLevel::value()))), + null, + ); } } diff --git a/src/Rules/Methods/MethodCallableRule.php b/src/Rules/Methods/MethodCallableRule.php index c7326882592..7eb5c3a172a 100644 --- a/src/Rules/Methods/MethodCallableRule.php +++ b/src/Rules/Methods/MethodCallableRule.php @@ -3,11 +3,17 @@ namespace PHPStan\Rules\Methods; use PhpParser\Node; +use PHPStan\Analyser\CollectedDataEmitter; +use PHPStan\Analyser\NodeCallbackInvoker; use PHPStan\Analyser\Scope; use PHPStan\DependencyInjection\RegisteredRule; +use PHPStan\Internal\SprintfHelper; use PHPStan\Node\MethodCallableNode; +use PHPStan\Reflection\PartialFunctionApplicationParameters; +use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use function array_merge; /** * @implements Rule @@ -16,7 +22,10 @@ final class MethodCallableRule implements Rule { - public function __construct(private MethodCallCheck $methodCallCheck) + public function __construct( + private MethodCallCheck $methodCallCheck, + private FunctionCallParametersCheck $parametersCheck, + ) { } @@ -25,7 +34,7 @@ public function getNodeType(): string return MethodCallableNode::class; } - public function processNode(Node $node, Scope $scope): array + public function processNode(Node $node, Scope&NodeCallbackInvoker&CollectedDataEmitter $scope): array { if (!$node->getOriginalNode()->isFirstClassCallable()) { if (!$scope->getPhpVersion()->supportsPartialFunctionApplication()->yes()) { @@ -36,6 +45,11 @@ public function processNode(Node $node, Scope $scope): array ->build(), ]; } + // compile errors, even when the callee is unknown + $syntaxErrors = $this->parametersCheck->checkPartialApplicationSyntax($node->getOriginalNode()); + if ($syntaxErrors !== []) { + return $syntaxErrors; + } } elseif (!$scope->getPhpVersion()->supportsFirstClassCallables()->yes()) { return [ RuleErrorBuilder::message('First-class callables are supported only on PHP 8.1 and later.') @@ -61,7 +75,23 @@ public function processNode(Node $node, Scope $scope): array $methodNameName = $methodName->toString(); - return $this->methodCallCheck->check($scope, $methodNameName, $node->getVar(), $node->getName())[0]; + [$errors, $methodReflection] = $this->methodCallCheck->check($scope, $methodNameName, $node->getVar(), $node->getName()); + if ($methodReflection === null || $node->getOriginalNode()->isFirstClassCallable()) { + return $errors; + } + + $declaringClass = $methodReflection->getDeclaringClass(); + + return array_merge($errors, $this->parametersCheck->checkPartialApplication( + PartialFunctionApplicationParameters::selectVariant($node->getArgs(), $methodReflection->getVariants(), $methodReflection->getNamedArgumentsVariants()), + $scope, + $declaringClass->isBuiltin(), + $node->getOriginalNode(), + 'method', + $methodReflection->acceptsNamedArguments(), + 'method ' . SprintfHelper::escapeFormatString($declaringClass->getDisplayName() . '::' . $methodReflection->getName() . '()'), + $methodReflection, + )); } } diff --git a/src/Rules/Methods/StaticMethodCallableRule.php b/src/Rules/Methods/StaticMethodCallableRule.php index d845156e90f..1b947da8991 100644 --- a/src/Rules/Methods/StaticMethodCallableRule.php +++ b/src/Rules/Methods/StaticMethodCallableRule.php @@ -3,11 +3,17 @@ namespace PHPStan\Rules\Methods; use PhpParser\Node; +use PHPStan\Analyser\CollectedDataEmitter; +use PHPStan\Analyser\NodeCallbackInvoker; use PHPStan\Analyser\Scope; use PHPStan\DependencyInjection\RegisteredRule; +use PHPStan\Internal\SprintfHelper; use PHPStan\Node\StaticMethodCallableNode; +use PHPStan\Reflection\PartialFunctionApplicationParameters; +use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use function array_merge; /** * @implements Rule @@ -16,7 +22,10 @@ final class StaticMethodCallableRule implements Rule { - public function __construct(private StaticMethodCallCheck $methodCallCheck) + public function __construct( + private StaticMethodCallCheck $methodCallCheck, + private FunctionCallParametersCheck $parametersCheck, + ) { } @@ -25,7 +34,7 @@ public function getNodeType(): string return StaticMethodCallableNode::class; } - public function processNode(Node $node, Scope $scope): array + public function processNode(Node $node, Scope&NodeCallbackInvoker&CollectedDataEmitter $scope): array { if (!$node->getOriginalNode()->isFirstClassCallable()) { if (!$scope->getPhpVersion()->supportsPartialFunctionApplication()->yes()) { @@ -36,6 +45,11 @@ public function processNode(Node $node, Scope $scope): array ->build(), ]; } + // compile errors, even when the callee is unknown + $syntaxErrors = $this->parametersCheck->checkPartialApplicationSyntax($node->getOriginalNode()); + if ($syntaxErrors !== []) { + return $syntaxErrors; + } } elseif (!$scope->getPhpVersion()->supportsFirstClassCallables()->yes()) { return [ RuleErrorBuilder::message('First-class callables are supported only on PHP 8.1 and later.') @@ -52,7 +66,23 @@ public function processNode(Node $node, Scope $scope): array $methodNameName = $methodName->toString(); - return $this->methodCallCheck->check($scope, $methodNameName, $node->getClass(), $node->getName())[0]; + [$errors, $methodReflection] = $this->methodCallCheck->check($scope, $methodNameName, $node->getClass(), $node->getName()); + if ($methodReflection === null || $node->getOriginalNode()->isFirstClassCallable()) { + return $errors; + } + + $declaringClass = $methodReflection->getDeclaringClass(); + + return array_merge($errors, $this->parametersCheck->checkPartialApplication( + PartialFunctionApplicationParameters::selectVariant($node->getArgs(), $methodReflection->getVariants(), $methodReflection->getNamedArgumentsVariants()), + $scope, + $declaringClass->isBuiltin(), + $node->getOriginalNode(), + 'staticMethod', + $methodReflection->acceptsNamedArguments(), + 'static method ' . SprintfHelper::escapeFormatString($declaringClass->getDisplayName() . '::' . $methodReflection->getName() . '()'), + $methodReflection, + )); } } diff --git a/src/Rules/RuleLevelHelper.php b/src/Rules/RuleLevelHelper.php index dafeac72578..525bd2bf2e2 100644 --- a/src/Rules/RuleLevelHelper.php +++ b/src/Rules/RuleLevelHelper.php @@ -210,6 +210,7 @@ private function transformAcceptedType(Type $acceptingType, Type $acceptedType): $acceptedType->acceptsNamedArguments(), $acceptedType->mustUseReturnValue(), isStatic: $acceptedType->isStaticClosure(), + origin: $acceptedType->getOrigin(), ); } diff --git a/src/Type/ClosureOrigin.php b/src/Type/ClosureOrigin.php new file mode 100644 index 00000000000..bb072684e4a --- /dev/null +++ b/src/Type/ClosureOrigin.php @@ -0,0 +1,414 @@ +|null $partialApplicationArgs the name and the bound type (null for `?`) of each + * argument of a partial function application before `...`, + * null for a first-class callable + * @param list $boundParameterNames the callee's parameters the partial function application bound + */ + private function __construct( + private ?string $functionName, + private ?Type $calledOnType, + private ?string $methodName, + private bool $isStaticCall, + private ?array $partialApplicationArgs, + private bool $hasVariadicPlaceholder, + private array $boundParameterNames = [], + ) + { + } + + public static function forFunction(string $functionName): self + { + return new self($functionName, null, null, false, null, true); + } + + public static function forMethod(Type $calledOnType, string $methodName, bool $isStaticCall): self + { + return new self(null, $calledOnType, $methodName, $isStaticCall, null, true); + } + + /** + * @param array $args + * @param array $boundArgTypes keyed like $args + */ + public function withPartialApplication(array $args, array $boundArgTypes): self + { + $partialApplicationArgs = []; + $hasVariadicPlaceholder = false; + foreach ($args as $i => $arg) { + if ($arg instanceof VariadicPlaceholder) { + $hasVariadicPlaceholder = true; + continue; + } + $partialApplicationArgs[] = [ + $arg->name?->toString(), + $arg instanceof Arg ? $boundArgTypes[$i] ?? new MixedType() : null, + ]; + } + + return new self($this->functionName, $this->calledOnType, $this->methodName, $this->isStaticCall, $partialApplicationArgs, $hasVariadicPlaceholder); + } + + /** + * @param list $boundParameterNames + */ + public function withBoundParameterNames(array $boundParameterNames): self + { + return new self($this->functionName, $this->calledOnType, $this->methodName, $this->isStaticCall, $this->partialApplicationArgs, $this->hasVariadicPlaceholder, $boundParameterNames); + } + + /** + * The names a call of the closure cannot pass by name: PHP reports that such an argument + * overwrites the bound one when the closure is variadic. + * + * @return list + */ + public function getBoundParameterNames(): array + { + return $this->boundParameterNames; + } + + public function isFirstClassCallable(): bool + { + return $this->partialApplicationArgs === null; + } + + /** + * Whether the closure is one of a method called on an object, bound to that object for + * good: unbinding it fails. Closure::__invoke(...) is the closure itself, so it does not count. + */ + public function keepsCalledOnObject(): bool + { + return $this->methodName !== null + && !$this->isStaticCall + && $this->calledOnType !== null + && (new ObjectType(Closure::class))->isSuperTypeOf($this->calledOnType)->no(); + } + + /** + * The answers of a union's members combined per closure the union can hold. Closures + * created from the same callable with the same arguments are one closure, overloaded + * with the variants of its callee: like the variants of a callable string, any of its + * signatures that holds is enough. + * + * @param list $types + * @param list $results the answer for each of $types + * @return list + */ + public static function combineOverloadAcceptsResults(array $types, array $results): array + { + $combined = []; + foreach (self::groupOverloadResults($types, $results) as $overloads) { + $result = $overloads[0]; + foreach (array_slice($overloads, 1) as $overload) { + $result = $result->or($overload); + } + $combined[] = $result; + } + + return $combined; + } + + /** + * @see combineOverloadAcceptsResults() + * @param list $types + * @param list $results the answer for each of $types + * @return list + */ + public static function combineOverloadIsSuperTypeOfResults(array $types, array $results): array + { + $combined = []; + foreach (self::groupOverloadResults($types, $results) as $overloads) { + $combined[] = count($overloads) === 1 ? $overloads[0] : $overloads[0]->or(...array_slice($overloads, 1)); + } + + return $combined; + } + + /** + * @template TResult + * @param list $types + * @param list $results + * @return list> + */ + private static function groupOverloadResults(array $types, array $results): array + { + $origins = []; + $groups = []; + foreach ($types as $i => $type) { + $origin = $type instanceof ClosureType ? $type->getOrigin() : null; + if ($origin !== null) { + foreach ($origins as $index => $groupOrigin) { + if ($groupOrigin !== null && $groupOrigin->equals($origin)) { + $groups[$index][] = $results[$i]; + continue 2; + } + } + } + $origins[] = $origin; + $groups[] = [$results[$i]]; + } + + return $groups; + } + + public function equals(self $other): bool + { + if ( + $this->functionName !== $other->functionName + || $this->methodName !== $other->methodName + || $this->isStaticCall !== $other->isStaticCall + || $this->hasVariadicPlaceholder !== $other->hasVariadicPlaceholder + || $this->boundParameterNames !== $other->boundParameterNames + ) { + return false; + } + if ($this->calledOnType !== null && ($other->calledOnType === null || !$this->calledOnType->equals($other->calledOnType))) { + return false; + } + if ($this->partialApplicationArgs === null || $other->partialApplicationArgs === null) { + return $this->partialApplicationArgs === $other->partialApplicationArgs; + } + if (count($this->partialApplicationArgs) !== count($other->partialApplicationArgs)) { + return false; + } + foreach ($this->partialApplicationArgs as $i => [$name, $type]) { + [$otherName, $otherType] = $other->partialApplicationArgs[$i]; + if ($name !== $otherName) { + return false; + } + if ($type === null || $otherType === null) { + if ($type !== $otherType) { + return false; + } + continue; + } + if (!$type->equals($otherType)) { + return false; + } + } + + return true; + } + + public function describe(): string + { + if ($this->functionName !== null) { + $callee = $this->functionName; + } elseif ($this->calledOnType !== null) { + $callee = sprintf('%s%s%s', $this->calledOnType->describe(VerbosityLevel::cache()), $this->isStaticCall ? '::' : '->', $this->methodName); + } else { + $callee = ''; + } + if ($this->partialApplicationArgs === null) { + return $callee . '(...)'; + } + + $args = []; + foreach ($this->partialApplicationArgs as [$name, $type]) { + $args[] = ($name !== null ? $name . ': ' : '') . ($type !== null ? $type->describe(VerbosityLevel::cache()) : '?'); + } + if ($this->hasVariadicPlaceholder) { + $args[] = '...'; + } + + return sprintf('%s(%s)', $callee, implode(', ', $args)); + } + + /** + * @param callable(Type): Type $cb + */ + public function traverse(callable $cb): self + { + $changed = false; + $calledOnType = $this->calledOnType; + if ($calledOnType !== null) { + $calledOnType = $cb($calledOnType); + $changed = $calledOnType !== $this->calledOnType; + } + $partialApplicationArgs = $this->partialApplicationArgs; + if ($partialApplicationArgs !== null) { + foreach ($partialApplicationArgs as $i => [$name, $type]) { + if ($type === null) { + continue; + } + $newType = $cb($type); + if ($newType === $type) { + continue; + } + $partialApplicationArgs[$i] = [$name, $newType]; + $changed = true; + } + } + if (!$changed) { + return $this; + } + + return new self($this->functionName, $calledOnType, $this->methodName, $this->isStaticCall, $partialApplicationArgs, $this->hasVariadicPlaceholder, $this->boundParameterNames); + } + + /** + * The call of the callee that calling the closure as $call makes, null when its + * arguments do not map onto the callee - the call is then analysed on the closure's + * signature alone. + */ + public function createCall(FuncCall $call, ClosureType $closure): ?CallLike + { + $args = $this->createArgs($call, $closure); + if ($args === null) { + return null; + } + + $attributes = $call->getAttributes(); + unset($attributes[ExprPrinter::ATTRIBUTE_CACHE_KEY]); + if ($this->functionName !== null && $this->functionName !== '') { + return new FuncCall(new FullyQualified($this->functionName), $args, $attributes); + } + if ($this->calledOnType === null || $this->methodName === null || $this->methodName === '') { + return null; + } + if ($this->isStaticCall) { + return new StaticCall(new TypeExpr($this->calledOnType), new Identifier($this->methodName), $args, $attributes); + } + + return new MethodCall(new TypeExpr($this->calledOnType), new Identifier($this->methodName), $args, $attributes); + } + + /** + * @return list|null + */ + private function createArgs(FuncCall $call, ClosureType $closure): ?array + { + $callArgs = $call->getArgs(); + if ($this->partialApplicationArgs === null) { + return $callArgs; + } + + // the closure's parameters are the positional placeholders, the named + // placeholders and, with `...`, the callee's unbound parameters and its variadic + $parameters = $closure->getParameters(); + $declaredCount = count($parameters); + if ($closure->isVariadic() && $declaredCount > 0 && $parameters[$declaredCount - 1]->isVariadic()) { + $declaredCount--; + } + $indexesByName = []; + foreach (array_slice($parameters, 0, $declaredCount) as $i => $parameter) { + $indexesByName[$parameter->getName()] = $i; + } + + $argsByParameter = []; + $extraPositional = []; + $extraNamed = []; + $position = 0; + foreach ($callArgs as $arg) { + if ($arg->unpack) { + return null; + } + if ($arg->name === null) { + if ($position < $declaredCount) { + $argsByParameter[$position++] = $arg; + continue; + } + $extraPositional[] = $arg; + continue; + } + $index = $indexesByName[$arg->name->toString()] ?? null; + if ($index === null) { + $extraNamed[] = $arg; + continue; + } + $argsByParameter[$index] = $arg; + } + if (!$closure->isVariadic() && ($extraPositional !== [] || $extraNamed !== [])) { + return null; + } + + $calleeArgs = []; + $parameterIndex = 0; + // past a named argument, the remaining parameters go by name too + $named = $this->hasNamedArgs(); + foreach ([false, true] as $namedPass) { + foreach ($this->partialApplicationArgs as [$name, $type]) { + if (($name !== null) !== $namedPass) { + continue; + } + $nameIdentifier = $name !== null ? new Identifier($name) : null; + if ($type !== null) { + $calleeArgs[] = new Arg(new TypeExpr($type), name: $nameIdentifier); + continue; + } + $arg = $argsByParameter[$parameterIndex++] ?? null; + if ($arg === null) { + return null; + } + $calleeArgs[] = new Arg($arg->value, attributes: $arg->getAttributes(), name: $nameIdentifier); + } + } + + if ($this->hasVariadicPlaceholder) { + for (; $parameterIndex < $declaredCount; $parameterIndex++) { + $arg = $argsByParameter[$parameterIndex] ?? null; + if ($arg === null) { + // an optional parameter left out: the ones after it go by name + $named = true; + continue; + } + $parameterName = $parameters[$parameterIndex]->getName(); + if ($named && $parameterName === '') { + return null; + } + $calleeArgs[] = new Arg($arg->value, attributes: $arg->getAttributes(), name: $named ? new Identifier($parameterName) : null); + } + } + if ($extraPositional !== [] && $named) { + return null; + } + + return [...$calleeArgs, ...$extraPositional, ...$extraNamed]; + } + + private function hasNamedArgs(): bool + { + foreach ($this->partialApplicationArgs ?? [] as [$name]) { + if ($name !== null) { + return true; + } + } + + return false; + } + +} diff --git a/src/Type/ClosureType.php b/src/Type/ClosureType.php index 4d29a0c6724..3e0731026f9 100644 --- a/src/Type/ClosureType.php +++ b/src/Type/ClosureType.php @@ -57,6 +57,7 @@ use function array_map; use function array_merge; use function count; +use function in_array; /** @api */ #[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ClosureType.cpp')] @@ -111,6 +112,7 @@ class ClosureType implements TypeWithClassName, CallableParametersAcceptor * @param InvalidateExprNode[] $invalidateExpressions * @param string[] $usedVariables * @param array $byRefUseTypes per by-ref use of a closure whose effects apply where it is invoked, the marker of its site (see ClosureSignatureInference) + * @param ClosureOrigin|null $origin the callee of a first-class callable or a partial function application, whose call a call of the closure replays */ public function __construct( ?array $parameters = null, @@ -129,6 +131,7 @@ public function __construct( ?Assertions $assertions = null, ?TrinaryLogic $isStatic = null, private array $byRefUseTypes = [], + private ?ClosureOrigin $origin = null, ) { if ($acceptsNamedArguments === null) { @@ -267,12 +270,19 @@ private function isSuperTypeOfInternal(Type $type, bool $treatMixedAsAny, bool $ if (!$variant instanceof CallableParametersAcceptor) { return IsSuperTypeOfResult::createNo([]); } - return CallableTypeHelper::isParametersAcceptorSuperTypeOf( + $result = CallableTypeHelper::isParametersAcceptorSuperTypeOf( $this, $variant, $treatMixedAsAny, $strictTypes, ); + if (!$treatMixedAsAny && $this->origin !== null && !self::hasEqualOrigins($this, $type)) { + // a closure created from another callee, or from an unknown one, + // is not known to be created from this one + return $result->and(IsSuperTypeOfResult::createMaybe()); + } + + return $result; } if ($type->getObjectClassNames() === [Closure::class]) { @@ -291,7 +301,17 @@ public function equals(Type $type): bool return $this->describe(VerbosityLevel::precise()) === $type->describe(VerbosityLevel::precise()) && $this->isPure()->equals($type->isPure()) && $this->isStatic->equals($type->isStatic) - && $this->hasEqualUnresolvedSignature($type); + && $this->hasEqualUnresolvedSignature($type) + && self::hasEqualOrigins($this, $type); + } + + private static function hasEqualOrigins(self $a, self $b): bool + { + if ($a->origin === null || $b->origin === null) { + return $a->origin === $b->origin; + } + + return $a->origin->equals($b->origin); } /** @@ -351,6 +371,14 @@ function (): string { return $prefix . $this->describeCallable(); }, + function (): string { + $description = $this->describe(VerbosityLevel::precise()); + if ($this->origin === null) { + return $description; + } + + return $description . ' from ' . $this->origin->describe(); + }, ); } @@ -480,10 +508,11 @@ public function getMethod(string $methodName, ClassMemberAccessAnswerer $scope): public function getUnresolvedMethodPrototype(string $methodName, ClassMemberAccessAnswerer $scope): UnresolvedMethodPrototypeReflection { - if ($methodName === 'call') { + if (in_array($methodName, ['call', '__invoke'], true)) { return new ClosureCallUnresolvedMethodPrototypeReflection( $this->objectType->getUnresolvedMethodPrototype($methodName, $scope), $this, + $methodName === 'call', ); } @@ -571,6 +600,11 @@ public function getByRefUseTypes(): array return $this->byRefUseTypes; } + public function getOrigin(): ?ClosureOrigin + { + return $this->origin; + } + /** * Whether an UnresolvedTemplateArgumentType occurs anywhere in the * closure's signature - it is still being inferred (see @@ -836,6 +870,7 @@ public function traverse(callable $cb): Type $this->assertions->mapTypes($cb), $this->isStatic, $this->byRefUseTypes, + $this->origin?->traverse($cb), ); } @@ -890,6 +925,7 @@ public function traverseSimultaneously(Type $right, callable $cb): Type $this->assertions, $this->isStatic, $this->byRefUseTypes, + $this->origin, ); } diff --git a/src/Type/Php/ClosureBindDynamicReturnTypeExtension.php b/src/Type/Php/ClosureBindDynamicReturnTypeExtension.php index 1234067633d..d07ec840917 100644 --- a/src/Type/Php/ClosureBindDynamicReturnTypeExtension.php +++ b/src/Type/Php/ClosureBindDynamicReturnTypeExtension.php @@ -40,8 +40,8 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, return null; } + $newThisIsNull = isset($args[1]) ? $scope->getType($args[1]->value)->isNull() : TrinaryLogic::createYes(); if ($closureType->isStaticClosure()->yes()) { - $newThisIsNull = isset($args[1]) ? $scope->getType($args[1]->value)->isNull() : TrinaryLogic::createYes(); if ($newThisIsNull->yes()) { return $closureType; } @@ -52,6 +52,11 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, return new BenevolentUnionType([$closureType, new NullType()]); } + $origin = $closureType->getOrigin(); + if ($newThisIsNull->yes() && $origin !== null && $origin->keepsCalledOnObject()) { + return new NullType(); + } + return new BenevolentUnionType([$closureType, new NullType()]); } diff --git a/src/Type/Php/ClosureBindToDynamicReturnTypeExtension.php b/src/Type/Php/ClosureBindToDynamicReturnTypeExtension.php index dc9aaf33a6f..1517b1b5b84 100644 --- a/src/Type/Php/ClosureBindToDynamicReturnTypeExtension.php +++ b/src/Type/Php/ClosureBindToDynamicReturnTypeExtension.php @@ -35,9 +35,9 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method return null; } + $args = $methodCall->getArgs(); + $newThisIsNull = isset($args[0]) ? $scope->getType($args[0]->value)->isNull() : TrinaryLogic::createYes(); if ($closureType->isStaticClosure()->yes()) { - $args = $methodCall->getArgs(); - $newThisIsNull = isset($args[0]) ? $scope->getType($args[0]->value)->isNull() : TrinaryLogic::createYes(); if ($newThisIsNull->yes()) { return $closureType; } @@ -48,6 +48,11 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method return new BenevolentUnionType([$closureType, new NullType()]); } + $origin = $closureType->getOrigin(); + if ($newThisIsNull->yes() && $origin !== null && $origin->keepsCalledOnObject()) { + return new NullType(); + } + return new BenevolentUnionType([$closureType, new NullType()]); } diff --git a/src/Type/UnionType.php b/src/Type/UnionType.php index 99b46164c63..5506cc53738 100644 --- a/src/Type/UnionType.php +++ b/src/Type/UnionType.php @@ -416,7 +416,12 @@ public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult return IsSuperTypeOfResult::createFromBoolean($containment->yes()); } - return IsSuperTypeOfResult::extremeIdentity(...array_map(static fn (Type $innerType) => $otherType->isSuperTypeOf($innerType), $this->types)); + $results = array_map(static fn (Type $innerType) => $otherType->isSuperTypeOf($innerType), $this->types); + if ($this->hasClosureMember()) { + $results = ClosureOrigin::combineOverloadIsSuperTypeOfResults($this->types, $results); + } + + return IsSuperTypeOfResult::extremeIdentity(...$results); } public function isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsResult @@ -428,7 +433,24 @@ public function isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsRes return AcceptsResult::createYes(); } - return AcceptsResult::extremeIdentity(...array_map(static fn (Type $innerType) => $acceptingType->accepts($innerType, $strictTypes), $this->types)); + $results = array_map(static fn (Type $innerType) => $acceptingType->accepts($innerType, $strictTypes), $this->types); + if ($this->hasClosureMember()) { + $results = ClosureOrigin::combineOverloadAcceptsResults($this->types, $results); + } + + return AcceptsResult::extremeIdentity(...$results); + } + + /** Closure members of one overloaded callee answer together, see ClosureOrigin::combineOverloadAcceptsResults(). */ + private function hasClosureMember(): bool + { + foreach ($this->types as $type) { + if ($type instanceof ClosureType) { + return true; + } + } + + return false; } /** diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index 4976071022b..394a50d2487 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -1718,6 +1718,20 @@ public function testBug9746(): void $this->assertSame(9, $errors[1]->getLine()); } + #[RequiresPhp('>= 8.1.0')] + public function testUnknownDefaultValueNamedArguments(): void + { + // crash + $errors = $this->runAnalyse(__DIR__ . '/data/unknown-default-value-named-arguments.php'); + $this->assertCount(3, $errors); + $this->assertSame('Argument #1 ($min) must be passed explicitly, because the default value is not known.', $errors[0]->getMessage()); + $this->assertSame(7, $errors[0]->getLine()); + $this->assertSame('Argument #1 ($min) must be passed explicitly, because the default value is not known.', $errors[1]->getMessage()); + $this->assertSame(8, $errors[1]->getLine()); + $this->assertSame('Argument #2 ($close) must be passed explicitly, because the default value is not known.', $errors[2]->getMessage()); + $this->assertSame(9, $errors[2]->getLine()); + } + public function testBug15364(): void { // crash diff --git a/tests/PHPStan/Analyser/data/unknown-default-value-named-arguments.php b/tests/PHPStan/Analyser/data/unknown-default-value-named-arguments.php new file mode 100644 index 00000000000..0cf8bba5bce --- /dev/null +++ b/tests/PHPStan/Analyser/data/unknown-default-value-named-arguments.php @@ -0,0 +1,10 @@ += 8.1 + +namespace UnknownDefaultValueNamedArguments; + +function doFoo(callable $open, callable $read): void +{ + mt_rand(max: 5); + (mt_rand(...))(max: 5); + (session_set_save_handler(...))($open, read: $read); +} diff --git a/tests/PHPStan/Analyser/nsrt/bug-11421.php b/tests/PHPStan/Analyser/nsrt/bug-11421.php index 27ca5dda64f..83599c28a10 100644 --- a/tests/PHPStan/Analyser/nsrt/bug-11421.php +++ b/tests/PHPStan/Analyser/nsrt/bug-11421.php @@ -18,9 +18,9 @@ enum WordEnum: string } function (): void { - assertType('Closure(int): Bug11421Types\NumberEnum', NumberEnum::from(...)); - assertNativeType('Closure(int): mixed', NumberEnum::from(...)); - assertType('Closure(int): (Bug11421Types\NumberEnum|null)', NumberEnum::tryFrom(...)); - assertType('Closure(string): Bug11421Types\WordEnum', WordEnum::from(...)); - assertType('Closure(string): (Bug11421Types\WordEnum|null)', WordEnum::tryFrom(...)); + assertType('static-Closure(int): Bug11421Types\NumberEnum', NumberEnum::from(...)); + assertNativeType('static-Closure(int): mixed', NumberEnum::from(...)); + assertType('static-Closure(int): (Bug11421Types\NumberEnum|null)', NumberEnum::tryFrom(...)); + assertType('static-Closure(string): Bug11421Types\WordEnum', WordEnum::from(...)); + assertType('static-Closure(string): (Bug11421Types\WordEnum|null)', WordEnum::tryFrom(...)); }; diff --git a/tests/PHPStan/Analyser/nsrt/bug-15169-callables.php b/tests/PHPStan/Analyser/nsrt/bug-15169-callables.php index 3b377889675..ecae92a3da3 100644 --- a/tests/PHPStan/Analyser/nsrt/bug-15169-callables.php +++ b/tests/PHPStan/Analyser/nsrt/bug-15169-callables.php @@ -45,8 +45,8 @@ function firstClassCallables(C $c): void assertType('Closure(): array{a: int}', $c->info(...)); assertNativeType('Closure(): array', $c->info(...)); - assertType('Closure(): array{a: int}', C::staticInfo(...)); - assertNativeType('Closure(): array', C::staticInfo(...)); + assertType('static-Closure(): array{a: int}', C::staticInfo(...)); + assertNativeType('static-Closure(): array', C::staticInfo(...)); assertType('Closure(): array{a: int}', info(...)); assertNativeType('Closure(): array', info(...)); diff --git a/tests/PHPStan/Analyser/nsrt/first-class-callable-native-template.php b/tests/PHPStan/Analyser/nsrt/first-class-callable-native-template.php index 583929d2d39..d3e97ea67ea 100644 --- a/tests/PHPStan/Analyser/nsrt/first-class-callable-native-template.php +++ b/tests/PHPStan/Analyser/nsrt/first-class-callable-native-template.php @@ -15,7 +15,7 @@ function (PDOStatement $stmt, Foo $foo): void { assertType('Closure>(TArray, int=): true', sort(...)); $create = WeakReference::create(...); - assertType('Closure(TIn): WeakReference', $create); + assertType('static-Closure(TIn): WeakReference', $create); assertType('WeakReference', $create($foo)); $fetch = $stmt->fetchObject(...); diff --git a/tests/PHPStan/Analyser/nsrt/first-class-callable-replay.php b/tests/PHPStan/Analyser/nsrt/first-class-callable-replay.php new file mode 100644 index 00000000000..18a28061987 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/first-class-callable-replay.php @@ -0,0 +1,86 @@ += 8.1 + +declare(strict_types = 1); + +namespace FirstClassCallableReplay; + +use function PHPStan\Testing\assertType; + +class Foo +{ + + /** + * @param-out int $out + */ + public static function out(mixed &$out): void + { + $out = 1; + } + +} + +/** + * @param array $arr + */ +function problems(\DateTimeImmutable $d, array $arr, string $s, mixed $x): void +{ + $r = str_replace(...); + assertType('lowercase-string&non-falsy-string', $r(' ', '-', 'a b')); + assertType('lowercase-string&non-falsy-string', $r(subject: 'a b', search: ' ', replace: '-')); + assertType('3', strlen(...)('abc')); + + $a = [3, 1, 2]; + $sort = sort(...); + $sort($a); + assertType('non-empty-list<1|2|3>', $a); + + $pm = preg_match(...); + $pm('/(a)(b)?/', 'ab', $mm); + assertType("array{}|array{0: non-falsy-string, 1: 'a', 2?: 'b'}", $mm); + + $ake = array_key_exists(...); + if ($ake('a', $arr)) { + assertType("non-empty-array&hasOffset('a')", $arr); + } + + $isInt = is_int(...); + if ($isInt($x)) { + assertType('int', $x); + } + + $out = Foo::out(...); + $o = null; + $out($o); + assertType('int', $o); + + $m = $d->modify(...); + assertType('DateTimeImmutable', $m('+1 day')); +} + +function unions(bool $b, string $s): void +{ + $f = $b ? strtoupper(...) : strtoupper(...); + assertType("'A'", $f('a')); + + $g = $b ? strtoupper(...) : strtolower(...); + assertType("'A'|'a'", $g('a')); + + $plain = static fn (string $string): string => $string; + $h1 = $b ? strtoupper(...) : $plain; + $h2 = $b ? $plain : strtoupper(...); + assertType("'a'|uppercase-string", $h1('a')); + assertType("'a'|uppercase-string", $h2('a')); + + if ($b) { + $i = strtoupper(...); + } else { + $i = strtolower(...); + } + assertType("'A'|'a'", $i('a')); + + $n = $b ? is_int(...) : is_numeric(...); + $x = $s; + if ($n($x)) { + assertType('numeric-string', $x); + } +} diff --git a/tests/PHPStan/Analyser/nsrt/first-class-callables-constant-expressions.php b/tests/PHPStan/Analyser/nsrt/first-class-callables-constant-expressions.php new file mode 100644 index 00000000000..569b3f2c35d --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/first-class-callables-constant-expressions.php @@ -0,0 +1,33 @@ += 8.5 + +declare(strict_types = 1); + +namespace FirstClassCallablesConstantExpressions; + +use function PHPStan\Testing\assertType; + +const LENGTH = strlen(...); + +class Foo +{ + + public const UPPER = strtoupper(...); + + public const SELF = self::double(...); + + public static function double(int $i): int + { + return $i * 2; + } + + public function doFoo(): void + { + assertType('Closure(string): int<0, max>', LENGTH); + assertType('3', (LENGTH)('abc')); + assertType('Closure(string): uppercase-string', self::UPPER); + assertType("'A'", (self::UPPER)('a')); + assertType('static-Closure(int): int', self::SELF); + assertType('int', (self::SELF)(2)); + } + +} diff --git a/tests/PHPStan/Analyser/nsrt/first-class-callables.php b/tests/PHPStan/Analyser/nsrt/first-class-callables.php index 43cc852e889..b9392e2d8b8 100644 --- a/tests/PHPStan/Analyser/nsrt/first-class-callables.php +++ b/tests/PHPStan/Analyser/nsrt/first-class-callables.php @@ -12,7 +12,7 @@ class Foo public function doFoo(string $foo): void { assertType('Closure(string): void', $this->doFoo(...)); - assertType('Closure(): void', self::doBar(...)); + assertType('static-Closure(): void', self::doBar(...)); assertType('Closure', self::$foo(...)); assertType('Closure', $this->nonexistent(...)); assertType('Closure', $this->$foo(...)); @@ -114,3 +114,146 @@ public function doBaz(callable $n): void } } + +/** + * @method static string magicStatic(int $i) + * @method string magic(int $i) + */ +class MagicCallables +{ + + /** + * @param array $args + */ + public static function __callStatic(string $name, array $args): mixed + { + return ''; + } + + /** + * @param array $args + */ + public function __call(string $name, array $args): mixed + { + return ''; + } + + public function doFoo(): void + { + assertType('static-Closure(int): string', self::magicStatic(...)); + assertType('string', self::magicStatic(...)(1)); + assertType('Closure(int): string', $this->magic(...)); + assertType('string', $this->magic(...)(1)); + } + +} + +class MultiVariantCallables +{ + + public function doFoo(): void + { + assertType('(Closure(): int)|(Closure(int, int): int)', mt_rand(...)); + assertType('(Closure(string): (non-empty-string|false))|(Closure(string, string): (non-empty-string|false))', strtok(...)); + assertType('int<1, 6>', mt_rand(...)(1, 6)); + } + +} + +class SecondLevelCallables +{ + + /** + * @template T + * @param T $a + * @return T + */ + public function identity($a) + { + return $a; + } + + public function doFoo(): void + { + $f = $this->identity(...); + $g = $f(...); + assertType('Closure(T): T', $g); + assertType('1', $g(1)); + $h = $g(...); + assertType("'x'", $h('x')); + } + +} + +class NewCallable +{ + + public function doFoo(): void + { + assertType('*ERROR*', new \stdClass(...)); + } + +} + +class CallbackCallables +{ + + public function sum(int $carry, int $item): int + { + return $carry + $item; + } + + /** + * @param list $strings + * @param list $ints + */ + public function doFoo(array $strings, array $ints): void + { + usort($strings, strcmp(...)); + assertType('list', $strings); + assertType('int', array_reduce($ints, $this->sum(...), 0)); + assertType('lowercase-string&non-falsy-string', call_user_func_array(str_replace(...), [' ', '-', 'a b'])); + assertType('3', call_user_func(strlen(...), 'abc')); + } + +} + +class BindCallables +{ + + public static function doStatic(): int + { + return 1; + } + + public function doInstance(): int + { + return 1; + } + + public function doFoo(object $o, ?object $maybe): void + { + assertType('((Closure(string): int<0, max>)|null)', strlen(...)->bindTo($o)); + assertType('null', self::doStatic(...)->bindTo($o)); + assertType('null', \Closure::bind(self::doStatic(...), $o)); + assertType('static-Closure(): int', self::doStatic(...)->bindTo(null)); + assertType('((Closure(): int)|null)', $this->doInstance(...)->bindTo($o)); + // the closure of an instance method keeps its object + assertType('null', $this->doInstance(...)->bindTo(null)); + assertType('null', \Closure::bind($this->doInstance(...), null)); + // only unbinding it for sure returns null + assertType('((Closure(): int)|null)', $this->doInstance(...)->bindTo($maybe)); + assertType('((Closure(): int)|null)', \Closure::bind($this->doInstance(...), $maybe)); + } + + public function doInvoke(): void + { + $c = function (int $a, string $b, ?float $c = null): int { + return 1; + }; + assertType('1', $c->__invoke(1, 'x')); + assertType('Closure(int, string, float|null=): 1', $c->__invoke(...)); + assertType('((Closure(int, string, float|null=): 1)|null)', $c->__invoke(...)->bindTo(null)); + } + +} diff --git a/tests/PHPStan/Analyser/nsrt/partial-function-application-replay.php b/tests/PHPStan/Analyser/nsrt/partial-function-application-replay.php new file mode 100644 index 00000000000..7bf8f3893b3 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/partial-function-application-replay.php @@ -0,0 +1,69 @@ += 8.6 + +declare(strict_types = 1); + +namespace PartialFunctionApplicationReplay; + +use function PHPStan\Testing\assertType; + +/** + * @template T + * @param T $a + * @param T $b + * @return T + */ +function pick(mixed $a, mixed $b): mixed +{ + return $a; +} + +/** + * @param array $arr + */ +function bound(\DateTimeImmutable $d, array $arr, string $s): void +{ + $rp = str_replace(' ', '-', ?); + assertType('lowercase-string&non-falsy-string', $rp('a b')); + assertType('lowercase-string&non-falsy-string', $rp(subject: 'a b')); + + $rn = str_replace(search: ' ', replace: '-', ...); + assertType('lowercase-string&non-falsy-string', $rn('a b')); + + $fmt = sprintf('%s-%s', ?, ...); + assertType("'a-b'", $fmt('a', 'b')); + + $pm = preg_match('/(a)(b)?/', ?, ...); + $pm('ab', $mm); + assertType("array{}|array{0: non-falsy-string, 1: 'a', 2?: 'b'}", $mm); + + $has = array_key_exists('a', ?); + if ($has($arr)) { + assertType("non-empty-array&hasOffset('a')", $arr); + } + + $in = in_array(?, ['a', 'b'], true); + if ($in($s)) { + assertType("'a'|'b'", $s); + } + + $p = pick(1, ?); + assertType("1|'x'", $p('x')); + + $mod = $d->modify(?); + assertType('DateTimeImmutable', $mod('+1 day')); +} + +/** + * @param list<1|2> $ints + */ +function unions(bool $b, array $ints): void +{ + $p = $b ? str_replace(' ', '-', ?) : str_replace(' ', '_', ?); + assertType('lowercase-string&non-falsy-string', $p('a b')); + + $q = str_repeat('a', ?); + foreach ($ints as $i) { + $q = str_repeat((string) $i, ?); + } + assertType("'11'|'22'|'aa'", $q(2)); +} diff --git a/tests/PHPStan/Analyser/nsrt/partial-function-application-signature.php b/tests/PHPStan/Analyser/nsrt/partial-function-application-signature.php new file mode 100644 index 00000000000..6ac9a99ab37 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/partial-function-application-signature.php @@ -0,0 +1,228 @@ += 8.6 + +declare(strict_types = 1); + +namespace PartialFunctionApplicationSignature; + +use function PHPStan\Testing\assertType; + +function doFoo(int $a, string $b, float $c, bool ...$d): string +{ + return ''; +} + +function opt(int $a, string $b = 'B', float $c = 1.0): int +{ + return 1; +} + +function none(): void +{ +} + +function byRef(int &$a, string $b): void +{ +} + +function withNullableDefault(?int $a = null, string ...$rest): void +{ +} + +/** + * @template T + * @param T $a + * @return T + */ +function identity($a) +{ + return $a; +} + +/** + * @template T + * @param T $value + * @param T $other + * @return list + */ +function pair($value, $other): array +{ + return [$value, $other]; +} + +/** + * @template T + * @param T $value + * @return list + */ +function repeat($value, int $times): array +{ + return []; +} + +/** + * @template T + * @template U + * @param list $items + * @param callable(T): U $fn + * @return list + */ +function mapList(array $items, callable $fn): array +{ + return []; +} + +class Foo +{ + + public function doFoo(int $a, string $b, float ...$c): bool + { + return true; + } + + public static function doStatic(int $a, string $b = 'x'): int + { + return 1; + } + +} + +class Invokable +{ + + public function __invoke(int $a, string $b): bool + { + return true; + } + +} + +class Constants +{ + + const PARTIAL = doFoo(1, ?, ...); + + const REPEATED = repeat('a', ?); + +} + +function functions(): void +{ + // the cases checked against PHP 8.6 + assertType('static-Closure(float, bool ...): string', doFoo(1, 'b', ...)); + assertType('static-Closure(string, float, bool ...): string', doFoo(1, ?, ...)); + assertType('static-Closure(string, bool ...): string', doFoo(1, ?, 3.0, ...)); + assertType('static-Closure(string, bool ...): string', doFoo(1, ?, 3.0, true, ...)); + assertType('static-Closure(bool ...): string', doFoo(1, 'b', 3.0, ...)); + assertType('static-Closure(string): string', doFoo(1, ?, 3.0)); + assertType('static-Closure(string): string', doFoo(1, ?, 3.0, true)); + assertType('static-Closure(bool): string', doFoo(1, 'b', 3.0, true, ?)); + assertType('static-Closure(bool, bool): string', doFoo(1, 'b', 3.0, ?, ?)); + assertType('static-Closure(bool, bool ...): string', doFoo(1, 'b', 3.0, ?, ...)); + assertType('static-Closure(bool ...): string', doFoo(1, 'b', 3.0, x: true, ...)); + + // a placeholder is required even for an optional parameter, ... keeps the optionality + assertType('static-Closure(int): int', opt(?)); + assertType('static-Closure(int, string): int', opt(?, ?)); + assertType('static-Closure(string=, float=): int', opt(1, ...)); + assertType('static-Closure(): int', opt(1, 'b', 2.0, ...)); + assertType('static-Closure(int|null, string ...): void', withNullableDefault(?, ...)); + + // named placeholders come after the positional ones, in the order they are written, + // and before what ... adds + assertType('static-Closure(float, int, string): string', doFoo(c: ?, a: ?, b: ?)); + assertType('static-Closure(int, float, string, bool ...): string', doFoo(?, c: ?, ...)); + assertType('static-Closure(string, int, float=): int', opt(b: ?, ...)); + assertType('static-Closure(int): int', opt(?, c: 2.0)); + + // by-ref is kept + assertType('static-Closure(int, string): void', byRef(?, ?)); + + // the partial application throws when it is created + assertType('Closure', doFoo(1, ?)); + assertType('Closure', none(?)); + assertType('Closure', none(1, ...)); + assertType('Closure', opt(1, 'b', 2.0, ?)); + assertType('Closure', opt(x: ?)); + assertType('Closure', doFoo(1, 'b', 3.0, d: ?)); + assertType('Closure', opt(?, a: 1)); + assertType('Closure', opt(a: ?, a: ?)); + assertType('Closure', doFoo(?, ..., ...)); + + // built-ins + assertType('static-Closure(string): (non-empty-string|false)', strtok(?)); + assertType('static-Closure(string, string): (non-empty-string|false)', strtok(?, ?)); + assertType('static-Closure(string): int<0, max>', strlen(?)); + // PHP creates it from the declared mt_rand(int $min = UNKNOWN, int $max = UNKNOWN), calling it throws + assertType('Closure', mt_rand(?)); + // PHP throws when ... or a later named argument leaves out a parameter whose default it does not know + assertType('Closure', array_keys(?, ...)); + assertType('Closure', array_keys(?, strict: ?)); + assertType('Closure', mt_rand(?, ...)); + assertType('Closure', array_walk(?, ?, ...)); + assertType('static-Closure(array, mixed, bool=): list', array_keys(?, ?, ...)); + assertType('static-Closure(array|object, callable): true', array_walk(?, ?)); + + // templates + assertType('static-Closure(T): T', identity(?)); + assertType('static-Closure(int): list<\'a\'>', repeat('a', ?)); + assertType('static-Closure(T): list', repeat(?, 3)); + // a template a closure parameter still mentions gets what the bound arguments bring to it + assertType('static-Closure(T): list<\'x\'|T>', pair(?, 'x')); + $pair = pair(?, 'x'); + assertType('list<1|\'x\'>', $pair(1)); +} + +/** + * @param list $ints + */ +function templatesThroughCallbacks(array $ints): void +{ + assertType('list>', array_map(pair(?, 'x'), $ints)); + assertType('list>', array_map(repeat(?, 2), $ints)); + assertType('list>', mapList($ints, pair(?, 'x'))); + assertType('list>', mapList($ints, repeat(?, 2))); + assertType('list', mapList($ints, identity(...))); + assertType('list', mapList($ints, identity(?))); +} + +function methods(Foo $foo): void +{ + assertType('Closure(string): bool', $foo->doFoo(1, ?)); + assertType('Closure(float, float): bool', $foo->doFoo(1, 'b', ?, ?)); + assertType('Closure(string, float ...): bool', $foo->doFoo(1, ...)); + assertType('Closure', $foo->doFoo(?)); + + assertType('static-Closure(int): int', Foo::doStatic(?)); + assertType('static-Closure(int, string=): int', Foo::doStatic(?, ...)); + assertType('static-Closure(string): int', Foo::doStatic(1, ?)); + assertType('Closure', Foo::doStatic(1, 'b', ?)); +} + +function closures(Invokable $i): void +{ + assertType('Closure(string): bool', $i(1, ?)); + assertType('Closure(int): bool', $i->__invoke(?, 'x')); + assertType('static-Closure(string, float, bool ...): string', Constants::PARTIAL); + assertType('static-Closure(int): list<\'a\'>', Constants::REPEATED); + + $c = fn (int $a, string $b, float $c = 1.0): int => 1; + assertType('Closure(string): 1', $c(1, ?)); + assertType('Closure(string): 1', $c->__invoke(1, ?)); + assertType('Closure(string, float=): 1', $c(1, ...)); + assertType('Closure', $c(?)); + + $d = doFoo(1, ?, ...); + assertType('static-Closure(string): string', $d(?, 3.0)); + assertType('static-Closure(bool): string', $d('b', 3.0, ?)); +} + +function bind(Foo $foo, Invokable $i, object $o): void +{ + assertType('null', doFoo(1, ?, ...)->bindTo($o)); + assertType('null', strlen(?)->bindTo($o)); + assertType('static-Closure(string): string', doFoo(1, ?, 3.0)->bindTo(null)); + assertType('null', Foo::doStatic(1, ?)->bindTo($o)); + assertType('((Closure(string, float ...): bool)|null)', $foo->doFoo(1, ...)->bindTo($o)); + assertType('null', $foo->doFoo(1, ...)->bindTo(null)); + assertType('((Closure(string): bool)|null)', $i(1, ?)->bindTo($o)); +} diff --git a/tests/PHPStan/Analyser/nsrt/static-late-binding.php b/tests/PHPStan/Analyser/nsrt/static-late-binding.php index ea3c3a44bdc..ebe06ad9c60 100644 --- a/tests/PHPStan/Analyser/nsrt/static-late-binding.php +++ b/tests/PHPStan/Analyser/nsrt/static-late-binding.php @@ -90,7 +90,7 @@ public function foo(): void assertType('StaticLateBinding\B', B::retStatic(...)()); assertType('static(StaticLateBinding\B)', self::retStatic(...)()); assertType('static(StaticLateBinding\B)', static::retStatic(...)()); - assertType('static(StaticLateBinding\A)', parent::retStatic(...)()); // could be static(StaticLateBinding\B) + assertType('static(StaticLateBinding\B)', parent::retStatic(...)()); assertType('static(StaticLateBinding\B)', $this->retStatic(...)()); assertType('bool', X::retStatic(...)()); assertType('mixed', $clUnioned::retStatic(...)()); // should be bool|StaticLateBinding\A https://github.com/phpstan/phpstan/issues/11687 diff --git a/tests/PHPStan/Reflection/AttributeReflectionTest.php b/tests/PHPStan/Reflection/AttributeReflectionTest.php index c23fc3d485c..35144c2f75a 100644 --- a/tests/PHPStan/Reflection/AttributeReflectionTest.php +++ b/tests/PHPStan/Reflection/AttributeReflectionTest.php @@ -161,7 +161,7 @@ public static function dataAttributeReflections(): iterable [ 'ClosureInAttribute\\AttrWithCallback', [ - 'callback' => 'Closure(int): void', + 'callback' => 'static-Closure(int): void', ], ], ], diff --git a/tests/PHPStan/Reflection/Php/data/backed-enum-from-parameter-type-off.php b/tests/PHPStan/Reflection/Php/data/backed-enum-from-parameter-type-off.php index 0309fe076b2..e3f0bd568ae 100644 --- a/tests/PHPStan/Reflection/Php/data/backed-enum-from-parameter-type-off.php +++ b/tests/PHPStan/Reflection/Php/data/backed-enum-from-parameter-type-off.php @@ -17,8 +17,8 @@ enum WordEnum: string } function (): void { - assertType('Closure(int|string): BackedEnumFromParameterTypeOff\NumberEnum', NumberEnum::from(...)); - assertType('Closure(int|string): (BackedEnumFromParameterTypeOff\NumberEnum|null)', NumberEnum::tryFrom(...)); - assertType('Closure(int|string): BackedEnumFromParameterTypeOff\WordEnum', WordEnum::from(...)); - assertType('Closure(int|string): (BackedEnumFromParameterTypeOff\WordEnum|null)', WordEnum::tryFrom(...)); + assertType('static-Closure(int|string): BackedEnumFromParameterTypeOff\NumberEnum', NumberEnum::from(...)); + assertType('static-Closure(int|string): (BackedEnumFromParameterTypeOff\NumberEnum|null)', NumberEnum::tryFrom(...)); + assertType('static-Closure(int|string): BackedEnumFromParameterTypeOff\WordEnum', WordEnum::from(...)); + assertType('static-Closure(int|string): (BackedEnumFromParameterTypeOff\WordEnum|null)', WordEnum::tryFrom(...)); }; diff --git a/tests/PHPStan/Rules/Classes/InstantiationCallableRuleTest.php b/tests/PHPStan/Rules/Classes/InstantiationCallableRuleTest.php index d30f3a29f65..adcce7f0b84 100644 --- a/tests/PHPStan/Rules/Classes/InstantiationCallableRuleTest.php +++ b/tests/PHPStan/Rules/Classes/InstantiationCallableRuleTest.php @@ -4,6 +4,7 @@ use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; +use PHPUnit\Framework\Attributes\RequiresPhp; /** * @extends RuleTestCase @@ -26,4 +27,19 @@ public function testRule(): void ]); } + #[RequiresPhp('>= 8.6.0-dev')] + public function testPartialFunctionApplication(): void + { + $this->analyse([__DIR__ . '/data/instantiation-partial-function-application.php'], [ + [ + 'Cannot create callable from the new operator.', + 14, + ], + [ + 'Cannot create callable from the new operator.', + 15, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php b/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php index cc27c26e7f4..497936b5bce 100644 --- a/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php +++ b/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php @@ -464,16 +464,12 @@ public function testBug7048(): void 'Unknown parameter $recurrences in call to DatePeriod constructor.', 21, ], - [ - 'Missing parameter $end (int|TEnd of DateTimeInterface) in call to DatePeriod constructor.', - 18, - ], [ 'Unknown parameter $isostr in call to DatePeriod constructor.', 25, ], [ - 'Missing parameter $start (string) in call to DatePeriod constructor.', + 'Missing parameter $start (string|TDate of DateTimeInterface) in call to DatePeriod constructor.', 24, ], [ @@ -826,4 +822,15 @@ public function testBug14002Part2(): void $this->analyse([__DIR__ . '/data/bug-14002-2.php'], []); } + #[RequiresPhp('>= 8.1.0')] + public function testUnknownDefaultValue(): void + { + $this->analyse([__DIR__ . '/../Functions/data/unknown-default-value.php'], [ + [ + 'Argument #2 ($interval) must be passed explicitly, because the default value is not known.', + 19, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Classes/data/instantiation-partial-function-application.php b/tests/PHPStan/Rules/Classes/data/instantiation-partial-function-application.php new file mode 100644 index 00000000000..91b4cb625c7 --- /dev/null +++ b/tests/PHPStan/Rules/Classes/data/instantiation-partial-function-application.php @@ -0,0 +1,18 @@ += 8.6 + +namespace InstantiationPartialFunctionApplication; + +class Foo +{ + + public function __construct(int $a, string $b) + { + } + + public function doFoo(): void + { + $f = new self(?, ?); + $g = new self(1, ...); + } + +} diff --git a/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php b/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php index c507dd69742..d43a9500e84 100644 --- a/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php +++ b/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php @@ -413,6 +413,10 @@ public function testPartialFunctionApplication(): void 'Dead catch - DeadCatchPartialFunctionApplication\FooException is never thrown in the try block.', 61, ], + [ + 'Dead catch - JsonException is never thrown in the try block.', + 76, + ], ]); } @@ -423,6 +427,10 @@ public function testFirstClassCallables(): void 'Dead catch - InvalidArgumentException is never thrown in the try block.', 29, ], + [ + 'Dead catch - JsonException is never thrown in the try block.', + 45, + ], ]); } diff --git a/tests/PHPStan/Rules/Exceptions/data/dead-catch-first-class-callables.php b/tests/PHPStan/Rules/Exceptions/data/dead-catch-first-class-callables.php index a212159e99a..1a5da34cea6 100644 --- a/tests/PHPStan/Rules/Exceptions/data/dead-catch-first-class-callables.php +++ b/tests/PHPStan/Rules/Exceptions/data/dead-catch-first-class-callables.php @@ -31,4 +31,20 @@ public function doBaz(): void } } + public function doJson(string $s): void + { + $decode = json_decode(...); + try { + $decode($s, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + + } + + try { + $decode($s); + } catch (\JsonException $e) { + + } + } + } diff --git a/tests/PHPStan/Rules/Exceptions/data/dead-catch-partial-function-application.php b/tests/PHPStan/Rules/Exceptions/data/dead-catch-partial-function-application.php index a44ca47a4ae..bb38a7041a2 100644 --- a/tests/PHPStan/Rules/Exceptions/data/dead-catch-partial-function-application.php +++ b/tests/PHPStan/Rules/Exceptions/data/dead-catch-partial-function-application.php @@ -61,3 +61,18 @@ function (Foo $foo, callable $cb): void { } catch (FooException $e) { } }; + +function (string $s): void { + // calling the closure throws what the call of its callee throws + $decodeThrowing = json_decode(?, flags: JSON_THROW_ON_ERROR); + try { + $decodeThrowing($s); + } catch (\JsonException $e) { + } + + $decode = json_decode(?, true); + try { + $decode($s); + } catch (\JsonException $e) { + } +}; diff --git a/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php b/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php index ce9a3cc7ab5..8ee0a598f32 100644 --- a/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php @@ -49,6 +49,7 @@ protected function getRule(): Rule checkMissingTypehints: true, ), $ruleLevelHelper, + $reflectionProvider, reportMaybes: true, ); } @@ -200,6 +201,25 @@ public function testNamedArguments(): void ]); } + #[RequiresPhp('>= 8.1.0')] + public function testNamedArgumentsOfMultiVariantFirstClassCallable(): void + { + $this->analyse([__DIR__ . '/data/callables-named-arguments-multi-variant.php'], [ + [ + 'Callable (Closure(): int)|(Closure(int, int): int) invoked with 1 parameter, 2 required.', + 7, + ], + [ + 'Argument #2 ($close) must be passed explicitly, because the default value is not known.', + 11, + ], + [ + 'Callable (Closure(array<(int&TK)|(string&TK), TV>, array<(int&TK)|(string&TK), TV>, array, array|callable(mixed, mixed): int, array|callable(mixed, mixed): int ...): array<(int&TK)|(string&TK), TV>)|(Closure(array<(int&TK)|(string&TK), TV>, array<(int&TK)|(string&TK), TV>, callable(TV, TV): int): array<(int&TK)|(string&TK), TV>) invoked with 1 parameter, at least 3 required.', + 14, + ], + ]); + } + public static function dataBug3566(): array { return [ @@ -284,6 +304,26 @@ public function testFirstClassCallables(): void 'Unknown parameter $str in call to callable (Closure(string): (non-empty-string|false))|(Closure(string, string): (non-empty-string|false)).', 54, ], + [ + 'Missing parameter $b (string) in call to closure.', + 69, + ], + [ + 'Argument for parameter $a has already been passed.', + 70, + ], + [ + 'Parameter $a of closure expects int, string given.', + 72, + ], + [ + 'Parameter $b of closure expects string, int given.', + 72, + ], + [ + 'Parameter #1 $array of closure is passed by reference, so it expects variables only.', + 76, + ], ]); } @@ -493,6 +533,69 @@ public function testBug15442(): void $this->analyse([__DIR__ . '/data/bug-15442.php'], []); } + #[RequiresPhp('>= 8.1.0')] + public function testPartialFunctionApplicationClosureCalls(): void + { + $this->analyse([__DIR__ . '/data/partial-function-application-closure-calls.php'], [ + [ + 'Missing parameter $d0 (bool) in call to closure.', + 24, + ], + [ + 'Missing parameter $d1 (bool) in call to closure.', + 24, + ], + [ + 'Unknown parameter $d in call to closure.', + 24, + ], + [ + 'Parameter $rest0 of closure expects int, string given.', + 29, + ], + [ + 'Closure invoked with 1 parameter, 2 required.', + 33, + ], + [ + 'Parameter #2 $a of closure expects int, float given.', + 39, + ], + [ + 'Argument for parameter $a has already been bound by the partial function application.', + 46, + ], + [ + 'Argument for parameter $c has already been bound by the partial function application.', + 48, + ], + [ + 'Argument for parameter $x has already been bound by the partial function application.', + 52, + ], + [ + 'Unknown parameter $a in call to closure.', + 56, + ], + [ + 'Argument for parameter $a has already been bound by the partial function application.', + 60, + ], + [ + 'Missing parameter $arguments0 (string) in call to closure.', + 93, + ], + [ + 'Unknown parameter $x in call to closure.', + 93, + ], + [ + 'Parameter #1 $a of closure is passed by reference, so it expects variables only.', + 105, + ], + ]); + } + #[RequiresPhp('>= 8.1.0')] public function testBug15235(): void { @@ -515,4 +618,19 @@ public function testBug11935WithCheckExplicitMixed(): void ]); } + #[RequiresPhp('>= 8.1.0')] + public function testUnknownDefaultValue(): void + { + $this->analyse([__DIR__ . '/data/unknown-default-value.php'], [ + [ + 'Argument #2 ($filter_value) must be passed explicitly, because the default value is not known.', + 27, + ], + [ + 'Argument #1 ($min) must be passed explicitly, because the default value is not known.', + 28, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 9940ef555b5..43e424ce46b 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -1868,6 +1868,25 @@ public function testNamedParametersForMultiVariantFunctions(): void $this->analyse([__DIR__ . '/data/call-to-function-named-params-multivariant.php'], []); } + #[RequiresPhp('>= 8.0.0')] + public function testNamedArgumentsCountOfMultiVariantFunctions(): void + { + $this->analyse([__DIR__ . '/data/call-to-function-named-params-multivariant-errors.php'], [ + [ + 'Function mt_rand invoked with 1 parameter, 2 required.', + 5, + ], + [ + 'Argument #1 ($min) must be passed explicitly, because the default value is not known.', + 6, + ], + [ + 'Function array_udiff invoked with 1 parameter, at least 3 required.', + 8, + ], + ]); + } + public function testBug9793(): void { $errors = []; @@ -3539,4 +3558,99 @@ public function testBug15700(): void ]); } + #[RequiresPhp('>= 8.1.0')] + public function testFirstClassCallableCallbacks(): void + { + $this->analyse([__DIR__ . '/data/first-class-callable-callbacks.php'], [ + [ + 'Parameter #2 $callback of function usort expects callable(string, string): int, Closure(int, int): int given.', + 71, + ], + [ + 'Parameter #2 $callback of function uasort expects callable(string, string): int, Closure(int, int): int given.', + 72, + ], + [ + 'Parameter #2 $callback of function usort expects callable(int, int): int, Closure(string, string): int given.', + 73, + ], + [ + 'Parameter #2 $callback of function array_reduce expects callable(int, string): int, Closure(int, int): int given.', + 74, + ], + [ + 'Parameter #2 $callback of function array_reduce expects callable(string, int): string, Closure(string, string): string given.', + 75, + ], + [ + 'Parameter #2 $callback of function array_walk expects callable(string, int<0, max>): mixed, Closure(int, int): void given.', + 76, + ], + [ + 'Parameter #2 $callback of function array_walk expects callable(int, int<0, max>): mixed, Closure(string, string): void given.', + 77, + ], + [ + 'Parameter #1 $callback of function array_map expects (callable(int): mixed)|null, (Closure(string): (non-empty-string|false))|(Closure(string, string): (non-empty-string|false)) given.', + 78, + 'Type #1 from the union: Parameter #2 $token of passed callable is required but accepting callable does not have that parameter. It will be called without it.', + ], + [ + 'Parameter #1 $callback of function array_map expects (callable(int): mixed)|null, (Closure(string): lowercase-string)|(Closure(string): uppercase-string) given.', + 87, + ], + ]); + } + + #[RequiresPhp('>= 8.6.0-dev')] + public function testPartialFunctionApplicationCallbacks(): void + { + $this->analyse([__DIR__ . '/data/partial-function-application-callbacks.php'], [ + [ + 'Parameter #1 $callback of function array_map expects (callable(string): mixed)|null, Closure(int): string given.', + 73, + ], + [ + 'Parameter #1 $callback of function array_map expects (callable(int): mixed)|null, Closure(int, string): string given.', + 74, + 'Type #1 from the union: Parameter #2 $prefix of passed callable is required but accepting callable does not have that parameter. It will be called without it.', + ], + [ + 'Parameter #2 $callback of function array_filter expects (callable(int): bool)|null, Closure(string): bool given.', + 75, + ], + [ + 'Parameter #2 $callback of function usort expects callable(string, string): int, Closure(int, int): int given.', + 76, + ], + [ + 'Parameter #2 $callback of function usort expects callable(int, int): int, Closure(int, bool): int given.', + 77, + ], + [ + 'Parameter #2 $fn of function PartialFunctionApplicationCallbacks\\mapList expects callable(string): string, Closure(int): string given.', + 78, + ], + ]); + } + + #[RequiresPhp('>= 8.1.0')] + public function testUnknownDefaultValue(): void + { + $this->analyse([__DIR__ . '/data/unknown-default-value.php'], [ + [ + 'Argument #2 ($filter_value) must be passed explicitly, because the default value is not known.', + 7, + ], + [ + 'Argument #1 ($min) must be passed explicitly, because the default value is not known.', + 8, + ], + [ + 'Argument #2 ($close) must be passed explicitly, because the default value is not known.', + 9, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Functions/FunctionCallableRuleTest.php b/tests/PHPStan/Rules/Functions/FunctionCallableRuleTest.php index 81595b5816d..c285bf1a35e 100644 --- a/tests/PHPStan/Rules/Functions/FunctionCallableRuleTest.php +++ b/tests/PHPStan/Rules/Functions/FunctionCallableRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Functions; +use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -30,6 +31,7 @@ protected function getRule(): Rule checkBenevolentUnionTypes: false, discoveringSymbolsTip: true, ), + self::getContainer()->getByType(FunctionCallParametersCheck::class), true, true, ); @@ -83,27 +85,27 @@ public function testDynamicCallForbidden(): void { $errors = [ [ - 'Cannot create callable from compact(), it cannot be called dynamically.', + 'Calling the callable created from compact() throws, it cannot be called dynamically.', 7, ], [ - 'Cannot create callable from extract(), it cannot be called dynamically.', + 'Calling the callable created from extract() throws, it cannot be called dynamically.', 8, ], [ - 'Cannot create callable from func_get_arg(), it cannot be called dynamically.', + 'Calling the callable created from func_get_arg() throws, it cannot be called dynamically.', 9, ], [ - 'Cannot create callable from func_get_args(), it cannot be called dynamically.', + 'Calling the callable created from func_get_args() throws, it cannot be called dynamically.', 10, ], [ - 'Cannot create callable from func_num_args(), it cannot be called dynamically.', + 'Calling the callable created from func_num_args() throws, it cannot be called dynamically.', 11, ], [ - 'Cannot create callable from get_defined_vars(), it cannot be called dynamically.', + 'Calling the callable created from get_defined_vars() throws, it cannot be called dynamically.', 12, ], [ @@ -111,7 +113,7 @@ public function testDynamicCallForbidden(): void 13, ], [ - 'Cannot create callable from compact(), it cannot be called dynamically.', + 'Calling the callable created from compact() throws, it cannot be called dynamically.', 13, ], ]; @@ -158,6 +160,137 @@ public function testPartialFunctionApplication(): void $this->analyse([__DIR__ . '/data/function-partial-function-application.php'], $errors); } + #[RequiresPhp('>= 8.6.0-dev')] + public function testPartialFunctionApplicationArguments(): void + { + $this->analyse([__DIR__ . '/data/partial-function-application-arguments.php'], [ + [ + 'Function PartialFunctionApplicationArguments\\doFoo partially applied with 2 arguments, at least 3 required.', + 35, + ], + [ + 'Function PartialFunctionApplicationArguments\\none partially applied with 1 argument, 0 required.', + 36, + ], + [ + 'Function PartialFunctionApplicationArguments\\none partially applied with 1 argument, 0 required.', + 37, + ], + [ + 'Function PartialFunctionApplicationArguments\\opt partially applied with 4 arguments, 1-3 required.', + 38, + ], + [ + 'Cannot use named placeholder for unknown or variadic parameter $x.', + 39, + ], + [ + 'Cannot use named placeholder for unknown or variadic parameter $d.', + 40, + ], + [ + 'Argument for parameter $a has already been passed.', + 41, + ], + [ + 'Argument for parameter $a has already been passed.', + 42, + ], + [ + 'Parameter #1 $a of function PartialFunctionApplicationArguments\\opt expects int, string given.', + 43, + ], + [ + 'Parameter #1 $a of function PartialFunctionApplicationArguments\\byRef is passed by reference, so it expects variables only.', + 44, + ], + [ + 'Cannot combine partial application and unpacking.', + 45, + ], + [ + 'Function strtok partially applied with 3 arguments, 1-2 required.', + 46, + ], + [ + 'Missing parameter $b (string) in partial application of function PartialFunctionApplicationArguments\\doFoo.', + 47, + ], + [ + 'Missing parameter $c (float) in partial application of function PartialFunctionApplicationArguments\\doFoo.', + 47, + ], + [ + 'Named argument cannot be followed by a positional argument.', + 47, + ], + [ + 'Variadic placeholder must be last.', + 48, + ], + [ + 'Parameter #1 $a of closure expects int, string given.', + 55, + ], + [ + 'Closure partially applied with 3 arguments, 2 required.', + 56, + ], + [ + 'Parameter #1 $a of function PartialFunctionApplicationArguments\\intOnly expects int, string given.', + 75, + ], + [ + 'Variadic placeholder must be last.', + 82, + ], + [ + 'Cannot combine partial application and unpacking.', + 83, + ], + [ + 'Variadic placeholder must be last.', + 84, + ], + [ + 'Variadic placeholder may only appear once.', + 89, + ], + [ + 'Variadic placeholder may only appear once.', + 90, + ], + [ + 'Variadic placeholder must be last.', + 91, + ], + [ + 'Function mt_rand partially applied with 1 argument, 2 required.', + 97, + ], + [ + 'Function mt_rand partially applied with 3 arguments, 0-2 required.', + 98, + ], + [ + 'Argument #2 ($filter_value) must be passed explicitly, because the default value is not known.', + 106, + ], + [ + 'Argument #2 ($filter_value) must be passed explicitly, because the default value is not known.', + 107, + ], + [ + 'Argument #2 ($max) must be passed explicitly, because the default value is not known.', + 108, + ], + [ + 'Argument #3 ($arg) must be passed explicitly, because the default value is not known.', + 109, + ], + ]); + } + public function testConditionallyExecutedCode(): void { $errors = [ diff --git a/tests/PHPStan/Rules/Functions/data/call-first-class-callables.php b/tests/PHPStan/Rules/Functions/data/call-first-class-callables.php index 981ca9cccc7..7959ebbbdc5 100644 --- a/tests/PHPStan/Rules/Functions/data/call-first-class-callables.php +++ b/tests/PHPStan/Rules/Functions/data/call-first-class-callables.php @@ -53,3 +53,25 @@ function doBaz($context, \Closure $union): void $strtok(string: 'a b', token: ' '); $strtok(str: 'a b'); } + +function namedArgs(int $a, string $b, bool ...$c): void +{ +} + +/** + * @param list $ints + */ +function storedClosures(array $ints): void +{ + $f = namedArgs(...); + $f(b: 'x', a: 1); + $f(1, 'x', true, false); + $f(a: 1); + $f(1, a: 2, b: 'x'); + $f(1, 'x', d: true); + $f(b: 1, a: 'x'); + + $sort = sort(...); + $sort($ints); + $sort([3, 1, 2]); +} diff --git a/tests/PHPStan/Rules/Functions/data/call-to-function-named-params-multivariant-errors.php b/tests/PHPStan/Rules/Functions/data/call-to-function-named-params-multivariant-errors.php new file mode 100644 index 00000000000..130139c5abf --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/call-to-function-named-params-multivariant-errors.php @@ -0,0 +1,8 @@ += 8.0 + +namespace CallToFunctionNamedParamsMultiVariantErrors; + +mt_rand(min: 1); +mt_rand(max: 1); +mt_rand(min: 1, max: 2); +array_udiff(array: [1]); diff --git a/tests/PHPStan/Rules/Functions/data/callables-named-arguments-multi-variant.php b/tests/PHPStan/Rules/Functions/data/callables-named-arguments-multi-variant.php new file mode 100644 index 00000000000..465a37e2d77 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/callables-named-arguments-multi-variant.php @@ -0,0 +1,15 @@ += 8.1 + +namespace CallablesNamedArgumentsMultiVariant; + +function (callable $open, callable $read): void { + $f = mt_rand(...); + $f(min: 1); + $f(min: 1, max: 2); + + $g = session_set_save_handler(...); + $g($open, read: $read); + + $h = array_udiff(...); + $h(array: [1]); +}; diff --git a/tests/PHPStan/Rules/Functions/data/first-class-callable-callbacks.php b/tests/PHPStan/Rules/Functions/data/first-class-callable-callbacks.php new file mode 100644 index 00000000000..a1b46d22e74 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/first-class-callable-callbacks.php @@ -0,0 +1,88 @@ += 8.1 + +declare(strict_types = 1); + +namespace FirstClassCallableCallbacks; + +function compareInts(int $a, int $b): int +{ + return $a <=> $b; +} + +function sum(int $carry, int $item): int +{ + return $carry + $item; +} + +function increment(int &$value, int $key): void +{ + $value++; +} + +function describe(string $value, string $key): void +{ +} + +class Callbacks +{ + + public function compare(string $a, string $b): int + { + return strcmp($a, $b); + } + + public static function concat(string $carry, string $item): string + { + return $carry . $item; + } + +} + +/** + * @param list $ints + * @param list $strings + * @param array $map + */ +function compatible(array $ints, array $strings, array $map, Callbacks $callbacks): void +{ + usort($ints, compareInts(...)); + usort($strings, strcmp(...)); + uasort($map, $callbacks->compare(...)); + array_reduce($ints, sum(...), 0); + array_reduce($strings, Callbacks::concat(...), ''); + array_walk($ints, increment(...)); + array_walk($map, describe(...)); + call_user_func_array(compareInts(...), [1, 2]); + call_user_func_array(str_replace(...), [' ', '-', 'a b']); + + // the closure of a multi-variant function fits when any of its variants does + array_reduce($ints, max(...), 0); + array_map(max(...), $ints, $ints); + array_map(mt_rand(...), $ints, $ints); +} + +/** + * @param list $ints + * @param list $strings + * @param array $map + */ +function incompatible(array $ints, array $strings, array $map, Callbacks $callbacks): void +{ + usort($strings, compareInts(...)); + uasort($map, compareInts(...)); + usort($ints, $callbacks->compare(...)); + array_reduce($strings, sum(...), 0); + array_reduce($ints, Callbacks::concat(...), ''); + array_walk($strings, increment(...)); + array_walk($ints, describe(...)); + array_map(strtok(...), $ints); +} + +/** + * @param list $ints + */ +function differentCallees(array $ints, bool $flag): void +{ + // closures of different functions are alternatives, each of them has to fit + array_map($flag ? strtoupper(...) : strtolower(...), $ints); +} diff --git a/tests/PHPStan/Rules/Functions/data/partial-function-application-arguments.php b/tests/PHPStan/Rules/Functions/data/partial-function-application-arguments.php new file mode 100644 index 00000000000..d951bb9cfdf --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/partial-function-application-arguments.php @@ -0,0 +1,116 @@ += 8.6 + +declare(strict_types = 1); + +namespace PartialFunctionApplicationArguments; + +function doFoo(int $a, string $b, float $c, bool ...$d): string +{ + return ''; +} + +function opt(int $a, string $b = 'B', float $c = 1.0): int +{ + return 1; +} + +function none(): void +{ +} + +function byRef(int &$a, string $b): void +{ +} + +function test(int $i, array $arr): void +{ + doFoo(1, ?, 3.0); + doFoo(1, ?, ...); + doFoo(1, 'b', 3.0, x: true, ...); + none(...); + byRef($i, ?); + strtok(?); + opt(?, c: 2.0); + + doFoo(1, ?); + none(?); + none(1, ...); + opt(1, 'b', 2.0, ?); + opt(x: ?, a: 1); + doFoo(1, 'b', 3.0, d: ?); + opt(?, a: 1); + opt(a: ?, a: ?); + opt('x', ?); + byRef(1, ?); + opt(...$arr, ?); + strtok('a', 'b', ?); + doFoo(a: 1, ?); + doFoo(..., ?); +} + +function closures(): void +{ + $c = fn (int $a, string $b): int => 1; + $c(1, ?); + $c('x', ?); + $c(1, 'b', ?); +} + +/** + * @template T of int + * @param T $a + * @return T + */ +function intOnly($a) +{ + return $a; +} + +function templates(): void +{ + // templates are resolved from the bound arguments + usort(?, fn (int $a, int $b): int => $a <=> $b); + array_map(fn (string $s): int => 1, ?); + intOnly(1, ...); + intOnly('x', ...); +} + +/** @param array $ints */ +function placementsWithUnknownCallees(mixed $cb, array $ints): void +{ + // compile errors whatever the callee is + undefinedFunction(..., ?); + undefinedFunction(?, ...$ints); + $cb(..., ?); +} + +function variadicPlaceholderPlacements(): void +{ + doFoo(?, ..., ...); + doFoo(1, ..., ..., ?); + doFoo(1, ..., c: 5.0); +} + +function multiVariant(): void +{ + // no variant of mt_rand() takes 1 or 3 arguments + mt_rand(?); + mt_rand(?, ?, ?, ...); + mt_rand(1, ?); + mt_rand(...); +} + +function unknownDefaults(): void +{ + // PHP does not know the default of $filter_value, mt_rand()'s $max or array_walk()'s $arg + array_keys(?, ...); + array_keys(?, strict: ?); + mt_rand(1, ...); + array_walk(?, ?, ...); + + array_keys(?); + array_keys(?, ?, ...); + array_keys(?, ?, strict: ?); + mt_rand(?, ?); + array_walk(?, ?); +} diff --git a/tests/PHPStan/Rules/Functions/data/partial-function-application-callbacks.php b/tests/PHPStan/Rules/Functions/data/partial-function-application-callbacks.php new file mode 100644 index 00000000000..8cfd6b591f1 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/partial-function-application-callbacks.php @@ -0,0 +1,79 @@ += 8.6 + +declare(strict_types = 1); + +namespace PartialFunctionApplicationCallbacks; + +function intToString(int $i, string $prefix): string +{ + return $prefix . $i; +} + +function compareInts(int $a, int $b, bool $reverse): int +{ + return $reverse ? $b <=> $a : $a <=> $b; +} + +/** + * @template T + * @template U + * @param list $items + * @param callable(T): U $fn + * @return list + */ +function mapList(array $items, callable $fn): array +{ + return []; +} + +/** + * @template T + * @param T $value + * @return list + */ +function repeat($value, int $times): array +{ + return []; +} + +/** + * @template T + * @param T $value + * @param T $other + * @return list + */ +function pair($value, $other): array +{ + return [$value, $other]; +} + +/** + * @param list $ints + * @param list $strings + */ +function compatible(array $ints, array $strings): void +{ + array_map(intToString(?, 'n'), $ints); + array_map(intToString(prefix: 'n', i: ?), $ints); + array_filter($strings, str_contains(?, 'x')); + usort($ints, compareInts(?, ?, true)); + mapList($ints, intToString(?, 'n')); + mapList($ints, repeat(?, 2)); + mapList($strings, pair(?, 'x')); + mapList($ints, pair(?, 'x')); + array_map(repeat(...), $ints, $ints); +} + +/** + * @param list $ints + * @param list $strings + */ +function incompatible(array $ints, array $strings): void +{ + array_map(intToString(?, 'n'), $strings); + array_map(intToString(?, ?), $ints); + array_filter($ints, str_contains(?, 'x')); + usort($strings, compareInts(?, ?, true)); + usort($ints, compareInts(?, true, ...)); + mapList($strings, intToString(?, 'n')); +} diff --git a/tests/PHPStan/Rules/Functions/data/partial-function-application-closure-calls.php b/tests/PHPStan/Rules/Functions/data/partial-function-application-closure-calls.php new file mode 100644 index 00000000000..3450f12c49b --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/partial-function-application-closure-calls.php @@ -0,0 +1,108 @@ += 8.6 + +declare(strict_types = 1); + +namespace PartialFunctionApplicationClosureCalls; + +function doFoo(int $a, string $b, float $c, bool ...$d): string +{ + return ''; +} + +/** + * @param int ...$rest + */ +function opt(int $a, string $b = 'B', int ...$rest): void +{ +} + +function test(): void +{ + // a ? landing in the variadic is named after it: $d0, $d1, ... + $f = doFoo(1, 'b', 3.0, ?, ?); + $f(d0: true, d1: false); + $f(d: true); + + $g = opt(1, 'b', ?, ...); + $g(rest0: 1); + $g(1, 2, 3); + $g(rest0: 'x'); + + // a ? is required even for an optional parameter, and keeps its name + $h = opt(?, ?); + $h(1); + $h(a: 1, b: 'x'); + + // named placeholders come first after the positional ones + $i = doFoo(c: ?, a: ?, b: ?); + $i(1.0, 1, 'b'); + $i(1, 1.0, 'b'); +} + +function bound(bool $flag): void +{ + // a variadic closure cannot take a bound parameter by name + $j = doFoo(1, ?, ...); + $j('b', 1.0, a: true); + $j('b', 1.0, x: true); + doFoo(1, ?, 3.0, ...)('b', c: true); + + // a bound argument the variadic collects by name counts too + $k = doFoo(1, 'b', 3.0, x: true, ...); + $k(x: false); + $k(y: false); + + // a closure that is not variadic reports the name as unknown + opt(1, ?)('b', a: 1); + + // a union reports it when every member bound the parameter + $l = $flag ? doFoo(1, 'b', ?, ...) : doFoo(2, 'c', ?, ...); + $l(1.0, a: true); + $m = $flag ? doFoo(1, 'b', ?, ...) : static fn (float $c, bool ...$d): string => ''; + $m(1.0, a: true); +} + +function forwardsToFuncGetArgs($a): array +{ + return func_get_args(); +} + +function forwardedArguments(): void +{ + // the variadic placeholder forwards the extra arguments to func_get_args() + forwardsToFuncGetArgs(?, ...)(1, 2, 3); +} + +/** + * @method int magic(string $x, int $y) + */ +class Magic +{ + + /** @param array $arguments */ + public function __call(string $name, array $arguments): int + { + return 1; + } + +} + +function magicMethods(Magic $magic): void +{ + // a method called through __call() takes its placeholders as $arguments0, $arguments1... + $magic->magic(?, 1)(x: 'a'); + $magic->magic(?, ?)(arguments0: 'a', arguments1: 1); +} + +function byRef(int &$a, string $b): void +{ +} + +function byRefPlaceholder(): void +{ + // the closure keeps the by-ref parameter its placeholder stands for + $f = byRef(?, ?); + $f(1, 'b'); + $i = 1; + $f($i, 'b'); +} diff --git a/tests/PHPStan/Rules/Functions/data/unknown-default-value.php b/tests/PHPStan/Rules/Functions/data/unknown-default-value.php new file mode 100644 index 00000000000..ab0a8d82534 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/unknown-default-value.php @@ -0,0 +1,31 @@ += 8.1 + +namespace UnknownDefaultValue; + +function functions(array $a, callable $open, callable $read): void +{ + array_keys($a, strict: true); + mt_rand(max: 5); + session_set_save_handler($open, read: $read); + + array_keys($a, 1, strict: true); + mt_rand(min: 1, max: 5); + array_keys(array: $a); +} + +function methods(\IntlCalendar $calendar, \DateTimeImmutable $start, \DateTimeImmutable $end): void +{ + $calendar->set(2020, 1, hour: 5); + new \DatePeriod($start, end: $end); + + $calendar->set(2020, 1, 1, hour: 5); +} + +function closures(array $a): void +{ + $keys = array_keys(...); + $keys($a, strict: true); + (mt_rand(...))(max: 5); + + $keys($a, 1, strict: true); +} diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index 62658809769..fac7245ac79 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -231,6 +231,10 @@ public function testCallMethods(): void 'Method PDO::query() invoked with 0 parameters, 1-4 required.', 113, ], + [ + 'Method Closure::__invoke() invoked with 3 parameters, 0 required.', + 139, + ], [ 'Parameter #1 $bar of method Test\ClassWithNullableProperty::doBar() is passed by reference, so it expects variables only.', 167, @@ -3334,7 +3338,7 @@ public function testNamedParametersForMultiVariantFunctions(): void 10, ], [ - 'Missing parameter $name (array) in call to method XSLTProcessor::setParameter().', + 'Missing parameter $name (array|string) in call to method XSLTProcessor::setParameter().', 10, ], [ @@ -4659,4 +4663,18 @@ public function testDeadCatch(): void ]); } + #[RequiresPhp('>= 8.1.0')] + public function testUnknownDefaultValue(): void + { + $this->checkThisOnly = false; + $this->checkNullables = true; + $this->checkUnionTypes = true; + $this->analyse([__DIR__ . '/../Functions/data/unknown-default-value.php'], [ + [ + 'Argument #3 ($dayOfMonth) must be passed explicitly, because the default value is not known.', + 18, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Methods/MethodCallableRuleTest.php b/tests/PHPStan/Rules/Methods/MethodCallableRuleTest.php index 74e4a4164c7..1d3d02ab358 100644 --- a/tests/PHPStan/Rules/Methods/MethodCallableRuleTest.php +++ b/tests/PHPStan/Rules/Methods/MethodCallableRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Methods; +use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -35,6 +36,7 @@ protected function getRule(): Rule checkFunctionNameCase: true, reportMagicMethods: true, ), + self::getContainer()->getByType(FunctionCallParametersCheck::class), ); } @@ -114,6 +116,53 @@ public function testNullsafe(): void ]); } + #[RequiresPhp('>= 8.6.0-dev')] + public function testPartialFunctionApplicationArguments(): void + { + $this->analyse([__DIR__ . '/data/partial-function-application-method-arguments.php'], [ + [ + 'Method PartialFunctionApplicationMethodArguments\\Foo::doFoo() partially applied with 1 argument, at least 2 required.', + 28, + ], + [ + 'Parameter #1 $a of method PartialFunctionApplicationMethodArguments\\Foo::doFoo() expects int, string given.', + 29, + ], + [ + 'Cannot use named placeholder for unknown or variadic parameter $c.', + 30, + ], + [ + 'Variadic placeholder must be last.', + 42, + ], + [ + 'Cannot combine partial application and unpacking.', + 43, + ], + [ + 'Cannot use named placeholder for unknown or variadic parameter $x.', + 72, + ], + [ + 'Variadic placeholder may only appear once.', + 78, + ], + [ + 'Cannot combine nullsafe operator with Closure creation.', + 80, + ], + [ + 'Argument #2 ($value) must be passed explicitly, because the default value is not known.', + 86, + ], + [ + 'Argument #2 ($default) must be passed explicitly, because the default value is not known.', + 87, + ], + ]); + } + public function testConditionallyExecutedCode(): void { $errors = [ diff --git a/tests/PHPStan/Rules/Methods/StaticMethodCallableRuleTest.php b/tests/PHPStan/Rules/Methods/StaticMethodCallableRuleTest.php index dfb921a2be7..6b5a025ee9f 100644 --- a/tests/PHPStan/Rules/Methods/StaticMethodCallableRuleTest.php +++ b/tests/PHPStan/Rules/Methods/StaticMethodCallableRuleTest.php @@ -6,6 +6,7 @@ use PHPStan\Rules\ClassCaseSensitivityCheck; use PHPStan\Rules\ClassForbiddenNameCheck; use PHPStan\Rules\ClassNameCheck; +use PHPStan\Rules\FunctionCallParametersCheck; use PHPStan\Rules\RestrictedUsage\RestrictedClassNameUsageExtension; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; @@ -52,6 +53,7 @@ protected function getRule(): Rule discoveringSymbolsTip: true, reportMagicMethods: true, ), + self::getContainer()->getByType(FunctionCallParametersCheck::class), ); } @@ -104,6 +106,10 @@ public function testRule(): void 'Cannot call static method doFoo() on int.', 22, ], + [ + 'Cannot call abstract method StaticMethodCallable\\AbstractParent::doFoo().', + 88, + ], ]); } @@ -133,6 +139,41 @@ public function testPartialFunctionApplication(): void $this->analyse([__DIR__ . '/data/method-partial-function-application.php'], $errors); } + #[RequiresPhp('>= 8.6.0-dev')] + public function testPartialFunctionApplicationArguments(): void + { + $this->analyse([__DIR__ . '/data/partial-function-application-method-arguments.php'], [ + [ + 'Static method PartialFunctionApplicationMethodArguments\\Foo::doStatic() partially applied with 3 arguments, 1-2 required.', + 31, + ], + [ + 'Missing parameter $a (int) in partial application of static method PartialFunctionApplicationMethodArguments\\Foo::doStatic().', + 32, + ], + [ + 'Argument for parameter $a has already been passed.', + 33, + ], + [ + 'Variadic placeholder must be last.', + 44, + ], + [ + 'Cannot combine partial application and unpacking.', + 45, + ], + [ + 'Cannot use named placeholder for unknown or variadic parameter $y.', + 73, + ], + [ + 'Variadic placeholder may only appear once.', + 79, + ], + ]); + } + public function testConditionallyExecutedCode(): void { $errors = [ diff --git a/tests/PHPStan/Rules/Methods/data/partial-function-application-method-arguments.php b/tests/PHPStan/Rules/Methods/data/partial-function-application-method-arguments.php new file mode 100644 index 00000000000..016525bb8f0 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/partial-function-application-method-arguments.php @@ -0,0 +1,90 @@ += 8.6 + +declare(strict_types = 1); + +namespace PartialFunctionApplicationMethodArguments; + +class Foo +{ + + public function doFoo(int $a, string $b, float ...$c): bool + { + return true; + } + + public static function doStatic(int $a, string $b = 'x'): int + { + return 1; + } + + public function test(): void + { + $this->doFoo(1, ?); + $this->doFoo(1, ?, ?, ?); + $this->doFoo(?, ...); + self::doStatic(?); + self::doStatic(1, ?, ...); + + $this->doFoo(?); + $this->doFoo('x', ?); + $this->doFoo(1, 'b', c: ?); + self::doStatic(1, 'b', ?); + self::doStatic(b: ?); + static::doStatic(?, a: 1); + } + +} + +/** @param array $ints */ +function placementsWithUnknownCallees(Foo $foo, array $ints): void +{ + // compile errors whatever the callee is + $foo->undefinedMethod(..., ?); + $foo->undefinedMethod(?, ...$ints); + Foo::undefinedStatic(..., ?); + Foo::undefinedStatic(?, ...$ints); +} + +/** + * @method int magic(string $x, int $y) + * @method static int staticMagic(string $x, int $y) + */ +class Magic +{ + + /** @param array $arguments */ + public function __call(string $name, array $arguments): int + { + return 1; + } + + /** @param array $arguments */ + public static function __callStatic(string $name, array $arguments): int + { + return 1; + } + +} + +function magicMethods(Magic $magic): void +{ + // the __call() trampoline only has a variadic parameter + $magic->magic(x: ?); + Magic::staticMagic(?, y: ?); +} + +function variadicPlaceholderPlacements(Foo $foo, ?Foo $nullableFoo): void +{ + $foo->doFoo(?, ..., ...); + Foo::doStatic(?, ..., ...); + $nullableFoo?->doFoo(1, ?); +} + +function unknownDefaults(\ReflectionProperty $rp, \ReflectionClass $rc): void +{ + // PHP does not know the default of $value or $default + $rp->setValue(?, ...); + $rc->getStaticPropertyValue(?, ...); + $rp->setValue(?, ?); + $rp->setValue(?); +} diff --git a/tests/PHPStan/Rules/Methods/data/static-method-callable.php b/tests/PHPStan/Rules/Methods/data/static-method-callable.php index d8256c1c4b7..4e3d3ee6b5d 100644 --- a/tests/PHPStan/Rules/Methods/data/static-method-callable.php +++ b/tests/PHPStan/Rules/Methods/data/static-method-callable.php @@ -67,3 +67,28 @@ public function doFoo() } } + +abstract class AbstractParent +{ + + abstract public function doFoo(): int; + + public function doBar(): int + { + return 1; + } + +} + +class AbstractChild extends AbstractParent +{ + + public function doFoo(): int + { + parent::doFoo(...); + parent::doBar(...); + + return 1; + } + +} diff --git a/turbo-ext/src/ArgumentsNormalizer.cpp b/turbo-ext/src/ArgumentsNormalizer.cpp index 8ab0753d140..f13ec4931b2 100644 --- a/turbo-ext/src/ArgumentsNormalizer.cpp +++ b/turbo-ext/src/ArgumentsNormalizer.cpp @@ -730,19 +730,8 @@ class ArgumentsNormalizer bool variadic = false; if (UNEXPECTED(!parameterIsVariadic(parameter, variadic))) return zv::Val(); if (!variadic) { - zv::Val name = parameterGetName(parameter); - if (UNEXPECTED(name.isUndef())) return zv::Val(); - zend_string *nameString = zval_get_string(name.raw()); - zend_string *message = zend_strpprintf(0, "An optional parameter $%s must have a default value", ZSTR_VAL(nameString)); - zend_string_release(nameString); - zval messageZv; - ZVAL_STR(&messageZv, message); - zv::Val exception = pt_type_new(PT_CLASS_SHOULD_NOT_HAPPEN, 1, &messageZv); - zend_string_release(message); - if (UNEXPECTED(exception.isUndef())) return zv::Val(); - zval raw = exception.take(); - zend_throw_exception_object(&raw); - return zv::Val(); + // like an optional parameter combined from variants that do not all have it + return zv::Val::null(); } zval emptyKeys, emptyValues, constantArray; ZVAL_EMPTY_ARRAY(&emptyKeys); diff --git a/turbo-ext/src/ClosureType.cpp b/turbo-ext/src/ClosureType.cpp index b0a2d83154d..deb3769e126 100644 --- a/turbo-ext/src/ClosureType.cpp +++ b/turbo-ext/src/ClosureType.cpp @@ -29,6 +29,7 @@ #include "TypeTraits.h" #include "AnalyserValues.h" #include "generated/ClosureType.h" +#include "Engine.h" namespace slots = ptdecl::ClosureType::slot; namespace sigs = ptdecl::ClosureType::sig; @@ -89,6 +90,7 @@ struct ClosureTypeArguments zval *assertions; zval *isStatic; zval *byRefUseTypes; + zval *origin; }; /* Mirrors PHPStan\Type\ClosureType. State lives in the PHP object's slots. */ @@ -118,6 +120,9 @@ class ClosureType writeSlot(slots::invalidateExpressions, a.invalidateExpressions != NULL ? a.invalidateExpressions : &emptyArray); writeSlot(slots::usedVariables, a.usedVariables != NULL ? a.usedVariables : &emptyArray); writeSlot(slots::byRefUseTypes, a.byRefUseTypes != NULL ? a.byRefUseTypes : &emptyArray); + zval null = {}; + ZVAL_NULL(&null); + writeSlot(slots::origin, a.origin != NULL ? a.origin : &null); writeSlot(slots::acceptsNamedArguments, a.acceptsNamedArguments != NULL ? a.acceptsNamedArguments : pt_trinary_singleton(PT_TRI_YES)); writeSlot(slots::mustUseReturnValue, a.mustUseReturnValue != NULL ? a.mustUseReturnValue : pt_trinary_singleton(PT_TRI_MAYBE)); @@ -206,6 +211,7 @@ class ClosureType zval *invalidateExpressions() const { return slot(self, slots::invalidateExpressions, "invalidateExpressions"); } zval *usedVariables() const { return slot(self, slots::usedVariables, "usedVariables"); } zval *byRefUseTypes() const { return slot(self, slots::byRefUseTypes, "byRefUseTypes"); } + zval *origin() const { return slot(self, slots::origin, "origin"); } static zval *slot(zend_object *object, uint32_t index, const char *name) { return pt_typed_slot(object, index, pt_ce_closure_type, name); } @@ -346,7 +352,19 @@ class ClosureType if (!isCallableAcceptor) return pt_type_is_super_type_of_result(PT_TRI_NO); zval selfZv; ZVAL_OBJ(&selfZv, self); - return pt_callable_type_helper_is_parameters_acceptor_super_type_of(&selfZv, variant.raw(), treatMixedAsAny, strictTypes); + zv::Val result = pt_callable_type_helper_is_parameters_acceptor_super_type_of(&selfZv, variant.raw(), treatMixedAsAny, strictTypes); + if (UNEXPECTED(result.isUndef()) || treatMixedAsAny) return result; + zval *ownOrigin = origin(); + if (UNEXPECTED(ownOrigin == NULL)) return zv::Val(); + if (Z_TYPE_P(ownOrigin) != IS_OBJECT) return result; + bool equalOrigins; + if (UNEXPECTED(!hasEqualOrigins(Z_OBJ_P(type), equalOrigins))) return zv::Val(); + if (equalOrigins) return result; + /* a closure created from another callee, or from an unknown one, + * is not known to be created from this one */ + zv::Val maybe = pt_type_is_super_type_of_result(PT_TRI_MAYBE); + if (UNEXPECTED(maybe.isUndef())) return zv::Val(); + return pt_type_call(Z_OBJ_P(result.raw()), PT_LC("and"), 1, maybe.raw()); } /* $type->getObjectClassNames() === [Closure::class] */ zv::Val classNames = pt_type_op(Z_OBJ_P(type), PT_OP_GET_OBJECT_CLASS_NAMES, 0, NULL); @@ -394,7 +412,26 @@ class ClosureType out = false; return true; } - return hasEqualUnresolvedSignature(Z_OBJ_P(type), out); + if (UNEXPECTED(!hasEqualUnresolvedSignature(Z_OBJ_P(type), out))) return false; + if (!out) return true; + return hasEqualOrigins(Z_OBJ_P(type), out); + } + + /* Mirrors the private static hasEqualOrigins(): both without an origin, + * or with equal ones; false with an exception pending */ + [[nodiscard]] bool hasEqualOrigins(zend_object *other, bool &out) const + { + zval *ownOrigin = origin(); + zval *theirOrigin = ownOrigin != NULL ? slot(other, slots::origin, "origin") : NULL; + if (UNEXPECTED(theirOrigin == NULL)) return false; + if (Z_TYPE_P(ownOrigin) != IS_OBJECT || Z_TYPE_P(theirOrigin) != IS_OBJECT) { + out = Z_TYPE_P(ownOrigin) != IS_OBJECT && Z_TYPE_P(theirOrigin) != IS_OBJECT; + return true; + } + int equal = pt_type_call_is_true(Z_OBJ_P(ownOrigin), PT_LC("equals"), 1, theirOrigin); + if (UNEXPECTED(equal < 0)) return false; + out = equal == 1; + return true; } /* Mirrors the private hasEqualUnresolvedSignature(): the markers of a @@ -504,7 +541,24 @@ class ClosureType if (common == 1) return prefixedName(); return describeCallable(); } - /* the precise and cache levels */ + if (which == PT_VERBOSITY_CACHE) { + /* the precise description and the origin */ + zv::Val precise = pt_type_verbosity_level(PT_VERBOSITY_LEVEL_PRECISE); + if (UNEXPECTED(precise.isUndef())) return zv::Val(); + zv::Val description = thisDescribe(precise.raw()); + if (UNEXPECTED(description.isUndef())) return zv::Val(); + zval *ownOrigin = origin(); + if (UNEXPECTED(ownOrigin == NULL)) return zv::Val(); + if (Z_TYPE_P(ownOrigin) != IS_OBJECT) return description; + zv::Val originDescription = pt_type_call(Z_OBJ_P(ownOrigin), PT_LC("describe"), 0, NULL); + if (UNEXPECTED(originDescription.isUndef())) return zv::Val(); + if (UNEXPECTED(Z_TYPE_P(description.raw()) != IS_STRING || Z_TYPE_P(originDescription.raw()) != IS_STRING)) { + zend_type_error("phpstan_turbo: describe() must return a string"); + return zv::Val(); + } + return zv::Val::adoptString(zend_strpprintf(0, "%s from %s", ZSTR_VAL(Z_STR_P(description.raw())), ZSTR_VAL(Z_STR_P(originDescription.raw())))); + } + /* the precise level */ zval *isStaticSlot = isStatic(); if (UNEXPECTED(isStaticSlot == NULL)) return zv::Val(); zend_long staticValue = pt_type_trinary_value(isStaticSlot); @@ -556,17 +610,18 @@ class ClosureType return pt_type_transformed_member(self, PT_LC("getunresolvedmethodprototype"), true, methodName, scope); } - /* the object type's prototype, wrapped for `call` in a - * ClosureCallUnresolvedMethodPrototypeReflection over $this; UNDEF = - * pending exception */ + /* the object type's prototype, wrapped for `call` and `__invoke` in a + * ClosureCallUnresolvedMethodPrototypeReflection over $this (taking the + * new $this first for `call` only); UNDEF = pending exception */ zv::Val getUnresolvedMethodPrototype(zval *methodName, zval *scope) const { zv::Args args{methodName, scope}; - if (zv::Ref(methodName).stringEquals("call")) { + bool isCall = zv::Ref(methodName).stringEquals("call"); + if (isCall || zv::Ref(methodName).stringEquals("__invoke")) { zv::Val prototype = delegate(PT_LC("getunresolvedmethodprototype"), 2, args); if (UNEXPECTED(prototype.isUndef())) return zv::Val(); - zv::Args wrapArgs{prototype.raw(), self}; - return pt_type_new(PT_CLASS_CLOSURE_CALL_UNRESOLVED_METHOD_PROTOTYPE_REFLECTION, 2, wrapArgs); + zv::Args wrapArgs{prototype.raw(), self, isCall}; + return pt_type_new(PT_CLASS_CLOSURE_CALL_UNRESOLVED_METHOD_PROTOTYPE_REFLECTION, 3, wrapArgs); } return delegate(PT_LC("getunresolvedmethodprototype"), 2, args); } @@ -645,6 +700,13 @@ class ClosureType } zv::Val mappedAssertions = pt_assertions_map_types(args.assertions, &fci->function_name); if (UNEXPECTED(mappedAssertions.isUndef())) return zv::Val(); + /* $this->origin !== null ? $this->origin->traverse($cb) : null */ + zv::Val traversedOrigin; + if (Z_TYPE_P(args.origin) == IS_OBJECT) { + traversedOrigin = pt_type_call(Z_OBJ_P(args.origin), PT_LC("traverse"), 1, &fci->function_name); + if (UNEXPECTED(traversedOrigin.isUndef())) return zv::Val(); + args.origin = traversedOrigin.raw(); + } args.parameters = traversedParameters.raw(); args.returnType = traversedReturnType.raw(); args.variadic = variadic == 1; @@ -860,7 +922,8 @@ class ClosureType a.assertions = a.mustUseReturnValue != NULL ? assertions() : NULL; a.isStatic = a.assertions != NULL ? isStatic() : NULL; a.byRefUseTypes = a.isStatic != NULL ? byRefUseTypes() : NULL; - if (UNEXPECTED(a.byRefUseTypes == NULL)) return false; + a.origin = a.byRefUseTypes != NULL ? origin() : NULL; + if (UNEXPECTED(a.origin == NULL)) return false; a.variadic = zend_is_true(variadic); return true; } @@ -871,12 +934,25 @@ class ClosureType using phpstanturbo::ClosureType; using phpstanturbo::ClosureTypeArguments; -bool pt_closure_type_new(zval *out, zval *parameters, zval *returnType, bool variadic, zval *templateTypeMap, zval *resolvedTemplateTypeMap, zval *callSiteVarianceMap, zval *templateTags, zval *throwPoints, zval *impurePoints, zval *invalidateExpressions, zval *usedVariables, zval *acceptsNamedArguments, zval *mustUseReturnValue, zval *assertions, zval *isStatic, zval *byRefUseTypes) +bool pt_closure_type_new(zval *out, zval *parameters, zval *returnType, bool variadic, zval *templateTypeMap, zval *resolvedTemplateTypeMap, zval *callSiteVarianceMap, zval *templateTags, zval *throwPoints, zval *impurePoints, zval *invalidateExpressions, zval *usedVariables, zval *acceptsNamedArguments, zval *mustUseReturnValue, zval *assertions, zval *isStatic, zval *byRefUseTypes, zval *origin) { - ClosureTypeArguments a = { parameters, returnType, variadic, templateTypeMap, resolvedTemplateTypeMap, callSiteVarianceMap, templateTags, throwPoints, impurePoints, invalidateExpressions, usedVariables, acceptsNamedArguments, mustUseReturnValue, assertions, isStatic, byRefUseTypes }; + ClosureTypeArguments a = { parameters, returnType, variadic, templateTypeMap, resolvedTemplateTypeMap, callSiteVarianceMap, templateTags, throwPoints, impurePoints, invalidateExpressions, usedVariables, acceptsNamedArguments, mustUseReturnValue, assertions, isStatic, byRefUseTypes, origin }; return pt_val_into(ClosureType::create(a), out); } +zv::Val pt_closure_origin_for_function(zval *functionName) +{ + static pt_method_site site; + return pt_call_static_cached(site, PT_CLASS_CLOSURE_ORIGIN, PT_LC("forfunction"), 1, functionName); +} + +zv::Val pt_closure_origin_for_method(zval *calledOnType, zval *methodName, bool isStaticCall) +{ + static pt_method_site site; + zv::Args argv{calledOnType, methodName, isStaticCall}; + return pt_call_static_cached(site, PT_CLASS_CLOSURE_ORIGIN, PT_LC("formethod"), 3, argv); +} + zv::Val pt_closure_type_get_by_ref_use_types(zval *closureType) { if (EXPECTED(Z_OBJCE_P(closureType) == pt_ce_closure_type)) { @@ -1024,10 +1100,11 @@ PT_MINIT_REGISTRATION(pt_register_closure_type) reg::withDefault(reg::obj("assertions", "PHPStan\\Reflection\\Assertions", true), "null"), reg::withDefault(reg::obj("isStatic", ptcls::trinaryLogic, true), "null"), reg::withDefault(reg::arrayArg("byRefUseTypes"), "[]"), + reg::withDefault(reg::obj("origin", "PHPStan\\Type\\ClosureOrigin", true), "null"), }, [](INTERNAL_FUNCTION_PARAMETERS) { ClosureTypeArguments a = {}; a.variadic = true; - ZEND_PARSE_PARAMETERS_START(0, 16) + ZEND_PARSE_PARAMETERS_START(0, 17) Z_PARAM_OPTIONAL Z_PARAM_ARRAY_OR_NULL(a.parameters) Z_PARAM_OBJECT_OR_NULL(a.returnType) @@ -1045,6 +1122,7 @@ PT_MINIT_REGISTRATION(pt_register_closure_type) Z_PARAM_OBJECT_OR_NULL(a.assertions) Z_PARAM_OBJECT_OR_NULL(a.isStatic) Z_PARAM_ARRAY(a.byRefUseTypes) + Z_PARAM_OBJECT_OR_NULL(a.origin) ZEND_PARSE_PARAMETERS_END(); PT_THIS.construct(a); }); @@ -1057,6 +1135,10 @@ PT_MINIT_REGISTRATION(pt_register_closure_type) ZEND_PARSE_PARAMETERS_NONE(); cltReturnSlot(INTERNAL_FUNCTION_PARAM_PASSTHRU, PT_THIS.byRefUseTypes()); }); + cls.method(sigs::getOrigin, [](INTERNAL_FUNCTION_PARAMETERS) { + ZEND_PARSE_PARAMETERS_NONE(); + cltReturnSlot(INTERNAL_FUNCTION_PARAM_PASSTHRU, PT_THIS.origin()); + }); cls.method(sigs::containsUnresolvedTemplateArgument, [](INTERNAL_FUNCTION_PARAMETERS) { ZEND_PARSE_PARAMETERS_NONE(); bool contains; diff --git a/turbo-ext/src/FuncCallHandler.cpp b/turbo-ext/src/FuncCallHandler.cpp index 4516d4d303b..2d59110db60 100644 --- a/turbo-ext/src/FuncCallHandler.cpp +++ b/turbo-ext/src/FuncCallHandler.cpp @@ -252,7 +252,6 @@ pt_property_site pt_fch_param_by_ref_site; pt_property_site pt_fch_param_var_site; pt_property_site pt_fch_variable_name_site; pt_property_site pt_fch_string_value_site; -pt_property_site pt_fch_inner_name_site; pt_property_site pt_fch_attributes_site; pt_property_site pt_fch_closure_uses_site; pt_property_site pt_fch_use_by_ref_site; @@ -303,12 +302,6 @@ zv::Val callArgs(zval *call) return hold.isUndef() ? zv::Val::copyOf(zv::Ref(args)) : std::move(hold); } -/* $call->isFirstClassCallable(); false = pending exception */ -[[nodiscard]] inline bool isFirstClassCallable(zval *call, bool &out) -{ - return pt_call_like_is_first_class_callable(Z_OBJ_P(call), out); -} - /* $call->isPartialFunctionApplication(); false = pending exception */ [[nodiscard]] inline bool isPartialFunctionApplication(zval *call, bool &out) { @@ -1288,7 +1281,13 @@ class FuncCallHandler dependencies = pt_dependencies_merge({nameDependencies, argsDependencies, ownDependencies.raw()}); if (UNEXPECTED(dependencies.isUndef())) return zv::Val(); } - return pt_expression_result_finalize(preliminaryResult.raw(), scope.raw(), hasYield, isAlwaysTerminating, throwPoints.raw(), impurePoints.raw(), variableFlow.raw(), dependencies.raw()); + zv::Val result = pt_expression_result_finalize(preliminaryResult.raw(), scope.raw(), hasYield, isAlwaysTerminating, throwPoints.raw(), impurePoints.raw(), variableFlow.raw(), dependencies.raw()); + if (UNEXPECTED(result.isUndef()) || nameResult.isNull() || calleeNameType.isNull()) return result; + + /* ClosureOriginCallReplay::replay($nodeScopeResolver, $this->expressionResultFactory, $expr, $nameResult, $nameType, $scopeBeforeArgs, $storage, $result) */ + static pt_method_site replaySite; + zv::Args replayArgv{nodeScopeResolver, slot(slots::expressionResultFactory), expr, nameResult.raw(), calleeNameType.raw(), scopeBeforeArgs, storage, result.raw()}; + return pt_call_static_cached(replaySite, PT_CLASS_CLOSURE_ORIGIN_CALL_REPLAY, PT_LC("replay"), 8, replayArgv); } /* the handler entry (Engine.h) */ @@ -2102,14 +2101,6 @@ class FuncCallHandler if (UNEXPECTED(value == NULL)) return zv::Val(); functionName = pt_name_node_new(PT_CLASS_NAME, value); if (UNEXPECTED(functionName.isUndef())) return zv::Val(); - } else if (isA(name, PT_CLASS_FUNC_CALL)) { - zval *innerName = nodeProp(pt_fch_inner_name_site, name, PT_LC("name")); - if (UNEXPECTED(innerName == NULL)) return zv::Val(); - if (isA(innerName, PT_CLASS_NAME)) { - bool firstClassCallable; - if (UNEXPECTED(!isFirstClassCallable(name, firstClassCallable))) return zv::Val(); - if (firstClassCallable) functionName = zv::Val::copyOf(zv::Ref(innerName)); - } } if (UNEXPECTED(EG(exception))) return zv::Val(); diff --git a/turbo-ext/src/FunctionCallableNodeHandler.cpp b/turbo-ext/src/FunctionCallableNodeHandler.cpp index ba9339cb1e0..2fc3a164771 100644 --- a/turbo-ext/src/FunctionCallableNodeHandler.cpp +++ b/turbo-ext/src/FunctionCallableNodeHandler.cpp @@ -255,12 +255,6 @@ class FunctionCallableNodeHandler zv::Val originalNodeHold; zval *originalNode = ptveh::getterRead(ptveh::functionCallableNodeOriginalNode, expr, PT_LC("getoriginalnode"), originalNodeHold); if (UNEXPECTED(originalNode == NULL)) return zv::Val(); - bool firstClassCallable; - if (UNEXPECTED(!pt_call_like_is_first_class_callable(Z_OBJ_P(originalNode), firstClassCallable))) return zv::Val(); - if (!firstClassCallable) { - // the signature of a partial function application is not inferred yet - return ptveh::closureObjectType(); - } zval *originalName = ptveh::nodeRead(ptveh::funcCallName, originalNode); if (UNEXPECTED(originalName == NULL)) return zv::Val(); int originalNameIsExpr = ptveh::isInstance(originalName, PT_CLASS_EXPR); @@ -279,8 +273,10 @@ class FunctionCallableNodeHandler if (UNEXPECTED(!pt_mutating_scope_native_types_promoted(Z_OBJ_P(scope), nativeTypesPromoted))) return zv::Val(); zv::Val callableType = pt_expression_result_get_type_on_scope(nameResult, scope, nativeTypesPromoted); if (UNEXPECTED(callableType.isUndef())) return zv::Val(); - bool closureObject; - if (UNEXPECTED(!ptveh::isClosureObject(callableType.raw(), closureObject))) return zv::Val(); + bool firstClassCallable; + if (UNEXPECTED(!pt_call_like_is_first_class_callable(Z_OBJ_P(originalNode), firstClassCallable))) return zv::Val(); + bool closureObject = false; + if (firstClassCallable && UNEXPECTED(!ptveh::isClosureObject(callableType.raw(), closureObject))) return zv::Val(); if (closureObject) { // the first-class callable of a closure object is the object itself return callableType; @@ -296,14 +292,27 @@ class FunctionCallableNodeHandler if (UNEXPECTED(!pt_mutating_scope_native_types_promoted(Z_OBJ_P(scope), nativeTypesPromoted))) return zv::Val(); zval null = {}; ZVAL_NULL(&null); - return ptveh::createFirstClassCallable(OBJ_PROP_NUM(self, slots::initializerExprTypeResolver), &null, acceptors.raw(), nativeTypesPromoted); + zval *partialApplicationArgs = &null; + zv::Val rawArgsHold; + if (!firstClassCallable) { + partialApplicationArgs = pt_call_like_raw_args(Z_OBJ_P(originalNode), rawArgsHold); + if (UNEXPECTED(partialApplicationArgs == NULL)) return zv::Val(); + } + zv::Val boundArgTypes; + if (UNEXPECTED(!ptveh::boundArgTypesOrNull(scope, originalNode, boundArgTypes))) return zv::Val(); + if (boundArgTypes.isNull()) { + boundArgTypes = zv::Val(zv::Arr::empty()); + } + return ptveh::createFirstClassCallable(OBJ_PROP_NUM(self, slots::initializerExprTypeResolver), &null, acceptors.raw(), nativeTypesPromoted, partialApplicationArgs, boundArgTypes.raw(), &null); } zv::Val initializerExprContext = ptveh::initializerExprContextFromScope(scope); if (UNEXPECTED(initializerExprContext.isUndef())) return zv::Val(); bool nativeTypesPromoted; if (UNEXPECTED(!pt_mutating_scope_native_types_promoted(Z_OBJ_P(scope), nativeTypesPromoted))) return zv::Val(); - return ptveh::getFirstClassCallableType(OBJ_PROP_NUM(self, slots::initializerExprTypeResolver), originalNode, initializerExprContext.raw(), nativeTypesPromoted); + zv::Val boundArgTypes; + if (UNEXPECTED(!ptveh::boundArgTypesOrNull(scope, originalNode, boundArgTypes))) return zv::Val(); + return ptveh::getFirstClassCallableType(OBJ_PROP_NUM(self, slots::initializerExprTypeResolver), originalNode, initializerExprContext.raw(), nativeTypesPromoted, boundArgTypes.raw()); } /* the handler entry (Engine.h) */ diff --git a/turbo-ext/src/InitializerExprTypeResolver.cpp b/turbo-ext/src/InitializerExprTypeResolver.cpp index b97bd81ba40..07700666852 100644 --- a/turbo-ext/src/InitializerExprTypeResolver.cpp +++ b/turbo-ext/src/InitializerExprTypeResolver.cpp @@ -1243,7 +1243,9 @@ class InitializerExprTypeResolver bool firstClassCallable; if (UNEXPECTED(!pt_call_like_is_partial_function_application(Z_OBJ_P(expr), firstClassCallable))) return zv::Val(); if (firstClassCallable) { - return getFirstClassCallableType(expr, context, false); + zval nullBoundArgTypes; + ZVAL_NULL(&nullBoundArgTypes); + return getFirstClassCallableType(expr, context, false, &nullBoundArgTypes); } break; } @@ -2164,14 +2166,47 @@ class InitializerExprTypeResolver return 0; } - /* Mirrors getFirstClassCallableType(). */ - zv::Val getFirstClassCallableType(zval *expr, zval *context, bool nativeTypesPromoted) const + /* Mirrors getFirstClassCallableType(); $boundArgTypes PHP null for null */ + zv::Val getFirstClassCallableType(zval *expr, zval *context, bool nativeTypesPromoted, zval *boundArgTypesIn) const { bool firstClassCallable; if (UNEXPECTED(!pt_call_like_is_first_class_callable(Z_OBJ_P(expr), firstClassCallable))) return zv::Val(); + zval nullArgs; + ZVAL_NULL(&nullArgs); + zval *partialApplicationArgs = &nullArgs; + zv::Val rawArgsHold; + // $boundArgTypes ?? [] + zv::Val boundArgTypesHold = zv::Val(zv::Arr::empty()); + zval *boundArgTypes = boundArgTypesHold.raw(); if (!firstClassCallable) { - // the signature of a partial function application is not inferred yet - return newObjectTypeLiteral(PT_LC("Closure")); + partialApplicationArgs = pt_call_like_raw_args(Z_OBJ_P(expr), rawArgsHold); + if (UNEXPECTED(partialApplicationArgs == NULL)) return zv::Val(); + if (Z_TYPE_P(boundArgTypesIn) != IS_NULL) { + boundArgTypes = boundArgTypesIn; + } else { + if (UNEXPECTED(!requireArray(partialApplicationArgs))) return zv::Val(); + zv::Arr resolved = zv::Arr::create(0); + for (zv::ArrayEntry entry : zv::ArrRef(partialApplicationArgs)) { + zval *arg = entry.value().deref().raw(); + int isArg = isAClass(arg, PT_CLASS_ARG); + if (UNEXPECTED(isArg < 0)) return zv::Val(); + if (!isArg) { + continue; + } + zval *value = nodeProp(pt_ietr_arg_value, arg); + if (UNEXPECTED(value == NULL)) return zv::Val(); + IETR_VAL(argType, getType(value, context)); + zval key; + if (entry.hasStringKey()) { + ZVAL_STR(&key, entry.stringKey()); + } else { + ZVAL_LONG(&key, (zend_long) entry.indexKey()); + } + if (UNEXPECTED(!arrayKeyUpdate(resolved, &key, std::move(argType)))) return zv::Val(); + } + boundArgTypesHold = zv::Val(std::move(resolved)); + boundArgTypes = boundArgTypesHold.raw(); + } } int isFuncCall = isAClass(expr, PT_CLASS_FUNC_CALL); @@ -2191,7 +2226,9 @@ class InitializerExprTypeResolver IETR_VAL(reflectionProvider, reflectionProviderOf(prop(slots::reflectionProviderProvider))); IETR_VAL(function, pt_reflection_provider_get_function(reflectionProvider.raw(), name, context)); IETR_VAL(variants, callOn(function.raw(), mGetVariants)); - return createFirstClassCallable(function.raw(), variants.raw(), nativeTypesPromoted); + IETR_VAL(functionName, callOn(function.raw(), mGetName)); + IETR_VAL(origin, pt_closure_origin_for_function(functionName.raw())); + return createFirstClassCallable(function.raw(), variants.raw(), nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin.raw()); } return newObjectTypeLiteral(PT_LC("Closure")); @@ -2267,7 +2304,8 @@ class InitializerExprTypeResolver } IETR_VAL(variants, callOn(method.raw(), mGetVariants)); - return createFirstClassCallable(method.raw(), variants.raw(), nativeTypesPromoted); + IETR_VAL(origin, pt_closure_origin_for_method(classType.raw(), &methodName, true)); + return createFirstClassCallable(method.raw(), variants.raw(), nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin.raw()); } int isNew = isAClass(expr, PT_CLASS_NEW); @@ -2333,9 +2371,25 @@ class InitializerExprTypeResolver return zv::Val(std::move(renamed)); } - /* Mirrors createFirstClassCallable(); $function PHP null for null */ - static zv::Val createFirstClassCallable(zval *function, zval *variants, bool nativeTypesPromoted) + /* Mirrors createFirstClassCallable(); $function, $partialApplicationArgs and $origin PHP null for null */ + static zv::Val createFirstClassCallable(zval *function, zval *variants, bool nativeTypesPromoted, zval *partialApplicationArgs, zval *boundArgTypes, zval *originIn) { + bool partialApplication = Z_TYPE_P(partialApplicationArgs) != IS_NULL; + zv::Val origin = zv::Val::copyOf(zv::Ref(originIn)); + if (Z_TYPE_P(originIn) == IS_OBJECT && partialApplication) { + zv::Args withArgv{partialApplicationArgs, boundArgTypes}; + origin = pt_type_call(Z_OBJ_P(originIn), PT_LC("withpartialapplication"), 2, withArgv); + if (UNEXPECTED(origin.isUndef())) return zv::Val(); + } + if (partialApplication) { + static pt_method_site leavesUnknownDefaultValueSite; + zv::Args leavesArgv{variants, partialApplicationArgs}; + IETR_VAL(leavesUnknownDefaultValue, pt_call_static_cached(leavesUnknownDefaultValueSite, PT_CLASS_PARTIAL_FUNCTION_APPLICATION_PARAMETERS, PT_LC("leavesunknowndefaultvalue"), 2, leavesArgv)); + if (zend_is_true(leavesUnknownDefaultValue.raw())) { + // creating the closure throws + return newObjectTypeLiteral(PT_LC("Closure")); + } + } if (UNEXPECTED(Z_TYPE_P(variants) != IS_ARRAY)) { zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_value_name(variants)); if (UNEXPECTED(EG(exception) != NULL)) return zv::Val(); @@ -2383,27 +2437,6 @@ class InitializerExprTypeResolver returnType = std::move(nativeReturnType); } - zv::Arr templateTags = zv::Arr::create(0); - { - IETR_VAL(templateTypeMap, callOn(variant, mGetTemplateTypeMap)); - IETR_VAL(templateTypes, callOn(templateTypeMap.raw(), mGetTypes)); - if (UNEXPECTED(!requireArray(templateTypes.raw()))) return zv::Val(); - for (zv::ArrayEntry entry : zv::ArrRef(templateTypes.raw())) { - zval *templateType = entry.value().raw(); - if (!isA(templateType, templateTypeCe)) { - continue; - } - IETR_VAL(tagName, callOn(templateType, mGetName)); - IETR_VAL(name, callOn(templateType, mGetName)); - IETR_VAL(bound, callOn(templateType, mGetBound)); - IETR_VAL(defaultType, callOn(templateType, mGetDefault)); - IETR_VAL(variance, callOn(templateType, mGetVariance)); - zv::Args tagArgs{name.raw(), bound.raw(), defaultType.raw(), variance.raw()}; - IETR_VAL(tag, pt_type_new(PT_CLASS_TEMPLATE_TAG, 4, tagArgs)); - if (UNEXPECTED(!arrayKeyUpdate(templateTags, tagName.raw(), std::move(tag)))) return zv::Val(); - } - } - zv::Val throwPoints = zv::Val(zv::Arr::empty()); zv::Val impurePoints = zv::Val(zv::Arr::empty()); zv::Val acceptsNamedArguments = zv::Val::copyOf(zv::Ref(pt_trinary_singleton(PT_TRI_YES))); @@ -2472,6 +2505,18 @@ class InitializerExprTypeResolver if (UNEXPECTED(acceptsNamedArguments.isUndef())) return zv::Val(); mustUseReturnValue = callOn(function, mMustUseReturnValue); if (UNEXPECTED(mustUseReturnValue.isUndef())) return zv::Val(); + // binding an object to the closure of a static method, or to a partial + // application of a function, fails; a function's first-class callable can be bound + zend_class_entry *methodReflectionCe = pt_class(PT_CLASS_EXTENDED_METHOD_REFLECTION); + if (UNEXPECTED(methodReflectionCe == NULL)) return zv::Val(); + bool staticClosure = partialApplication; + if (instanceof_function(Z_OBJCE_P(function), methodReflectionCe)) { + IETR_VAL(isStaticMethod, callOn(function, mIsStatic)); + staticClosure = zend_is_true(isStaticMethod.raw()); + } + if (staticClosure) { + isStaticClosure = zv::Val::copyOf(zv::Ref(pt_trinary_singleton(PT_TRI_YES))); + } } IETR_VAL(variantParameters, callOn(variant, mGetParameters)); @@ -2480,6 +2525,67 @@ class InitializerExprTypeResolver IETR_VAL(renamedParameters, renameParameters(parameters.raw(), namedArgumentNames.raw())); parameters = std::move(renamedParameters); } + IETR_VAL(isVariadicHold, callOn(variant, mIsVariadic)); + bool isVariadic = zend_is_true(isVariadicHold.raw()); + IETR_VAL(templateTypeMapInit, callOn(variant, mGetTemplateTypeMap)); + zv::Val templateTypeMap = std::move(templateTypeMapInit); + zv::Val variantOrigin = zv::Val::copyOf(zv::Ref(origin.raw())); + if (partialApplication) { + static pt_method_site applySite; + zv::Args applyArgv{parameters.raw(), isVariadic, partialApplicationArgs, boundArgTypes, returnType.raw(), templateTypeMap.raw()}; + IETR_VAL(applied, pt_call_static_cached(applySite, PT_CLASS_PARTIAL_FUNCTION_APPLICATION_PARAMETERS, PT_LC("apply"), 6, applyArgv)); + if (Z_TYPE_P(applied.raw()) == IS_NULL) { + // creating the closure from this variant throws + continue; + } + if (UNEXPECTED(!requireArray(applied.raw()))) return zv::Val(); + zval *appliedParameters = zend_hash_index_find(Z_ARRVAL_P(applied.raw()), 0); + zval *appliedIsVariadic = zend_hash_index_find(Z_ARRVAL_P(applied.raw()), 1); + zval *appliedReturnType = zend_hash_index_find(Z_ARRVAL_P(applied.raw()), 2); + zval *appliedTemplateTypeMap = zend_hash_index_find(Z_ARRVAL_P(applied.raw()), 3); + zval *appliedBoundParameterNames = zend_hash_index_find(Z_ARRVAL_P(applied.raw()), 4); + if (UNEXPECTED(appliedParameters == NULL || appliedIsVariadic == NULL || appliedReturnType == NULL || appliedTemplateTypeMap == NULL || appliedBoundParameterNames == NULL)) { + pt_throw_should_not_happen(); + return zv::Val(); + } + parameters = zv::Val::copyOf(zv::Ref(appliedParameters)); + isVariadic = zend_is_true(appliedIsVariadic); + returnType = zv::Val::copyOf(zv::Ref(appliedReturnType)); + templateTypeMap = zv::Val::copyOf(zv::Ref(appliedTemplateTypeMap)); + static pt_method_site magicNamesSite; + zv::Args magicNamesArgv{function, partialApplicationArgs}; + IETR_VAL(magicMethodParameterNames, pt_call_static_cached(magicNamesSite, PT_CLASS_PARTIAL_FUNCTION_APPLICATION_PARAMETERS, PT_LC("getmagicmethodparameternames"), 2, magicNamesArgv)); + if (Z_TYPE_P(magicMethodParameterNames.raw()) == IS_NULL) { + // creating the closure of a method called through __call() throws + continue; + } + IETR_VAL(renamedForMagicMethod, renameParameters(parameters.raw(), magicMethodParameterNames.raw())); + parameters = std::move(renamedForMagicMethod); + if (Z_TYPE_P(variantOrigin.raw()) == IS_OBJECT) { + IETR_VAL(withBoundNames, pt_type_call(Z_OBJ_P(variantOrigin.raw()), PT_LC("withboundparameternames"), 1, appliedBoundParameterNames)); + variantOrigin = std::move(withBoundNames); + } + } + + zv::Arr templateTags = zv::Arr::create(0); + { + IETR_VAL(templateTypes, callOn(templateTypeMap.raw(), mGetTypes)); + if (UNEXPECTED(!requireArray(templateTypes.raw()))) return zv::Val(); + for (zv::ArrayEntry entry : zv::ArrRef(templateTypes.raw())) { + zval *templateType = entry.value().raw(); + if (!isA(templateType, templateTypeCe)) { + continue; + } + IETR_VAL(tagName, callOn(templateType, mGetName)); + IETR_VAL(name, callOn(templateType, mGetName)); + IETR_VAL(bound, callOn(templateType, mGetBound)); + IETR_VAL(defaultType, callOn(templateType, mGetDefault)); + IETR_VAL(variance, callOn(templateType, mGetVariance)); + zv::Args tagArgs{name.raw(), bound.raw(), defaultType.raw(), variance.raw()}; + IETR_VAL(tag, pt_type_new(PT_CLASS_TEMPLATE_TAG, 4, tagArgs)); + if (UNEXPECTED(!arrayKeyUpdate(templateTags, tagName.raw(), std::move(tag)))) return zv::Val(); + } + } zv::Val assertions; if (hasFunction) { assertions = callOn(function, mGetAsserts); @@ -2494,8 +2600,6 @@ class InitializerExprTypeResolver // like @return ($value is int ? true : false) on is_int(), // also becomes a type predicate of the resulting Closure IETR_VAL(predicateAssertions, withConditionalReturnPredicate(assertions.raw(), variant)); - IETR_VAL(isVariadicHold, callOn(variant, mIsVariadic)); - IETR_VAL(templateTypeMap, callOn(variant, mGetTemplateTypeMap)); IETR_VAL(resolvedTemplateTypeMap, callOn(variant, mGetResolvedTemplateTypeMap)); zv::Val callSiteVarianceMap = extendedAcceptor ? callOn(variant, mGetCallSiteVarianceMap) @@ -2506,7 +2610,7 @@ class InitializerExprTypeResolver &closureType, parameters.raw(), returnType.raw(), - zend_is_true(isVariadicHold.raw()), + isVariadic, templateTypeMap.raw(), resolvedTemplateTypeMap.raw(), callSiteVarianceMap.raw(), @@ -2518,11 +2622,17 @@ class InitializerExprTypeResolver acceptsNamedArguments.raw(), mustUseReturnValue.raw(), predicateAssertions.raw(), - isStaticClosure.raw() + isStaticClosure.raw(), + NULL, + variantOrigin.raw() ))) return zv::Val(); closureTypes.push(zv::Val::adopt(closureType)); } + if (partialApplication && zend_hash_num_elements(closureTypes.table()) == 0) { + return newObjectTypeLiteral(PT_LC("Closure")); + } + return unionOf(closureTypes); } @@ -3472,20 +3582,20 @@ zv::Val pt_initializer_expr_type_resolver_get_function_type(zval *resolver, zval return callResolverMethod(site, resolver, PT_LC("getfunctiontype"), 4, argv); } -zv::Val pt_initializer_expr_type_resolver_get_first_class_callable_type(zval *resolver, zval *expr, zval *context, bool nativeTypesPromoted) +zv::Val pt_initializer_expr_type_resolver_get_first_class_callable_type(zval *resolver, zval *expr, zval *context, bool nativeTypesPromoted, zval *boundArgTypes) { - if (EXPECTED(isNativeResolver(resolver))) return InitializerExprTypeResolver(Z_OBJ_P(resolver)).getFirstClassCallableType(expr, context, nativeTypesPromoted); + if (EXPECTED(isNativeResolver(resolver))) return InitializerExprTypeResolver(Z_OBJ_P(resolver)).getFirstClassCallableType(expr, context, nativeTypesPromoted, boundArgTypes); static pt_method_site site; - zv::Args argv{expr, context, nativeTypesPromoted}; - return callResolverMethod(site, resolver, PT_LC("getfirstclasscallabletype"), 3, argv); + zv::Args argv{expr, context, nativeTypesPromoted, boundArgTypes}; + return callResolverMethod(site, resolver, PT_LC("getfirstclasscallabletype"), 4, argv); } -zv::Val pt_initializer_expr_type_resolver_create_first_class_callable(zval *resolver, zval *function, zval *variants, bool nativeTypesPromoted) +zv::Val pt_initializer_expr_type_resolver_create_first_class_callable(zval *resolver, zval *function, zval *variants, bool nativeTypesPromoted, zval *partialApplicationArgs, zval *boundArgTypes, zval *origin) { - if (EXPECTED(isNativeResolver(resolver))) return InitializerExprTypeResolver::createFirstClassCallable(function, variants, nativeTypesPromoted); + if (EXPECTED(isNativeResolver(resolver))) return InitializerExprTypeResolver::createFirstClassCallable(function, variants, nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin); static pt_method_site site; - zv::Args argv{function, variants, nativeTypesPromoted}; - return callResolverMethod(site, resolver, PT_LC("createfirstclasscallable"), 3, argv); + zv::Args argv{function, variants, nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin}; + return callResolverMethod(site, resolver, PT_LC("createfirstclasscallable"), 6, argv); } zv::Val pt_initializer_expr_type_resolver_get_class_const_fetch_type_by_reflection(zval *resolver, zval *class_, zval *constantName, zval *classReflection, const pt_ietr_get_type &getTypeCallback, bool nativeTypesPromoted) @@ -3693,17 +3803,44 @@ PT_MINIT_REGISTRATION(pt_register_initializer_expr_type_resolver) }); cls.method(sigs::getFirstClassCallableType, [](INTERNAL_FUNCTION_PARAMETERS) { - zval *expr, *context; + zval *expr, *context, *boundArgTypes = NULL; bool nativeTypesPromoted; - if (!zp::parse(execute_data, expr, context, nativeTypesPromoted)) RETURN_THROWS(); + if (!zp::parse>(execute_data, expr, context, nativeTypesPromoted, boundArgTypes)) RETURN_THROWS(); if (UNEXPECTED(!ietrArgClass(expr, 1, PT_CLASS_CALL_LIKE, "PhpParser\\Node\\Expr\\CallLike") || !ietrArgContext(context, 2))) RETURN_THROWS(); - PT_RETURN_VAL(IETR_THIS.getFirstClassCallableType(expr, context, nativeTypesPromoted)); + zval nullBoundArgTypes; + if (boundArgTypes == NULL) { + ZVAL_NULL(&nullBoundArgTypes); + boundArgTypes = &nullBoundArgTypes; + } + PT_RETURN_VAL(IETR_THIS.getFirstClassCallableType(expr, context, nativeTypesPromoted, boundArgTypes)); }); cls.method(sigs::createFirstClassCallable, [](INTERNAL_FUNCTION_PARAMETERS) { - zval *function, *variants; + zval *function, *variants, *partialApplicationArgs = NULL, *boundArgTypes = NULL, *origin = NULL; bool nativeTypesPromoted; - if (!zp::parse(execute_data, function, variants, nativeTypesPromoted)) RETURN_THROWS(); + if (!zp::parse, zp::Opt, zp::Opt>(execute_data, function, variants, nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin)) RETURN_THROWS(); + zval nullOrigin; + if (origin == NULL) { + ZVAL_NULL(&nullOrigin); + origin = &nullOrigin; + } else if (Z_TYPE_P(origin) == IS_OBJECT) { + zend_class_entry *closureOriginCe = pt_class(PT_CLASS_CLOSURE_ORIGIN); + if (UNEXPECTED(closureOriginCe == NULL)) RETURN_THROWS(); + if (UNEXPECTED(!instanceof_function(Z_OBJCE_P(origin), closureOriginCe))) { + zend_argument_type_error(6, "must be of type ?PHPStan\\Type\\ClosureOrigin, %s given", zend_zval_value_name(origin)); + RETURN_THROWS(); + } + } + zval nullArgs; + if (partialApplicationArgs == NULL) { + ZVAL_NULL(&nullArgs); + partialApplicationArgs = &nullArgs; + } + zval emptyBoundArgTypes; + if (boundArgTypes == NULL) { + ZVAL_EMPTY_ARRAY(&emptyBoundArgTypes); + boundArgTypes = &emptyBoundArgTypes; + } zval nullFunction; if (function == NULL) { ZVAL_NULL(&nullFunction); @@ -3717,7 +3854,7 @@ PT_MINIT_REGISTRATION(pt_register_initializer_expr_type_resolver) RETURN_THROWS(); } } - PT_RETURN_VAL(InitializerExprTypeResolver::createFirstClassCallable(function, variants, nativeTypesPromoted)); + PT_RETURN_VAL(InitializerExprTypeResolver::createFirstClassCallable(function, variants, nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin)); }); cls.method(sigs::getBitwiseAndType, IETR_OPERATOR_GLUE(self.getOperatorType(IETR_BITWISE_AND, left, right, getTypeCallback))); diff --git a/turbo-ext/src/InstantiationCallableNodeHandler.cpp b/turbo-ext/src/InstantiationCallableNodeHandler.cpp index f3254efbdb6..537ce308707 100644 --- a/turbo-ext/src/InstantiationCallableNodeHandler.cpp +++ b/turbo-ext/src/InstantiationCallableNodeHandler.cpp @@ -194,7 +194,9 @@ class InstantiationCallableNodeHandler if (UNEXPECTED(originalNode == NULL)) return; zv::Val initializerExprContext = ptveh::initializerExprContextFromScope(&captures[2]); if (UNEXPECTED(initializerExprContext.isUndef())) return; - type = ptveh::getFirstClassCallableType(OBJ_PROP_NUM(Z_OBJ(captures[0]), slots::initializerExprTypeResolver), originalNode, initializerExprContext.raw(), nativeTypesPromoted); + zval nullBoundArgTypes; + ZVAL_NULL(&nullBoundArgTypes); + type = ptveh::getFirstClassCallableType(OBJ_PROP_NUM(Z_OBJ(captures[0]), slots::initializerExprTypeResolver), originalNode, initializerExprContext.raw(), nativeTypesPromoted, &nullBoundArgTypes); }); if (UNEXPECTED(type.isUndef())) return; type.intoReturnValue(return_value); diff --git a/turbo-ext/src/MethodCallableNodeHandler.cpp b/turbo-ext/src/MethodCallableNodeHandler.cpp index 0f27b68c1c4..435bdc1c8ca 100644 --- a/turbo-ext/src/MethodCallableNodeHandler.cpp +++ b/turbo-ext/src/MethodCallableNodeHandler.cpp @@ -237,12 +237,6 @@ class MethodCallableNodeHandler if (!originalNameIsIdentifier) { return ptveh::closureObjectType(); } - bool firstClassCallable; - if (UNEXPECTED(!pt_call_like_is_first_class_callable(Z_OBJ_P(originalNode), firstClassCallable))) return zv::Val(); - if (!firstClassCallable) { - // the signature of a partial function application is not inferred yet - return ptveh::closureObjectType(); - } // $originalNode->var is the same node as $expr->getVar(), processed in // processExpr - read its ExpressionResult instead of Scope::getType() @@ -265,7 +259,24 @@ class MethodCallableNodeHandler zv::Val variants = pt_extended_method_reflection_call(method.raw(), PT_MR_GET_VARIANTS); if (UNEXPECTED(variants.isUndef())) return zv::Val(); if (UNEXPECTED(!pt_mutating_scope_native_types_promoted(Z_OBJ_P(scope), nativeTypesPromoted))) return zv::Val(); - return ptveh::createFirstClassCallable(OBJ_PROP_NUM(self, slots::initializerExprTypeResolver), method.raw(), variants.raw(), nativeTypesPromoted); + bool firstClassCallable; + if (UNEXPECTED(!pt_call_like_is_first_class_callable(Z_OBJ_P(originalNode), firstClassCallable))) return zv::Val(); + zval nullArgs; + ZVAL_NULL(&nullArgs); + zval *partialApplicationArgs = &nullArgs; + zv::Val rawArgsHold; + if (!firstClassCallable) { + partialApplicationArgs = pt_call_like_raw_args(Z_OBJ_P(originalNode), rawArgsHold); + if (UNEXPECTED(partialApplicationArgs == NULL)) return zv::Val(); + } + zv::Val boundArgTypes; + if (UNEXPECTED(!ptveh::boundArgTypesOrNull(scope, originalNode, boundArgTypes))) return zv::Val(); + if (boundArgTypes.isNull()) { + boundArgTypes = zv::Val(zv::Arr::empty()); + } + zv::Val origin = pt_closure_origin_for_method(varType.raw(), methodName, false); + if (UNEXPECTED(origin.isUndef())) return zv::Val(); + return ptveh::createFirstClassCallable(OBJ_PROP_NUM(self, slots::initializerExprTypeResolver), method.raw(), variants.raw(), nativeTypesPromoted, partialApplicationArgs, boundArgTypes.raw(), origin.raw()); } /* the handler entry (Engine.h) */ diff --git a/turbo-ext/src/StaticMethodCallableNodeHandler.cpp b/turbo-ext/src/StaticMethodCallableNodeHandler.cpp index c33ff9fbb8b..c649c01ba3a 100644 --- a/turbo-ext/src/StaticMethodCallableNodeHandler.cpp +++ b/turbo-ext/src/StaticMethodCallableNodeHandler.cpp @@ -282,7 +282,10 @@ class StaticMethodCallableNodeHandler /* fn (bool $nativeTypesPromoted): Type => * $this->initializerExprTypeResolver->getFirstClassCallableType($expr->getOriginalNode(), - * InitializerExprContext::fromScope($beforeScope), $nativeTypesPromoted) — + * InitializerExprContext::fromScope($beforeScope), $nativeTypesPromoted, + * $expr->getOriginalNode()->isFirstClassCallable() ? null : + * PartialFunctionApplicationParameters::getBoundArgTypes($nativeTypesPromoted + * ? $beforeScope->doNotTreatPhpDocTypesAsCertain() : $beforeScope, $expr->getOriginalNode())) — * captures: $this, $expr, $beforeScope */ static void typeCallbackBody(zval *captures, uint32_t argc, zval *argv, zval *return_value) { @@ -295,7 +298,12 @@ class StaticMethodCallableNodeHandler if (UNEXPECTED(originalNode == NULL)) return; zv::Val initializerExprContext = ptveh::initializerExprContextFromScope(&captures[2]); if (UNEXPECTED(initializerExprContext.isUndef())) return; - type = ptveh::getFirstClassCallableType(OBJ_PROP_NUM(Z_OBJ(captures[0]), slots::initializerExprTypeResolver), originalNode, initializerExprContext.raw(), nativeTypesPromoted); + zv::Val scopeHold; + zval *boundArgTypesScope = ptveh::promotedScope(&captures[2], nativeTypesPromoted, scopeHold); + if (UNEXPECTED(boundArgTypesScope == NULL)) return; + zv::Val boundArgTypes; + if (UNEXPECTED(!ptveh::boundArgTypesOrNull(boundArgTypesScope, originalNode, boundArgTypes))) return; + type = ptveh::getFirstClassCallableType(OBJ_PROP_NUM(Z_OBJ(captures[0]), slots::initializerExprTypeResolver), originalNode, initializerExprContext.raw(), nativeTypesPromoted, boundArgTypes.raw()); }); if (UNEXPECTED(type.isUndef())) return; type.intoReturnValue(return_value); diff --git a/turbo-ext/src/UnionType.cpp b/turbo-ext/src/UnionType.cpp index 1e6c36967e6..1d34d005cb3 100644 --- a/turbo-ext/src/UnionType.cpp +++ b/turbo-ext/src/UnionType.cpp @@ -35,6 +35,7 @@ #include "TypeTraits.h" #include "generated/UnionType.h" +#include "Engine.h" namespace slots = ptdecl::UnionType::slot; namespace sigs = ptdecl::UnionType::sig; @@ -845,6 +846,9 @@ class UnionType zv::Val results = mapReversed(PT_LC("issupertypeof"), Z_OBJ_P(otherType), 0, NULL); if (UNEXPECTED(results.isUndef())) return zv::Val(); + static pt_method_site combineSite; + results = combineOverloadResults(std::move(results), combineSite, PT_LC("combineoverloadissupertypeofresults")); + if (UNEXPECTED(results.isUndef())) return zv::Val(); return pt_is_super_type_of_result_extreme_identity_spread(zv::ArrRef(results.raw()).table()); } @@ -860,9 +864,32 @@ class UnionType ZVAL_BOOL(&strictZv, strictTypes); zv::Val results = mapReversed(PT_LC("accepts"), Z_OBJ_P(acceptingType), 1, &strictZv); if (UNEXPECTED(results.isUndef())) return zv::Val(); + static pt_method_site combineSite; + results = combineOverloadResults(std::move(results), combineSite, PT_LC("combineoverloadacceptsresults")); + if (UNEXPECTED(results.isUndef())) return zv::Val(); return pt_accepts_result_extreme_identity_spread(zv::ArrRef(results.raw()).table()); } + /* The results as they are without a ClosureType member (the private + * hasClosureMember()), else ClosureOrigin::combineOverload*Results($this->types, + * $results) named by lcName; UNDEF = pending exception */ + zv::Val combineOverloadResults(zv::Val results, pt_method_site &site, const char *lcName, size_t lcNameLen) const + { + zval *types = this->types(); + if (UNEXPECTED(types == NULL)) return zv::Val(); + bool hasClosure = false; + for (zv::ArrayEntry entry : zv::ArrRef(types)) { + zval *member = entry.value().deref().raw(); + if (Z_TYPE_P(member) == IS_OBJECT && instanceof_function(Z_OBJCE_P(member), pt_ce_closure_type)) { + hasClosure = true; + break; + } + } + if (!hasClosure) return results; + zv::Args argv{types, results.raw()}; + return pt_call_static_cached(site, PT_CLASS_CLOSURE_ORIGIN, lcName, lcNameLen, 2, argv); + } + /* the same class (`$type instanceof static`) with the same member * count, then the finite sets or member-by-member equals() with each * match consumed once; false with an exception pending */ diff --git a/turbo-ext/src/VirtualExprHandlers.h b/turbo-ext/src/VirtualExprHandlers.h index de28871e48c..499615e10e8 100644 --- a/turbo-ext/src/VirtualExprHandlers.h +++ b/turbo-ext/src/VirtualExprHandlers.h @@ -141,16 +141,33 @@ inline zval *nodeRead(NodeProp &prop, zval *node) * once they are ported) */ -/* $initializerExprTypeResolver->createFirstClassCallable($function, $variants, $nativeTypesPromoted) */ -inline zv::Val createFirstClassCallable(zval *initializerExprTypeResolver, zval *function, zval *variants, bool nativeTypesPromoted) +/* $initializerExprTypeResolver->createFirstClassCallable($function, $variants, $nativeTypesPromoted, $partialApplicationArgs, $boundArgTypes, $origin) */ +inline zv::Val createFirstClassCallable(zval *initializerExprTypeResolver, zval *function, zval *variants, bool nativeTypesPromoted, zval *partialApplicationArgs, zval *boundArgTypes, zval *origin) { - return pt_initializer_expr_type_resolver_create_first_class_callable(initializerExprTypeResolver, function, variants, nativeTypesPromoted); + return pt_initializer_expr_type_resolver_create_first_class_callable(initializerExprTypeResolver, function, variants, nativeTypesPromoted, partialApplicationArgs, boundArgTypes, origin); } -/* $initializerExprTypeResolver->getFirstClassCallableType($expr, $context, $nativeTypesPromoted) */ -inline zv::Val getFirstClassCallableType(zval *initializerExprTypeResolver, zval *expr, zval *context, bool nativeTypesPromoted) +/* $initializerExprTypeResolver->getFirstClassCallableType($expr, $context, $nativeTypesPromoted, $boundArgTypes) */ +inline zv::Val getFirstClassCallableType(zval *initializerExprTypeResolver, zval *expr, zval *context, bool nativeTypesPromoted, zval *boundArgTypes) { - return pt_initializer_expr_type_resolver_get_first_class_callable_type(initializerExprTypeResolver, expr, context, nativeTypesPromoted); + return pt_initializer_expr_type_resolver_get_first_class_callable_type(initializerExprTypeResolver, expr, context, nativeTypesPromoted, boundArgTypes); +} + +/* PartialFunctionApplicationParameters::getBoundArgTypes($scope, $call) for a partial + * function application, PHP null for a first-class callable (written into out, + * which owns it); false = pending exception */ +inline bool boundArgTypesOrNull(zval *scope, zval *call, zv::Val &out) +{ + bool firstClassCallable; + if (UNEXPECTED(!pt_call_like_is_first_class_callable(Z_OBJ_P(call), firstClassCallable))) return false; + if (firstClassCallable) { + out = zv::Val::null(); + return true; + } + static pt_method_site site; + zv::Args argv{scope, call}; + out = pt_call_static_cached(site, PT_CLASS_PARTIAL_FUNCTION_APPLICATION_PARAMETERS, PT_LC("getboundargtypes"), 2, argv); + return !out.isUndef(); } /* InitializerExprContext::fromScope($scope) */ diff --git a/turbo-ext/src/generated/ClosureType.h b/turbo-ext/src/generated/ClosureType.h index a2e7e5a8e39..9c0fc814225 100644 --- a/turbo-ext/src/generated/ClosureType.h +++ b/turbo-ext/src/generated/ClosureType.h @@ -30,6 +30,7 @@ inline constexpr uint32_t throwPoints = 16; inline constexpr uint32_t invalidateExpressions = 17; inline constexpr uint32_t usedVariables = 18; inline constexpr uint32_t byRefUseTypes = 19; +inline constexpr uint32_t origin = 20; } // namespace slot inline void declareClass(reg::Class &cls) @@ -60,6 +61,7 @@ inline void declareProperties(reg::Class &cls) cls.property("invalidateExpressions", ZEND_ACC_PRIVATE, reg::PropertyKind::Typed, MAY_BE_ARRAY); cls.property("usedVariables", ZEND_ACC_PRIVATE, reg::PropertyKind::Typed, MAY_BE_ARRAY); cls.property("byRefUseTypes", ZEND_ACC_PRIVATE, reg::PropertyKind::Typed, MAY_BE_ARRAY); + cls.property("origin", ZEND_ACC_PRIVATE, reg::PropertyKind::Typed, MAY_BE_NULL, "PHPStan\\Type\\ClosureOrigin"); } /* the shared registrars of the traits the twin uses, in its own order (a used trait's own traits after it) */ @@ -101,164 +103,170 @@ inline constexpr char strings[] = "PHPStan\\Reflection\\Assertions\0" /* 351 */ "isStatic\0" /* 381 */ "byRefUseTypes\0" /* 390 */ - "__construct\0" /* 404 */ - "\0" /* 416 */ - "getAsserts\0" /* 417 */ - "getTemplateTags\0" /* 428 */ - "PHPStan\\Type\\ClosureType\0" /* 444 */ - "createPure\0" /* 469 */ - "isPure\0" /* 480 */ - "getClassName\0" /* 487 */ - "PHPStan\\Reflection\\ClassReflection\0" /* 500 */ - "getClassReflection\0" /* 535 */ - "className\0" /* 554 */ - "PHPStan\\Type\\TypeWithClassName\0" /* 564 */ - "getAncestorWithClassName\0" /* 595 */ - "getReferencedClasses\0" /* 620 */ - "getObjectClassNames\0" /* 641 */ - "getObjectClassReflections\0" /* 661 */ - "type\0" /* 687 */ - "strictTypes\0" /* 692 */ - "PHPStan\\Type\\AcceptsResult\0" /* 704 */ - "accepts\0" /* 731 */ - "PHPStan\\Type\\IsSuperTypeOfResult\0" /* 739 */ - "isSuperTypeOf\0" /* 772 */ - "treatMixedAsAny\0" /* 786 */ - "isSuperTypeOfInternal\0" /* 802 */ - "equals\0" /* 824 */ - "other\0" /* 831 */ - "hasEqualUnresolvedSignature\0" /* 837 */ - "level\0" /* 865 */ - "PHPStan\\Type\\VerbosityLevel\0" /* 871 */ - "describe\0" /* 899 */ - "describeCallable\0" /* 908 */ - "isOffsetAccessLegal\0" /* 925 */ - "isObject\0" /* 945 */ - "getClassStringType\0" /* 954 */ - "isEnum\0" /* 973 */ - "ancestorClassName\0" /* 980 */ - "templateTypeName\0" /* 998 */ - "getTemplateType\0" /* 1015 */ - "canAccessProperties\0" /* 1031 */ - "propertyName\0" /* 1051 */ - "hasProperty\0" /* 1064 */ - "scope\0" /* 1076 */ - "PHPStan\\Reflection\\ClassMemberAccessAnswerer\0" /* 1082 */ - "PHPStan\\Reflection\\ExtendedPropertyReflection\0" /* 1127 */ - "getProperty\0" /* 1173 */ - "PHPStan\\Reflection\\Type\\UnresolvedPropertyPrototypeReflection\0" /* 1185 */ - "getUnresolvedPropertyPrototype\0" /* 1247 */ - "hasInstanceProperty\0" /* 1278 */ - "getInstanceProperty\0" /* 1298 */ - "getUnresolvedInstancePropertyPrototype\0" /* 1318 */ - "hasStaticProperty\0" /* 1357 */ - "getStaticProperty\0" /* 1375 */ - "getUnresolvedStaticPropertyPrototype\0" /* 1393 */ - "canCallMethods\0" /* 1430 */ - "methodName\0" /* 1445 */ - "hasMethod\0" /* 1456 */ - "PHPStan\\Reflection\\ExtendedMethodReflection\0" /* 1466 */ - "getMethod\0" /* 1510 */ - "PHPStan\\Reflection\\Type\\UnresolvedMethodPrototypeReflection\0" /* 1520 */ - "getUnresolvedMethodPrototype\0" /* 1580 */ - "canAccessConstants\0" /* 1609 */ - "constantName\0" /* 1628 */ - "hasConstant\0" /* 1641 */ - "PHPStan\\Reflection\\ClassConstantReflection\0" /* 1653 */ - "getConstant\0" /* 1696 */ - "getConstantStrings\0" /* 1708 */ - "isIterable\0" /* 1727 */ - "isIterableAtLeastOnce\0" /* 1738 */ - "isCallable\0" /* 1760 */ - "getEnumCases\0" /* 1771 */ - "PHPStan\\Type\\Enum\\EnumCaseObjectType\0" /* 1784 */ - "getEnumCaseObject\0" /* 1821 */ - "isCommonCallable\0" /* 1839 */ - "getCallableParametersAcceptors\0" /* 1856 */ - "getThrowPoints\0" /* 1887 */ - "getImpurePoints\0" /* 1902 */ - "getInvalidateExpressions\0" /* 1918 */ - "getUsedVariables\0" /* 1943 */ - "getByRefUseTypes\0" /* 1960 */ - "containsUnresolvedTemplateArgument\0" /* 1977 */ - "isStaticClosure\0" /* 2012 */ - "isCloneable\0" /* 2028 */ - "PHPStan\\Type\\BooleanType\0" /* 2040 */ - "toBoolean\0" /* 2065 */ - "toNumber\0" /* 2075 */ - "toBitwiseNotType\0" /* 2084 */ - "toGetClassResultType\0" /* 2101 */ - "reflectionProvider\0" /* 2122 */ - "PHPStan\\Reflection\\ReflectionProvider\0" /* 2141 */ - "toClassConstantType\0" /* 2179 */ - "PHPStan\\Type\\ClassNameToObjectTypeResult\0" /* 2199 */ - "toObjectTypeForInstanceofCheck\0" /* 2240 */ - "objectOrClassType\0" /* 2271 */ - "allowString\0" /* 2289 */ - "allowSameClass\0" /* 2301 */ - "toObjectTypeForIsACheck\0" /* 2316 */ - "toAbsoluteNumber\0" /* 2340 */ - "toInteger\0" /* 2357 */ - "toFloat\0" /* 2367 */ - "toString\0" /* 2375 */ - "toArray\0" /* 2384 */ - "toArrayKey\0" /* 2392 */ - "toCoercedArgumentType\0" /* 2403 */ - "getTemplateTypeMap\0" /* 2425 */ - "getResolvedTemplateTypeMap\0" /* 2444 */ - "getCallSiteVarianceMap\0" /* 2471 */ - "getParameters\0" /* 2494 */ - "isVariadic\0" /* 2508 */ - "getReturnType\0" /* 2519 */ - "receivedType\0" /* 2533 */ - "inferTemplateTypes\0" /* 2546 */ - "parametersAcceptor\0" /* 2565 */ - "PHPStan\\Reflection\\ParametersAcceptor\0" /* 2584 */ - "inferTemplateTypesOnParametersAcceptor\0" /* 2622 */ - "positionVariance\0" /* 2661 */ - "PHPStan\\Type\\Generic\\TemplateTypeVariance\0" /* 2678 */ - "getReferencedTemplateTypes\0" /* 2720 */ - "cb\0" /* 2747 */ - "traverse\0" /* 2750 */ - "right\0" /* 2759 */ - "traverseSimultaneously\0" /* 2765 */ - "isNull\0" /* 2788 */ - "isConstantValue\0" /* 2795 */ - "isConstantScalarValue\0" /* 2811 */ - "getConstantScalarTypes\0" /* 2833 */ - "getConstantScalarValues\0" /* 2856 */ - "isTrue\0" /* 2880 */ - "isFalse\0" /* 2887 */ - "isBoolean\0" /* 2895 */ - "isFloat\0" /* 2905 */ - "isInteger\0" /* 2913 */ - "isString\0" /* 2923 */ - "isNumericString\0" /* 2932 */ - "isDecimalIntegerString\0" /* 2948 */ - "isNonEmptyString\0" /* 2971 */ - "isNonFalsyString\0" /* 2988 */ - "isLiteralString\0" /* 3005 */ - "isLowercaseString\0" /* 3021 */ - "isClassString\0" /* 3039 */ - "isUppercaseString\0" /* 3053 */ - "getClassStringObjectType\0" /* 3071 */ - "getObjectTypeOrClassStringObjectType\0" /* 3096 */ - "isVoid\0" /* 3133 */ - "isScalar\0" /* 3140 */ - "phpVersion\0" /* 3149 */ - "PHPStan\\Php\\PhpVersion\0" /* 3160 */ - "looseCompare\0" /* 3183 */ - "exponent\0" /* 3196 */ - "arithmeticPower\0" /* 3205 */ - "getFiniteTypes\0" /* 3221 */ - "PHPStan\\PhpDocParser\\Ast\\Type\\TypeNode\0" /* 3236 */ - "toPhpDocNode\0" /* 3275 */ - "position\0" /* 3288 */ - "PHPStan\\Type\\NativeTypePosition\0" /* 3297 */ - "toNativePhpTypeNode\0" /* 3329 */ - "hasTemplateOrLateResolvableType\0" /* 3349 */ - "PHPStan\\Type\\ValueSet\0" /* 3381 */ - "toValueSet"; /* 3403 */ + "origin\0" /* 404 */ + "PHPStan\\Type\\ClosureOrigin\0" /* 411 */ + "__construct\0" /* 438 */ + "\0" /* 450 */ + "getAsserts\0" /* 451 */ + "getTemplateTags\0" /* 462 */ + "PHPStan\\Type\\ClosureType\0" /* 478 */ + "createPure\0" /* 503 */ + "isPure\0" /* 514 */ + "getClassName\0" /* 521 */ + "PHPStan\\Reflection\\ClassReflection\0" /* 534 */ + "getClassReflection\0" /* 569 */ + "className\0" /* 588 */ + "PHPStan\\Type\\TypeWithClassName\0" /* 598 */ + "getAncestorWithClassName\0" /* 629 */ + "getReferencedClasses\0" /* 654 */ + "getObjectClassNames\0" /* 675 */ + "getObjectClassReflections\0" /* 695 */ + "type\0" /* 721 */ + "strictTypes\0" /* 726 */ + "PHPStan\\Type\\AcceptsResult\0" /* 738 */ + "accepts\0" /* 765 */ + "PHPStan\\Type\\IsSuperTypeOfResult\0" /* 773 */ + "isSuperTypeOf\0" /* 806 */ + "treatMixedAsAny\0" /* 820 */ + "isSuperTypeOfInternal\0" /* 836 */ + "equals\0" /* 858 */ + "a\0" /* 865 */ + "b\0" /* 867 */ + "hasEqualOrigins\0" /* 869 */ + "other\0" /* 885 */ + "hasEqualUnresolvedSignature\0" /* 891 */ + "level\0" /* 919 */ + "PHPStan\\Type\\VerbosityLevel\0" /* 925 */ + "describe\0" /* 953 */ + "describeCallable\0" /* 962 */ + "isOffsetAccessLegal\0" /* 979 */ + "isObject\0" /* 999 */ + "getClassStringType\0" /* 1008 */ + "isEnum\0" /* 1027 */ + "ancestorClassName\0" /* 1034 */ + "templateTypeName\0" /* 1052 */ + "getTemplateType\0" /* 1069 */ + "canAccessProperties\0" /* 1085 */ + "propertyName\0" /* 1105 */ + "hasProperty\0" /* 1118 */ + "scope\0" /* 1130 */ + "PHPStan\\Reflection\\ClassMemberAccessAnswerer\0" /* 1136 */ + "PHPStan\\Reflection\\ExtendedPropertyReflection\0" /* 1181 */ + "getProperty\0" /* 1227 */ + "PHPStan\\Reflection\\Type\\UnresolvedPropertyPrototypeReflection\0" /* 1239 */ + "getUnresolvedPropertyPrototype\0" /* 1301 */ + "hasInstanceProperty\0" /* 1332 */ + "getInstanceProperty\0" /* 1352 */ + "getUnresolvedInstancePropertyPrototype\0" /* 1372 */ + "hasStaticProperty\0" /* 1411 */ + "getStaticProperty\0" /* 1429 */ + "getUnresolvedStaticPropertyPrototype\0" /* 1447 */ + "canCallMethods\0" /* 1484 */ + "methodName\0" /* 1499 */ + "hasMethod\0" /* 1510 */ + "PHPStan\\Reflection\\ExtendedMethodReflection\0" /* 1520 */ + "getMethod\0" /* 1564 */ + "PHPStan\\Reflection\\Type\\UnresolvedMethodPrototypeReflection\0" /* 1574 */ + "getUnresolvedMethodPrototype\0" /* 1634 */ + "canAccessConstants\0" /* 1663 */ + "constantName\0" /* 1682 */ + "hasConstant\0" /* 1695 */ + "PHPStan\\Reflection\\ClassConstantReflection\0" /* 1707 */ + "getConstant\0" /* 1750 */ + "getConstantStrings\0" /* 1762 */ + "isIterable\0" /* 1781 */ + "isIterableAtLeastOnce\0" /* 1792 */ + "isCallable\0" /* 1814 */ + "getEnumCases\0" /* 1825 */ + "PHPStan\\Type\\Enum\\EnumCaseObjectType\0" /* 1838 */ + "getEnumCaseObject\0" /* 1875 */ + "isCommonCallable\0" /* 1893 */ + "getCallableParametersAcceptors\0" /* 1910 */ + "getThrowPoints\0" /* 1941 */ + "getImpurePoints\0" /* 1956 */ + "getInvalidateExpressions\0" /* 1972 */ + "getUsedVariables\0" /* 1997 */ + "getByRefUseTypes\0" /* 2014 */ + "getOrigin\0" /* 2031 */ + "containsUnresolvedTemplateArgument\0" /* 2041 */ + "isStaticClosure\0" /* 2076 */ + "isCloneable\0" /* 2092 */ + "PHPStan\\Type\\BooleanType\0" /* 2104 */ + "toBoolean\0" /* 2129 */ + "toNumber\0" /* 2139 */ + "toBitwiseNotType\0" /* 2148 */ + "toGetClassResultType\0" /* 2165 */ + "reflectionProvider\0" /* 2186 */ + "PHPStan\\Reflection\\ReflectionProvider\0" /* 2205 */ + "toClassConstantType\0" /* 2243 */ + "PHPStan\\Type\\ClassNameToObjectTypeResult\0" /* 2263 */ + "toObjectTypeForInstanceofCheck\0" /* 2304 */ + "objectOrClassType\0" /* 2335 */ + "allowString\0" /* 2353 */ + "allowSameClass\0" /* 2365 */ + "toObjectTypeForIsACheck\0" /* 2380 */ + "toAbsoluteNumber\0" /* 2404 */ + "toInteger\0" /* 2421 */ + "toFloat\0" /* 2431 */ + "toString\0" /* 2439 */ + "toArray\0" /* 2448 */ + "toArrayKey\0" /* 2456 */ + "toCoercedArgumentType\0" /* 2467 */ + "getTemplateTypeMap\0" /* 2489 */ + "getResolvedTemplateTypeMap\0" /* 2508 */ + "getCallSiteVarianceMap\0" /* 2535 */ + "getParameters\0" /* 2558 */ + "isVariadic\0" /* 2572 */ + "getReturnType\0" /* 2583 */ + "receivedType\0" /* 2597 */ + "inferTemplateTypes\0" /* 2610 */ + "parametersAcceptor\0" /* 2629 */ + "PHPStan\\Reflection\\ParametersAcceptor\0" /* 2648 */ + "inferTemplateTypesOnParametersAcceptor\0" /* 2686 */ + "positionVariance\0" /* 2725 */ + "PHPStan\\Type\\Generic\\TemplateTypeVariance\0" /* 2742 */ + "getReferencedTemplateTypes\0" /* 2784 */ + "cb\0" /* 2811 */ + "traverse\0" /* 2814 */ + "right\0" /* 2823 */ + "traverseSimultaneously\0" /* 2829 */ + "isNull\0" /* 2852 */ + "isConstantValue\0" /* 2859 */ + "isConstantScalarValue\0" /* 2875 */ + "getConstantScalarTypes\0" /* 2897 */ + "getConstantScalarValues\0" /* 2920 */ + "isTrue\0" /* 2944 */ + "isFalse\0" /* 2951 */ + "isBoolean\0" /* 2959 */ + "isFloat\0" /* 2969 */ + "isInteger\0" /* 2977 */ + "isString\0" /* 2987 */ + "isNumericString\0" /* 2996 */ + "isDecimalIntegerString\0" /* 3012 */ + "isNonEmptyString\0" /* 3035 */ + "isNonFalsyString\0" /* 3052 */ + "isLiteralString\0" /* 3069 */ + "isLowercaseString\0" /* 3085 */ + "isClassString\0" /* 3103 */ + "isUppercaseString\0" /* 3117 */ + "getClassStringObjectType\0" /* 3135 */ + "getObjectTypeOrClassStringObjectType\0" /* 3160 */ + "isVoid\0" /* 3197 */ + "isScalar\0" /* 3204 */ + "phpVersion\0" /* 3213 */ + "PHPStan\\Php\\PhpVersion\0" /* 3224 */ + "looseCompare\0" /* 3247 */ + "exponent\0" /* 3260 */ + "arithmeticPower\0" /* 3269 */ + "getFiniteTypes\0" /* 3285 */ + "PHPStan\\PhpDocParser\\Ast\\Type\\TypeNode\0" /* 3300 */ + "toPhpDocNode\0" /* 3339 */ + "position\0" /* 3352 */ + "PHPStan\\Type\\NativeTypePosition\0" /* 3361 */ + "toNativePhpTypeNode\0" /* 3393 */ + "hasTemplateOrLateResolvableType\0" /* 3413 */ + "PHPStan\\Type\\ValueSet\0" /* 3445 */ + "toValueSet"; /* 3467 */ inline constexpr reg::PackedArg args[] = { reg::packed(0, MAY_BE_NULL | MAY_BE_ARRAY, reg::NoString, false, false, 11), /* __construct $parameters */ reg::packed(16, MAY_BE_NULL, 27, false, false, 11), /* __construct $returnType */ @@ -276,287 +284,294 @@ inline constexpr reg::PackedArg args[] = { reg::packed(340, MAY_BE_NULL, 351, false, false, 11), /* __construct $assertions */ reg::packed(381, MAY_BE_NULL, 300, false, false, 11), /* __construct $isStatic */ reg::packed(390, MAY_BE_ARRAY, reg::NoString, false, false, 214), /* __construct $byRefUseTypes */ - reg::packed(416, 0, 351), /* getAsserts return */ - reg::packed(416, MAY_BE_ARRAY), /* getTemplateTags return */ - reg::packed(416, 0, 444), /* createPure return */ - reg::packed(416, 0, 300), /* isPure return */ - reg::packed(416, MAY_BE_STRING), /* getClassName return */ - reg::packed(416, MAY_BE_NULL, 500), /* getClassReflection return */ - reg::packed(554, MAY_BE_STRING), /* getAncestorWithClassName $className */ - reg::packed(416, MAY_BE_NULL, 564), /* getAncestorWithClassName return */ - reg::packed(416, MAY_BE_ARRAY), /* getReferencedClasses return */ - reg::packed(416, MAY_BE_ARRAY), /* getObjectClassNames return */ - reg::packed(416, MAY_BE_ARRAY), /* getObjectClassReflections return */ - reg::packed(687, 0, 27), /* accepts $type */ - reg::packed(692, MAY_BE_BOOL), /* accepts $strictTypes */ - reg::packed(416, 0, 704), /* accepts return */ - reg::packed(687, 0, 27), /* isSuperTypeOf $type */ - reg::packed(416, 0, 739), /* isSuperTypeOf return */ - reg::packed(687, 0, 27), /* isSuperTypeOfInternal $type */ - reg::packed(786, MAY_BE_BOOL), /* isSuperTypeOfInternal $treatMixedAsAny */ - reg::packed(692, MAY_BE_BOOL, reg::NoString, false, false, 54), /* isSuperTypeOfInternal $strictTypes */ - reg::packed(416, 0, 739), /* isSuperTypeOfInternal return */ - reg::packed(687, 0, 27), /* equals $type */ - reg::packed(416, MAY_BE_BOOL), /* equals return */ - reg::packed(831, 0, 444), /* hasEqualUnresolvedSignature $other */ - reg::packed(416, MAY_BE_BOOL), /* hasEqualUnresolvedSignature return */ - reg::packed(865, 0, 871), /* describe $level */ - reg::packed(416, MAY_BE_STRING), /* describe return */ - reg::packed(416, MAY_BE_STRING), /* describeCallable return */ - reg::packed(416, 0, 300), /* isOffsetAccessLegal return */ - reg::packed(416, 0, 300), /* isObject return */ - reg::packed(416, 0, 27), /* getClassStringType return */ - reg::packed(416, 0, 300), /* isEnum return */ - reg::packed(980, MAY_BE_STRING), /* getTemplateType $ancestorClassName */ - reg::packed(998, MAY_BE_STRING), /* getTemplateType $templateTypeName */ - reg::packed(416, 0, 27), /* getTemplateType return */ - reg::packed(416, 0, 300), /* canAccessProperties return */ - reg::packed(1051, MAY_BE_STRING), /* hasProperty $propertyName */ - reg::packed(416, 0, 300), /* hasProperty return */ - reg::packed(1051, MAY_BE_STRING), /* getProperty $propertyName */ - reg::packed(1076, 0, 1082), /* getProperty $scope */ - reg::packed(416, 0, 1127), /* getProperty return */ - reg::packed(1051, MAY_BE_STRING), /* getUnresolvedPropertyPrototype $propertyName */ - reg::packed(1076, 0, 1082), /* getUnresolvedPropertyPrototype $scope */ - reg::packed(416, 0, 1185), /* getUnresolvedPropertyPrototype return */ - reg::packed(1051, MAY_BE_STRING), /* hasInstanceProperty $propertyName */ - reg::packed(416, 0, 300), /* hasInstanceProperty return */ - reg::packed(1051, MAY_BE_STRING), /* getInstanceProperty $propertyName */ - reg::packed(1076, 0, 1082), /* getInstanceProperty $scope */ - reg::packed(416, 0, 1127), /* getInstanceProperty return */ - reg::packed(1051, MAY_BE_STRING), /* getUnresolvedInstancePropertyPrototype $propertyName */ - reg::packed(1076, 0, 1082), /* getUnresolvedInstancePropertyPrototype $scope */ - reg::packed(416, 0, 1185), /* getUnresolvedInstancePropertyPrototype return */ - reg::packed(1051, MAY_BE_STRING), /* hasStaticProperty $propertyName */ - reg::packed(416, 0, 300), /* hasStaticProperty return */ - reg::packed(1051, MAY_BE_STRING), /* getStaticProperty $propertyName */ - reg::packed(1076, 0, 1082), /* getStaticProperty $scope */ - reg::packed(416, 0, 1127), /* getStaticProperty return */ - reg::packed(1051, MAY_BE_STRING), /* getUnresolvedStaticPropertyPrototype $propertyName */ - reg::packed(1076, 0, 1082), /* getUnresolvedStaticPropertyPrototype $scope */ - reg::packed(416, 0, 1185), /* getUnresolvedStaticPropertyPrototype return */ - reg::packed(416, 0, 300), /* canCallMethods return */ - reg::packed(1445, MAY_BE_STRING), /* hasMethod $methodName */ - reg::packed(416, 0, 300), /* hasMethod return */ - reg::packed(1445, MAY_BE_STRING), /* getMethod $methodName */ - reg::packed(1076, 0, 1082), /* getMethod $scope */ - reg::packed(416, 0, 1466), /* getMethod return */ - reg::packed(1445, MAY_BE_STRING), /* getUnresolvedMethodPrototype $methodName */ - reg::packed(1076, 0, 1082), /* getUnresolvedMethodPrototype $scope */ - reg::packed(416, 0, 1520), /* getUnresolvedMethodPrototype return */ - reg::packed(416, 0, 300), /* canAccessConstants return */ - reg::packed(1628, MAY_BE_STRING), /* hasConstant $constantName */ - reg::packed(416, 0, 300), /* hasConstant return */ - reg::packed(1628, MAY_BE_STRING), /* getConstant $constantName */ - reg::packed(416, 0, 1653), /* getConstant return */ - reg::packed(416, MAY_BE_ARRAY), /* getConstantStrings return */ - reg::packed(416, 0, 300), /* isIterable return */ - reg::packed(416, 0, 300), /* isIterableAtLeastOnce return */ - reg::packed(416, 0, 300), /* isCallable return */ - reg::packed(416, MAY_BE_ARRAY), /* getEnumCases return */ - reg::packed(416, MAY_BE_NULL, 1784), /* getEnumCaseObject return */ - reg::packed(416, MAY_BE_BOOL), /* isCommonCallable return */ - reg::packed(1076, 0, 1082), /* getCallableParametersAcceptors $scope */ - reg::packed(416, MAY_BE_ARRAY), /* getCallableParametersAcceptors return */ - reg::packed(416, MAY_BE_ARRAY), /* getThrowPoints return */ - reg::packed(416, MAY_BE_ARRAY), /* getImpurePoints return */ - reg::packed(416, MAY_BE_ARRAY), /* getInvalidateExpressions return */ - reg::packed(416, MAY_BE_ARRAY), /* getUsedVariables return */ - reg::packed(416, MAY_BE_ARRAY), /* getByRefUseTypes return */ - reg::packed(416, MAY_BE_BOOL), /* containsUnresolvedTemplateArgument return */ - reg::packed(416, 0, 300), /* acceptsNamedArguments return */ - reg::packed(416, 0, 300), /* mustUseReturnValue return */ - reg::packed(416, 0, 300), /* isStaticClosure return */ - reg::packed(416, 0, 300), /* isCloneable return */ - reg::packed(416, 0, 2040), /* toBoolean return */ - reg::packed(416, 0, 27), /* toNumber return */ - reg::packed(416, 0, 27), /* toBitwiseNotType return */ - reg::packed(416, 0, 27), /* toGetClassResultType return */ - reg::packed(2122, 0, 2141), /* toClassConstantType $reflectionProvider */ - reg::packed(416, 0, 27), /* toClassConstantType return */ - reg::packed(416, 0, 2199), /* toObjectTypeForInstanceofCheck return */ - reg::packed(2271, 0, 27), /* toObjectTypeForIsACheck $objectOrClassType */ - reg::packed(2289, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowString */ - reg::packed(2301, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowSameClass */ - reg::packed(416, 0, 2199), /* toObjectTypeForIsACheck return */ - reg::packed(416, 0, 27), /* toAbsoluteNumber return */ - reg::packed(416, 0, 27), /* toInteger return */ - reg::packed(416, 0, 27), /* toFloat return */ - reg::packed(416, 0, 27), /* toString return */ - reg::packed(416, 0, 27), /* toArray return */ - reg::packed(416, 0, 27), /* toArrayKey return */ - reg::packed(692, MAY_BE_BOOL), /* toCoercedArgumentType $strictTypes */ - reg::packed(416, 0, 27), /* toCoercedArgumentType return */ - reg::packed(416, 0, 75), /* getTemplateTypeMap return */ - reg::packed(416, 0, 75), /* getResolvedTemplateTypeMap return */ - reg::packed(416, 0, 156), /* getCallSiteVarianceMap return */ - reg::packed(416, MAY_BE_ARRAY), /* getParameters return */ - reg::packed(416, MAY_BE_BOOL), /* isVariadic return */ - reg::packed(416, 0, 27), /* getReturnType return */ - reg::packed(2533, 0, 27), /* inferTemplateTypes $receivedType */ - reg::packed(416, 0, 75), /* inferTemplateTypes return */ - reg::packed(2565, 0, 2584), /* inferTemplateTypesOnParametersAcceptor $parametersAcceptor */ - reg::packed(416, 0, 75), /* inferTemplateTypesOnParametersAcceptor return */ - reg::packed(2661, 0, 2678), /* getReferencedTemplateTypes $positionVariance */ - reg::packed(416, MAY_BE_ARRAY), /* getReferencedTemplateTypes return */ - reg::packed(2747, MAY_BE_CALLABLE), /* traverse $cb */ - reg::packed(416, 0, 27), /* traverse return */ - reg::packed(2759, 0, 27), /* traverseSimultaneously $right */ - reg::packed(2747, MAY_BE_CALLABLE), /* traverseSimultaneously $cb */ - reg::packed(416, 0, 27), /* traverseSimultaneously return */ - reg::packed(416, 0, 300), /* isNull return */ - reg::packed(416, 0, 300), /* isConstantValue return */ - reg::packed(416, 0, 300), /* isConstantScalarValue return */ - reg::packed(416, MAY_BE_ARRAY), /* getConstantScalarTypes return */ - reg::packed(416, MAY_BE_ARRAY), /* getConstantScalarValues return */ - reg::packed(416, 0, 300), /* isTrue return */ - reg::packed(416, 0, 300), /* isFalse return */ - reg::packed(416, 0, 300), /* isBoolean return */ - reg::packed(416, 0, 300), /* isFloat return */ - reg::packed(416, 0, 300), /* isInteger return */ - reg::packed(416, 0, 300), /* isString return */ - reg::packed(416, 0, 300), /* isNumericString return */ - reg::packed(416, 0, 300), /* isDecimalIntegerString return */ - reg::packed(416, 0, 300), /* isNonEmptyString return */ - reg::packed(416, 0, 300), /* isNonFalsyString return */ - reg::packed(416, 0, 300), /* isLiteralString return */ - reg::packed(416, 0, 300), /* isLowercaseString return */ - reg::packed(416, 0, 300), /* isClassString return */ - reg::packed(416, 0, 300), /* isUppercaseString return */ - reg::packed(416, 0, 27), /* getClassStringObjectType return */ - reg::packed(416, 0, 27), /* getObjectTypeOrClassStringObjectType return */ - reg::packed(416, 0, 300), /* isVoid return */ - reg::packed(416, 0, 300), /* isScalar return */ - reg::packed(687, 0, 27), /* looseCompare $type */ - reg::packed(3149, 0, 3160), /* looseCompare $phpVersion */ - reg::packed(416, 0, 2040), /* looseCompare return */ - reg::packed(3196, 0, 27), /* arithmeticPower $exponent */ - reg::packed(3149, 0, 3160), /* arithmeticPower $phpVersion */ - reg::packed(416, 0, 27), /* arithmeticPower return */ - reg::packed(416, MAY_BE_ARRAY), /* getFiniteTypes return */ - reg::packed(416, 0, 3236), /* toPhpDocNode return */ - reg::packed(3288, 0, 3297), /* toNativePhpTypeNode $position */ - reg::packed(416, MAY_BE_BOOL), /* hasTemplateOrLateResolvableType return */ - reg::packed(416, 0, 3381), /* toValueSet return */ + reg::packed(404, MAY_BE_NULL, 411, false, false, 11), /* __construct $origin */ + reg::packed(450, 0, 351), /* getAsserts return */ + reg::packed(450, MAY_BE_ARRAY), /* getTemplateTags return */ + reg::packed(450, 0, 478), /* createPure return */ + reg::packed(450, 0, 300), /* isPure return */ + reg::packed(450, MAY_BE_STRING), /* getClassName return */ + reg::packed(450, MAY_BE_NULL, 534), /* getClassReflection return */ + reg::packed(588, MAY_BE_STRING), /* getAncestorWithClassName $className */ + reg::packed(450, MAY_BE_NULL, 598), /* getAncestorWithClassName return */ + reg::packed(450, MAY_BE_ARRAY), /* getReferencedClasses return */ + reg::packed(450, MAY_BE_ARRAY), /* getObjectClassNames return */ + reg::packed(450, MAY_BE_ARRAY), /* getObjectClassReflections return */ + reg::packed(721, 0, 27), /* accepts $type */ + reg::packed(726, MAY_BE_BOOL), /* accepts $strictTypes */ + reg::packed(450, 0, 738), /* accepts return */ + reg::packed(721, 0, 27), /* isSuperTypeOf $type */ + reg::packed(450, 0, 773), /* isSuperTypeOf return */ + reg::packed(721, 0, 27), /* isSuperTypeOfInternal $type */ + reg::packed(820, MAY_BE_BOOL), /* isSuperTypeOfInternal $treatMixedAsAny */ + reg::packed(726, MAY_BE_BOOL, reg::NoString, false, false, 54), /* isSuperTypeOfInternal $strictTypes */ + reg::packed(450, 0, 773), /* isSuperTypeOfInternal return */ + reg::packed(721, 0, 27), /* equals $type */ + reg::packed(450, MAY_BE_BOOL), /* equals return */ + reg::packed(865, 0, 478), /* hasEqualOrigins $a */ + reg::packed(867, 0, 478), /* hasEqualOrigins $b */ + reg::packed(450, MAY_BE_BOOL), /* hasEqualOrigins return */ + reg::packed(885, 0, 478), /* hasEqualUnresolvedSignature $other */ + reg::packed(450, MAY_BE_BOOL), /* hasEqualUnresolvedSignature return */ + reg::packed(919, 0, 925), /* describe $level */ + reg::packed(450, MAY_BE_STRING), /* describe return */ + reg::packed(450, MAY_BE_STRING), /* describeCallable return */ + reg::packed(450, 0, 300), /* isOffsetAccessLegal return */ + reg::packed(450, 0, 300), /* isObject return */ + reg::packed(450, 0, 27), /* getClassStringType return */ + reg::packed(450, 0, 300), /* isEnum return */ + reg::packed(1034, MAY_BE_STRING), /* getTemplateType $ancestorClassName */ + reg::packed(1052, MAY_BE_STRING), /* getTemplateType $templateTypeName */ + reg::packed(450, 0, 27), /* getTemplateType return */ + reg::packed(450, 0, 300), /* canAccessProperties return */ + reg::packed(1105, MAY_BE_STRING), /* hasProperty $propertyName */ + reg::packed(450, 0, 300), /* hasProperty return */ + reg::packed(1105, MAY_BE_STRING), /* getProperty $propertyName */ + reg::packed(1130, 0, 1136), /* getProperty $scope */ + reg::packed(450, 0, 1181), /* getProperty return */ + reg::packed(1105, MAY_BE_STRING), /* getUnresolvedPropertyPrototype $propertyName */ + reg::packed(1130, 0, 1136), /* getUnresolvedPropertyPrototype $scope */ + reg::packed(450, 0, 1239), /* getUnresolvedPropertyPrototype return */ + reg::packed(1105, MAY_BE_STRING), /* hasInstanceProperty $propertyName */ + reg::packed(450, 0, 300), /* hasInstanceProperty return */ + reg::packed(1105, MAY_BE_STRING), /* getInstanceProperty $propertyName */ + reg::packed(1130, 0, 1136), /* getInstanceProperty $scope */ + reg::packed(450, 0, 1181), /* getInstanceProperty return */ + reg::packed(1105, MAY_BE_STRING), /* getUnresolvedInstancePropertyPrototype $propertyName */ + reg::packed(1130, 0, 1136), /* getUnresolvedInstancePropertyPrototype $scope */ + reg::packed(450, 0, 1239), /* getUnresolvedInstancePropertyPrototype return */ + reg::packed(1105, MAY_BE_STRING), /* hasStaticProperty $propertyName */ + reg::packed(450, 0, 300), /* hasStaticProperty return */ + reg::packed(1105, MAY_BE_STRING), /* getStaticProperty $propertyName */ + reg::packed(1130, 0, 1136), /* getStaticProperty $scope */ + reg::packed(450, 0, 1181), /* getStaticProperty return */ + reg::packed(1105, MAY_BE_STRING), /* getUnresolvedStaticPropertyPrototype $propertyName */ + reg::packed(1130, 0, 1136), /* getUnresolvedStaticPropertyPrototype $scope */ + reg::packed(450, 0, 1239), /* getUnresolvedStaticPropertyPrototype return */ + reg::packed(450, 0, 300), /* canCallMethods return */ + reg::packed(1499, MAY_BE_STRING), /* hasMethod $methodName */ + reg::packed(450, 0, 300), /* hasMethod return */ + reg::packed(1499, MAY_BE_STRING), /* getMethod $methodName */ + reg::packed(1130, 0, 1136), /* getMethod $scope */ + reg::packed(450, 0, 1520), /* getMethod return */ + reg::packed(1499, MAY_BE_STRING), /* getUnresolvedMethodPrototype $methodName */ + reg::packed(1130, 0, 1136), /* getUnresolvedMethodPrototype $scope */ + reg::packed(450, 0, 1574), /* getUnresolvedMethodPrototype return */ + reg::packed(450, 0, 300), /* canAccessConstants return */ + reg::packed(1682, MAY_BE_STRING), /* hasConstant $constantName */ + reg::packed(450, 0, 300), /* hasConstant return */ + reg::packed(1682, MAY_BE_STRING), /* getConstant $constantName */ + reg::packed(450, 0, 1707), /* getConstant return */ + reg::packed(450, MAY_BE_ARRAY), /* getConstantStrings return */ + reg::packed(450, 0, 300), /* isIterable return */ + reg::packed(450, 0, 300), /* isIterableAtLeastOnce return */ + reg::packed(450, 0, 300), /* isCallable return */ + reg::packed(450, MAY_BE_ARRAY), /* getEnumCases return */ + reg::packed(450, MAY_BE_NULL, 1838), /* getEnumCaseObject return */ + reg::packed(450, MAY_BE_BOOL), /* isCommonCallable return */ + reg::packed(1130, 0, 1136), /* getCallableParametersAcceptors $scope */ + reg::packed(450, MAY_BE_ARRAY), /* getCallableParametersAcceptors return */ + reg::packed(450, MAY_BE_ARRAY), /* getThrowPoints return */ + reg::packed(450, MAY_BE_ARRAY), /* getImpurePoints return */ + reg::packed(450, MAY_BE_ARRAY), /* getInvalidateExpressions return */ + reg::packed(450, MAY_BE_ARRAY), /* getUsedVariables return */ + reg::packed(450, MAY_BE_ARRAY), /* getByRefUseTypes return */ + reg::packed(450, MAY_BE_NULL, 411), /* getOrigin return */ + reg::packed(450, MAY_BE_BOOL), /* containsUnresolvedTemplateArgument return */ + reg::packed(450, 0, 300), /* acceptsNamedArguments return */ + reg::packed(450, 0, 300), /* mustUseReturnValue return */ + reg::packed(450, 0, 300), /* isStaticClosure return */ + reg::packed(450, 0, 300), /* isCloneable return */ + reg::packed(450, 0, 2104), /* toBoolean return */ + reg::packed(450, 0, 27), /* toNumber return */ + reg::packed(450, 0, 27), /* toBitwiseNotType return */ + reg::packed(450, 0, 27), /* toGetClassResultType return */ + reg::packed(2186, 0, 2205), /* toClassConstantType $reflectionProvider */ + reg::packed(450, 0, 27), /* toClassConstantType return */ + reg::packed(450, 0, 2263), /* toObjectTypeForInstanceofCheck return */ + reg::packed(2335, 0, 27), /* toObjectTypeForIsACheck $objectOrClassType */ + reg::packed(2353, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowString */ + reg::packed(2365, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowSameClass */ + reg::packed(450, 0, 2263), /* toObjectTypeForIsACheck return */ + reg::packed(450, 0, 27), /* toAbsoluteNumber return */ + reg::packed(450, 0, 27), /* toInteger return */ + reg::packed(450, 0, 27), /* toFloat return */ + reg::packed(450, 0, 27), /* toString return */ + reg::packed(450, 0, 27), /* toArray return */ + reg::packed(450, 0, 27), /* toArrayKey return */ + reg::packed(726, MAY_BE_BOOL), /* toCoercedArgumentType $strictTypes */ + reg::packed(450, 0, 27), /* toCoercedArgumentType return */ + reg::packed(450, 0, 75), /* getTemplateTypeMap return */ + reg::packed(450, 0, 75), /* getResolvedTemplateTypeMap return */ + reg::packed(450, 0, 156), /* getCallSiteVarianceMap return */ + reg::packed(450, MAY_BE_ARRAY), /* getParameters return */ + reg::packed(450, MAY_BE_BOOL), /* isVariadic return */ + reg::packed(450, 0, 27), /* getReturnType return */ + reg::packed(2597, 0, 27), /* inferTemplateTypes $receivedType */ + reg::packed(450, 0, 75), /* inferTemplateTypes return */ + reg::packed(2629, 0, 2648), /* inferTemplateTypesOnParametersAcceptor $parametersAcceptor */ + reg::packed(450, 0, 75), /* inferTemplateTypesOnParametersAcceptor return */ + reg::packed(2725, 0, 2742), /* getReferencedTemplateTypes $positionVariance */ + reg::packed(450, MAY_BE_ARRAY), /* getReferencedTemplateTypes return */ + reg::packed(2811, MAY_BE_CALLABLE), /* traverse $cb */ + reg::packed(450, 0, 27), /* traverse return */ + reg::packed(2823, 0, 27), /* traverseSimultaneously $right */ + reg::packed(2811, MAY_BE_CALLABLE), /* traverseSimultaneously $cb */ + reg::packed(450, 0, 27), /* traverseSimultaneously return */ + reg::packed(450, 0, 300), /* isNull return */ + reg::packed(450, 0, 300), /* isConstantValue return */ + reg::packed(450, 0, 300), /* isConstantScalarValue return */ + reg::packed(450, MAY_BE_ARRAY), /* getConstantScalarTypes return */ + reg::packed(450, MAY_BE_ARRAY), /* getConstantScalarValues return */ + reg::packed(450, 0, 300), /* isTrue return */ + reg::packed(450, 0, 300), /* isFalse return */ + reg::packed(450, 0, 300), /* isBoolean return */ + reg::packed(450, 0, 300), /* isFloat return */ + reg::packed(450, 0, 300), /* isInteger return */ + reg::packed(450, 0, 300), /* isString return */ + reg::packed(450, 0, 300), /* isNumericString return */ + reg::packed(450, 0, 300), /* isDecimalIntegerString return */ + reg::packed(450, 0, 300), /* isNonEmptyString return */ + reg::packed(450, 0, 300), /* isNonFalsyString return */ + reg::packed(450, 0, 300), /* isLiteralString return */ + reg::packed(450, 0, 300), /* isLowercaseString return */ + reg::packed(450, 0, 300), /* isClassString return */ + reg::packed(450, 0, 300), /* isUppercaseString return */ + reg::packed(450, 0, 27), /* getClassStringObjectType return */ + reg::packed(450, 0, 27), /* getObjectTypeOrClassStringObjectType return */ + reg::packed(450, 0, 300), /* isVoid return */ + reg::packed(450, 0, 300), /* isScalar return */ + reg::packed(721, 0, 27), /* looseCompare $type */ + reg::packed(3213, 0, 3224), /* looseCompare $phpVersion */ + reg::packed(450, 0, 2104), /* looseCompare return */ + reg::packed(3260, 0, 27), /* arithmeticPower $exponent */ + reg::packed(3213, 0, 3224), /* arithmeticPower $phpVersion */ + reg::packed(450, 0, 27), /* arithmeticPower return */ + reg::packed(450, MAY_BE_ARRAY), /* getFiniteTypes return */ + reg::packed(450, 0, 3300), /* toPhpDocNode return */ + reg::packed(3352, 0, 3361), /* toNativePhpTypeNode $position */ + reg::packed(450, MAY_BE_BOOL), /* hasTemplateOrLateResolvableType return */ + reg::packed(450, 0, 3445), /* toValueSet return */ }; using Sig = reg::Sig; } // namespace sigtab /* the signatures of the methods the class declares itself (a used trait's are in the trait's header) */ namespace sig { -inline constexpr sigtab::Sig __construct = { { 404 /* __construct */, 0, 0, 16, reg::NoArg, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getAsserts = { { 417 /* getAsserts */, 0, 16, 0, 16, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getTemplateTags = { { 428 /* getTemplateTags */, 0, 17, 0, 17, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig createPure = { { 469 /* createPure */, 0, 18, 0, 18, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC } }; -inline constexpr sigtab::Sig isPure = { { 480 /* isPure */, 0, 19, 0, 19, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getClassName = { { 487 /* getClassName */, 0, 20, 0, 20, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getClassReflection = { { 535 /* getClassReflection */, 0, 21, 0, 21, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getAncestorWithClassName = { { 595 /* getAncestorWithClassName */, 1, 22, 1, 23, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getReferencedClasses = { { 620 /* getReferencedClasses */, 0, 24, 0, 24, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getObjectClassNames = { { 641 /* getObjectClassNames */, 0, 25, 0, 25, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getObjectClassReflections = { { 661 /* getObjectClassReflections */, 0, 26, 0, 26, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig accepts = { { 731 /* accepts */, 2, 27, 2, 29, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isSuperTypeOf = { { 772 /* isSuperTypeOf */, 1, 30, 1, 31, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isSuperTypeOfInternal = { { 802 /* isSuperTypeOfInternal */, 2, 32, 3, 35, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig equals = { { 824 /* equals */, 1, 36, 1, 37, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasEqualUnresolvedSignature = { { 837 /* hasEqualUnresolvedSignature */, 1, 38, 1, 39, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig describe = { { 899 /* describe */, 1, 40, 1, 41, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig describeCallable = { { 908 /* describeCallable */, 0, 42, 0, 42, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig isOffsetAccessLegal = { { 925 /* isOffsetAccessLegal */, 0, 43, 0, 43, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isObject = { { 945 /* isObject */, 0, 44, 0, 44, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getClassStringType = { { 954 /* getClassStringType */, 0, 45, 0, 45, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isEnum = { { 973 /* isEnum */, 0, 46, 0, 46, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getTemplateType = { { 1015 /* getTemplateType */, 2, 47, 2, 49, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig canAccessProperties = { { 1031 /* canAccessProperties */, 0, 50, 0, 50, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasProperty = { { 1064 /* hasProperty */, 1, 51, 1, 52, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getProperty = { { 1173 /* getProperty */, 2, 53, 2, 55, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedPropertyPrototype = { { 1247 /* getUnresolvedPropertyPrototype */, 2, 56, 2, 58, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasInstanceProperty = { { 1278 /* hasInstanceProperty */, 1, 59, 1, 60, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getInstanceProperty = { { 1298 /* getInstanceProperty */, 2, 61, 2, 63, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedInstancePropertyPrototype = { { 1318 /* getUnresolvedInstancePropertyPrototype */, 2, 64, 2, 66, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasStaticProperty = { { 1357 /* hasStaticProperty */, 1, 67, 1, 68, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getStaticProperty = { { 1375 /* getStaticProperty */, 2, 69, 2, 71, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedStaticPropertyPrototype = { { 1393 /* getUnresolvedStaticPropertyPrototype */, 2, 72, 2, 74, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig canCallMethods = { { 1430 /* canCallMethods */, 0, 75, 0, 75, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasMethod = { { 1456 /* hasMethod */, 1, 76, 1, 77, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getMethod = { { 1510 /* getMethod */, 2, 78, 2, 80, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedMethodPrototype = { { 1580 /* getUnresolvedMethodPrototype */, 2, 81, 2, 83, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig canAccessConstants = { { 1609 /* canAccessConstants */, 0, 84, 0, 84, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasConstant = { { 1641 /* hasConstant */, 1, 85, 1, 86, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstant = { { 1696 /* getConstant */, 1, 87, 1, 88, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstantStrings = { { 1708 /* getConstantStrings */, 0, 89, 0, 89, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isIterable = { { 1727 /* isIterable */, 0, 90, 0, 90, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isIterableAtLeastOnce = { { 1738 /* isIterableAtLeastOnce */, 0, 91, 0, 91, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isCallable = { { 1760 /* isCallable */, 0, 92, 0, 92, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getEnumCases = { { 1771 /* getEnumCases */, 0, 93, 0, 93, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getEnumCaseObject = { { 1821 /* getEnumCaseObject */, 0, 94, 0, 94, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isCommonCallable = { { 1839 /* isCommonCallable */, 0, 95, 0, 95, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getCallableParametersAcceptors = { { 1856 /* getCallableParametersAcceptors */, 1, 96, 1, 97, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getThrowPoints = { { 1887 /* getThrowPoints */, 0, 98, 0, 98, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getImpurePoints = { { 1902 /* getImpurePoints */, 0, 99, 0, 99, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getInvalidateExpressions = { { 1918 /* getInvalidateExpressions */, 0, 100, 0, 100, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUsedVariables = { { 1943 /* getUsedVariables */, 0, 101, 0, 101, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getByRefUseTypes = { { 1960 /* getByRefUseTypes */, 0, 102, 0, 102, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig containsUnresolvedTemplateArgument = { { 1977 /* containsUnresolvedTemplateArgument */, 0, 103, 0, 103, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig acceptsNamedArguments = { { 278 /* acceptsNamedArguments */, 0, 104, 0, 104, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig mustUseReturnValue = { { 321 /* mustUseReturnValue */, 0, 105, 0, 105, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isStaticClosure = { { 2012 /* isStaticClosure */, 0, 106, 0, 106, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isCloneable = { { 2028 /* isCloneable */, 0, 107, 0, 107, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toBoolean = { { 2065 /* toBoolean */, 0, 108, 0, 108, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toNumber = { { 2075 /* toNumber */, 0, 109, 0, 109, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toBitwiseNotType = { { 2084 /* toBitwiseNotType */, 0, 110, 0, 110, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toGetClassResultType = { { 2101 /* toGetClassResultType */, 0, 111, 0, 111, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toClassConstantType = { { 2179 /* toClassConstantType */, 1, 112, 1, 113, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toObjectTypeForInstanceofCheck = { { 2240 /* toObjectTypeForInstanceofCheck */, 0, 114, 0, 114, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toObjectTypeForIsACheck = { { 2316 /* toObjectTypeForIsACheck */, 3, 115, 3, 118, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toAbsoluteNumber = { { 2340 /* toAbsoluteNumber */, 0, 119, 0, 119, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toInteger = { { 2357 /* toInteger */, 0, 120, 0, 120, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toFloat = { { 2367 /* toFloat */, 0, 121, 0, 121, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toString = { { 2375 /* toString */, 0, 122, 0, 122, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toArray = { { 2384 /* toArray */, 0, 123, 0, 123, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toArrayKey = { { 2392 /* toArrayKey */, 0, 124, 0, 124, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toCoercedArgumentType = { { 2403 /* toCoercedArgumentType */, 1, 125, 1, 126, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getTemplateTypeMap = { { 2425 /* getTemplateTypeMap */, 0, 127, 0, 127, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getResolvedTemplateTypeMap = { { 2444 /* getResolvedTemplateTypeMap */, 0, 128, 0, 128, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getCallSiteVarianceMap = { { 2471 /* getCallSiteVarianceMap */, 0, 129, 0, 129, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getParameters = { { 2494 /* getParameters */, 0, 130, 0, 130, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isVariadic = { { 2508 /* isVariadic */, 0, 131, 0, 131, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getReturnType = { { 2519 /* getReturnType */, 0, 132, 0, 132, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig inferTemplateTypes = { { 2546 /* inferTemplateTypes */, 1, 133, 1, 134, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig inferTemplateTypesOnParametersAcceptor = { { 2622 /* inferTemplateTypesOnParametersAcceptor */, 1, 135, 1, 136, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getReferencedTemplateTypes = { { 2720 /* getReferencedTemplateTypes */, 1, 137, 1, 138, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig traverse = { { 2750 /* traverse */, 1, 139, 1, 140, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig traverseSimultaneously = { { 2765 /* traverseSimultaneously */, 2, 141, 2, 143, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNull = { { 2788 /* isNull */, 0, 144, 0, 144, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isConstantValue = { { 2795 /* isConstantValue */, 0, 145, 0, 145, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isConstantScalarValue = { { 2811 /* isConstantScalarValue */, 0, 146, 0, 146, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstantScalarTypes = { { 2833 /* getConstantScalarTypes */, 0, 147, 0, 147, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstantScalarValues = { { 2856 /* getConstantScalarValues */, 0, 148, 0, 148, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isTrue = { { 2880 /* isTrue */, 0, 149, 0, 149, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isFalse = { { 2887 /* isFalse */, 0, 150, 0, 150, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isBoolean = { { 2895 /* isBoolean */, 0, 151, 0, 151, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isFloat = { { 2905 /* isFloat */, 0, 152, 0, 152, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isInteger = { { 2913 /* isInteger */, 0, 153, 0, 153, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isString = { { 2923 /* isString */, 0, 154, 0, 154, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNumericString = { { 2932 /* isNumericString */, 0, 155, 0, 155, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isDecimalIntegerString = { { 2948 /* isDecimalIntegerString */, 0, 156, 0, 156, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNonEmptyString = { { 2971 /* isNonEmptyString */, 0, 157, 0, 157, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNonFalsyString = { { 2988 /* isNonFalsyString */, 0, 158, 0, 158, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isLiteralString = { { 3005 /* isLiteralString */, 0, 159, 0, 159, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isLowercaseString = { { 3021 /* isLowercaseString */, 0, 160, 0, 160, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isClassString = { { 3039 /* isClassString */, 0, 161, 0, 161, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isUppercaseString = { { 3053 /* isUppercaseString */, 0, 162, 0, 162, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getClassStringObjectType = { { 3071 /* getClassStringObjectType */, 0, 163, 0, 163, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getObjectTypeOrClassStringObjectType = { { 3096 /* getObjectTypeOrClassStringObjectType */, 0, 164, 0, 164, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isVoid = { { 3133 /* isVoid */, 0, 165, 0, 165, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isScalar = { { 3140 /* isScalar */, 0, 166, 0, 166, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig looseCompare = { { 3183 /* looseCompare */, 2, 167, 2, 169, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig arithmeticPower = { { 3205 /* arithmeticPower */, 2, 170, 2, 172, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getFiniteTypes = { { 3221 /* getFiniteTypes */, 0, 173, 0, 173, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toPhpDocNode = { { 3275 /* toPhpDocNode */, 0, 174, 0, 174, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toNativePhpTypeNode = { { 3329 /* toNativePhpTypeNode */, 1, 175, 1, reg::NoArg, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasTemplateOrLateResolvableType = { { 3349 /* hasTemplateOrLateResolvableType */, 0, 176, 0, 176, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toValueSet = { { 3403 /* toValueSet */, 0, 177, 0, 177, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig __construct = { { 438 /* __construct */, 0, 0, 17, reg::NoArg, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getAsserts = { { 451 /* getAsserts */, 0, 17, 0, 17, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getTemplateTags = { { 462 /* getTemplateTags */, 0, 18, 0, 18, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig createPure = { { 503 /* createPure */, 0, 19, 0, 19, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC } }; +inline constexpr sigtab::Sig isPure = { { 514 /* isPure */, 0, 20, 0, 20, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getClassName = { { 521 /* getClassName */, 0, 21, 0, 21, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getClassReflection = { { 569 /* getClassReflection */, 0, 22, 0, 22, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getAncestorWithClassName = { { 629 /* getAncestorWithClassName */, 1, 23, 1, 24, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getReferencedClasses = { { 654 /* getReferencedClasses */, 0, 25, 0, 25, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getObjectClassNames = { { 675 /* getObjectClassNames */, 0, 26, 0, 26, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getObjectClassReflections = { { 695 /* getObjectClassReflections */, 0, 27, 0, 27, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig accepts = { { 765 /* accepts */, 2, 28, 2, 30, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isSuperTypeOf = { { 806 /* isSuperTypeOf */, 1, 31, 1, 32, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isSuperTypeOfInternal = { { 836 /* isSuperTypeOfInternal */, 2, 33, 3, 36, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig equals = { { 858 /* equals */, 1, 37, 1, 38, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasEqualOrigins = { { 869 /* hasEqualOrigins */, 2, 39, 2, 41, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; +inline constexpr sigtab::Sig hasEqualUnresolvedSignature = { { 891 /* hasEqualUnresolvedSignature */, 1, 42, 1, 43, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig describe = { { 953 /* describe */, 1, 44, 1, 45, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig describeCallable = { { 962 /* describeCallable */, 0, 46, 0, 46, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig isOffsetAccessLegal = { { 979 /* isOffsetAccessLegal */, 0, 47, 0, 47, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isObject = { { 999 /* isObject */, 0, 48, 0, 48, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getClassStringType = { { 1008 /* getClassStringType */, 0, 49, 0, 49, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isEnum = { { 1027 /* isEnum */, 0, 50, 0, 50, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getTemplateType = { { 1069 /* getTemplateType */, 2, 51, 2, 53, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig canAccessProperties = { { 1085 /* canAccessProperties */, 0, 54, 0, 54, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasProperty = { { 1118 /* hasProperty */, 1, 55, 1, 56, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getProperty = { { 1227 /* getProperty */, 2, 57, 2, 59, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedPropertyPrototype = { { 1301 /* getUnresolvedPropertyPrototype */, 2, 60, 2, 62, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasInstanceProperty = { { 1332 /* hasInstanceProperty */, 1, 63, 1, 64, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getInstanceProperty = { { 1352 /* getInstanceProperty */, 2, 65, 2, 67, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedInstancePropertyPrototype = { { 1372 /* getUnresolvedInstancePropertyPrototype */, 2, 68, 2, 70, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasStaticProperty = { { 1411 /* hasStaticProperty */, 1, 71, 1, 72, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getStaticProperty = { { 1429 /* getStaticProperty */, 2, 73, 2, 75, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedStaticPropertyPrototype = { { 1447 /* getUnresolvedStaticPropertyPrototype */, 2, 76, 2, 78, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig canCallMethods = { { 1484 /* canCallMethods */, 0, 79, 0, 79, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasMethod = { { 1510 /* hasMethod */, 1, 80, 1, 81, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getMethod = { { 1564 /* getMethod */, 2, 82, 2, 84, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedMethodPrototype = { { 1634 /* getUnresolvedMethodPrototype */, 2, 85, 2, 87, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig canAccessConstants = { { 1663 /* canAccessConstants */, 0, 88, 0, 88, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasConstant = { { 1695 /* hasConstant */, 1, 89, 1, 90, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstant = { { 1750 /* getConstant */, 1, 91, 1, 92, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstantStrings = { { 1762 /* getConstantStrings */, 0, 93, 0, 93, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isIterable = { { 1781 /* isIterable */, 0, 94, 0, 94, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isIterableAtLeastOnce = { { 1792 /* isIterableAtLeastOnce */, 0, 95, 0, 95, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isCallable = { { 1814 /* isCallable */, 0, 96, 0, 96, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getEnumCases = { { 1825 /* getEnumCases */, 0, 97, 0, 97, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getEnumCaseObject = { { 1875 /* getEnumCaseObject */, 0, 98, 0, 98, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isCommonCallable = { { 1893 /* isCommonCallable */, 0, 99, 0, 99, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getCallableParametersAcceptors = { { 1910 /* getCallableParametersAcceptors */, 1, 100, 1, 101, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getThrowPoints = { { 1941 /* getThrowPoints */, 0, 102, 0, 102, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getImpurePoints = { { 1956 /* getImpurePoints */, 0, 103, 0, 103, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getInvalidateExpressions = { { 1972 /* getInvalidateExpressions */, 0, 104, 0, 104, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUsedVariables = { { 1997 /* getUsedVariables */, 0, 105, 0, 105, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getByRefUseTypes = { { 2014 /* getByRefUseTypes */, 0, 106, 0, 106, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getOrigin = { { 2031 /* getOrigin */, 0, 107, 0, 107, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig containsUnresolvedTemplateArgument = { { 2041 /* containsUnresolvedTemplateArgument */, 0, 108, 0, 108, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig acceptsNamedArguments = { { 278 /* acceptsNamedArguments */, 0, 109, 0, 109, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig mustUseReturnValue = { { 321 /* mustUseReturnValue */, 0, 110, 0, 110, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isStaticClosure = { { 2076 /* isStaticClosure */, 0, 111, 0, 111, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isCloneable = { { 2092 /* isCloneable */, 0, 112, 0, 112, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toBoolean = { { 2129 /* toBoolean */, 0, 113, 0, 113, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toNumber = { { 2139 /* toNumber */, 0, 114, 0, 114, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toBitwiseNotType = { { 2148 /* toBitwiseNotType */, 0, 115, 0, 115, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toGetClassResultType = { { 2165 /* toGetClassResultType */, 0, 116, 0, 116, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toClassConstantType = { { 2243 /* toClassConstantType */, 1, 117, 1, 118, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toObjectTypeForInstanceofCheck = { { 2304 /* toObjectTypeForInstanceofCheck */, 0, 119, 0, 119, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toObjectTypeForIsACheck = { { 2380 /* toObjectTypeForIsACheck */, 3, 120, 3, 123, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toAbsoluteNumber = { { 2404 /* toAbsoluteNumber */, 0, 124, 0, 124, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toInteger = { { 2421 /* toInteger */, 0, 125, 0, 125, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toFloat = { { 2431 /* toFloat */, 0, 126, 0, 126, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toString = { { 2439 /* toString */, 0, 127, 0, 127, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toArray = { { 2448 /* toArray */, 0, 128, 0, 128, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toArrayKey = { { 2456 /* toArrayKey */, 0, 129, 0, 129, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toCoercedArgumentType = { { 2467 /* toCoercedArgumentType */, 1, 130, 1, 131, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getTemplateTypeMap = { { 2489 /* getTemplateTypeMap */, 0, 132, 0, 132, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getResolvedTemplateTypeMap = { { 2508 /* getResolvedTemplateTypeMap */, 0, 133, 0, 133, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getCallSiteVarianceMap = { { 2535 /* getCallSiteVarianceMap */, 0, 134, 0, 134, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getParameters = { { 2558 /* getParameters */, 0, 135, 0, 135, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isVariadic = { { 2572 /* isVariadic */, 0, 136, 0, 136, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getReturnType = { { 2583 /* getReturnType */, 0, 137, 0, 137, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig inferTemplateTypes = { { 2610 /* inferTemplateTypes */, 1, 138, 1, 139, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig inferTemplateTypesOnParametersAcceptor = { { 2686 /* inferTemplateTypesOnParametersAcceptor */, 1, 140, 1, 141, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getReferencedTemplateTypes = { { 2784 /* getReferencedTemplateTypes */, 1, 142, 1, 143, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig traverse = { { 2814 /* traverse */, 1, 144, 1, 145, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig traverseSimultaneously = { { 2829 /* traverseSimultaneously */, 2, 146, 2, 148, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNull = { { 2852 /* isNull */, 0, 149, 0, 149, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isConstantValue = { { 2859 /* isConstantValue */, 0, 150, 0, 150, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isConstantScalarValue = { { 2875 /* isConstantScalarValue */, 0, 151, 0, 151, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstantScalarTypes = { { 2897 /* getConstantScalarTypes */, 0, 152, 0, 152, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstantScalarValues = { { 2920 /* getConstantScalarValues */, 0, 153, 0, 153, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isTrue = { { 2944 /* isTrue */, 0, 154, 0, 154, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isFalse = { { 2951 /* isFalse */, 0, 155, 0, 155, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isBoolean = { { 2959 /* isBoolean */, 0, 156, 0, 156, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isFloat = { { 2969 /* isFloat */, 0, 157, 0, 157, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isInteger = { { 2977 /* isInteger */, 0, 158, 0, 158, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isString = { { 2987 /* isString */, 0, 159, 0, 159, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNumericString = { { 2996 /* isNumericString */, 0, 160, 0, 160, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isDecimalIntegerString = { { 3012 /* isDecimalIntegerString */, 0, 161, 0, 161, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNonEmptyString = { { 3035 /* isNonEmptyString */, 0, 162, 0, 162, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNonFalsyString = { { 3052 /* isNonFalsyString */, 0, 163, 0, 163, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isLiteralString = { { 3069 /* isLiteralString */, 0, 164, 0, 164, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isLowercaseString = { { 3085 /* isLowercaseString */, 0, 165, 0, 165, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isClassString = { { 3103 /* isClassString */, 0, 166, 0, 166, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isUppercaseString = { { 3117 /* isUppercaseString */, 0, 167, 0, 167, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getClassStringObjectType = { { 3135 /* getClassStringObjectType */, 0, 168, 0, 168, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getObjectTypeOrClassStringObjectType = { { 3160 /* getObjectTypeOrClassStringObjectType */, 0, 169, 0, 169, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isVoid = { { 3197 /* isVoid */, 0, 170, 0, 170, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isScalar = { { 3204 /* isScalar */, 0, 171, 0, 171, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig looseCompare = { { 3247 /* looseCompare */, 2, 172, 2, 174, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig arithmeticPower = { { 3269 /* arithmeticPower */, 2, 175, 2, 177, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getFiniteTypes = { { 3285 /* getFiniteTypes */, 0, 178, 0, 178, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toPhpDocNode = { { 3339 /* toPhpDocNode */, 0, 179, 0, 179, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toNativePhpTypeNode = { { 3393 /* toNativePhpTypeNode */, 1, 180, 1, reg::NoArg, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasTemplateOrLateResolvableType = { { 3413 /* hasTemplateOrLateResolvableType */, 0, 181, 0, 181, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toValueSet = { { 3467 /* toValueSet */, 0, 182, 0, 182, ZEND_ACC_PUBLIC } }; } // namespace sig } // namespace ptdecl::ClosureType diff --git a/turbo-ext/src/generated/InitializerExprTypeResolver.h b/turbo-ext/src/generated/InitializerExprTypeResolver.h index 6c25986814d..1c17629aeca 100644 --- a/turbo-ext/src/generated/InitializerExprTypeResolver.h +++ b/turbo-ext/src/generated/InitializerExprTypeResolver.h @@ -95,61 +95,66 @@ inline constexpr char strings[] = "isParameterValueNullable\0" /* 981 */ "PhpParser\\Node\\Expr\\CallLike\0" /* 1006 */ "nativeTypesPromoted\0" /* 1035 */ - "getFirstClassCallableType\0" /* 1055 */ - "function\0" /* 1081 */ - "PHPStan\\Reflection\\FunctionReflection|PHPStan\\Reflection\\ExtendedMethodReflection\0" /* 1090 */ - "variants\0" /* 1172 */ - "createFirstClassCallable\0" /* 1181 */ - "parameters\0" /* 1206 */ - "names\0" /* 1217 */ - "renameParameters\0" /* 1223 */ - "getBitwiseAndType\0" /* 1240 */ - "getBitwiseOrType\0" /* 1258 */ - "getBitwiseXorType\0" /* 1275 */ - "getSpaceshipType\0" /* 1293 */ - "getDivType\0" /* 1310 */ - "getModType\0" /* 1321 */ - "getPlusType\0" /* 1332 */ - "getMinusType\0" /* 1344 */ - "getMulType\0" /* 1357 */ - "getPowType\0" /* 1368 */ - "getShiftLeftType\0" /* 1379 */ - "getShiftRightType\0" /* 1396 */ - "leftType\0" /* 1414 */ - "rightType\0" /* 1423 */ - "PHPStan\\Type\\TypeResult\0" /* 1433 */ - "resolveIdenticalType\0" /* 1457 */ - "resolveEqualType\0" /* 1478 */ - "isNonNumericString\0" /* 1495 */ - "PHPStan\\Type\\Constant\\ConstantArrayType\0" /* 1514 */ - "valueComparisonCallback\0" /* 1554 */ - "resolveConstantArrayTypeComparison\0" /* 1578 */ - "class\0" /* 1613 */ - "PhpParser\\Node\\Name|PhpParser\\Node\\Expr\0" /* 1619 */ - "constantName\0" /* 1659 */ - "classReflection\0" /* 1672 */ - "PHPStan\\Reflection\\ClassReflection\0" /* 1688 */ - "false\0" /* 1723 */ - "getClassConstFetchTypeByReflection\0" /* 1729 */ - "fetchedOnType\0" /* 1764 */ - "transformStaticType\0" /* 1778 */ - "getClassConstFetchType\0" /* 1798 */ - "getUnaryPlusType\0" /* 1821 */ - "getUnaryMinusType\0" /* 1838 */ - "getBitwiseNotType\0" /* 1856 */ - "getBitwiseNotTypeFromType\0" /* 1874 */ - "name\0" /* 1900 */ - "PhpParser\\Node\\Name\0" /* 1905 */ - "resolveName\0" /* 1925 */ - "PHPStan\\Type\\TypeWithClassName\0" /* 1937 */ - "resolveTypeByName\0" /* 1968 */ - "classType\0" /* 1986 */ - "methodReflectionCandidate\0" /* 1996 */ - "PHPStan\\Reflection\\MethodReflection\0" /* 2022 */ - "resolveTypeByNameWithLateStaticBinding\0" /* 2058 */ - "PHPStan\\Reflection\\ReflectionProvider\0" /* 2097 */ - "getReflectionProvider\0" /* 2135 */ - "getNeverType"; /* 2157 */ + "boundArgTypes\0" /* 1055 */ + "getFirstClassCallableType\0" /* 1069 */ + "function\0" /* 1095 */ + "PHPStan\\Reflection\\FunctionReflection|PHPStan\\Reflection\\ExtendedMethodReflection\0" /* 1104 */ + "variants\0" /* 1186 */ + "partialApplicationArgs\0" /* 1195 */ + "[]\0" /* 1218 */ + "origin\0" /* 1221 */ + "PHPStan\\Type\\ClosureOrigin\0" /* 1228 */ + "createFirstClassCallable\0" /* 1255 */ + "parameters\0" /* 1280 */ + "names\0" /* 1291 */ + "renameParameters\0" /* 1297 */ + "getBitwiseAndType\0" /* 1314 */ + "getBitwiseOrType\0" /* 1332 */ + "getBitwiseXorType\0" /* 1349 */ + "getSpaceshipType\0" /* 1367 */ + "getDivType\0" /* 1384 */ + "getModType\0" /* 1395 */ + "getPlusType\0" /* 1406 */ + "getMinusType\0" /* 1418 */ + "getMulType\0" /* 1431 */ + "getPowType\0" /* 1442 */ + "getShiftLeftType\0" /* 1453 */ + "getShiftRightType\0" /* 1470 */ + "leftType\0" /* 1488 */ + "rightType\0" /* 1497 */ + "PHPStan\\Type\\TypeResult\0" /* 1507 */ + "resolveIdenticalType\0" /* 1531 */ + "resolveEqualType\0" /* 1552 */ + "isNonNumericString\0" /* 1569 */ + "PHPStan\\Type\\Constant\\ConstantArrayType\0" /* 1588 */ + "valueComparisonCallback\0" /* 1628 */ + "resolveConstantArrayTypeComparison\0" /* 1652 */ + "class\0" /* 1687 */ + "PhpParser\\Node\\Name|PhpParser\\Node\\Expr\0" /* 1693 */ + "constantName\0" /* 1733 */ + "classReflection\0" /* 1746 */ + "PHPStan\\Reflection\\ClassReflection\0" /* 1762 */ + "false\0" /* 1797 */ + "getClassConstFetchTypeByReflection\0" /* 1803 */ + "fetchedOnType\0" /* 1838 */ + "transformStaticType\0" /* 1852 */ + "getClassConstFetchType\0" /* 1872 */ + "getUnaryPlusType\0" /* 1895 */ + "getUnaryMinusType\0" /* 1912 */ + "getBitwiseNotType\0" /* 1930 */ + "getBitwiseNotTypeFromType\0" /* 1948 */ + "name\0" /* 1974 */ + "PhpParser\\Node\\Name\0" /* 1979 */ + "resolveName\0" /* 1999 */ + "PHPStan\\Type\\TypeWithClassName\0" /* 2011 */ + "resolveTypeByName\0" /* 2042 */ + "classType\0" /* 2060 */ + "methodReflectionCandidate\0" /* 2070 */ + "PHPStan\\Reflection\\MethodReflection\0" /* 2096 */ + "resolveTypeByNameWithLateStaticBinding\0" /* 2132 */ + "PHPStan\\Reflection\\ReflectionProvider\0" /* 2171 */ + "getReflectionProvider\0" /* 2209 */ + "getNeverType"; /* 2231 */ inline constexpr reg::PackedArg args[] = { reg::packed(0, 0, 17), /* __construct $constantResolver */ reg::packed(51, 0, 78), /* __construct $reflectionProviderProvider */ @@ -193,13 +198,17 @@ inline constexpr reg::PackedArg args[] = { reg::packed(551, 0, 1006), /* getFirstClassCallableType $expr */ reg::packed(576, 0, 584), /* getFirstClassCallableType $context */ reg::packed(1035, MAY_BE_BOOL), /* getFirstClassCallableType $nativeTypesPromoted */ + reg::packed(1055, MAY_BE_NULL | MAY_BE_ARRAY, reg::NoString, false, false, 825), /* getFirstClassCallableType $boundArgTypes */ reg::packed(626, 0, 627), /* getFirstClassCallableType return */ - reg::packed(1081, MAY_BE_NULL, 1090), /* createFirstClassCallable $function */ - reg::packed(1172, MAY_BE_ARRAY), /* createFirstClassCallable $variants */ + reg::packed(1095, MAY_BE_NULL, 1104), /* createFirstClassCallable $function */ + reg::packed(1186, MAY_BE_ARRAY), /* createFirstClassCallable $variants */ reg::packed(1035, MAY_BE_BOOL), /* createFirstClassCallable $nativeTypesPromoted */ + reg::packed(1195, MAY_BE_NULL | MAY_BE_ARRAY, reg::NoString, false, false, 825), /* createFirstClassCallable $partialApplicationArgs */ + reg::packed(1055, MAY_BE_ARRAY, reg::NoString, false, false, 1218), /* createFirstClassCallable $boundArgTypes */ + reg::packed(1221, MAY_BE_NULL, 1228, false, false, 825), /* createFirstClassCallable $origin */ reg::packed(626, 0, 627), /* createFirstClassCallable return */ - reg::packed(1206, MAY_BE_ARRAY), /* renameParameters $parameters */ - reg::packed(1217, MAY_BE_ARRAY), /* renameParameters $names */ + reg::packed(1280, MAY_BE_ARRAY), /* renameParameters $parameters */ + reg::packed(1291, MAY_BE_ARRAY), /* renameParameters $names */ reg::packed(626, MAY_BE_ARRAY), /* renameParameters return */ reg::packed(703, 0, 556), /* getBitwiseAndType $left */ reg::packed(708, 0, 556), /* getBitwiseAndType $right */ @@ -249,31 +258,31 @@ inline constexpr reg::PackedArg args[] = { reg::packed(708, 0, 556), /* getShiftRightType $right */ reg::packed(714, MAY_BE_CALLABLE), /* getShiftRightType $getTypeCallback */ reg::packed(626, 0, 627), /* getShiftRightType return */ - reg::packed(1414, 0, 627), /* resolveIdenticalType $leftType */ - reg::packed(1423, 0, 627), /* resolveIdenticalType $rightType */ - reg::packed(626, 0, 1433), /* resolveIdenticalType return */ - reg::packed(1414, 0, 627), /* resolveEqualType $leftType */ - reg::packed(1423, 0, 627), /* resolveEqualType $rightType */ + reg::packed(1488, 0, 627), /* resolveIdenticalType $leftType */ + reg::packed(1497, 0, 627), /* resolveIdenticalType $rightType */ + reg::packed(626, 0, 1507), /* resolveIdenticalType return */ + reg::packed(1488, 0, 627), /* resolveEqualType $leftType */ + reg::packed(1497, 0, 627), /* resolveEqualType $rightType */ reg::packed(789, MAY_BE_NULL, 801, false, false, 825), /* resolveEqualType $phpVersions */ - reg::packed(626, 0, 1433), /* resolveEqualType return */ + reg::packed(626, 0, 1507), /* resolveEqualType return */ reg::packed(907, 0, 627), /* isNonNumericString $type */ reg::packed(789, MAY_BE_ARRAY), /* isNonNumericString $phpVersions */ reg::packed(626, MAY_BE_BOOL), /* isNonNumericString return */ - reg::packed(1414, 0, 1514), /* resolveConstantArrayTypeComparison $leftType */ - reg::packed(1423, 0, 1514), /* resolveConstantArrayTypeComparison $rightType */ - reg::packed(1554, MAY_BE_CALLABLE), /* resolveConstantArrayTypeComparison $valueComparisonCallback */ - reg::packed(626, 0, 1433), /* resolveConstantArrayTypeComparison return */ - reg::packed(1613, 0, 1619), /* getClassConstFetchTypeByReflection $class */ - reg::packed(1659, MAY_BE_STRING), /* getClassConstFetchTypeByReflection $constantName */ - reg::packed(1672, MAY_BE_NULL, 1688), /* getClassConstFetchTypeByReflection $classReflection */ + reg::packed(1488, 0, 1588), /* resolveConstantArrayTypeComparison $leftType */ + reg::packed(1497, 0, 1588), /* resolveConstantArrayTypeComparison $rightType */ + reg::packed(1628, MAY_BE_CALLABLE), /* resolveConstantArrayTypeComparison $valueComparisonCallback */ + reg::packed(626, 0, 1507), /* resolveConstantArrayTypeComparison return */ + reg::packed(1687, 0, 1693), /* getClassConstFetchTypeByReflection $class */ + reg::packed(1733, MAY_BE_STRING), /* getClassConstFetchTypeByReflection $constantName */ + reg::packed(1746, MAY_BE_NULL, 1762), /* getClassConstFetchTypeByReflection $classReflection */ reg::packed(714, MAY_BE_CALLABLE), /* getClassConstFetchTypeByReflection $getTypeCallback */ - reg::packed(1035, MAY_BE_BOOL, reg::NoString, false, false, 1723), /* getClassConstFetchTypeByReflection $nativeTypesPromoted */ + reg::packed(1035, MAY_BE_BOOL, reg::NoString, false, false, 1797), /* getClassConstFetchTypeByReflection $nativeTypesPromoted */ reg::packed(626, 0, 627), /* getClassConstFetchTypeByReflection return */ reg::packed(907, 0, 627), /* transformStaticType $type */ - reg::packed(1764, 0, 627), /* transformStaticType $fetchedOnType */ + reg::packed(1838, 0, 627), /* transformStaticType $fetchedOnType */ reg::packed(626, 0, 627), /* transformStaticType return */ - reg::packed(1613, 0, 1619), /* getClassConstFetchType $class */ - reg::packed(1659, MAY_BE_STRING), /* getClassConstFetchType $constantName */ + reg::packed(1687, 0, 1693), /* getClassConstFetchType $class */ + reg::packed(1733, MAY_BE_STRING), /* getClassConstFetchType $constantName */ reg::packed(653, MAY_BE_NULL | MAY_BE_STRING), /* getClassConstFetchType $className */ reg::packed(714, MAY_BE_CALLABLE), /* getClassConstFetchType $getTypeCallback */ reg::packed(626, 0, 627), /* getClassConstFetchType return */ @@ -288,19 +297,19 @@ inline constexpr reg::PackedArg args[] = { reg::packed(626, 0, 627), /* getBitwiseNotType return */ reg::packed(880, 0, 627), /* getBitwiseNotTypeFromType $exprType */ reg::packed(626, 0, 627), /* getBitwiseNotTypeFromType return */ - reg::packed(1900, 0, 1905), /* resolveName $name */ - reg::packed(1672, MAY_BE_NULL, 1688), /* resolveName $classReflection */ + reg::packed(1974, 0, 1979), /* resolveName $name */ + reg::packed(1746, MAY_BE_NULL, 1762), /* resolveName $classReflection */ reg::packed(626, MAY_BE_STRING), /* resolveName return */ - reg::packed(1900, 0, 1905), /* resolveTypeByName $name */ - reg::packed(1672, MAY_BE_NULL, 1688), /* resolveTypeByName $classReflection */ - reg::packed(626, 0, 1937), /* resolveTypeByName return */ - reg::packed(1613, 0, 1905), /* resolveTypeByNameWithLateStaticBinding $class */ - reg::packed(1986, 0, 627), /* resolveTypeByNameWithLateStaticBinding $classType */ - reg::packed(1996, 0, 2022), /* resolveTypeByNameWithLateStaticBinding $methodReflectionCandidate */ + reg::packed(1974, 0, 1979), /* resolveTypeByName $name */ + reg::packed(1746, MAY_BE_NULL, 1762), /* resolveTypeByName $classReflection */ + reg::packed(626, 0, 2011), /* resolveTypeByName return */ + reg::packed(1687, 0, 1979), /* resolveTypeByNameWithLateStaticBinding $class */ + reg::packed(2060, 0, 627), /* resolveTypeByNameWithLateStaticBinding $classType */ + reg::packed(2070, 0, 2096), /* resolveTypeByNameWithLateStaticBinding $methodReflectionCandidate */ reg::packed(626, 0, 627), /* resolveTypeByNameWithLateStaticBinding return */ - reg::packed(626, 0, 2097), /* getReflectionProvider return */ - reg::packed(1414, 0, 627), /* getNeverType $leftType */ - reg::packed(1423, 0, 627), /* getNeverType $rightType */ + reg::packed(626, 0, 2171), /* getReflectionProvider return */ + reg::packed(1488, 0, 627), /* getNeverType $leftType */ + reg::packed(1497, 0, 627), /* getNeverType $rightType */ reg::packed(626, 0, 627), /* getNeverType return */ }; using Sig = reg::Sig; @@ -318,37 +327,37 @@ inline constexpr sigtab::Sig getCastType = { { 868 /* getCastType */, 2, 27, 2, inline constexpr sigtab::Sig getCastObjectType = { { 889 /* getCastObjectType */, 1, 30, 1, 31, ZEND_ACC_PUBLIC } }; inline constexpr sigtab::Sig getFunctionType = { { 934 /* getFunctionType */, 4, 32, 4, 36, ZEND_ACC_PUBLIC } }; inline constexpr sigtab::Sig isParameterValueNullable = { { 981 /* isParameterValueNullable */, 1, 37, 1, 38, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getFirstClassCallableType = { { 1055 /* getFirstClassCallableType */, 3, 39, 3, 42, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig createFirstClassCallable = { { 1181 /* createFirstClassCallable */, 3, 43, 3, 46, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig renameParameters = { { 1223 /* renameParameters */, 2, 47, 2, 49, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; -inline constexpr sigtab::Sig getBitwiseAndType = { { 1240 /* getBitwiseAndType */, 3, 50, 3, 53, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getBitwiseOrType = { { 1258 /* getBitwiseOrType */, 3, 54, 3, 57, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getBitwiseXorType = { { 1275 /* getBitwiseXorType */, 3, 58, 3, 61, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getSpaceshipType = { { 1293 /* getSpaceshipType */, 3, 62, 3, 65, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getDivType = { { 1310 /* getDivType */, 3, 66, 3, 69, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getModType = { { 1321 /* getModType */, 3, 70, 3, 73, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getPlusType = { { 1332 /* getPlusType */, 3, 74, 3, 77, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getMinusType = { { 1344 /* getMinusType */, 3, 78, 3, 81, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getMulType = { { 1357 /* getMulType */, 3, 82, 3, 85, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getPowType = { { 1368 /* getPowType */, 3, 86, 3, 89, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getShiftLeftType = { { 1379 /* getShiftLeftType */, 3, 90, 3, 93, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getShiftRightType = { { 1396 /* getShiftRightType */, 3, 94, 3, 97, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig resolveIdenticalType = { { 1457 /* resolveIdenticalType */, 2, 98, 2, 100, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig resolveEqualType = { { 1478 /* resolveEqualType */, 2, 101, 3, 104, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNonNumericString = { { 1495 /* isNonNumericString */, 2, 105, 2, 107, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; -inline constexpr sigtab::Sig resolveConstantArrayTypeComparison = { { 1578 /* resolveConstantArrayTypeComparison */, 3, 108, 3, 111, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getClassConstFetchTypeByReflection = { { 1729 /* getClassConstFetchTypeByReflection */, 4, 112, 5, 117, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig transformStaticType = { { 1778 /* transformStaticType */, 2, 118, 2, 120, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getClassConstFetchType = { { 1798 /* getClassConstFetchType */, 4, 121, 4, 125, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnaryPlusType = { { 1821 /* getUnaryPlusType */, 2, 126, 2, 128, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnaryMinusType = { { 1838 /* getUnaryMinusType */, 2, 129, 2, 131, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getBitwiseNotType = { { 1856 /* getBitwiseNotType */, 2, 132, 2, 134, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getBitwiseNotTypeFromType = { { 1874 /* getBitwiseNotTypeFromType */, 1, 135, 1, 136, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig resolveName = { { 1925 /* resolveName */, 2, 137, 2, 139, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig resolveTypeByName = { { 1968 /* resolveTypeByName */, 2, 140, 2, 142, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig resolveTypeByNameWithLateStaticBinding = { { 2058 /* resolveTypeByNameWithLateStaticBinding */, 3, 143, 3, 146, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getReflectionProvider = { { 2135 /* getReflectionProvider */, 0, 147, 0, 147, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getNeverType = { { 2157 /* getNeverType */, 2, 148, 2, 150, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getFirstClassCallableType = { { 1069 /* getFirstClassCallableType */, 3, 39, 4, 43, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig createFirstClassCallable = { { 1255 /* createFirstClassCallable */, 3, 44, 6, 50, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig renameParameters = { { 1297 /* renameParameters */, 2, 51, 2, 53, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; +inline constexpr sigtab::Sig getBitwiseAndType = { { 1314 /* getBitwiseAndType */, 3, 54, 3, 57, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getBitwiseOrType = { { 1332 /* getBitwiseOrType */, 3, 58, 3, 61, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getBitwiseXorType = { { 1349 /* getBitwiseXorType */, 3, 62, 3, 65, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getSpaceshipType = { { 1367 /* getSpaceshipType */, 3, 66, 3, 69, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getDivType = { { 1384 /* getDivType */, 3, 70, 3, 73, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getModType = { { 1395 /* getModType */, 3, 74, 3, 77, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getPlusType = { { 1406 /* getPlusType */, 3, 78, 3, 81, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getMinusType = { { 1418 /* getMinusType */, 3, 82, 3, 85, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getMulType = { { 1431 /* getMulType */, 3, 86, 3, 89, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getPowType = { { 1442 /* getPowType */, 3, 90, 3, 93, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getShiftLeftType = { { 1453 /* getShiftLeftType */, 3, 94, 3, 97, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getShiftRightType = { { 1470 /* getShiftRightType */, 3, 98, 3, 101, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig resolveIdenticalType = { { 1531 /* resolveIdenticalType */, 2, 102, 2, 104, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig resolveEqualType = { { 1552 /* resolveEqualType */, 2, 105, 3, 108, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNonNumericString = { { 1569 /* isNonNumericString */, 2, 109, 2, 111, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; +inline constexpr sigtab::Sig resolveConstantArrayTypeComparison = { { 1652 /* resolveConstantArrayTypeComparison */, 3, 112, 3, 115, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getClassConstFetchTypeByReflection = { { 1803 /* getClassConstFetchTypeByReflection */, 4, 116, 5, 121, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig transformStaticType = { { 1852 /* transformStaticType */, 2, 122, 2, 124, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getClassConstFetchType = { { 1872 /* getClassConstFetchType */, 4, 125, 4, 129, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnaryPlusType = { { 1895 /* getUnaryPlusType */, 2, 130, 2, 132, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnaryMinusType = { { 1912 /* getUnaryMinusType */, 2, 133, 2, 135, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getBitwiseNotType = { { 1930 /* getBitwiseNotType */, 2, 136, 2, 138, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getBitwiseNotTypeFromType = { { 1948 /* getBitwiseNotTypeFromType */, 1, 139, 1, 140, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig resolveName = { { 1999 /* resolveName */, 2, 141, 2, 143, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig resolveTypeByName = { { 2042 /* resolveTypeByName */, 2, 144, 2, 146, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig resolveTypeByNameWithLateStaticBinding = { { 2132 /* resolveTypeByNameWithLateStaticBinding */, 3, 147, 3, 150, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getReflectionProvider = { { 2209 /* getReflectionProvider */, 0, 151, 0, 151, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getNeverType = { { 2231 /* getNeverType */, 2, 152, 2, 154, ZEND_ACC_PRIVATE } }; } // namespace sig } // namespace ptdecl::InitializerExprTypeResolver diff --git a/turbo-ext/src/generated/UnionType.h b/turbo-ext/src/generated/UnionType.h index 66861a8da1f..e852fdef5a3 100644 --- a/turbo-ext/src/generated/UnionType.h +++ b/turbo-ext/src/generated/UnionType.h @@ -90,210 +90,211 @@ inline constexpr char strings[] = "isSubTypeOf\0" /* 433 */ "acceptingType\0" /* 445 */ "isAcceptedBy\0" /* 459 */ - "yesOnly\0" /* 472 */ - "PHPStan\\TrinaryLogic\0" /* 480 */ - "finiteTypeSetContainedIn\0" /* 501 */ - "equals\0" /* 526 */ - "level\0" /* 533 */ - "PHPStan\\Type\\VerbosityLevel\0" /* 539 */ - "describe\0" /* 567 */ - "canCallback\0" /* 576 */ - "hasCallback\0" /* 588 */ - "hasInternal\0" /* 600 */ - "getCallback\0" /* 612 */ - "getInternal\0" /* 624 */ - "ancestorClassName\0" /* 636 */ - "templateTypeName\0" /* 654 */ - "getTemplateType\0" /* 671 */ - "isObject\0" /* 687 */ - "getClassStringType\0" /* 696 */ - "isEnum\0" /* 715 */ - "canAccessProperties\0" /* 722 */ - "propertyName\0" /* 742 */ - "hasProperty\0" /* 755 */ - "scope\0" /* 767 */ - "PHPStan\\Reflection\\ClassMemberAccessAnswerer\0" /* 773 */ - "PHPStan\\Reflection\\ExtendedPropertyReflection\0" /* 818 */ - "getProperty\0" /* 864 */ - "PHPStan\\Reflection\\Type\\UnresolvedPropertyPrototypeReflection\0" /* 876 */ - "getUnresolvedPropertyPrototype\0" /* 938 */ - "hasInstanceProperty\0" /* 969 */ - "getInstanceProperty\0" /* 989 */ - "getUnresolvedInstancePropertyPrototype\0" /* 1009 */ - "hasStaticProperty\0" /* 1048 */ - "getStaticProperty\0" /* 1066 */ - "getUnresolvedStaticPropertyPrototype\0" /* 1084 */ - "canCallMethods\0" /* 1121 */ - "methodName\0" /* 1136 */ - "hasMethod\0" /* 1147 */ - "PHPStan\\Reflection\\ExtendedMethodReflection\0" /* 1157 */ - "getMethod\0" /* 1201 */ - "PHPStan\\Reflection\\Type\\UnresolvedMethodPrototypeReflection\0" /* 1211 */ - "getUnresolvedMethodPrototype\0" /* 1271 */ - "canAccessConstants\0" /* 1300 */ - "constantName\0" /* 1319 */ - "hasConstant\0" /* 1332 */ - "PHPStan\\Reflection\\ClassConstantReflection\0" /* 1344 */ - "getConstant\0" /* 1387 */ - "isIterable\0" /* 1399 */ - "isIterableAtLeastOnce\0" /* 1410 */ - "getArraySize\0" /* 1432 */ - "getIterableKeyType\0" /* 1445 */ - "getFirstIterableKeyType\0" /* 1464 */ - "getLastIterableKeyType\0" /* 1488 */ - "getIterableValueType\0" /* 1511 */ - "getFirstIterableValueType\0" /* 1532 */ - "getLastIterableValueType\0" /* 1558 */ - "isArray\0" /* 1583 */ - "isConstantArray\0" /* 1591 */ - "isOversizedArray\0" /* 1607 */ - "isList\0" /* 1624 */ - "isString\0" /* 1631 */ - "isNumericString\0" /* 1640 */ - "isDecimalIntegerString\0" /* 1656 */ - "isNonEmptyString\0" /* 1679 */ - "isNonFalsyString\0" /* 1696 */ - "isLiteralString\0" /* 1713 */ - "isLowercaseString\0" /* 1729 */ - "isUppercaseString\0" /* 1747 */ - "isClassString\0" /* 1765 */ - "getClassStringObjectType\0" /* 1779 */ - "getObjectTypeOrClassStringObjectType\0" /* 1804 */ - "isVoid\0" /* 1841 */ - "isScalar\0" /* 1848 */ - "phpVersion\0" /* 1857 */ - "PHPStan\\Php\\PhpVersion\0" /* 1868 */ - "PHPStan\\Type\\BooleanType\0" /* 1891 */ - "looseCompare\0" /* 1916 */ - "isOffsetAccessible\0" /* 1929 */ - "isOffsetAccessLegal\0" /* 1948 */ - "offsetType\0" /* 1968 */ - "hasOffsetValueType\0" /* 1979 */ - "getOffsetValueType\0" /* 1998 */ - "doGetOffsetValueType\0" /* 2017 */ - "valueType\0" /* 2038 */ - "unionValues\0" /* 2048 */ - "true\0" /* 2060 */ - "setOffsetValueType\0" /* 2065 */ - "setExistingOffsetValueType\0" /* 2084 */ - "unsetOffset\0" /* 2111 */ - "filterValueType\0" /* 2123 */ - "strict\0" /* 2139 */ - "getKeysArrayFiltered\0" /* 2146 */ - "getKeysArray\0" /* 2167 */ - "getValuesArray\0" /* 2180 */ - "lengthType\0" /* 2195 */ - "preserveKeys\0" /* 2206 */ - "chunkArray\0" /* 2219 */ - "fillKeysArray\0" /* 2230 */ - "flipArray\0" /* 2244 */ - "otherArraysType\0" /* 2254 */ - "intersectKeyArray\0" /* 2270 */ - "popArray\0" /* 2288 */ - "reverseArray\0" /* 2297 */ - "needleType\0" /* 2310 */ - "null\0" /* 2321 */ - "searchArray\0" /* 2326 */ - "shiftArray\0" /* 2338 */ - "shuffleArray\0" /* 2349 */ - "sliceArray\0" /* 2362 */ - "replacementType\0" /* 2373 */ - "spliceArray\0" /* 2389 */ - "sizeType\0" /* 2401 */ - "truncateListToSize\0" /* 2410 */ - "makeListMaybe\0" /* 2429 */ - "cb\0" /* 2443 */ - "mapValueType\0" /* 2446 */ - "mapKeyType\0" /* 2459 */ - "makeAllArrayKeysOptional\0" /* 2470 */ - "case\0" /* 2495 */ - "changeKeyCaseArray\0" /* 2500 */ - "filterArrayRemovingFalsey\0" /* 2519 */ - "getEnumCases\0" /* 2545 */ - "PHPStan\\Type\\Enum\\EnumCaseObjectType\0" /* 2558 */ - "getEnumCaseObject\0" /* 2595 */ - "isCallable\0" /* 2613 */ - "getCallableParametersAcceptors\0" /* 2624 */ - "isCloneable\0" /* 2655 */ - "isSmallerThan\0" /* 2667 */ - "isSmallerThanOrEqual\0" /* 2681 */ - "isNull\0" /* 2702 */ - "isConstantValue\0" /* 2709 */ - "isConstantScalarValue\0" /* 2725 */ - "getConstantScalarTypes\0" /* 2747 */ - "getConstantScalarValues\0" /* 2770 */ - "isTrue\0" /* 2794 */ - "isFalse\0" /* 2801 */ - "isBoolean\0" /* 2809 */ - "isFloat\0" /* 2819 */ - "isInteger\0" /* 2827 */ - "getSmallerType\0" /* 2837 */ - "getSmallerOrEqualType\0" /* 2852 */ - "getGreaterType\0" /* 2874 */ - "getGreaterOrEqualType\0" /* 2889 */ - "isGreaterThan\0" /* 2911 */ - "isGreaterThanOrEqual\0" /* 2925 */ - "toBoolean\0" /* 2946 */ - "toNumber\0" /* 2956 */ - "PHPStan\\Type\\NumberSet\0" /* 2965 */ - "toNumberSet\0" /* 2988 */ - "toBitwiseNotType\0" /* 3000 */ - "toGetClassResultType\0" /* 3017 */ - "reflectionProvider\0" /* 3038 */ - "PHPStan\\Reflection\\ReflectionProvider\0" /* 3057 */ - "toClassConstantType\0" /* 3095 */ - "PHPStan\\Type\\ClassNameToObjectTypeResult\0" /* 3115 */ - "toObjectTypeForInstanceofCheck\0" /* 3156 */ - "objectOrClassType\0" /* 3187 */ - "allowString\0" /* 3205 */ - "allowSameClass\0" /* 3217 */ - "toObjectTypeForIsACheck\0" /* 3232 */ - "toAbsoluteNumber\0" /* 3256 */ - "toString\0" /* 3273 */ - "toInteger\0" /* 3282 */ - "toFloat\0" /* 3292 */ - "toArray\0" /* 3300 */ - "toArrayKey\0" /* 3308 */ - "toCoercedArgumentType\0" /* 3319 */ - "receivedType\0" /* 3341 */ - "PHPStan\\Type\\Generic\\TemplateTypeMap\0" /* 3354 */ - "inferTemplateTypes\0" /* 3391 */ - "PHPStan\\Type\\Generic\\TemplateType\0" /* 3410 */ - "getNakedTemplateType\0" /* 3444 */ - "inferred\0" /* 3465 */ - "getAbsorbedTemplateTypes\0" /* 3474 */ - "templateType\0" /* 3499 */ - "inferTemplateTypesOn\0" /* 3512 */ - "positionVariance\0" /* 3533 */ - "PHPStan\\Type\\Generic\\TemplateTypeVariance\0" /* 3550 */ - "getReferencedTemplateTypes\0" /* 3592 */ - "traverse\0" /* 3619 */ - "right\0" /* 3628 */ - "traverseSimultaneously\0" /* 3634 */ - "typeToRemove\0" /* 3657 */ - "tryRemove\0" /* 3670 */ - "exponent\0" /* 3680 */ - "arithmeticPower\0" /* 3689 */ - "getFiniteTypes\0" /* 3705 */ - "getResult\0" /* 3720 */ - "unionResults\0" /* 3730 */ - "notBenevolentUnionResults\0" /* 3743 */ - "getType\0" /* 3769 */ - "unionTypes\0" /* 3777 */ - "getValues\0" /* 3788 */ - "criteria\0" /* 3798 */ - "pickFromTypes\0" /* 3807 */ - "PHPStan\\PhpDocParser\\Ast\\Type\\TypeNode\0" /* 3821 */ - "toPhpDocNode\0" /* 3860 */ - "position\0" /* 3873 */ - "PHPStan\\Type\\NativeTypePosition\0" /* 3882 */ - "toNativePhpTypeNode\0" /* 3914 */ - "notBenevolentPickFromTypes\0" /* 3934 */ - "hasTemplateOrLateResolvableType\0" /* 3961 */ - "getPossiblyLooselyEqualType\0" /* 3993 */ - "getAlwaysLooselyEqualType\0" /* 4021 */ - "PHPStan\\Type\\ValueSet\0" /* 4047 */ - "toValueSet"; /* 4069 */ + "hasClosureMember\0" /* 472 */ + "yesOnly\0" /* 489 */ + "PHPStan\\TrinaryLogic\0" /* 497 */ + "finiteTypeSetContainedIn\0" /* 518 */ + "equals\0" /* 543 */ + "level\0" /* 550 */ + "PHPStan\\Type\\VerbosityLevel\0" /* 556 */ + "describe\0" /* 584 */ + "canCallback\0" /* 593 */ + "hasCallback\0" /* 605 */ + "hasInternal\0" /* 617 */ + "getCallback\0" /* 629 */ + "getInternal\0" /* 641 */ + "ancestorClassName\0" /* 653 */ + "templateTypeName\0" /* 671 */ + "getTemplateType\0" /* 688 */ + "isObject\0" /* 704 */ + "getClassStringType\0" /* 713 */ + "isEnum\0" /* 732 */ + "canAccessProperties\0" /* 739 */ + "propertyName\0" /* 759 */ + "hasProperty\0" /* 772 */ + "scope\0" /* 784 */ + "PHPStan\\Reflection\\ClassMemberAccessAnswerer\0" /* 790 */ + "PHPStan\\Reflection\\ExtendedPropertyReflection\0" /* 835 */ + "getProperty\0" /* 881 */ + "PHPStan\\Reflection\\Type\\UnresolvedPropertyPrototypeReflection\0" /* 893 */ + "getUnresolvedPropertyPrototype\0" /* 955 */ + "hasInstanceProperty\0" /* 986 */ + "getInstanceProperty\0" /* 1006 */ + "getUnresolvedInstancePropertyPrototype\0" /* 1026 */ + "hasStaticProperty\0" /* 1065 */ + "getStaticProperty\0" /* 1083 */ + "getUnresolvedStaticPropertyPrototype\0" /* 1101 */ + "canCallMethods\0" /* 1138 */ + "methodName\0" /* 1153 */ + "hasMethod\0" /* 1164 */ + "PHPStan\\Reflection\\ExtendedMethodReflection\0" /* 1174 */ + "getMethod\0" /* 1218 */ + "PHPStan\\Reflection\\Type\\UnresolvedMethodPrototypeReflection\0" /* 1228 */ + "getUnresolvedMethodPrototype\0" /* 1288 */ + "canAccessConstants\0" /* 1317 */ + "constantName\0" /* 1336 */ + "hasConstant\0" /* 1349 */ + "PHPStan\\Reflection\\ClassConstantReflection\0" /* 1361 */ + "getConstant\0" /* 1404 */ + "isIterable\0" /* 1416 */ + "isIterableAtLeastOnce\0" /* 1427 */ + "getArraySize\0" /* 1449 */ + "getIterableKeyType\0" /* 1462 */ + "getFirstIterableKeyType\0" /* 1481 */ + "getLastIterableKeyType\0" /* 1505 */ + "getIterableValueType\0" /* 1528 */ + "getFirstIterableValueType\0" /* 1549 */ + "getLastIterableValueType\0" /* 1575 */ + "isArray\0" /* 1600 */ + "isConstantArray\0" /* 1608 */ + "isOversizedArray\0" /* 1624 */ + "isList\0" /* 1641 */ + "isString\0" /* 1648 */ + "isNumericString\0" /* 1657 */ + "isDecimalIntegerString\0" /* 1673 */ + "isNonEmptyString\0" /* 1696 */ + "isNonFalsyString\0" /* 1713 */ + "isLiteralString\0" /* 1730 */ + "isLowercaseString\0" /* 1746 */ + "isUppercaseString\0" /* 1764 */ + "isClassString\0" /* 1782 */ + "getClassStringObjectType\0" /* 1796 */ + "getObjectTypeOrClassStringObjectType\0" /* 1821 */ + "isVoid\0" /* 1858 */ + "isScalar\0" /* 1865 */ + "phpVersion\0" /* 1874 */ + "PHPStan\\Php\\PhpVersion\0" /* 1885 */ + "PHPStan\\Type\\BooleanType\0" /* 1908 */ + "looseCompare\0" /* 1933 */ + "isOffsetAccessible\0" /* 1946 */ + "isOffsetAccessLegal\0" /* 1965 */ + "offsetType\0" /* 1985 */ + "hasOffsetValueType\0" /* 1996 */ + "getOffsetValueType\0" /* 2015 */ + "doGetOffsetValueType\0" /* 2034 */ + "valueType\0" /* 2055 */ + "unionValues\0" /* 2065 */ + "true\0" /* 2077 */ + "setOffsetValueType\0" /* 2082 */ + "setExistingOffsetValueType\0" /* 2101 */ + "unsetOffset\0" /* 2128 */ + "filterValueType\0" /* 2140 */ + "strict\0" /* 2156 */ + "getKeysArrayFiltered\0" /* 2163 */ + "getKeysArray\0" /* 2184 */ + "getValuesArray\0" /* 2197 */ + "lengthType\0" /* 2212 */ + "preserveKeys\0" /* 2223 */ + "chunkArray\0" /* 2236 */ + "fillKeysArray\0" /* 2247 */ + "flipArray\0" /* 2261 */ + "otherArraysType\0" /* 2271 */ + "intersectKeyArray\0" /* 2287 */ + "popArray\0" /* 2305 */ + "reverseArray\0" /* 2314 */ + "needleType\0" /* 2327 */ + "null\0" /* 2338 */ + "searchArray\0" /* 2343 */ + "shiftArray\0" /* 2355 */ + "shuffleArray\0" /* 2366 */ + "sliceArray\0" /* 2379 */ + "replacementType\0" /* 2390 */ + "spliceArray\0" /* 2406 */ + "sizeType\0" /* 2418 */ + "truncateListToSize\0" /* 2427 */ + "makeListMaybe\0" /* 2446 */ + "cb\0" /* 2460 */ + "mapValueType\0" /* 2463 */ + "mapKeyType\0" /* 2476 */ + "makeAllArrayKeysOptional\0" /* 2487 */ + "case\0" /* 2512 */ + "changeKeyCaseArray\0" /* 2517 */ + "filterArrayRemovingFalsey\0" /* 2536 */ + "getEnumCases\0" /* 2562 */ + "PHPStan\\Type\\Enum\\EnumCaseObjectType\0" /* 2575 */ + "getEnumCaseObject\0" /* 2612 */ + "isCallable\0" /* 2630 */ + "getCallableParametersAcceptors\0" /* 2641 */ + "isCloneable\0" /* 2672 */ + "isSmallerThan\0" /* 2684 */ + "isSmallerThanOrEqual\0" /* 2698 */ + "isNull\0" /* 2719 */ + "isConstantValue\0" /* 2726 */ + "isConstantScalarValue\0" /* 2742 */ + "getConstantScalarTypes\0" /* 2764 */ + "getConstantScalarValues\0" /* 2787 */ + "isTrue\0" /* 2811 */ + "isFalse\0" /* 2818 */ + "isBoolean\0" /* 2826 */ + "isFloat\0" /* 2836 */ + "isInteger\0" /* 2844 */ + "getSmallerType\0" /* 2854 */ + "getSmallerOrEqualType\0" /* 2869 */ + "getGreaterType\0" /* 2891 */ + "getGreaterOrEqualType\0" /* 2906 */ + "isGreaterThan\0" /* 2928 */ + "isGreaterThanOrEqual\0" /* 2942 */ + "toBoolean\0" /* 2963 */ + "toNumber\0" /* 2973 */ + "PHPStan\\Type\\NumberSet\0" /* 2982 */ + "toNumberSet\0" /* 3005 */ + "toBitwiseNotType\0" /* 3017 */ + "toGetClassResultType\0" /* 3034 */ + "reflectionProvider\0" /* 3055 */ + "PHPStan\\Reflection\\ReflectionProvider\0" /* 3074 */ + "toClassConstantType\0" /* 3112 */ + "PHPStan\\Type\\ClassNameToObjectTypeResult\0" /* 3132 */ + "toObjectTypeForInstanceofCheck\0" /* 3173 */ + "objectOrClassType\0" /* 3204 */ + "allowString\0" /* 3222 */ + "allowSameClass\0" /* 3234 */ + "toObjectTypeForIsACheck\0" /* 3249 */ + "toAbsoluteNumber\0" /* 3273 */ + "toString\0" /* 3290 */ + "toInteger\0" /* 3299 */ + "toFloat\0" /* 3309 */ + "toArray\0" /* 3317 */ + "toArrayKey\0" /* 3325 */ + "toCoercedArgumentType\0" /* 3336 */ + "receivedType\0" /* 3358 */ + "PHPStan\\Type\\Generic\\TemplateTypeMap\0" /* 3371 */ + "inferTemplateTypes\0" /* 3408 */ + "PHPStan\\Type\\Generic\\TemplateType\0" /* 3427 */ + "getNakedTemplateType\0" /* 3461 */ + "inferred\0" /* 3482 */ + "getAbsorbedTemplateTypes\0" /* 3491 */ + "templateType\0" /* 3516 */ + "inferTemplateTypesOn\0" /* 3529 */ + "positionVariance\0" /* 3550 */ + "PHPStan\\Type\\Generic\\TemplateTypeVariance\0" /* 3567 */ + "getReferencedTemplateTypes\0" /* 3609 */ + "traverse\0" /* 3636 */ + "right\0" /* 3645 */ + "traverseSimultaneously\0" /* 3651 */ + "typeToRemove\0" /* 3674 */ + "tryRemove\0" /* 3687 */ + "exponent\0" /* 3697 */ + "arithmeticPower\0" /* 3706 */ + "getFiniteTypes\0" /* 3722 */ + "getResult\0" /* 3737 */ + "unionResults\0" /* 3747 */ + "notBenevolentUnionResults\0" /* 3760 */ + "getType\0" /* 3786 */ + "unionTypes\0" /* 3794 */ + "getValues\0" /* 3805 */ + "criteria\0" /* 3815 */ + "pickFromTypes\0" /* 3824 */ + "PHPStan\\PhpDocParser\\Ast\\Type\\TypeNode\0" /* 3838 */ + "toPhpDocNode\0" /* 3877 */ + "position\0" /* 3890 */ + "PHPStan\\Type\\NativeTypePosition\0" /* 3899 */ + "toNativePhpTypeNode\0" /* 3931 */ + "notBenevolentPickFromTypes\0" /* 3951 */ + "hasTemplateOrLateResolvableType\0" /* 3978 */ + "getPossiblyLooselyEqualType\0" /* 4010 */ + "getAlwaysLooselyEqualType\0" /* 4038 */ + "PHPStan\\Type\\ValueSet\0" /* 4064 */ + "toValueSet"; /* 4086 */ inline constexpr reg::PackedArg args[] = { reg::packed(0, MAY_BE_ARRAY), /* __construct $types */ reg::packed(6, MAY_BE_BOOL, reg::NoString, false, false, 17), /* __construct $normalized */ @@ -321,66 +322,67 @@ inline constexpr reg::PackedArg args[] = { reg::packed(445, 0, 79), /* isAcceptedBy $acceptingType */ reg::packed(329, MAY_BE_BOOL), /* isAcceptedBy $strictTypes */ reg::packed(78, 0, 341), /* isAcceptedBy return */ + reg::packed(78, MAY_BE_BOOL), /* hasClosureMember return */ reg::packed(376, 0, 79), /* finiteTypeSetContainedIn $otherType */ - reg::packed(472, MAY_BE_BOOL), /* finiteTypeSetContainedIn $yesOnly */ - reg::packed(78, MAY_BE_NULL, 480), /* finiteTypeSetContainedIn return */ + reg::packed(489, MAY_BE_BOOL), /* finiteTypeSetContainedIn $yesOnly */ + reg::packed(78, MAY_BE_NULL, 497), /* finiteTypeSetContainedIn return */ reg::packed(324, 0, 79), /* equals $type */ reg::packed(78, MAY_BE_BOOL), /* equals return */ - reg::packed(533, 0, 539), /* describe $level */ + reg::packed(550, 0, 556), /* describe $level */ reg::packed(78, MAY_BE_STRING), /* describe return */ - reg::packed(576, MAY_BE_CALLABLE), /* hasInternal $canCallback */ - reg::packed(588, MAY_BE_CALLABLE), /* hasInternal $hasCallback */ - reg::packed(78, 0, 480), /* hasInternal return */ - reg::packed(588, MAY_BE_CALLABLE), /* getInternal $hasCallback */ - reg::packed(612, MAY_BE_CALLABLE), /* getInternal $getCallback */ + reg::packed(593, MAY_BE_CALLABLE), /* hasInternal $canCallback */ + reg::packed(605, MAY_BE_CALLABLE), /* hasInternal $hasCallback */ + reg::packed(78, 0, 497), /* hasInternal return */ + reg::packed(605, MAY_BE_CALLABLE), /* getInternal $hasCallback */ + reg::packed(629, MAY_BE_CALLABLE), /* getInternal $getCallback */ reg::packed(78, MAY_BE_OBJECT), /* getInternal return */ - reg::packed(636, MAY_BE_STRING), /* getTemplateType $ancestorClassName */ - reg::packed(654, MAY_BE_STRING), /* getTemplateType $templateTypeName */ + reg::packed(653, MAY_BE_STRING), /* getTemplateType $ancestorClassName */ + reg::packed(671, MAY_BE_STRING), /* getTemplateType $templateTypeName */ reg::packed(78, 0, 79), /* getTemplateType return */ - reg::packed(78, 0, 480), /* isObject return */ + reg::packed(78, 0, 497), /* isObject return */ reg::packed(78, 0, 79), /* getClassStringType return */ - reg::packed(78, 0, 480), /* isEnum return */ - reg::packed(78, 0, 480), /* canAccessProperties return */ - reg::packed(742, MAY_BE_STRING), /* hasProperty $propertyName */ - reg::packed(78, 0, 480), /* hasProperty return */ - reg::packed(742, MAY_BE_STRING), /* getProperty $propertyName */ - reg::packed(767, 0, 773), /* getProperty $scope */ - reg::packed(78, 0, 818), /* getProperty return */ - reg::packed(742, MAY_BE_STRING), /* getUnresolvedPropertyPrototype $propertyName */ - reg::packed(767, 0, 773), /* getUnresolvedPropertyPrototype $scope */ - reg::packed(78, 0, 876), /* getUnresolvedPropertyPrototype return */ - reg::packed(742, MAY_BE_STRING), /* hasInstanceProperty $propertyName */ - reg::packed(78, 0, 480), /* hasInstanceProperty return */ - reg::packed(742, MAY_BE_STRING), /* getInstanceProperty $propertyName */ - reg::packed(767, 0, 773), /* getInstanceProperty $scope */ - reg::packed(78, 0, 818), /* getInstanceProperty return */ - reg::packed(742, MAY_BE_STRING), /* getUnresolvedInstancePropertyPrototype $propertyName */ - reg::packed(767, 0, 773), /* getUnresolvedInstancePropertyPrototype $scope */ - reg::packed(78, 0, 876), /* getUnresolvedInstancePropertyPrototype return */ - reg::packed(742, MAY_BE_STRING), /* hasStaticProperty $propertyName */ - reg::packed(78, 0, 480), /* hasStaticProperty return */ - reg::packed(742, MAY_BE_STRING), /* getStaticProperty $propertyName */ - reg::packed(767, 0, 773), /* getStaticProperty $scope */ - reg::packed(78, 0, 818), /* getStaticProperty return */ - reg::packed(742, MAY_BE_STRING), /* getUnresolvedStaticPropertyPrototype $propertyName */ - reg::packed(767, 0, 773), /* getUnresolvedStaticPropertyPrototype $scope */ - reg::packed(78, 0, 876), /* getUnresolvedStaticPropertyPrototype return */ - reg::packed(78, 0, 480), /* canCallMethods return */ - reg::packed(1136, MAY_BE_STRING), /* hasMethod $methodName */ - reg::packed(78, 0, 480), /* hasMethod return */ - reg::packed(1136, MAY_BE_STRING), /* getMethod $methodName */ - reg::packed(767, 0, 773), /* getMethod $scope */ - reg::packed(78, 0, 1157), /* getMethod return */ - reg::packed(1136, MAY_BE_STRING), /* getUnresolvedMethodPrototype $methodName */ - reg::packed(767, 0, 773), /* getUnresolvedMethodPrototype $scope */ - reg::packed(78, 0, 1211), /* getUnresolvedMethodPrototype return */ - reg::packed(78, 0, 480), /* canAccessConstants return */ - reg::packed(1319, MAY_BE_STRING), /* hasConstant $constantName */ - reg::packed(78, 0, 480), /* hasConstant return */ - reg::packed(1319, MAY_BE_STRING), /* getConstant $constantName */ - reg::packed(78, 0, 1344), /* getConstant return */ - reg::packed(78, 0, 480), /* isIterable return */ - reg::packed(78, 0, 480), /* isIterableAtLeastOnce return */ + reg::packed(78, 0, 497), /* isEnum return */ + reg::packed(78, 0, 497), /* canAccessProperties return */ + reg::packed(759, MAY_BE_STRING), /* hasProperty $propertyName */ + reg::packed(78, 0, 497), /* hasProperty return */ + reg::packed(759, MAY_BE_STRING), /* getProperty $propertyName */ + reg::packed(784, 0, 790), /* getProperty $scope */ + reg::packed(78, 0, 835), /* getProperty return */ + reg::packed(759, MAY_BE_STRING), /* getUnresolvedPropertyPrototype $propertyName */ + reg::packed(784, 0, 790), /* getUnresolvedPropertyPrototype $scope */ + reg::packed(78, 0, 893), /* getUnresolvedPropertyPrototype return */ + reg::packed(759, MAY_BE_STRING), /* hasInstanceProperty $propertyName */ + reg::packed(78, 0, 497), /* hasInstanceProperty return */ + reg::packed(759, MAY_BE_STRING), /* getInstanceProperty $propertyName */ + reg::packed(784, 0, 790), /* getInstanceProperty $scope */ + reg::packed(78, 0, 835), /* getInstanceProperty return */ + reg::packed(759, MAY_BE_STRING), /* getUnresolvedInstancePropertyPrototype $propertyName */ + reg::packed(784, 0, 790), /* getUnresolvedInstancePropertyPrototype $scope */ + reg::packed(78, 0, 893), /* getUnresolvedInstancePropertyPrototype return */ + reg::packed(759, MAY_BE_STRING), /* hasStaticProperty $propertyName */ + reg::packed(78, 0, 497), /* hasStaticProperty return */ + reg::packed(759, MAY_BE_STRING), /* getStaticProperty $propertyName */ + reg::packed(784, 0, 790), /* getStaticProperty $scope */ + reg::packed(78, 0, 835), /* getStaticProperty return */ + reg::packed(759, MAY_BE_STRING), /* getUnresolvedStaticPropertyPrototype $propertyName */ + reg::packed(784, 0, 790), /* getUnresolvedStaticPropertyPrototype $scope */ + reg::packed(78, 0, 893), /* getUnresolvedStaticPropertyPrototype return */ + reg::packed(78, 0, 497), /* canCallMethods return */ + reg::packed(1153, MAY_BE_STRING), /* hasMethod $methodName */ + reg::packed(78, 0, 497), /* hasMethod return */ + reg::packed(1153, MAY_BE_STRING), /* getMethod $methodName */ + reg::packed(784, 0, 790), /* getMethod $scope */ + reg::packed(78, 0, 1174), /* getMethod return */ + reg::packed(1153, MAY_BE_STRING), /* getUnresolvedMethodPrototype $methodName */ + reg::packed(784, 0, 790), /* getUnresolvedMethodPrototype $scope */ + reg::packed(78, 0, 1228), /* getUnresolvedMethodPrototype return */ + reg::packed(78, 0, 497), /* canAccessConstants return */ + reg::packed(1336, MAY_BE_STRING), /* hasConstant $constantName */ + reg::packed(78, 0, 497), /* hasConstant return */ + reg::packed(1336, MAY_BE_STRING), /* getConstant $constantName */ + reg::packed(78, 0, 1361), /* getConstant return */ + reg::packed(78, 0, 497), /* isIterable return */ + reg::packed(78, 0, 497), /* isIterableAtLeastOnce return */ reg::packed(78, 0, 79), /* getArraySize return */ reg::packed(78, 0, 79), /* getIterableKeyType return */ reg::packed(78, 0, 79), /* getFirstIterableKeyType return */ @@ -388,131 +390,131 @@ inline constexpr reg::PackedArg args[] = { reg::packed(78, 0, 79), /* getIterableValueType return */ reg::packed(78, 0, 79), /* getFirstIterableValueType return */ reg::packed(78, 0, 79), /* getLastIterableValueType return */ - reg::packed(78, 0, 480), /* isArray return */ - reg::packed(78, 0, 480), /* isConstantArray return */ - reg::packed(78, 0, 480), /* isOversizedArray return */ - reg::packed(78, 0, 480), /* isList return */ - reg::packed(78, 0, 480), /* isString return */ - reg::packed(78, 0, 480), /* isNumericString return */ - reg::packed(78, 0, 480), /* isDecimalIntegerString return */ - reg::packed(78, 0, 480), /* isNonEmptyString return */ - reg::packed(78, 0, 480), /* isNonFalsyString return */ - reg::packed(78, 0, 480), /* isLiteralString return */ - reg::packed(78, 0, 480), /* isLowercaseString return */ - reg::packed(78, 0, 480), /* isUppercaseString return */ - reg::packed(78, 0, 480), /* isClassString return */ + reg::packed(78, 0, 497), /* isArray return */ + reg::packed(78, 0, 497), /* isConstantArray return */ + reg::packed(78, 0, 497), /* isOversizedArray return */ + reg::packed(78, 0, 497), /* isList return */ + reg::packed(78, 0, 497), /* isString return */ + reg::packed(78, 0, 497), /* isNumericString return */ + reg::packed(78, 0, 497), /* isDecimalIntegerString return */ + reg::packed(78, 0, 497), /* isNonEmptyString return */ + reg::packed(78, 0, 497), /* isNonFalsyString return */ + reg::packed(78, 0, 497), /* isLiteralString return */ + reg::packed(78, 0, 497), /* isLowercaseString return */ + reg::packed(78, 0, 497), /* isUppercaseString return */ + reg::packed(78, 0, 497), /* isClassString return */ reg::packed(78, 0, 79), /* getClassStringObjectType return */ reg::packed(78, 0, 79), /* getObjectTypeOrClassStringObjectType return */ - reg::packed(78, 0, 480), /* isVoid return */ - reg::packed(78, 0, 480), /* isScalar return */ + reg::packed(78, 0, 497), /* isVoid return */ + reg::packed(78, 0, 497), /* isScalar return */ reg::packed(324, 0, 79), /* looseCompare $type */ - reg::packed(1857, 0, 1868), /* looseCompare $phpVersion */ - reg::packed(78, 0, 1891), /* looseCompare return */ - reg::packed(78, 0, 480), /* isOffsetAccessible return */ - reg::packed(78, 0, 480), /* isOffsetAccessLegal return */ - reg::packed(1968, 0, 79), /* hasOffsetValueType $offsetType */ - reg::packed(78, 0, 480), /* hasOffsetValueType return */ - reg::packed(1968, 0, 79), /* getOffsetValueType $offsetType */ + reg::packed(1874, 0, 1885), /* looseCompare $phpVersion */ + reg::packed(78, 0, 1908), /* looseCompare return */ + reg::packed(78, 0, 497), /* isOffsetAccessible return */ + reg::packed(78, 0, 497), /* isOffsetAccessLegal return */ + reg::packed(1985, 0, 79), /* hasOffsetValueType $offsetType */ + reg::packed(78, 0, 497), /* hasOffsetValueType return */ + reg::packed(1985, 0, 79), /* getOffsetValueType $offsetType */ reg::packed(78, 0, 79), /* getOffsetValueType return */ - reg::packed(1968, 0, 79), /* doGetOffsetValueType $offsetType */ + reg::packed(1985, 0, 79), /* doGetOffsetValueType $offsetType */ reg::packed(78, 0, 79), /* doGetOffsetValueType return */ - reg::packed(1968, MAY_BE_NULL, 79), /* setOffsetValueType $offsetType */ - reg::packed(2038, 0, 79), /* setOffsetValueType $valueType */ - reg::packed(2048, MAY_BE_BOOL, reg::NoString, false, false, 2060), /* setOffsetValueType $unionValues */ + reg::packed(1985, MAY_BE_NULL, 79), /* setOffsetValueType $offsetType */ + reg::packed(2055, 0, 79), /* setOffsetValueType $valueType */ + reg::packed(2065, MAY_BE_BOOL, reg::NoString, false, false, 2077), /* setOffsetValueType $unionValues */ reg::packed(78, 0, 79), /* setOffsetValueType return */ - reg::packed(1968, 0, 79), /* setExistingOffsetValueType $offsetType */ - reg::packed(2038, 0, 79), /* setExistingOffsetValueType $valueType */ + reg::packed(1985, 0, 79), /* setExistingOffsetValueType $offsetType */ + reg::packed(2055, 0, 79), /* setExistingOffsetValueType $valueType */ reg::packed(78, 0, 79), /* setExistingOffsetValueType return */ - reg::packed(1968, 0, 79), /* unsetOffset $offsetType */ + reg::packed(1985, 0, 79), /* unsetOffset $offsetType */ reg::packed(78, 0, 79), /* unsetOffset return */ - reg::packed(2123, 0, 79), /* getKeysArrayFiltered $filterValueType */ - reg::packed(2139, 0, 480), /* getKeysArrayFiltered $strict */ + reg::packed(2140, 0, 79), /* getKeysArrayFiltered $filterValueType */ + reg::packed(2156, 0, 497), /* getKeysArrayFiltered $strict */ reg::packed(78, 0, 79), /* getKeysArrayFiltered return */ reg::packed(78, 0, 79), /* getKeysArray return */ reg::packed(78, 0, 79), /* getValuesArray return */ - reg::packed(2195, 0, 79), /* chunkArray $lengthType */ - reg::packed(2206, 0, 480), /* chunkArray $preserveKeys */ + reg::packed(2212, 0, 79), /* chunkArray $lengthType */ + reg::packed(2223, 0, 497), /* chunkArray $preserveKeys */ reg::packed(78, 0, 79), /* chunkArray return */ - reg::packed(2038, 0, 79), /* fillKeysArray $valueType */ + reg::packed(2055, 0, 79), /* fillKeysArray $valueType */ reg::packed(78, 0, 79), /* fillKeysArray return */ reg::packed(78, 0, 79), /* flipArray return */ - reg::packed(2254, 0, 79), /* intersectKeyArray $otherArraysType */ + reg::packed(2271, 0, 79), /* intersectKeyArray $otherArraysType */ reg::packed(78, 0, 79), /* intersectKeyArray return */ reg::packed(78, 0, 79), /* popArray return */ - reg::packed(2206, 0, 480), /* reverseArray $preserveKeys */ + reg::packed(2223, 0, 497), /* reverseArray $preserveKeys */ reg::packed(78, 0, 79), /* reverseArray return */ - reg::packed(2310, 0, 79), /* searchArray $needleType */ - reg::packed(2139, MAY_BE_NULL, 480, false, false, 2321), /* searchArray $strict */ + reg::packed(2327, 0, 79), /* searchArray $needleType */ + reg::packed(2156, MAY_BE_NULL, 497, false, false, 2338), /* searchArray $strict */ reg::packed(78, 0, 79), /* searchArray return */ reg::packed(78, 0, 79), /* shiftArray return */ reg::packed(78, 0, 79), /* shuffleArray return */ - reg::packed(1968, 0, 79), /* sliceArray $offsetType */ - reg::packed(2195, 0, 79), /* sliceArray $lengthType */ - reg::packed(2206, 0, 480), /* sliceArray $preserveKeys */ + reg::packed(1985, 0, 79), /* sliceArray $offsetType */ + reg::packed(2212, 0, 79), /* sliceArray $lengthType */ + reg::packed(2223, 0, 497), /* sliceArray $preserveKeys */ reg::packed(78, 0, 79), /* sliceArray return */ - reg::packed(1968, 0, 79), /* spliceArray $offsetType */ - reg::packed(2195, 0, 79), /* spliceArray $lengthType */ - reg::packed(2373, 0, 79), /* spliceArray $replacementType */ + reg::packed(1985, 0, 79), /* spliceArray $offsetType */ + reg::packed(2212, 0, 79), /* spliceArray $lengthType */ + reg::packed(2390, 0, 79), /* spliceArray $replacementType */ reg::packed(78, 0, 79), /* spliceArray return */ - reg::packed(2401, 0, 79), /* truncateListToSize $sizeType */ + reg::packed(2418, 0, 79), /* truncateListToSize $sizeType */ reg::packed(78, 0, 79), /* truncateListToSize return */ reg::packed(78, 0, 79), /* makeListMaybe return */ - reg::packed(2443, MAY_BE_CALLABLE), /* mapValueType $cb */ + reg::packed(2460, MAY_BE_CALLABLE), /* mapValueType $cb */ reg::packed(78, 0, 79), /* mapValueType return */ - reg::packed(2443, MAY_BE_CALLABLE), /* mapKeyType $cb */ + reg::packed(2460, MAY_BE_CALLABLE), /* mapKeyType $cb */ reg::packed(78, 0, 79), /* mapKeyType return */ reg::packed(78, 0, 79), /* makeAllArrayKeysOptional return */ - reg::packed(2495, MAY_BE_NULL | MAY_BE_LONG), /* changeKeyCaseArray $case */ + reg::packed(2512, MAY_BE_NULL | MAY_BE_LONG), /* changeKeyCaseArray $case */ reg::packed(78, 0, 79), /* changeKeyCaseArray return */ reg::packed(78, 0, 79), /* filterArrayRemovingFalsey return */ reg::packed(78, MAY_BE_ARRAY), /* getEnumCases return */ - reg::packed(78, MAY_BE_NULL, 2558), /* getEnumCaseObject return */ - reg::packed(78, 0, 480), /* isCallable return */ - reg::packed(767, 0, 773), /* getCallableParametersAcceptors $scope */ + reg::packed(78, MAY_BE_NULL, 2575), /* getEnumCaseObject return */ + reg::packed(78, 0, 497), /* isCallable return */ + reg::packed(784, 0, 790), /* getCallableParametersAcceptors $scope */ reg::packed(78, MAY_BE_ARRAY), /* getCallableParametersAcceptors return */ - reg::packed(78, 0, 480), /* isCloneable return */ + reg::packed(78, 0, 497), /* isCloneable return */ reg::packed(376, 0, 79), /* isSmallerThan $otherType */ - reg::packed(1857, 0, 1868), /* isSmallerThan $phpVersion */ - reg::packed(78, 0, 480), /* isSmallerThan return */ + reg::packed(1874, 0, 1885), /* isSmallerThan $phpVersion */ + reg::packed(78, 0, 497), /* isSmallerThan return */ reg::packed(376, 0, 79), /* isSmallerThanOrEqual $otherType */ - reg::packed(1857, 0, 1868), /* isSmallerThanOrEqual $phpVersion */ - reg::packed(78, 0, 480), /* isSmallerThanOrEqual return */ - reg::packed(78, 0, 480), /* isNull return */ - reg::packed(78, 0, 480), /* isConstantValue return */ - reg::packed(78, 0, 480), /* isConstantScalarValue return */ + reg::packed(1874, 0, 1885), /* isSmallerThanOrEqual $phpVersion */ + reg::packed(78, 0, 497), /* isSmallerThanOrEqual return */ + reg::packed(78, 0, 497), /* isNull return */ + reg::packed(78, 0, 497), /* isConstantValue return */ + reg::packed(78, 0, 497), /* isConstantScalarValue return */ reg::packed(78, MAY_BE_ARRAY), /* getConstantScalarTypes return */ reg::packed(78, MAY_BE_ARRAY), /* getConstantScalarValues return */ - reg::packed(78, 0, 480), /* isTrue return */ - reg::packed(78, 0, 480), /* isFalse return */ - reg::packed(78, 0, 480), /* isBoolean return */ - reg::packed(78, 0, 480), /* isFloat return */ - reg::packed(78, 0, 480), /* isInteger return */ - reg::packed(1857, 0, 1868), /* getSmallerType $phpVersion */ + reg::packed(78, 0, 497), /* isTrue return */ + reg::packed(78, 0, 497), /* isFalse return */ + reg::packed(78, 0, 497), /* isBoolean return */ + reg::packed(78, 0, 497), /* isFloat return */ + reg::packed(78, 0, 497), /* isInteger return */ + reg::packed(1874, 0, 1885), /* getSmallerType $phpVersion */ reg::packed(78, 0, 79), /* getSmallerType return */ - reg::packed(1857, 0, 1868), /* getSmallerOrEqualType $phpVersion */ + reg::packed(1874, 0, 1885), /* getSmallerOrEqualType $phpVersion */ reg::packed(78, 0, 79), /* getSmallerOrEqualType return */ - reg::packed(1857, 0, 1868), /* getGreaterType $phpVersion */ + reg::packed(1874, 0, 1885), /* getGreaterType $phpVersion */ reg::packed(78, 0, 79), /* getGreaterType return */ - reg::packed(1857, 0, 1868), /* getGreaterOrEqualType $phpVersion */ + reg::packed(1874, 0, 1885), /* getGreaterOrEqualType $phpVersion */ reg::packed(78, 0, 79), /* getGreaterOrEqualType return */ reg::packed(376, 0, 79), /* isGreaterThan $otherType */ - reg::packed(1857, 0, 1868), /* isGreaterThan $phpVersion */ - reg::packed(78, 0, 480), /* isGreaterThan return */ + reg::packed(1874, 0, 1885), /* isGreaterThan $phpVersion */ + reg::packed(78, 0, 497), /* isGreaterThan return */ reg::packed(376, 0, 79), /* isGreaterThanOrEqual $otherType */ - reg::packed(1857, 0, 1868), /* isGreaterThanOrEqual $phpVersion */ - reg::packed(78, 0, 480), /* isGreaterThanOrEqual return */ - reg::packed(78, 0, 1891), /* toBoolean return */ + reg::packed(1874, 0, 1885), /* isGreaterThanOrEqual $phpVersion */ + reg::packed(78, 0, 497), /* isGreaterThanOrEqual return */ + reg::packed(78, 0, 1908), /* toBoolean return */ reg::packed(78, 0, 79), /* toNumber return */ - reg::packed(78, MAY_BE_NULL, 2965), /* toNumberSet return */ + reg::packed(78, MAY_BE_NULL, 2982), /* toNumberSet return */ reg::packed(78, 0, 79), /* toBitwiseNotType return */ reg::packed(78, 0, 79), /* toGetClassResultType return */ - reg::packed(3038, 0, 3057), /* toClassConstantType $reflectionProvider */ + reg::packed(3055, 0, 3074), /* toClassConstantType $reflectionProvider */ reg::packed(78, 0, 79), /* toClassConstantType return */ - reg::packed(78, 0, 3115), /* toObjectTypeForInstanceofCheck return */ - reg::packed(3187, 0, 79), /* toObjectTypeForIsACheck $objectOrClassType */ - reg::packed(3205, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowString */ - reg::packed(3217, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowSameClass */ - reg::packed(78, 0, 3115), /* toObjectTypeForIsACheck return */ + reg::packed(78, 0, 3132), /* toObjectTypeForInstanceofCheck return */ + reg::packed(3204, 0, 79), /* toObjectTypeForIsACheck $objectOrClassType */ + reg::packed(3222, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowString */ + reg::packed(3234, MAY_BE_BOOL), /* toObjectTypeForIsACheck $allowSameClass */ + reg::packed(78, 0, 3132), /* toObjectTypeForIsACheck return */ reg::packed(78, 0, 79), /* toAbsoluteNumber return */ reg::packed(78, 0, 79), /* toString return */ reg::packed(78, 0, 79), /* toInteger return */ @@ -521,46 +523,46 @@ inline constexpr reg::PackedArg args[] = { reg::packed(78, 0, 79), /* toArrayKey return */ reg::packed(329, MAY_BE_BOOL), /* toCoercedArgumentType $strictTypes */ reg::packed(78, 0, 79), /* toCoercedArgumentType return */ - reg::packed(3341, 0, 79), /* inferTemplateTypes $receivedType */ - reg::packed(78, 0, 3354), /* inferTemplateTypes return */ + reg::packed(3358, 0, 79), /* inferTemplateTypes $receivedType */ + reg::packed(78, 0, 3371), /* inferTemplateTypes return */ reg::packed(324, 0, 79), /* getNakedTemplateType $type */ - reg::packed(78, MAY_BE_NULL, 3410), /* getNakedTemplateType return */ - reg::packed(3465, 0, 3354), /* getAbsorbedTemplateTypes $inferred */ - reg::packed(78, 0, 3354), /* getAbsorbedTemplateTypes return */ - reg::packed(3499, 0, 79), /* inferTemplateTypesOn $templateType */ - reg::packed(78, 0, 3354), /* inferTemplateTypesOn return */ - reg::packed(3533, 0, 3550), /* getReferencedTemplateTypes $positionVariance */ + reg::packed(78, MAY_BE_NULL, 3427), /* getNakedTemplateType return */ + reg::packed(3482, 0, 3371), /* getAbsorbedTemplateTypes $inferred */ + reg::packed(78, 0, 3371), /* getAbsorbedTemplateTypes return */ + reg::packed(3516, 0, 79), /* inferTemplateTypesOn $templateType */ + reg::packed(78, 0, 3371), /* inferTemplateTypesOn return */ + reg::packed(3550, 0, 3567), /* getReferencedTemplateTypes $positionVariance */ reg::packed(78, MAY_BE_ARRAY), /* getReferencedTemplateTypes return */ - reg::packed(2443, MAY_BE_CALLABLE), /* traverse $cb */ + reg::packed(2460, MAY_BE_CALLABLE), /* traverse $cb */ reg::packed(78, 0, 79), /* traverse return */ - reg::packed(3628, 0, 79), /* traverseSimultaneously $right */ - reg::packed(2443, MAY_BE_CALLABLE), /* traverseSimultaneously $cb */ + reg::packed(3645, 0, 79), /* traverseSimultaneously $right */ + reg::packed(2460, MAY_BE_CALLABLE), /* traverseSimultaneously $cb */ reg::packed(78, 0, 79), /* traverseSimultaneously return */ - reg::packed(3657, 0, 79), /* tryRemove $typeToRemove */ + reg::packed(3674, 0, 79), /* tryRemove $typeToRemove */ reg::packed(78, MAY_BE_NULL, 79), /* tryRemove return */ - reg::packed(3680, 0, 79), /* arithmeticPower $exponent */ - reg::packed(1857, 0, 1868), /* arithmeticPower $phpVersion */ + reg::packed(3697, 0, 79), /* arithmeticPower $exponent */ + reg::packed(1874, 0, 1885), /* arithmeticPower $phpVersion */ reg::packed(78, 0, 79), /* arithmeticPower return */ reg::packed(78, MAY_BE_ARRAY), /* getFiniteTypes return */ - reg::packed(3720, MAY_BE_CALLABLE), /* unionResults $getResult */ - reg::packed(78, 0, 480), /* unionResults return */ - reg::packed(3720, MAY_BE_CALLABLE), /* notBenevolentUnionResults $getResult */ - reg::packed(78, 0, 480), /* notBenevolentUnionResults return */ - reg::packed(3769, MAY_BE_CALLABLE), /* unionTypes $getType */ + reg::packed(3737, MAY_BE_CALLABLE), /* unionResults $getResult */ + reg::packed(78, 0, 497), /* unionResults return */ + reg::packed(3737, MAY_BE_CALLABLE), /* notBenevolentUnionResults $getResult */ + reg::packed(78, 0, 497), /* notBenevolentUnionResults return */ + reg::packed(3786, MAY_BE_CALLABLE), /* unionTypes $getType */ reg::packed(78, 0, 79), /* unionTypes return */ - reg::packed(3788, MAY_BE_CALLABLE), /* pickFromTypes $getValues */ - reg::packed(3798, MAY_BE_CALLABLE), /* pickFromTypes $criteria */ + reg::packed(3805, MAY_BE_CALLABLE), /* pickFromTypes $getValues */ + reg::packed(3815, MAY_BE_CALLABLE), /* pickFromTypes $criteria */ reg::packed(78, MAY_BE_ARRAY), /* pickFromTypes return */ - reg::packed(78, 0, 3821), /* toPhpDocNode return */ - reg::packed(3873, 0, 3882), /* toNativePhpTypeNode $position */ - reg::packed(3788, MAY_BE_CALLABLE), /* notBenevolentPickFromTypes $getValues */ + reg::packed(78, 0, 3838), /* toPhpDocNode return */ + reg::packed(3890, 0, 3899), /* toNativePhpTypeNode $position */ + reg::packed(3805, MAY_BE_CALLABLE), /* notBenevolentPickFromTypes $getValues */ reg::packed(78, MAY_BE_ARRAY), /* notBenevolentPickFromTypes return */ reg::packed(78, MAY_BE_BOOL), /* hasTemplateOrLateResolvableType return */ - reg::packed(1857, 0, 1868), /* getPossiblyLooselyEqualType $phpVersion */ + reg::packed(1874, 0, 1885), /* getPossiblyLooselyEqualType $phpVersion */ reg::packed(78, 0, 79), /* getPossiblyLooselyEqualType return */ - reg::packed(1857, 0, 1868), /* getAlwaysLooselyEqualType $phpVersion */ + reg::packed(1874, 0, 1885), /* getAlwaysLooselyEqualType $phpVersion */ reg::packed(78, 0, 79), /* getAlwaysLooselyEqualType return */ - reg::packed(78, 0, 4047), /* toValueSet return */ + reg::packed(78, 0, 4064), /* toValueSet return */ }; using Sig = reg::Sig; } // namespace sigtab @@ -584,147 +586,148 @@ inline constexpr sigtab::Sig accepts = { { 368 /* accepts */, 2, 16, 2, 18, ZEND inline constexpr sigtab::Sig isSuperTypeOf = { { 419 /* isSuperTypeOf */, 1, 19, 1, 20, ZEND_ACC_PUBLIC } }; inline constexpr sigtab::Sig isSubTypeOf = { { 433 /* isSubTypeOf */, 1, 21, 1, 22, ZEND_ACC_PUBLIC } }; inline constexpr sigtab::Sig isAcceptedBy = { { 459 /* isAcceptedBy */, 2, 23, 2, 25, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig finiteTypeSetContainedIn = { { 501 /* finiteTypeSetContainedIn */, 2, 26, 2, 28, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig equals = { { 526 /* equals */, 1, 29, 1, 30, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig describe = { { 567 /* describe */, 1, 31, 1, 32, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasInternal = { { 600 /* hasInternal */, 2, 33, 2, 35, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getInternal = { { 624 /* getInternal */, 2, 36, 2, 38, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig getTemplateType = { { 671 /* getTemplateType */, 2, 39, 2, 41, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isObject = { { 687 /* isObject */, 0, 42, 0, 42, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getClassStringType = { { 696 /* getClassStringType */, 0, 43, 0, 43, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isEnum = { { 715 /* isEnum */, 0, 44, 0, 44, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig canAccessProperties = { { 722 /* canAccessProperties */, 0, 45, 0, 45, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasProperty = { { 755 /* hasProperty */, 1, 46, 1, 47, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getProperty = { { 864 /* getProperty */, 2, 48, 2, 50, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedPropertyPrototype = { { 938 /* getUnresolvedPropertyPrototype */, 2, 51, 2, 53, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasInstanceProperty = { { 969 /* hasInstanceProperty */, 1, 54, 1, 55, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getInstanceProperty = { { 989 /* getInstanceProperty */, 2, 56, 2, 58, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedInstancePropertyPrototype = { { 1009 /* getUnresolvedInstancePropertyPrototype */, 2, 59, 2, 61, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasStaticProperty = { { 1048 /* hasStaticProperty */, 1, 62, 1, 63, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getStaticProperty = { { 1066 /* getStaticProperty */, 2, 64, 2, 66, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedStaticPropertyPrototype = { { 1084 /* getUnresolvedStaticPropertyPrototype */, 2, 67, 2, 69, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig canCallMethods = { { 1121 /* canCallMethods */, 0, 70, 0, 70, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasMethod = { { 1147 /* hasMethod */, 1, 71, 1, 72, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getMethod = { { 1201 /* getMethod */, 2, 73, 2, 75, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getUnresolvedMethodPrototype = { { 1271 /* getUnresolvedMethodPrototype */, 2, 76, 2, 78, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig canAccessConstants = { { 1300 /* canAccessConstants */, 0, 79, 0, 79, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasConstant = { { 1332 /* hasConstant */, 1, 80, 1, 81, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstant = { { 1387 /* getConstant */, 1, 82, 1, 83, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isIterable = { { 1399 /* isIterable */, 0, 84, 0, 84, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isIterableAtLeastOnce = { { 1410 /* isIterableAtLeastOnce */, 0, 85, 0, 85, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getArraySize = { { 1432 /* getArraySize */, 0, 86, 0, 86, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getIterableKeyType = { { 1445 /* getIterableKeyType */, 0, 87, 0, 87, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getFirstIterableKeyType = { { 1464 /* getFirstIterableKeyType */, 0, 88, 0, 88, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getLastIterableKeyType = { { 1488 /* getLastIterableKeyType */, 0, 89, 0, 89, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getIterableValueType = { { 1511 /* getIterableValueType */, 0, 90, 0, 90, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getFirstIterableValueType = { { 1532 /* getFirstIterableValueType */, 0, 91, 0, 91, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getLastIterableValueType = { { 1558 /* getLastIterableValueType */, 0, 92, 0, 92, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isArray = { { 1583 /* isArray */, 0, 93, 0, 93, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isConstantArray = { { 1591 /* isConstantArray */, 0, 94, 0, 94, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isOversizedArray = { { 1607 /* isOversizedArray */, 0, 95, 0, 95, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isList = { { 1624 /* isList */, 0, 96, 0, 96, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isString = { { 1631 /* isString */, 0, 97, 0, 97, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNumericString = { { 1640 /* isNumericString */, 0, 98, 0, 98, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isDecimalIntegerString = { { 1656 /* isDecimalIntegerString */, 0, 99, 0, 99, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNonEmptyString = { { 1679 /* isNonEmptyString */, 0, 100, 0, 100, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNonFalsyString = { { 1696 /* isNonFalsyString */, 0, 101, 0, 101, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isLiteralString = { { 1713 /* isLiteralString */, 0, 102, 0, 102, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isLowercaseString = { { 1729 /* isLowercaseString */, 0, 103, 0, 103, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isUppercaseString = { { 1747 /* isUppercaseString */, 0, 104, 0, 104, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isClassString = { { 1765 /* isClassString */, 0, 105, 0, 105, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getClassStringObjectType = { { 1779 /* getClassStringObjectType */, 0, 106, 0, 106, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getObjectTypeOrClassStringObjectType = { { 1804 /* getObjectTypeOrClassStringObjectType */, 0, 107, 0, 107, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isVoid = { { 1841 /* isVoid */, 0, 108, 0, 108, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isScalar = { { 1848 /* isScalar */, 0, 109, 0, 109, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig looseCompare = { { 1916 /* looseCompare */, 2, 110, 2, 112, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isOffsetAccessible = { { 1929 /* isOffsetAccessible */, 0, 113, 0, 113, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isOffsetAccessLegal = { { 1948 /* isOffsetAccessLegal */, 0, 114, 0, 114, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig hasOffsetValueType = { { 1979 /* hasOffsetValueType */, 1, 115, 1, 116, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getOffsetValueType = { { 1998 /* getOffsetValueType */, 1, 117, 1, 118, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig doGetOffsetValueType = { { 2017 /* doGetOffsetValueType */, 1, 119, 1, 120, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig setOffsetValueType = { { 2065 /* setOffsetValueType */, 2, 121, 3, 124, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig setExistingOffsetValueType = { { 2084 /* setExistingOffsetValueType */, 2, 125, 2, 127, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig unsetOffset = { { 2111 /* unsetOffset */, 1, 128, 1, 129, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getKeysArrayFiltered = { { 2146 /* getKeysArrayFiltered */, 2, 130, 2, 132, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getKeysArray = { { 2167 /* getKeysArray */, 0, 133, 0, 133, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getValuesArray = { { 2180 /* getValuesArray */, 0, 134, 0, 134, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig chunkArray = { { 2219 /* chunkArray */, 2, 135, 2, 137, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig fillKeysArray = { { 2230 /* fillKeysArray */, 1, 138, 1, 139, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig flipArray = { { 2244 /* flipArray */, 0, 140, 0, 140, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig intersectKeyArray = { { 2270 /* intersectKeyArray */, 1, 141, 1, 142, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig popArray = { { 2288 /* popArray */, 0, 143, 0, 143, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig reverseArray = { { 2297 /* reverseArray */, 1, 144, 1, 145, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig searchArray = { { 2326 /* searchArray */, 1, 146, 2, 148, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig shiftArray = { { 2338 /* shiftArray */, 0, 149, 0, 149, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig shuffleArray = { { 2349 /* shuffleArray */, 0, 150, 0, 150, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig sliceArray = { { 2362 /* sliceArray */, 3, 151, 3, 154, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig spliceArray = { { 2389 /* spliceArray */, 3, 155, 3, 158, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig truncateListToSize = { { 2410 /* truncateListToSize */, 1, 159, 1, 160, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig makeListMaybe = { { 2429 /* makeListMaybe */, 0, 161, 0, 161, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig mapValueType = { { 2446 /* mapValueType */, 1, 162, 1, 163, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig mapKeyType = { { 2459 /* mapKeyType */, 1, 164, 1, 165, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig makeAllArrayKeysOptional = { { 2470 /* makeAllArrayKeysOptional */, 0, 166, 0, 166, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig changeKeyCaseArray = { { 2500 /* changeKeyCaseArray */, 1, 167, 1, 168, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig filterArrayRemovingFalsey = { { 2519 /* filterArrayRemovingFalsey */, 0, 169, 0, 169, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getEnumCases = { { 2545 /* getEnumCases */, 0, 170, 0, 170, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getEnumCaseObject = { { 2595 /* getEnumCaseObject */, 0, 171, 0, 171, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isCallable = { { 2613 /* isCallable */, 0, 172, 0, 172, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getCallableParametersAcceptors = { { 2624 /* getCallableParametersAcceptors */, 1, 173, 1, 174, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isCloneable = { { 2655 /* isCloneable */, 0, 175, 0, 175, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isSmallerThan = { { 2667 /* isSmallerThan */, 2, 176, 2, 178, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isSmallerThanOrEqual = { { 2681 /* isSmallerThanOrEqual */, 2, 179, 2, 181, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isNull = { { 2702 /* isNull */, 0, 182, 0, 182, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isConstantValue = { { 2709 /* isConstantValue */, 0, 183, 0, 183, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isConstantScalarValue = { { 2725 /* isConstantScalarValue */, 0, 184, 0, 184, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstantScalarTypes = { { 2747 /* getConstantScalarTypes */, 0, 185, 0, 185, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getConstantScalarValues = { { 2770 /* getConstantScalarValues */, 0, 186, 0, 186, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isTrue = { { 2794 /* isTrue */, 0, 187, 0, 187, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isFalse = { { 2801 /* isFalse */, 0, 188, 0, 188, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isBoolean = { { 2809 /* isBoolean */, 0, 189, 0, 189, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isFloat = { { 2819 /* isFloat */, 0, 190, 0, 190, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isInteger = { { 2827 /* isInteger */, 0, 191, 0, 191, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getSmallerType = { { 2837 /* getSmallerType */, 1, 192, 1, 193, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getSmallerOrEqualType = { { 2852 /* getSmallerOrEqualType */, 1, 194, 1, 195, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getGreaterType = { { 2874 /* getGreaterType */, 1, 196, 1, 197, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getGreaterOrEqualType = { { 2889 /* getGreaterOrEqualType */, 1, 198, 1, 199, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isGreaterThan = { { 2911 /* isGreaterThan */, 2, 200, 2, 202, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig isGreaterThanOrEqual = { { 2925 /* isGreaterThanOrEqual */, 2, 203, 2, 205, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toBoolean = { { 2946 /* toBoolean */, 0, 206, 0, 206, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toNumber = { { 2956 /* toNumber */, 0, 207, 0, 207, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toNumberSet = { { 2988 /* toNumberSet */, 0, 208, 0, 208, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toBitwiseNotType = { { 3000 /* toBitwiseNotType */, 0, 209, 0, 209, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toGetClassResultType = { { 3017 /* toGetClassResultType */, 0, 210, 0, 210, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toClassConstantType = { { 3095 /* toClassConstantType */, 1, 211, 1, 212, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toObjectTypeForInstanceofCheck = { { 3156 /* toObjectTypeForInstanceofCheck */, 0, 213, 0, 213, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toObjectTypeForIsACheck = { { 3232 /* toObjectTypeForIsACheck */, 3, 214, 3, 217, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toAbsoluteNumber = { { 3256 /* toAbsoluteNumber */, 0, 218, 0, 218, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toString = { { 3273 /* toString */, 0, 219, 0, 219, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toInteger = { { 3282 /* toInteger */, 0, 220, 0, 220, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toFloat = { { 3292 /* toFloat */, 0, 221, 0, 221, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toArray = { { 3300 /* toArray */, 0, 222, 0, 222, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toArrayKey = { { 3308 /* toArrayKey */, 0, 223, 0, 223, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toCoercedArgumentType = { { 3319 /* toCoercedArgumentType */, 1, 224, 1, 225, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig inferTemplateTypes = { { 3391 /* inferTemplateTypes */, 1, 226, 1, 227, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getNakedTemplateType = { { 3444 /* getNakedTemplateType */, 1, 228, 1, 229, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; -inline constexpr sigtab::Sig getAbsorbedTemplateTypes = { { 3474 /* getAbsorbedTemplateTypes */, 1, 230, 1, 231, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig inferTemplateTypesOn = { { 3512 /* inferTemplateTypesOn */, 1, 232, 1, 233, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getReferencedTemplateTypes = { { 3592 /* getReferencedTemplateTypes */, 1, 234, 1, 235, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig traverse = { { 3619 /* traverse */, 1, 236, 1, 237, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig traverseSimultaneously = { { 3634 /* traverseSimultaneously */, 2, 238, 2, 240, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig tryRemove = { { 3670 /* tryRemove */, 1, 241, 1, 242, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig arithmeticPower = { { 3689 /* arithmeticPower */, 2, 243, 2, 245, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getFiniteTypes = { { 3705 /* getFiniteTypes */, 0, 246, 0, 246, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig unionResults = { { 3730 /* unionResults */, 1, 247, 1, 248, ZEND_ACC_PROTECTED } }; -inline constexpr sigtab::Sig notBenevolentUnionResults = { { 3743 /* notBenevolentUnionResults */, 1, 249, 1, 250, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig unionTypes = { { 3777 /* unionTypes */, 1, 251, 1, 252, ZEND_ACC_PROTECTED } }; -inline constexpr sigtab::Sig pickFromTypes = { { 3807 /* pickFromTypes */, 2, 253, 2, 255, ZEND_ACC_PROTECTED } }; -inline constexpr sigtab::Sig toPhpDocNode = { { 3860 /* toPhpDocNode */, 0, 256, 0, 256, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toNativePhpTypeNode = { { 3914 /* toNativePhpTypeNode */, 1, 257, 1, reg::NoArg, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig notBenevolentPickFromTypes = { { 3934 /* notBenevolentPickFromTypes */, 1, 258, 1, 259, ZEND_ACC_PRIVATE } }; -inline constexpr sigtab::Sig hasTemplateOrLateResolvableType = { { 3961 /* hasTemplateOrLateResolvableType */, 0, 260, 0, 260, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getPossiblyLooselyEqualType = { { 3993 /* getPossiblyLooselyEqualType */, 1, 261, 1, 262, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig getAlwaysLooselyEqualType = { { 4021 /* getAlwaysLooselyEqualType */, 1, 263, 1, 264, ZEND_ACC_PUBLIC } }; -inline constexpr sigtab::Sig toValueSet = { { 4069 /* toValueSet */, 0, 265, 0, 265, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasClosureMember = { { 472 /* hasClosureMember */, 0, 26, 0, 26, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig finiteTypeSetContainedIn = { { 518 /* finiteTypeSetContainedIn */, 2, 27, 2, 29, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig equals = { { 543 /* equals */, 1, 30, 1, 31, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig describe = { { 584 /* describe */, 1, 32, 1, 33, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasInternal = { { 617 /* hasInternal */, 2, 34, 2, 36, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getInternal = { { 641 /* getInternal */, 2, 37, 2, 39, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig getTemplateType = { { 688 /* getTemplateType */, 2, 40, 2, 42, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isObject = { { 704 /* isObject */, 0, 43, 0, 43, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getClassStringType = { { 713 /* getClassStringType */, 0, 44, 0, 44, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isEnum = { { 732 /* isEnum */, 0, 45, 0, 45, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig canAccessProperties = { { 739 /* canAccessProperties */, 0, 46, 0, 46, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasProperty = { { 772 /* hasProperty */, 1, 47, 1, 48, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getProperty = { { 881 /* getProperty */, 2, 49, 2, 51, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedPropertyPrototype = { { 955 /* getUnresolvedPropertyPrototype */, 2, 52, 2, 54, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasInstanceProperty = { { 986 /* hasInstanceProperty */, 1, 55, 1, 56, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getInstanceProperty = { { 1006 /* getInstanceProperty */, 2, 57, 2, 59, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedInstancePropertyPrototype = { { 1026 /* getUnresolvedInstancePropertyPrototype */, 2, 60, 2, 62, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasStaticProperty = { { 1065 /* hasStaticProperty */, 1, 63, 1, 64, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getStaticProperty = { { 1083 /* getStaticProperty */, 2, 65, 2, 67, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedStaticPropertyPrototype = { { 1101 /* getUnresolvedStaticPropertyPrototype */, 2, 68, 2, 70, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig canCallMethods = { { 1138 /* canCallMethods */, 0, 71, 0, 71, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasMethod = { { 1164 /* hasMethod */, 1, 72, 1, 73, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getMethod = { { 1218 /* getMethod */, 2, 74, 2, 76, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getUnresolvedMethodPrototype = { { 1288 /* getUnresolvedMethodPrototype */, 2, 77, 2, 79, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig canAccessConstants = { { 1317 /* canAccessConstants */, 0, 80, 0, 80, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasConstant = { { 1349 /* hasConstant */, 1, 81, 1, 82, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstant = { { 1404 /* getConstant */, 1, 83, 1, 84, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isIterable = { { 1416 /* isIterable */, 0, 85, 0, 85, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isIterableAtLeastOnce = { { 1427 /* isIterableAtLeastOnce */, 0, 86, 0, 86, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getArraySize = { { 1449 /* getArraySize */, 0, 87, 0, 87, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getIterableKeyType = { { 1462 /* getIterableKeyType */, 0, 88, 0, 88, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getFirstIterableKeyType = { { 1481 /* getFirstIterableKeyType */, 0, 89, 0, 89, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getLastIterableKeyType = { { 1505 /* getLastIterableKeyType */, 0, 90, 0, 90, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getIterableValueType = { { 1528 /* getIterableValueType */, 0, 91, 0, 91, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getFirstIterableValueType = { { 1549 /* getFirstIterableValueType */, 0, 92, 0, 92, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getLastIterableValueType = { { 1575 /* getLastIterableValueType */, 0, 93, 0, 93, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isArray = { { 1600 /* isArray */, 0, 94, 0, 94, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isConstantArray = { { 1608 /* isConstantArray */, 0, 95, 0, 95, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isOversizedArray = { { 1624 /* isOversizedArray */, 0, 96, 0, 96, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isList = { { 1641 /* isList */, 0, 97, 0, 97, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isString = { { 1648 /* isString */, 0, 98, 0, 98, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNumericString = { { 1657 /* isNumericString */, 0, 99, 0, 99, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isDecimalIntegerString = { { 1673 /* isDecimalIntegerString */, 0, 100, 0, 100, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNonEmptyString = { { 1696 /* isNonEmptyString */, 0, 101, 0, 101, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNonFalsyString = { { 1713 /* isNonFalsyString */, 0, 102, 0, 102, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isLiteralString = { { 1730 /* isLiteralString */, 0, 103, 0, 103, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isLowercaseString = { { 1746 /* isLowercaseString */, 0, 104, 0, 104, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isUppercaseString = { { 1764 /* isUppercaseString */, 0, 105, 0, 105, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isClassString = { { 1782 /* isClassString */, 0, 106, 0, 106, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getClassStringObjectType = { { 1796 /* getClassStringObjectType */, 0, 107, 0, 107, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getObjectTypeOrClassStringObjectType = { { 1821 /* getObjectTypeOrClassStringObjectType */, 0, 108, 0, 108, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isVoid = { { 1858 /* isVoid */, 0, 109, 0, 109, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isScalar = { { 1865 /* isScalar */, 0, 110, 0, 110, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig looseCompare = { { 1933 /* looseCompare */, 2, 111, 2, 113, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isOffsetAccessible = { { 1946 /* isOffsetAccessible */, 0, 114, 0, 114, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isOffsetAccessLegal = { { 1965 /* isOffsetAccessLegal */, 0, 115, 0, 115, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig hasOffsetValueType = { { 1996 /* hasOffsetValueType */, 1, 116, 1, 117, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getOffsetValueType = { { 2015 /* getOffsetValueType */, 1, 118, 1, 119, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig doGetOffsetValueType = { { 2034 /* doGetOffsetValueType */, 1, 120, 1, 121, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig setOffsetValueType = { { 2082 /* setOffsetValueType */, 2, 122, 3, 125, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig setExistingOffsetValueType = { { 2101 /* setExistingOffsetValueType */, 2, 126, 2, 128, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig unsetOffset = { { 2128 /* unsetOffset */, 1, 129, 1, 130, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getKeysArrayFiltered = { { 2163 /* getKeysArrayFiltered */, 2, 131, 2, 133, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getKeysArray = { { 2184 /* getKeysArray */, 0, 134, 0, 134, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getValuesArray = { { 2197 /* getValuesArray */, 0, 135, 0, 135, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig chunkArray = { { 2236 /* chunkArray */, 2, 136, 2, 138, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig fillKeysArray = { { 2247 /* fillKeysArray */, 1, 139, 1, 140, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig flipArray = { { 2261 /* flipArray */, 0, 141, 0, 141, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig intersectKeyArray = { { 2287 /* intersectKeyArray */, 1, 142, 1, 143, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig popArray = { { 2305 /* popArray */, 0, 144, 0, 144, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig reverseArray = { { 2314 /* reverseArray */, 1, 145, 1, 146, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig searchArray = { { 2343 /* searchArray */, 1, 147, 2, 149, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig shiftArray = { { 2355 /* shiftArray */, 0, 150, 0, 150, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig shuffleArray = { { 2366 /* shuffleArray */, 0, 151, 0, 151, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig sliceArray = { { 2379 /* sliceArray */, 3, 152, 3, 155, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig spliceArray = { { 2406 /* spliceArray */, 3, 156, 3, 159, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig truncateListToSize = { { 2427 /* truncateListToSize */, 1, 160, 1, 161, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig makeListMaybe = { { 2446 /* makeListMaybe */, 0, 162, 0, 162, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig mapValueType = { { 2463 /* mapValueType */, 1, 163, 1, 164, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig mapKeyType = { { 2476 /* mapKeyType */, 1, 165, 1, 166, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig makeAllArrayKeysOptional = { { 2487 /* makeAllArrayKeysOptional */, 0, 167, 0, 167, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig changeKeyCaseArray = { { 2517 /* changeKeyCaseArray */, 1, 168, 1, 169, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig filterArrayRemovingFalsey = { { 2536 /* filterArrayRemovingFalsey */, 0, 170, 0, 170, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getEnumCases = { { 2562 /* getEnumCases */, 0, 171, 0, 171, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getEnumCaseObject = { { 2612 /* getEnumCaseObject */, 0, 172, 0, 172, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isCallable = { { 2630 /* isCallable */, 0, 173, 0, 173, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getCallableParametersAcceptors = { { 2641 /* getCallableParametersAcceptors */, 1, 174, 1, 175, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isCloneable = { { 2672 /* isCloneable */, 0, 176, 0, 176, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isSmallerThan = { { 2684 /* isSmallerThan */, 2, 177, 2, 179, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isSmallerThanOrEqual = { { 2698 /* isSmallerThanOrEqual */, 2, 180, 2, 182, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isNull = { { 2719 /* isNull */, 0, 183, 0, 183, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isConstantValue = { { 2726 /* isConstantValue */, 0, 184, 0, 184, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isConstantScalarValue = { { 2742 /* isConstantScalarValue */, 0, 185, 0, 185, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstantScalarTypes = { { 2764 /* getConstantScalarTypes */, 0, 186, 0, 186, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getConstantScalarValues = { { 2787 /* getConstantScalarValues */, 0, 187, 0, 187, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isTrue = { { 2811 /* isTrue */, 0, 188, 0, 188, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isFalse = { { 2818 /* isFalse */, 0, 189, 0, 189, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isBoolean = { { 2826 /* isBoolean */, 0, 190, 0, 190, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isFloat = { { 2836 /* isFloat */, 0, 191, 0, 191, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isInteger = { { 2844 /* isInteger */, 0, 192, 0, 192, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getSmallerType = { { 2854 /* getSmallerType */, 1, 193, 1, 194, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getSmallerOrEqualType = { { 2869 /* getSmallerOrEqualType */, 1, 195, 1, 196, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getGreaterType = { { 2891 /* getGreaterType */, 1, 197, 1, 198, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getGreaterOrEqualType = { { 2906 /* getGreaterOrEqualType */, 1, 199, 1, 200, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isGreaterThan = { { 2928 /* isGreaterThan */, 2, 201, 2, 203, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig isGreaterThanOrEqual = { { 2942 /* isGreaterThanOrEqual */, 2, 204, 2, 206, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toBoolean = { { 2963 /* toBoolean */, 0, 207, 0, 207, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toNumber = { { 2973 /* toNumber */, 0, 208, 0, 208, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toNumberSet = { { 3005 /* toNumberSet */, 0, 209, 0, 209, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toBitwiseNotType = { { 3017 /* toBitwiseNotType */, 0, 210, 0, 210, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toGetClassResultType = { { 3034 /* toGetClassResultType */, 0, 211, 0, 211, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toClassConstantType = { { 3112 /* toClassConstantType */, 1, 212, 1, 213, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toObjectTypeForInstanceofCheck = { { 3173 /* toObjectTypeForInstanceofCheck */, 0, 214, 0, 214, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toObjectTypeForIsACheck = { { 3249 /* toObjectTypeForIsACheck */, 3, 215, 3, 218, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toAbsoluteNumber = { { 3273 /* toAbsoluteNumber */, 0, 219, 0, 219, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toString = { { 3290 /* toString */, 0, 220, 0, 220, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toInteger = { { 3299 /* toInteger */, 0, 221, 0, 221, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toFloat = { { 3309 /* toFloat */, 0, 222, 0, 222, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toArray = { { 3317 /* toArray */, 0, 223, 0, 223, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toArrayKey = { { 3325 /* toArrayKey */, 0, 224, 0, 224, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toCoercedArgumentType = { { 3336 /* toCoercedArgumentType */, 1, 225, 1, 226, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig inferTemplateTypes = { { 3408 /* inferTemplateTypes */, 1, 227, 1, 228, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getNakedTemplateType = { { 3461 /* getNakedTemplateType */, 1, 229, 1, 230, ZEND_ACC_PRIVATE | ZEND_ACC_STATIC } }; +inline constexpr sigtab::Sig getAbsorbedTemplateTypes = { { 3491 /* getAbsorbedTemplateTypes */, 1, 231, 1, 232, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig inferTemplateTypesOn = { { 3529 /* inferTemplateTypesOn */, 1, 233, 1, 234, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getReferencedTemplateTypes = { { 3609 /* getReferencedTemplateTypes */, 1, 235, 1, 236, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig traverse = { { 3636 /* traverse */, 1, 237, 1, 238, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig traverseSimultaneously = { { 3651 /* traverseSimultaneously */, 2, 239, 2, 241, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig tryRemove = { { 3687 /* tryRemove */, 1, 242, 1, 243, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig arithmeticPower = { { 3706 /* arithmeticPower */, 2, 244, 2, 246, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getFiniteTypes = { { 3722 /* getFiniteTypes */, 0, 247, 0, 247, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig unionResults = { { 3747 /* unionResults */, 1, 248, 1, 249, ZEND_ACC_PROTECTED } }; +inline constexpr sigtab::Sig notBenevolentUnionResults = { { 3760 /* notBenevolentUnionResults */, 1, 250, 1, 251, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig unionTypes = { { 3794 /* unionTypes */, 1, 252, 1, 253, ZEND_ACC_PROTECTED } }; +inline constexpr sigtab::Sig pickFromTypes = { { 3824 /* pickFromTypes */, 2, 254, 2, 256, ZEND_ACC_PROTECTED } }; +inline constexpr sigtab::Sig toPhpDocNode = { { 3877 /* toPhpDocNode */, 0, 257, 0, 257, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toNativePhpTypeNode = { { 3931 /* toNativePhpTypeNode */, 1, 258, 1, reg::NoArg, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig notBenevolentPickFromTypes = { { 3951 /* notBenevolentPickFromTypes */, 1, 259, 1, 260, ZEND_ACC_PRIVATE } }; +inline constexpr sigtab::Sig hasTemplateOrLateResolvableType = { { 3978 /* hasTemplateOrLateResolvableType */, 0, 261, 0, 261, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getPossiblyLooselyEqualType = { { 4010 /* getPossiblyLooselyEqualType */, 1, 262, 1, 263, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig getAlwaysLooselyEqualType = { { 4038 /* getAlwaysLooselyEqualType */, 1, 264, 1, 265, ZEND_ACC_PUBLIC } }; +inline constexpr sigtab::Sig toValueSet = { { 4086 /* toValueSet */, 0, 266, 0, 266, ZEND_ACC_PUBLIC } }; } // namespace sig } // namespace ptdecl::UnionType diff --git a/turbo-ext/src/support.cpp b/turbo-ext/src/support.cpp index a9915e4aa8f..62d889a5a13 100644 --- a/turbo-ext/src/support.cpp +++ b/turbo-ext/src/support.cpp @@ -417,6 +417,9 @@ static const pt_class_template pt_class_templates[PT_CLASS_COUNT] = { /* PT_CLASS_TYPE_NODE_DESCRIBER */ {"typeNodeDescriber", "PHPStan\\Type\\TypeNodeDescriber"}, /* PT_CLASS_ARRAY_MAP_CALLBACK_PARAMETER_TYPES */ {"arrayMapCallbackParameterTypes", "PHPStan\\Reflection\\ArrayMapCallbackParameterTypes"}, /* PT_CLASS_VALUE_DEPENDENCY_COLLECTOR */ {"valueDependencyCollector", "PHPStan\\Analyser\\ValueDependencyCollector"}, + /* PT_CLASS_PARTIAL_FUNCTION_APPLICATION_PARAMETERS */ {"partialFunctionApplicationParameters", "PHPStan\\Reflection\\PartialFunctionApplicationParameters"}, + /* PT_CLASS_CLOSURE_ORIGIN */ {"closureOrigin", "PHPStan\\Type\\ClosureOrigin"}, + /* PT_CLASS_CLOSURE_ORIGIN_CALL_REPLAY */ {"closureOriginCallReplay", "PHPStan\\Analyser\\ExprHandler\\Helper\\ClosureOriginCallReplay"}, }; zend_class_entry *pt_class(int idx) diff --git a/turbo-ext/src/support.h b/turbo-ext/src/support.h index 0ebc55a2717..b534721a537 100644 --- a/turbo-ext/src/support.h +++ b/turbo-ext/src/support.h @@ -523,6 +523,11 @@ enum { PT_CLASS_ARRAY_MAP_CALLBACK_PARAMETER_TYPES, /* the result cache's record of what a declaration's resolution looked up */ PT_CLASS_VALUE_DEPENDENCY_COLLECTOR, + /* the closure parameters of a partial function application */ + PT_CLASS_PARTIAL_FUNCTION_APPLICATION_PARAMETERS, + /* the callee of a closure created from a callable, and the replay of its calls */ + PT_CLASS_CLOSURE_ORIGIN, + PT_CLASS_CLOSURE_ORIGIN_CALL_REPLAY, PT_CLASS_COUNT }; @@ -1092,7 +1097,7 @@ extern zend_class_entry *pt_ce_closure_type; * exception */ [[nodiscard]] bool pt_iterable_type_new(zval *out, zval *keyType, zval *itemType); bool pt_callable_type_new(zval *out, zval *parameters = NULL, zval *returnType = NULL, bool variadic = true, zval *templateTypeMap = NULL, zval *resolvedTemplateTypeMap = NULL, zval *templateTags = NULL, zval *isPure = NULL, zval *assertions = NULL); -bool pt_closure_type_new(zval *out, zval *parameters = NULL, zval *returnType = NULL, bool variadic = true, zval *templateTypeMap = NULL, zval *resolvedTemplateTypeMap = NULL, zval *callSiteVarianceMap = NULL, zval *templateTags = NULL, zval *throwPoints = NULL, zval *impurePoints = NULL, zval *invalidateExpressions = NULL, zval *usedVariables = NULL, zval *acceptsNamedArguments = NULL, zval *mustUseReturnValue = NULL, zval *assertions = NULL, zval *isStatic = NULL, zval *byRefUseTypes = NULL); +bool pt_closure_type_new(zval *out, zval *parameters = NULL, zval *returnType = NULL, bool variadic = true, zval *templateTypeMap = NULL, zval *resolvedTemplateTypeMap = NULL, zval *callSiteVarianceMap = NULL, zval *templateTags = NULL, zval *throwPoints = NULL, zval *impurePoints = NULL, zval *invalidateExpressions = NULL, zval *usedVariables = NULL, zval *acceptsNamedArguments = NULL, zval *mustUseReturnValue = NULL, zval *assertions = NULL, zval *isStatic = NULL, zval *byRefUseTypes = NULL, zval *origin = NULL); /* merged from the parallel port branch */ /* the array-shape type (ConstantArrayType.cpp) */ @@ -3295,6 +3300,10 @@ zv::Val pt_closure_signature_inference_add_absorbed_in_union_of_two(zval *scope, /* $closureParameterResolver->resolveCallableTypeForScope($expr, $scope); * UNDEF = pending exception */ zv::Val pt_closure_parameter_resolver_resolve_callable_type_for_scope(zval *resolver, zval *expr, zval *scope); +/* ClosureOrigin::forFunction($functionName) / ClosureOrigin::forMethod($calledOnType, + * $methodName, $isStaticCall); UNDEF = pending exception */ +zv::Val pt_closure_origin_for_function(zval *functionName); +zv::Val pt_closure_origin_for_method(zval *calledOnType, zval *methodName, bool isStaticCall); /* $closureType->getByRefUseTypes(); UNDEF = pending exception */ zv::Val pt_closure_type_get_by_ref_use_types(zval *closureType); /* $closureType->containsUnresolvedTemplateArgument(); false = pending @@ -4082,8 +4091,10 @@ enum pt_ietr_binary_operator : uint8_t * (a TypeResult) / ->getArrayType($expr, $getTypeCallback) / * ->getCastType($expr, $getTypeCallback) / ->getCastObjectType($exprType) / * ->getFunctionType($type, $isNullable, $isVariadic, $context) / - * ->getFirstClassCallableType($expr, $context, $nativeTypesPromoted) / - * ->createFirstClassCallable($function, $variants, $nativeTypesPromoted) / + * ->getFirstClassCallableType($expr, $context, $nativeTypesPromoted, + * $boundArgTypes) / + * ->createFirstClassCallable($function, $variants, $nativeTypesPromoted, + * $partialApplicationArgs, $boundArgTypes, $origin) / * ->getClassConstFetchTypeByReflection($class, $constantName, * $classReflection, $getTypeCallback) / ->getUnaryPlusType($expr, * $getTypeCallback) / ->getUnaryMinusType(...) / ->getBitwiseNotType(...): @@ -4102,8 +4113,8 @@ zv::Val pt_initializer_expr_type_resolver_get_array_type(zval *resolver, zval *e zv::Val pt_initializer_expr_type_resolver_get_cast_type(zval *resolver, zval *expr, const pt_ietr_get_type &getTypeCallback); zv::Val pt_initializer_expr_type_resolver_get_cast_object_type(zval *resolver, zval *exprType); zv::Val pt_initializer_expr_type_resolver_get_function_type(zval *resolver, zval *type, bool isNullable, bool isVariadic, zval *context); -zv::Val pt_initializer_expr_type_resolver_get_first_class_callable_type(zval *resolver, zval *expr, zval *context, bool nativeTypesPromoted); -zv::Val pt_initializer_expr_type_resolver_create_first_class_callable(zval *resolver, zval *function, zval *variants, bool nativeTypesPromoted); +zv::Val pt_initializer_expr_type_resolver_get_first_class_callable_type(zval *resolver, zval *expr, zval *context, bool nativeTypesPromoted, zval *boundArgTypes); +zv::Val pt_initializer_expr_type_resolver_create_first_class_callable(zval *resolver, zval *function, zval *variants, bool nativeTypesPromoted, zval *partialApplicationArgs, zval *boundArgTypes, zval *origin); zv::Val pt_initializer_expr_type_resolver_get_class_const_fetch_type_by_reflection(zval *resolver, zval *class_, zval *constantName, zval *classReflection, const pt_ietr_get_type &getTypeCallback, bool nativeTypesPromoted = false); zv::Val pt_initializer_expr_type_resolver_get_unary_plus_type(zval *resolver, zval *expr, const pt_ietr_get_type &getTypeCallback); zv::Val pt_initializer_expr_type_resolver_get_unary_minus_type(zval *resolver, zval *expr, const pt_ietr_get_type &getTypeCallback); diff --git a/turbo-ext/tests/type-family.php b/turbo-ext/tests/type-family.php index e593c007c5a..c6ff137585e 100644 --- a/turbo-ext/tests/type-family.php +++ b/turbo-ext/tests/type-family.php @@ -2782,6 +2782,13 @@ public function getSubtractedType(): ?\PHPStan\Type\Type 'closureTemplate' => new \PHPStan\Type\ClosureType([$callableParam('a', $callableT), $callableParam('b', $callableU)], $callableT, true, $callableTemplateTypeMap, $callableResolvedTemplateTypeMap, null, $callableTemplateTags), 'closureAsserts' => new \PHPStan\Type\ClosureType([$callableParam('a', new \PHPStan\Type\MixedType())], new \PHPStan\Type\BooleanType(), assertions: $callableAssertionsIfTrue), 'closureAssertsTemplate' => new \PHPStan\Type\ClosureType([$callableParam('a', new \PHPStan\Type\MixedType())], new \PHPStan\Type\BooleanType(), true, $callableTemplateTypeMap, null, null, $callableTemplateTags, [], null, [], [], null, null, $callableAssertionsTemplate), + 'closureOriginStrtoupper' => new \PHPStan\Type\ClosureType([$callableParam('string', new \PHPStan\Type\StringType())], new \PHPStan\Type\StringType(), origin: \PHPStan\Type\ClosureOrigin::forFunction('strtoupper')), + 'closureOriginStrtoupperCopy' => new \PHPStan\Type\ClosureType([$callableParam('string', new \PHPStan\Type\StringType())], new \PHPStan\Type\StringType(), origin: \PHPStan\Type\ClosureOrigin::forFunction('strtoupper')), + 'closureOriginStrtolower' => new \PHPStan\Type\ClosureType([$callableParam('string', new \PHPStan\Type\StringType())], new \PHPStan\Type\StringType(), origin: \PHPStan\Type\ClosureOrigin::forFunction('strtolower')), + 'closureOriginPlain' => new \PHPStan\Type\ClosureType([$callableParam('string', new \PHPStan\Type\StringType())], new \PHPStan\Type\StringType()), + 'closureOriginMethod' => new \PHPStan\Type\ClosureType([$callableParam('modifier', new \PHPStan\Type\StringType())], new \PHPStan\Type\ObjectType(\DateTimeImmutable::class), origin: \PHPStan\Type\ClosureOrigin::forMethod(new \PHPStan\Type\ObjectType(\DateTimeImmutable::class), 'modify', false)), + 'closureOriginPartial' => new \PHPStan\Type\ClosureType([$callableParam('subject', new \PHPStan\Type\StringType())], new \PHPStan\Type\StringType(), origin: \PHPStan\Type\ClosureOrigin::forFunction('str_replace')->withPartialApplication([new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_(' ')), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('-')), new \PhpParser\Node\ArgPlaceholder()], [0 => new \PHPStan\Type\Constant\ConstantStringType(' '), 1 => new \PHPStan\Type\Constant\ConstantStringType('-')])), + 'closureOriginTemplate' => new \PHPStan\Type\ClosureType([$callableParam('a', $callableT)], $callableT, true, $callableTemplateTypeMap, null, null, $callableTemplateTags, origin: \PHPStan\Type\ClosureOrigin::forFunction('pick')->withPartialApplication([new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\Int_(1)), new \PhpParser\Node\ArgPlaceholder()], [0 => $callableT])), 'closureNestedMarker' => new \PHPStan\Type\ClosureType([$callableParam('a', new \PHPStan\Type\UnionType([new \PHPStan\Type\IntegerType(), new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\Generic\UnresolvedTemplateArgumentType(new \PhpParser\Node\Expr\Variable('x'), $callableT, null))]))], new \PHPStan\Type\VoidType()), 'iterable' => new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()), 'iterableExplicit' => new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(true), new \PHPStan\Type\MixedType(true)),