Skip to content

Commit b761812

Browse files
committed
Fix: Drop support for unsupported versions of rector/rector
1 parent 353974c commit b761812

File tree

15 files changed

+17
-1209
lines changed

15 files changed

+17
-1209
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,10 @@ jobs:
8989
echo "Generated files are different from commited files. Please run './safe.php generate' command and commit the results."
9090
exit 1;
9191
fi
92-
- name: "Check if refactoring can be done with rector/rector:~0.5.0"
93-
run: "composer install && composer rector && composer test"
94-
working-directory: "generator/tests/rector/0.5"
9592
96-
- name: "Check if refactoring can be done with rector/rector:~0.6.0"
93+
- name: "Check if refactoring can be done with rector/rector:~0.7.0"
9794
run: "composer install && composer rector && composer test"
98-
working-directory: "generator/tests/rector/0.6"
95+
working-directory: "generator/tests/rector/0.7"
9996

10097
- name: "Archive code coverage results"
10198
uses: "actions/upload-artifact@v1"

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
/generator/doc/entities/generated.ent
55
/composer.lock
66
vendor/
7-
/generator/tests/rector/0.5/composer.lock
8-
/generator/tests/rector/0.6/composer.lock
7+
/generator/tests/rector/0.7/composer.lock
98
.phpunit.result.cache

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,22 @@ find these functions but changing the namespace of the functions one function at
112112
Fortunately, Safe comes bundled with a "Rector" configuration file. [Rector](https://github.com/rectorphp/rector) is a command-line
113113
tool that performs instant refactoring of your application.
114114
115-
First, you need to install Rector:
115+
Run
116116
117117
```bash
118-
$ composer require --dev rector/rector ^0.6
118+
$ composer require --dev rector/rector:^0.7
119119
```
120120

121-
Now, you simply need to run Rector with this command:
121+
to install `rector/rector`.
122+
123+
Run
122124

123125
```bash
124-
vendor/bin/rector process src/ --config vendor/thecodingmachine/safe/rector-migrate-0.6.yml
126+
vendor/bin/rector process src/ --config vendor/thecodingmachine/safe/rector-migrate-0.7.yml
125127
```
126128

129+
to run `rector/rector`.
130+
127131
*Note:* do not forget to replace "src/" with the path to your source directory.
128132

129133
**Important:** the refactoring only performs a "dumb" replacement of functions. It will not modify the way

generator/src/FileCreator.php

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,40 +81,13 @@ public function generateFunctionsList(array $functions, string $path): void
8181
fclose($stream);
8282
}
8383

84-
/**
85-
* @deprecated Official support for rector/rector:~0.5 is not advertised anymore.
86-
*
87-
* This function generate a rector yml file containing a replacer for all functions
88-
*
89-
* @param Method[] $functions
90-
* @param string $path
91-
*/
92-
public function generateRectorFile(array $functions, string $path): void
93-
{
94-
$functionNames = $this->getFunctionsNameList($functions);
95-
$stream = fopen($path, 'w');
96-
if ($stream === false) {
97-
throw new \RuntimeException('Unable to write to '.$path);
98-
}
99-
fwrite($stream, "# This rector file is replacing all core PHP functions with the equivalent \"safe\" functions
100-
# It is targetting Rector 0.5.x versions.
101-
# If you are using Rector 0.4, please upgrade your Rector version
102-
services:
103-
Rector\Renaming\Rector\Function_\RenameFunctionRector:
104-
");
105-
foreach ($functionNames as $functionName) {
106-
fwrite($stream, ' '.$functionName.": 'Safe\\".$functionName."'\n");
107-
}
108-
fclose($stream);
109-
}
110-
11184
/**
11285
* Generates a configuration file for replacing all functions when using rector/rector:~0.6.
11386
*
11487
* @param Method[] $functions
11588
* @param string $path
11689
*/
117-
public function generateRectorFileForZeroPointSix(array $functions, string $path): void
90+
public function generateRectorFileForZeroPointSeven(array $functions, string $path): void
11891
{
11992
$functionNames = $this->getFunctionsNameList($functions);
12093

@@ -125,7 +98,7 @@ public function generateRectorFileForZeroPointSix(array $functions, string $path
12598
}
12699

127100
$header = <<<'TXT'
128-
# This file configures rector/rector:~0.6.0 to replace all PHP functions with their equivalent "safe" functions
101+
# This file configures rector/rector:~0.7.0 to replace all PHP functions with their equivalent "safe" functions
129102
130103
services:
131104
Rector\Renaming\Rector\Function_\RenameFunctionRector:

generator/src/GenerateCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3737
$fileCreator = new FileCreator();
3838
$fileCreator->generatePhpFile($functions, __DIR__ . '/../../generated/');
3939
$fileCreator->generateFunctionsList($functions, __DIR__ . '/../../generated/functionsList.php');
40-
$fileCreator->generateRectorFile($functions, __DIR__ . '/../../rector-migrate.yml');
41-
$fileCreator->generateRectorFileForZeroPointSix($functions, __DIR__ . '/../../rector-migrate-0.6.yml');
40+
$fileCreator->generateRectorFileForZeroPointSeven($functions, __DIR__ . '/../../rector-migrate-0.7.yml');
4241

4342

4443
$modules = [];

generator/tests/rector/0.5/composer.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

generator/tests/rector/0.5/phpunit.xml.dist

Lines changed: 0 additions & 18 deletions
This file was deleted.

generator/tests/rector/0.5/src/test.php

Lines changed: 0 additions & 2 deletions
This file was deleted.

generator/tests/rector/0.5/tests/RectorTest.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

generator/tests/rector/0.6/composer.json renamed to generator/tests/rector/0.7/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
},
77
"require": {
88
"php": "^7.2",
9-
"rector/rector": "^0.6.7"
9+
"rector/rector": "^0.7.6"
1010
},
1111
"require-dev": {
1212
"phpunit/phpunit": "^7"
1313
},
1414
"scripts": {
15-
"rector": "rector process src/ --config ../../../../rector-migrate-0.6.yml",
15+
"rector": "rector process src/ --config ../../../../rector-migrate-0.7.yml",
1616
"test": "phpunit"
1717
}
1818
}

0 commit comments

Comments
 (0)