-
Notifications
You must be signed in to change notification settings - Fork 550
Don't error with checkMissingCallableSignature: true about degraded closures
#4823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
staabm
wants to merge
13
commits into
phpstan:2.1.x
Choose a base branch
from
staabm:bug14012
base: 2.1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
39a0ed9
Don't error with checkMissingCallableSignature about degraded closures
staabm 293c5f9
another test
staabm ba972a5
simpler fix
staabm e3fe43d
assertType
staabm c9a817e
added failling test
staabm d0912a4
raise CLOSURES_COUNT_LIMIT
staabm acdc223
Update CallToFunctionParametersRuleTest.php
staabm ae1a7bc
adjust tests
staabm bd886d2
Discard changes to src/Type/CallableType.php
staabm dd56b1a
Update ConstantArrayTypeBuilder.php
staabm c76580e
simplify tests
staabm 435724d
Disable closure degradation for array-shape nodes
staabm 729c210
simplify
staabm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?php declare(strict_types=1); | ||
|
|
||
| namespace Bug14012; | ||
|
|
||
| use PhpParser\Node; | ||
| use PHPStan\Analyser\Scope; | ||
| use function PHPStan\Testing\assertType; | ||
|
|
||
| final class ExpectationMethodResolver | ||
| { | ||
| /** | ||
| * @var array{ | ||
| * hasMethod: \Closure(Scope, Node\Arg, Node\Arg): Node\Expr, | ||
| * hasProperty: \Closure(Scope, Node\Arg, Node\Arg): Node\Expr, | ||
| * isArray: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isBool: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isCallable: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isCountable: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isFalse: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isFloat: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isInstanceOf: \Closure(Scope, Node\Arg, Node\Arg): Node\Expr, | ||
| * isInt: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isIterable: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isList: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isMap: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isNaturalInt: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isNegativeInt: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isNonEmptyString: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isNull: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isNumeric: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isObject: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isPositiveInt: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isResource: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isSameAs: \Closure(Scope, Node\Arg, Node\Arg): Node\Expr, | ||
| * isScalar: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isString: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * isTrue: \Closure(Scope, Node\Arg): Node\Expr, | ||
| * } | ||
| */ | ||
| public static array $resolvers = []; | ||
| } | ||
|
|
||
| assertType("array{hasMethod: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg, PhpParser\Node\Arg): PhpParser\Node\Expr, hasProperty: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg, PhpParser\Node\Arg): PhpParser\Node\Expr, isArray: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isBool: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isCallable: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isCountable: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isFalse: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isFloat: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isInstanceOf: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg, PhpParser\Node\Arg): PhpParser\Node\Expr, isInt: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isIterable: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isList: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isMap: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isNaturalInt: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isNegativeInt: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isNonEmptyString: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isNull: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isNumeric: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isObject: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isPositiveInt: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isResource: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isSameAs: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg, PhpParser\Node\Arg): PhpParser\Node\Expr, isScalar: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isString: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr, isTrue: Closure(PHPStan\Analyser\Scope, PhpParser\Node\Arg): PhpParser\Node\Expr}", ExpectationMethodResolver::$resolvers); | ||
|
|
||
| /** | ||
| * @param callable(Scope, Node\Arg):Node\Expr $callable | ||
| */ | ||
| function doFoo($callable):void {} | ||
| doFoo(ExpectationMethodResolver::$resolvers['isArray']); | ||
|
|
||
| /** | ||
| * @param \Closure(Scope, Node\Arg):Node\Expr $callable | ||
| */ | ||
| function doBar($callable):void {} | ||
| doBar(ExpectationMethodResolver::$resolvers['isArray']); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.