Skip to content

[PHP 8.0] Add str_starts_with - rule #500 🎉🎉🎉#3228

Merged
TomasVotruba merged 2 commits intomasterfrom
str-starts-ends
Apr 23, 2020
Merged

[PHP 8.0] Add str_starts_with - rule #500 🎉🎉🎉#3228
TomasVotruba merged 2 commits intomasterfrom
str-starts-ends

Conversation

@TomasVotruba
Copy link
Copy Markdown
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