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.0] Add str_starts_with - rule #500 🎉🎉🎉 #3228

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Apr 23, 2020

 class SomeClass
 {
     public function run()
     {
-        $isMatch = substr($haystack, 0, strlen($needle)) === $needle;
+        $isMatch = str_starts_with($haystack, $needle);

-        $isNotMatch = substr($haystack, 0, strlen($needle)) !== $needle;
+        $isMatch = ! str_starts_with($haystack, $needle);
     }
 }

@TomasVotruba TomasVotruba force-pushed the str-starts-ends branch 4 times, most recently from 0fec032 to bd27eea Compare April 23, 2020 20:57
@TomasVotruba TomasVotruba changed the title str starts ends [PHP 8.0] Add str_starts_with Apr 23, 2020
@TomasVotruba TomasVotruba changed the title [PHP 8.0] Add str_starts_with [PHP 8.0] Add str_starts_with - rule #500 🎉🎉🎉 Apr 23, 2020
@TomasVotruba TomasVotruba merged commit 988fa5c into master Apr 23, 2020
@TomasVotruba TomasVotruba deleted the str-starts-ends branch April 23, 2020 21:14
TomasVotruba added a commit that referenced this pull request Dec 20, 2022
rectorphp/rector-src@cf2805b [TypeDeclaration] Skip optional yield on AddReturnTypeDeclarationFromYieldsRector (#3228)
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.

1 participant