fix: Ensure unmatched optional capture group is treated as null in parseRowColumnSelection - #578
Conversation
|
@zigzagdev sorry for the late reply I was busy. I am on the fence about this PR not because it is bad but because the feature itself is not on a good shape itself it requires fixing that can only happen once we moved to v10. I will try to review your PR later and see if I can still merge it. Either way thanks for the contribution. |
|
Thank you for the feedback! I understand the feature needs design improvements in v10. I'll keep this PR open and wait for v10. When you're ready to review or if there's anything I should adjust based on the v10 direction, please let me know. |
|
I will merge your fix. No need to wait for v10. This part of the code will nevertheless be fix when I start working on v10 in the meantime this fixes an issue with the current implementation so let's just do that Thanks for the contribution |
Summary
What I have done
PREG_UNMATCHED_AS_NULLflag to thepreg_matchcall inparseRowColumnSelection()''(empty string) rather than leaving them absent, causing$found['end'] ?? nullto return''instead ofnullrow=1,col=2) to always fail validation when combined with semicolon-separated expressions (e.g.row=1;3,col=1;3)Where I have changed
src/FragmentFinder.php: AddPREG_UNMATCHED_AS_NULLtopreg_matchand simplify$endassignment from$found['end'] ?? nullto$found['end']src/TabularDataReaderTestCase.php: Add test cases covering following casesrow=1;3,col=1;3)row=1;3-5)row=0;0)matchingFirstreturns partial results,matchingFirstOrFailthrowsFragmentNotFoundTest Plan
row=1;3row=1;3-5col=1;3row=0;0nullfrommatchingFirstand throw frommatchingFirstOrFailrow=0;3(×2)matchingFirstreturns only the valid result whilematchingFirstOrFailthrowsFragmentNotFoundTest Cases Result