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

[PHP 8.1] Add null to string in Function Call Arg: NullToStrictStringFuncCallArgRector #6910

Closed
samsonasik opened this issue Jan 4, 2022 · 7 comments · Fixed by rectorphp/rector-src#1655
Labels

Comments

@samsonasik
Copy link
Member

Feature Request

There are function calls that previously allow null to be need as string, eg: preg_split, ref ref https://3v4l.org/lbPsJ

preg_split("#a#", null);

Another use case is preg_match, ref https://3v4l.org/WQ1Pk

preg_match('/(foo)(bar)(baz)/', null, $matches);

that will error on php 8.1

I think we need to have general FuncCall Rector for it, eg: NullToStrictStringFuncCallArgRector that can have collection of function call with args that need to be string.

@samsonasik
Copy link
Member Author

Another function to have strict string arg in php 8.1, preg_match_all ref https://3v4l.org/AFWHB

@samsonasik
Copy link
Member Author

Also on explode function https://3v4l.org/3FsLf

@samsonasik
Copy link
Member Author

strlen as well https://3v4l.org/0s1Gs

@tigitz
Copy link

tigitz commented Mar 3, 2022

@samsonasik Not sure if it should be taken into account in this rector since the naming specifies StrictString but here are more functions where nullability has been deprecated:

@FlorinProfeanu
Copy link

Are there news about managing strtotime (on other similar functions)?

@samsonasik
Copy link
Member Author

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

Successfully merging a pull request may close this issue.

3 participants