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 return types on regex functions #108

Open
nkkollaw opened this issue Aug 8, 2017 · 5 comments
Open

Fix return types on regex functions #108

nkkollaw opened this issue Aug 8, 2017 · 5 comments

Comments

@nkkollaw
Copy link
Owner

nkkollaw commented Aug 8, 2017

They were suggesting on Reddit to "fix the return types on those godawful regex functions in PHP" (see https://www.reddit.com/r/PHP/comments/6rnt2p/zubr_wrapper_library_to_fix_inconsistencies_in/dl6knuw/).

Do we want to tackle this, and if yes—when?

@nkkollaw nkkollaw changed the title Fix return types on regex functions or not? Fix return types on regex functions? Aug 8, 2017
@Petah
Copy link

Petah commented Aug 9, 2017

What exactly are the inconsistencies?

@nkkollaw
Copy link
Owner Author

nkkollaw commented Aug 9, 2017

preg_grep returns array, preg_match returns int and saves matches to array passed by reference.

These are just 2.

@nkkollaw nkkollaw changed the title Fix return types on regex functions? Fix return types on regex functions Aug 9, 2017
@Petah
Copy link

Petah commented Aug 9, 2017

So it will be

$matches = preg_match(...);
if (!empty($matches)) {
    // use $matches
}

Instead of

if (preg_match(..., $matches)) {
    // use $matches
}

@Petah
Copy link

Petah commented Aug 9, 2017

Also for preg_match_all, is it no longer going to return the count of matches, and now only the matches array?

@nkkollaw
Copy link
Owner Author

nkkollaw commented Aug 9, 2017

Yes.

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

No branches or pull requests

2 participants