Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update rector-migrate.php to support latest Rector #372

Merged
merged 6 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions generator/src/FileCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Safe;

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use function array_merge;
use function file_exists;

Expand Down Expand Up @@ -101,16 +103,13 @@ public function generateRectorFile(array $functions, string $path): void

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

// This file configures rector/rector to replace all PHP functions with their equivalent "safe" functions.
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->set(RenameFunctionRector::class)
->call('configure', [[ RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
RenameFunctionRector::class,[
TXT;

fwrite($stream, $header);
Expand All @@ -119,7 +118,7 @@ public function generateRectorFile(array $functions, string $path): void
fwrite($stream, " '$functionName' => 'Safe\\$functionName',\n");
}

fwrite($stream, " ]]]);\n};\n");
fwrite($stream, " ]);\n};\n");
fclose($stream);
}

Expand Down
4 changes: 2 additions & 2 deletions generator/tests/rector/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"require": {
"php": "^8.0",
"rector/rector": "^0.11.36"
"rector/rector": "^0.13.10"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand All @@ -15,4 +15,4 @@
"rector": "rector process src/ --config ../../../rector-migrate.php",
"test": "phpunit"
}
}
}
13 changes: 5 additions & 8 deletions rector-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

// This file configures rector/rector to replace all PHP functions with their equivalent "safe" functions.
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->set(RenameFunctionRector::class)
->call('configure', [[ RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
'apache_getenv' => 'Safe\apache_getenv',
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
RenameFunctionRector::class,[ 'apache_getenv' => 'Safe\apache_getenv',
'apache_get_version' => 'Safe\apache_get_version',
'apache_lookup_uri' => 'Safe\apache_lookup_uri',
'apache_request_headers' => 'Safe\apache_request_headers',
Expand Down Expand Up @@ -1101,5 +1098,5 @@
'zip_entry_open' => 'Safe\zip_entry_open',
'zip_entry_read' => 'Safe\zip_entry_read',
'zlib_decode' => 'Safe\zlib_decode',
]]]);
]);
};