Skip to content
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

Fix null-removal on nested captured-arrays #37

Merged
merged 3 commits into from
Aug 23, 2024
Merged

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 22, 2024

as described in #34 (comment)

@@ -61,6 +61,18 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
$matchesType = new ConstantArrayType(
$matchesType->getKeyTypes(),
array_map(static function (Type $valueType): Type {
if (count($valueType->getConstantArrays()) === 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

when PREG_OFFSET_CAPTURE the $valueType is again a constant-array-type.

TypeCombinator::removeNull does not deep iterate into arrays

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the same logic already arround, but I guess we will get problems in the future with it when patterns are used which return more then 1 constant array (maybe one of the tagged union cases)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staabm staabm changed the title Fix null-removeal on nested captured-arrays Fix null-removal on nested captured-arrays Aug 22, 2024
@Seldaek
Copy link
Member

Seldaek commented Aug 23, 2024

Thanks, that solves it for replaceCallbackStrictGroups I think. The problem with isMatchAllStrictGroups and matchAllStrictGroups from #34 is still there tho right?

@Seldaek Seldaek merged commit c8bfe21 into composer:main Aug 23, 2024
10 checks passed
@staabm staabm deleted the fix branch August 23, 2024 14:17
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.

2 participants