Skip to content

Commit 0094669

Browse files
authored
Merge pull request #234 from Kharhamel/rectorFix
Fixed the rector bug
2 parents aa7aae7 + 3266d6b commit 0094669

File tree

8 files changed

+1187
-1134
lines changed

8 files changed

+1187
-1134
lines changed

.github/workflows/auto-regenerate.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ jobs:
3636
run: "composer install --no-interaction"
3737
working-directory: "generator"
3838

39-
- name: "Install dependencies with composer in root directory"
40-
run: "composer install --no-interaction"
41-
42-
43-
- name: "Dump autoloader with composer in root directory"
44-
run: "composer dump-autoload"
45-
46-
4739
- name: "Regenerate files"
4840
run: "./safe.php generate"
4941
working-directory: "generator"

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ jobs:
9999
exit 1;
100100
fi
101101
102-
- name: "Check if refactoring can be done with rector/rector:~0.7.0"
103-
run: "composer install && composer rector && composer test"
104-
working-directory: "generator/tests/rector/0.7"
105-
106102
- name: "Archive code coverage results"
107103
uses: "actions/upload-artifact@v1"
108104
with:
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2+
3+
name: "Rector Continuous Integration"
4+
5+
on:
6+
- "pull_request"
7+
- "push"
8+
9+
jobs:
10+
11+
rector-continuous-integration:
12+
name: "Check if refactoring can be done with rector/rector:~0.7.0"
13+
14+
runs-on: "ubuntu-latest"
15+
16+
strategy:
17+
matrix:
18+
php-version:
19+
- "7.2"
20+
- "7.3"
21+
- "7.4"
22+
23+
dependencies:
24+
- "highest"
25+
26+
steps:
27+
- name: "Checkout"
28+
uses: "actions/checkout@v2"
29+
30+
- name: "Install PHP with extensions"
31+
uses: "shivammathur/setup-php@v2"
32+
with:
33+
php-version: "${{ matrix.php-version }}"
34+
35+
- name: "Composer install"
36+
run: "composer install && composer rector && composer test"
37+
working-directory: "generator/tests/rector/0.7"
38+
39+
- name: "Run rector"
40+
run: "composer rector"
41+
working-directory: "generator/tests/rector/0.7"
42+
43+
- name: "Run tests"
44+
run: "composer test"
45+
working-directory: "generator/tests/rector/0.7"
46+

generator/src/FileCreator.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,29 @@ public function generateRectorFileForZeroPointSeven(array $functions, string $pa
9898
}
9999

100100
$header = <<<'TXT'
101+
<?php
102+
103+
declare(strict_types=1);
104+
105+
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
106+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
107+
101108
# This file configures rector/rector:~0.7.0 to replace all PHP functions with their equivalent "safe" functions
109+
return static function (ContainerConfigurator $containerConfigurator): void {
110+
$services = $containerConfigurator->services();
102111
103-
services:
104-
Rector\Renaming\Rector\Function_\RenameFunctionRector:
105-
$oldFunctionToNewFunction:
112+
$services->set(RenameFunctionRector::class)
113+
->call('configure', [[ RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
106114

107115
TXT;
108116

109117
fwrite($stream, $header);
110118

111119
foreach ($functionNames as $functionName) {
112-
fwrite($stream, ' '.$functionName.": 'Safe\\".$functionName."'\n");
120+
fwrite($stream, " '$functionName' => 'Safe\\$functionName',\n");
113121
}
114122

123+
fwrite($stream, "]]]);\n};\n");
115124
fclose($stream);
116125
}
117126

generator/src/GenerateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +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->generateRectorFileForZeroPointSeven($functions, __DIR__ . '/../../rector-migrate-0.7.yml');
40+
$fileCreator->generateRectorFileForZeroPointSeven($functions, __DIR__ . '/../../rector-migrate-0.7.php');
4141

4242

4343
$modules = [];

generator/tests/rector/0.7/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"phpunit/phpunit": "^7"
1313
},
1414
"scripts": {
15-
"rector": "rector process src/ --config ../../../../rector-migrate-0.7.yml",
15+
"rector": "rector process src/ --config ../../../../rector-migrate-0.7.php",
1616
"test": "phpunit"
1717
}
1818
}

0 commit comments

Comments
 (0)