preg_split sometimes returns array of arrays#324
preg_split sometimes returns array of arrays#324ondrejmirtes merged 1 commit intophpstan:masterfrom spaze:patch-2
Conversation
|
Wouldn't a dynamic return type extension be better for this? |
|
Thank you, but yes, dynamic return type extension would be better so that the user doesn't have to check against values that cannot occur in their situation :) @spaze I'm sure you won't have any problems writing one as you've already written some custom PHPStan rules :) Here are some pointers: * Basic info: https://phpstan.org/developing-extensions/dynamic-return-type-extensions
|
When PREG_SPLIT_OFFSET_CAPTURE is given, "this changes the return value in an array where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1."
|
Thanks, I've vaguely remembered there was a better way of doing things like this but... I've now changed this PR to use a dynamic type extension for that. And thanks @ondrejmirtes for those hints, helped a lot! |
|
Perfect, thank you :) |
|
Thanks for the release @ondrejmirtes! :-) |
When
PREG_SPLIT_OFFSET_CAPTUREflag is givenSee https://3v4l.org/B4Qf5
Then "this changes the return value in an array where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1."