Skip to content

minor: Parse all phpdoc types using full grammar#7010

Merged
kubawerlos merged 28 commits intoPHP-CS-Fixer:masterfrom
mvorisek:parse_all_phpdoc_types_with_regex
Jun 24, 2023
Merged

minor: Parse all phpdoc types using full grammar#7010
kubawerlos merged 28 commits intoPHP-CS-Fixer:masterfrom
mvorisek:parse_all_phpdoc_types_with_regex

Conversation

@mvorisek
Copy link
Copy Markdown
Contributor

@mvorisek mvorisek commented May 30, 2023

Phpdoc must be always parsed using full grammar otherwise regexes like in src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php originally cannot be always correct, as variables can be for example part of conditional type or $this.

fix #6984

@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch from 3ee1d28 to c7210b6 Compare May 30, 2023 07:52
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch from c7210b6 to 6eb8b44 Compare May 30, 2023 08:44
}

Preg::matchAll('/@dataProvider\s+([a-zA-Z0-9._:-\\\\x7f-\xff]+)/', $tokens[$docCommentIndex]->getContent(), $matches);
Preg::matchAll('/@dataProvider\h+(('.self::REGEX_CLASS.'::)?'.TypeExpression::REGEX_IDENTIFIER.')/', $tokens[$docCommentIndex]->getContent(), $matches);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch 2 times, most recently from 47de727 to 859ef21 Compare May 30, 2023 09:12
Comment thread tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php Outdated
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch 2 times, most recently from 871a1d3 to 5e5156c Compare May 30, 2023 10:03
* @param array<int, FooInterface>|string $c
* @param Foo|Bar $b
* @param array<[int, int]> $d
* @param array<array{int, int}> $d
Copy link
Copy Markdown
Contributor Author

@mvorisek mvorisek May 30, 2023

Choose a reason for hiding this comment

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

@mvorisek mvorisek changed the title minor: Parse all phpdoc types with full grammar minor: Parse all phpdoc types using full grammar May 30, 2023
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch 4 times, most recently from 87c5dc5 to 258507e Compare May 30, 2023 21:37
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch 5 times, most recently from 712198e to df656f9 Compare June 11, 2023 09:12
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch from 6fc3bb9 to 31cb5bb Compare June 11, 2023 10:37
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch from 5bb87fc to 7bc07c3 Compare June 11, 2023 11:09
@mvorisek
Copy link
Copy Markdown
Contributor Author

@Wirone can you please review this PR?

@Wirone
Copy link
Copy Markdown
Member

Wirone commented Jun 15, 2023

@mvorisek I know you're waiting for it and it's important, but it requires more focus and I did not have moment to review it properly. I've just recently been doing mostly basic stuff not requiring much thinking 🙂. Will try to give it a shot soon.

Copy link
Copy Markdown
Member

@Wirone Wirone left a comment

Choose a reason for hiding this comment

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

Whoa, this is really good work, I like it a lot! Left few small comments, though 🙂.

Comment thread src/DocBlock/TypeExpression.php Outdated
Comment thread src/DocBlock/TypeExpression.php Outdated
Comment thread src/DocBlock/TypeExpression.php Outdated
Comment thread src/Fixer/Phpdoc/PhpdocTypesFixer.php
Comment thread tests/DocBlock/TypeExpressionTest.php
Comment thread tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php Outdated
@mvorisek mvorisek force-pushed the parse_all_phpdoc_types_with_regex branch from 4dacc78 to 5cfbe8e Compare June 24, 2023 17:31
@kubawerlos kubawerlos merged commit d17f722 into PHP-CS-Fixer:master Jun 24, 2023
@kubawerlos
Copy link
Copy Markdown
Member

Thank you @mvorisek 👍🏼

@mvorisek mvorisek deleted the parse_all_phpdoc_types_with_regex branch June 24, 2023 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

phpdoc_param_order cannot sort if doc type is not a basic type

3 participants