Skip to content

Fix StrContainsRector when strpos offset is set #3086

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 2 commits into from
Nov 22, 2022

Conversation

ajgarlag
Copy link
Contributor

Based on https://getrector.org/demo/e99068d4-3691-4653-ab58-24f20efa13bf

This is my first PR on this project. Thanks for your work!

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
@@ -82,6 +85,13 @@ public function refactor(Node $node): ?Node
return null;
}

if (isset($funcCall->args[2])) {
if ($this->isName($funcCall->name, 'strpos') && $this->isPositiveInteger($funcCall->args[2]->value)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the same is true for stripos?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rule only works with strpos y strstr

@TomasVotruba
Copy link
Member

Thank you 👍

@TomasVotruba TomasVotruba merged commit 30afbb8 into rectorphp:main Nov 22, 2022
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.

None yet

4 participants