Bug Report
| Subject |
Details |
| Rector version |
2.6.6 |
Hi,
the rule StrContainsRector does not work for PHP7.4 => PHP8.0 upgrades.
The fix is missing a check for an empty string - have a look at the symfony polyfill implementation:
your rule StrContainsRector should be changed pretty much the same as the polyfill implementation - you need to add a check for empty string.
Best regards
Minimal PHP Code Causing Issue
https://getrector.com/demo/25e6222a-ae1d-4503-8098-c15ca53b2d1b
Expected Behaviour
do it like symfony implementation and check for empty needle aswell:
public static function str_contains(string $haystack, string $needle): bool
{
return '' === $needle || false !== strpos($haystack, $needle);
}
Bug Report
Hi,
the rule StrContainsRector does not work for PHP7.4 => PHP8.0 upgrades.
The fix is missing a check for an empty string - have a look at the symfony polyfill implementation:
your rule StrContainsRector should be changed pretty much the same as the polyfill implementation - you need to add a check for empty string.
Best regards
Minimal PHP Code Causing Issue
https://getrector.com/demo/25e6222a-ae1d-4503-8098-c15ca53b2d1b
Expected Behaviour
do it like symfony implementation and check for empty needle aswell: