-
Notifications
You must be signed in to change notification settings - Fork 545
Create PhpParserExpr.stub #4503
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9b26ffe
Create PHPParser.stub
staabm 73cdb39
Update ContainerDynamicReturnTypeExtension.php
staabm 5528d1c
fix
staabm 1f71973
cs
staabm 74fc363
Discard changes to build/PHPStan/Build/ContainerDynamicReturnTypeExte…
staabm c17dbe7
Add PhpParserStmt
staabm 7728361
fix
staabm 620123a
Update PhpParserExpr.stub
staabm 35818b8
added all classes wrapping stmts
staabm a8cbd0a
Update PhpParserStmt.stub
staabm d570956
fix
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <?php | ||
|
|
||
| namespace PhpParser\Node\Expr; | ||
|
|
||
| use PhpParser\Node; | ||
| use PhpParser\NodeAbstract; | ||
| use PhpParser\Node\Arg; | ||
| use PhpParser\Node\Expr; | ||
| use PhpParser\Node\Identifier; | ||
| use PhpParser\Node\VariadicPlaceholder; | ||
| use PhpParser\Node\FunctionLike; | ||
|
|
||
| abstract class CallLike extends Expr { | ||
| /** | ||
| * Return raw arguments, which may be actual Args, or VariadicPlaceholders for first-class | ||
| * callables. | ||
| * | ||
| * @return list<Arg|VariadicPlaceholder> | ||
| */ | ||
| abstract public function getRawArgs(): array; | ||
| /** | ||
| * Assert that this is not a first-class callable and return only ordinary Args. | ||
| * | ||
| * @return list<Arg> | ||
| */ | ||
| public function getArgs(): array { | ||
| assert(!$this->isFirstClassCallable()); | ||
| return $this->getRawArgs(); | ||
| } | ||
| } | ||
|
|
||
| class FuncCall extends CallLike { | ||
| /** @var list<Node\Arg|Node\VariadicPlaceholder> Arguments */ | ||
| public array $args; | ||
|
|
||
| /** | ||
| * Constructs a function call node. | ||
| * | ||
| * @param Node\Name|Expr $name Function name | ||
| * @param list<Node\Arg|Node\VariadicPlaceholder> $args Arguments | ||
| * @param array<string, mixed> $attributes Additional attributes | ||
| */ | ||
| public function __construct(Node $name, array $args = [], array $attributes = []) {} | ||
| } | ||
|
|
||
| class MethodCall extends CallLike { | ||
| /** @var list<Node\Arg|Node\VariadicPlaceholder> Arguments */ | ||
| public array $args; | ||
|
|
||
| /** | ||
| * Constructs a function call node. | ||
| * | ||
| * @param Expr $var Variable holding object | ||
| * @param string|Identifier|Expr $name Method name | ||
| * @param list<Arg|VariadicPlaceholder> $args Arguments | ||
| * @param array<string, mixed> $attributes Additional attributes | ||
| */ | ||
| public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {} | ||
| } | ||
|
|
||
| class New_ extends CallLike { | ||
| /** @var list<Arg|VariadicPlaceholder> 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<Arg|VariadicPlaceholder> $args Arguments | ||
| * @param array<string, mixed> $attributes Additional attributes | ||
| */ | ||
| public function __construct(Node $class, array $args = [], array $attributes = []) {} | ||
| } | ||
|
|
||
| class NullsafeMethodCall extends CallLike { | ||
| /** @var list<Arg|VariadicPlaceholder> Arguments */ | ||
| public array $args; | ||
|
|
||
| /** | ||
| * Constructs a nullsafe method call node. | ||
| * | ||
| * @param Expr $var Variable holding object | ||
| * @param string|Identifier|Expr $name Method name | ||
| * @param list<Arg|VariadicPlaceholder> $args Arguments | ||
| * @param array<string, mixed> $attributes Additional attributes | ||
| */ | ||
| public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {} | ||
| } | ||
|
|
||
| class StaticCall extends CallLike { | ||
| /** @var list<Arg|VariadicPlaceholder> Arguments */ | ||
| public array $args; | ||
|
|
||
| /** | ||
| * Constructs a static method call node. | ||
| * | ||
| * @param Node\Name|Expr $class Class name | ||
| * @param string|Identifier|Expr $name Method name | ||
| * @param list<Arg|VariadicPlaceholder> $args Arguments | ||
| * @param array<string, mixed> $attributes Additional attributes | ||
| */ | ||
| public function __construct(Node $class, $name, array $args = [], array $attributes = []) {} | ||
| } | ||
|
|
||
| class Closure extends Expr implements FunctionLike { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } |
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,10 @@ | ||
| <?php | ||
|
|
||
| namespace PhpParser\Node; | ||
|
|
||
| use PhpParser\NodeAbstract; | ||
|
|
||
| class PropertyHook extends NodeAbstract implements FunctionLike { | ||
| /** @var null|Expr|list<Stmt> Hook body */ | ||
| public $body; | ||
| } |
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,83 @@ | ||
| <?php | ||
|
|
||
| namespace PhpParser\Node\Stmt; | ||
|
|
||
| use PhpParser\Modifiers; | ||
| use PhpParser\Node; | ||
| use PhpParser\Node\FunctionLike; | ||
|
|
||
| class Block extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Case_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Catch_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Do_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class ElseIf_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Else_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Finally_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class For_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Foreach_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class If_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class Namespace_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class TryCatch extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class While_ extends Node\Stmt { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
||
| class ClassMethod extends Node\Stmt implements FunctionLike { | ||
| /** @var list<Node\Stmt>|null Statements */ | ||
| public ?array $stmts; | ||
| } | ||
|
|
||
| class Function_ extends Node\Stmt implements FunctionLike { | ||
| /** @var list<Node\Stmt> Statements */ | ||
| public array $stmts; | ||
| } | ||
|
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing a runtime check, to not change the phpdoc on a
@apiclassThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this is worse because suddenly you're throwing an exception for a valid input advertised by the signature.
If it's not a list, let's make it a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea.
It might even be worth creating a new rule which errors in my wrong code example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to express the logic you'd want...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error on conditions which always lead to unchecked exceptions, when the conditions narrows a parameter type.
But you are right, maybe too specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd merge this if you call array_values here instead 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was not at the computer until now. fix incoming ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also outside the entire time 😂