Find the best Rector rule to solve your problem. Searching through 897 rules.
Found 14 rules:
Replace foreach with boolean assignment + break OR foreach with early return with array_any
Replace foreach with boolean assignment and break OR foreach with early return with array_all
Change @deprecated annotation to Deprecated attribute
Replace json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE with json_validate()
Add override attribute to overridden methods
Change helper functions to str_starts_with()
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;
+ $isNotMatch = ! str_starts_with($haystack, $needle);
}
}
Replace mb_strpos() !== false and mb_strstr() with str_contains()
class SomeClass
{
public function run()
{
- return mb_strpos('abc', 'a') !== false;
+ return str_contains('abc', 'a');
}
}