Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parse generic callable #232

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
ondrejmirtes merged 2 commits into phpstan:1.23.x from mad-briller:parse_generic_callable
Feb 23, 2024

Conversation

Copy link
Contributor

@mad-briller mad-briller commented Feb 23, 2024
edited
Loading

Follow on from: #199 originally by @mvorisek

(削除) Making TemplateTagParser::parseTemplateTagValue() static seemed like the best approach to fix a circular dependency between TypeParser and TemplateTagParser, as it means the TypeParser must be passed for each call. (削除ここまで)

Also parseOptionalDescription was awkward to handle as it only needs to be used in PhpDocParser and calls many private functions of PhpDocParser, so i reworked that to be a callable instead of a boolean flag.

@mad-briller mad-briller force-pushed the parse_generic_callable branch 2 times, most recently from 7ce9640 to 6894d61 Compare February 23, 2024 13:38
@mad-briller mad-briller force-pushed the parse_generic_callable branch 2 times, most recently from 9e8d2b7 to cda3c21 Compare February 23, 2024 15:27
new IdentifierTypeNode('X'),
new IdentifierTypeNode('Z'),
])),
new CallableTypeTemplateNode(new IdentifierTypeNode('Ty'), new IdentifierTypeNode('Y')),
]), ''),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -913,7 +913,7 @@ public function provideParseData(): array
],
new IdentifierTypeNode('C'),
[
new CallableTypeTemplateNode(new IdentifierTypeNode('A'), null),
new TemplateTagValueNode('A', null, ''),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to change https://github.com/phpstan/phpdoc-parser/blob/1.25.0/src/Ast/PhpDoc/TemplateTagValueNode.php#L15 first to keep IdentifierTypeNode instead of string to allow to store enriched attributes like position in the source phpdoc.

Copy link
Contributor Author

@mad-briller mad-briller Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing TemplateTagValueNode would be a BC break though, and any other solution would require not reusing what already exists

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really solid! 👍

@ondrejmirtes ondrejmirtes merged commit c23674d into phpstan:1.23.x Feb 23, 2024
Copy link
Member

Perfect, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

+1 more reviewer

@mvorisek mvorisek mvorisek left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /