Skip to content

Conversation

@codebymikey
Copy link
Contributor

Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

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

@codebymikey could you provide a patch as well, you should can change this

with isNames() and array() of function names:

-        if (! $this->isName($funcCall, 'preg_split')) {
+        if (! $this->isNames($funcCall, [
             'preg_split',
              'preg_grep',
              'preg_match',
               // and so on...
         ])) {

@codebymikey
Copy link
Contributor Author

Wouldn't it be more flexible to create a new NullToStrictIntFuncCallArgRector rule that implements ConfigurableRectorInterface since the rules aren't just for preg_split()?

That way the same rule may be easily used for custom projects.

Also, is it fine to remove NullToStrictIntPregSlitFuncCallLimitArgRector in favour of the new one, or is it important to keep for backwards-compatibility purposes?

@TomasVotruba
Copy link
Member

Wouldn't it be more flexible to create a new NullToStrictIntFuncCallArgRector rule that implements ConfigurableRectorInterface since the rules aren't just for preg_split()?

Sounds best way. We'll still need to have it configured in the PHP set.

Also, is it fine to remove NullToStrictIntPregSlitFuncCallLimitArgRector in favour of the new one, or is it important to keep for backwards-compatibility purposes?

Keep the class, but remove the refactor() contents and add DeprecatedInterface, like here: https://github.com/rectorphp/rector-src/pull/7500/files#diff-629c6c9e2ef6591baab0ccad974d8e21c877184bbae333046828013a54c9056f

@samsonasik
Copy link
Member

This should similar implementation with NullToStrictStringFuncCallArgRector, but for int

final class NullToStrictStringFuncCallArgRector extends AbstractRector implements MinPhpVersionInterface

@TomasVotruba
Copy link
Member

@codebymikey Just checking, any progress on this? We usually close long-opened failing PRs with issues to avoid stalling.

@codebymikey
Copy link
Contributor Author

None I'm afraid as I haven't had the time to look into it, I just created the failing text fixture file as requested in the original issue, and added my thoughts regarding how a fix should be tackled.

@codebymikey codebymikey marked this pull request as draft November 28, 2025 16:52
@TomasVotruba
Copy link
Member

I see. @samsonasik provided clear context to fix it.
In that case I'll close both, as fix is needed over failing stale PRs.

Feel free reopen with fixing PR 👌

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.

Expand NullToStrictIntPregSlitFuncCallLimitArgRector to support more functions

3 participants