Skip to content

preg_match_all always returns an array of arrays #2668

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

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

vmcj
Copy link
Member

@vmcj vmcj commented Aug 31, 2024

Even if we cannot match anything we will have an array containing an empty array. That array indicates that nothing was matched.

Hopefully this fixes what #2665 tried to do.

Copy link
Member

@meisterT meisterT left a comment

Choose a reason for hiding this comment

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

After reading https://www.php.net/manual/en/function.preg-match-all.php#refsect1-function.preg-match-all-returnvalues my suggestion is to capture the return value and check it as well.

@vmcj
Copy link
Member Author

vmcj commented Sep 1, 2024

After reading https://www.php.net/manual/en/function.preg-match-all.php#refsect1-function.preg-match-all-returnvalues my suggestion is to capture the return value and check it as well.

from the commit message:

We should now fail when:
- preg_match_all fails
- preg_match_all returns it found 0 matches
- the redundant case (as safeguard) when the array has 0 matches

@vmcj vmcj requested a review from meisterT September 1, 2024 12:33
Even if we cannot match anything we would have had an array containing an empty array. That array indicates that nothing was matched.

We should now fail when:
- preg_match_all fails
- preg_match_all returns it found 0 matches
- the redundant case (as safeguard) when the array has 0 matches
@vmcj vmcj force-pushed the quick_fix_phpstan_bool branch from e9c8fde to 31fcfff Compare September 2, 2024 17:29
@vmcj vmcj added this pull request to the merge queue Sep 2, 2024
Merged via the queue into DOMjudge:main with commit 274d36a Sep 2, 2024
23 of 24 checks passed
@vmcj vmcj deleted the quick_fix_phpstan_bool branch September 2, 2024 17:30
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.

3 participants