Bug Report
| Subject |
Details |
| Rector version |
Rector v0.7.16 (same on v0.7.17 which contains master #3226 ) |
| Installed as |
prefixed Rector PHAR |
Minimal PHP Code Causing Issue
https://getrector.org/demo/3b20af0d-9c51-43d5-b081-c2180fefd052#result
It is valid on this link, but only because it use normal version, not prefixed.
When you run rector on same code, but prefixed phar version, it will do this.
public function run()
{
- return preg_replace('!/\*.*?\*/!s', '', $content);
+ return \_HumbugBox60a0d18192e0\Nette\Utils\Strings::replace($content, '!/\*.*?\*/!s', '');
}
As you can see, it replace preg_replace with prefixed class, not the valid one.
It is because of changed nette-utils-code-quality.yaml.
It looks like this:
# @see https://www.tomasvotruba.cz/blog/2018/07/30/hidden-gems-of-php-packages-nette-utils/
services:
Rector\Core\Rector\Function_\FunctionToStaticCallRector:
$functionToStaticCall:
# filesystem
file_get_contents: ['_HumbugBox60a0d18192e0\Nette\Utils\FileSystem', 'read']
unlink: ['_HumbugBox60a0d18192e0\Nette\Utils\FileSystem', 'delete']
rmdir: ['_HumbugBox60a0d18192e0\Nette\Utils\FileSystem', 'delete']
# strings
Rector\Nette\Rector\NotIdentical\StrposToStringsContainsRector: null
Rector\Nette\Rector\FuncCall\SubstrStrlenFunctionToNetteUtilsStringsRector: null
Rector\Nette\Rector\Identical\StartsWithFunctionToNetteUtilsStringsRector: null
Rector\Nette\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector: null
Rector\Nette\Rector\FuncCall\PregFunctionToNetteUtilsStringsRector: null
Rector\Nette\Rector\FuncCall\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector: null
Rector\Nette\Rector\FuncCall\FilePutContentsToFileSystemWriteRector: null
Expected Behaviour
public function run()
{
- return preg_replace('!/\*.*?\*/!s', '', $content);
+ return \Nette\Utils\Strings::replace($content, '!/\*.*?\*/!s', '');
}
Bug Report
Minimal PHP Code Causing Issue
https://getrector.org/demo/3b20af0d-9c51-43d5-b081-c2180fefd052#result
It is valid on this link, but only because it use normal version, not prefixed.
When you run rector on same code, but prefixed phar version, it will do this.
As you can see, it replace
preg_replacewith prefixed class, not the valid one.It is because of changed nette-utils-code-quality.yaml.
It looks like this:
Expected Behaviour