Skip to content

fix: fix support call-site generic variance#9253

Merged
kubawerlos merged 3 commits intoPHP-CS-Fixer:masterfrom
6b7562617765726c6f73:fix_call-site_generic_variance
Dec 1, 2025
Merged

fix: fix support call-site generic variance#9253
kubawerlos merged 3 commits intoPHP-CS-Fixer:masterfrom
6b7562617765726c6f73:fix_call-site_generic_variance

Conversation

@kubawerlos
Copy link
Copy Markdown
Member

fixes #9248
fixes #9249

@kubawerlos kubawerlos enabled auto-merge (squash) December 1, 2025 16:26
@coveralls
Copy link
Copy Markdown

coveralls commented Dec 1, 2025

Coverage Status

coverage: 93.172%. remained the same
when pulling 5d8ec64 on 6b7562617765726c6f73:fix_call-site_generic_variance
into 82a17c6 on PHP-CS-Fixer:master.

Copy link
Copy Markdown
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

fantastic, kudos 🎉

@kubawerlos kubawerlos merged commit 1d3537f into PHP-CS-Fixer:master Dec 1, 2025
32 of 33 checks passed
@kubawerlos kubawerlos deleted the fix_call-site_generic_variance branch December 1, 2025 20:54
@mvhirsch
Copy link
Copy Markdown

mvhirsch commented Dec 2, 2025

Thank you ❤️

@ker0x
Copy link
Copy Markdown

ker0x commented Dec 2, 2025

@kubawerlos Thank you for the quick fix!

* - and https://github.com/phpstan/phpdoc-parser/blob/1.26.0/src/Parser/PhpDocParser.php parser impl.
*/
private const REGEX_TYPE = '(?<type>(?x) # single type
(?:co(ntra)?variant\h+)?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
(?:co(ntra)?variant\h+)?
(?:co(?:ntra)?variant\h+)?

no capturing group needed, the regex should not have any unnamed capturing group in general

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no capturing group needed

👍🏻

the regex should not have any unnamed capturing group in general

can we somehow automate for code review? if you have idea, can you raise as PR proposal?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It should be possible to evaluate the regex with dummy input and check if the captured indexes of string type matches the count of integer indexes + 1 (whole match).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

in such case, one has to provide this dummy input for each regex. i wonder if we can do it with static analysis without input data

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

php-cs-fixer crashes on nested generic types with call-site variance Undefined array key "types"

6 participants