Skip to content

Commit 04568db

Browse files
committed
Migrating Rector generated fil to match v0.4
1 parent 9a4dbc5 commit 04568db

File tree

9 files changed

+58
-4
lines changed

9 files changed

+58
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/generator/doc/doc-en/
44
/generator/doc/entities/generated.ent
55
/composer.lock
6-
/vendor/
6+
/vendor/
7+
/generator/tests/rector/0.4/composer.lock
8+
/generator/tests/rector/0.4/vendor/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ script:
5454
echo "Generated files are different from commited files. Please run './safe.php generate' command and commit the results."
5555
exit 1;
5656
fi
57+
- cd tests/rector/0.4 && composer install && composer rector && composer test && cd ../../..
5758

5859
after_script:
5960
- cd generator && travis_retry php vendor/bin/php-coveralls -v

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ tool that performs instant refactoring of your application.
111111
First, you need to install Rector:
112112
113113
```bash
114-
$ composer require --dev rector/rector ^0.3
114+
$ composer require --dev rector/rector ^0.4
115115
```
116116

117117
Now, you simply need to run Rector with this command:

generator/src/FileCreator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function generateRectorFile(array $functions, string $path): void
127127
}
128128
fwrite($stream, "# This rector file is replacing all core PHP functions with the equivalent \"safe\" functions
129129
services:
130-
Rector\Rector\Function_\FunctionReplaceRector:
130+
Rector\Rector\Function_\RenameFunctionRector:
131131
\$oldFunctionToNewFunction:
132132
");
133133
foreach ($functionNames as $functionName) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"autoload": {
3+
"psr-4": {
4+
"Test\\": "src/"
5+
}
6+
},
7+
"require": {
8+
"php": ">=7.1",
9+
"rector/rector": "^0.4"
10+
},
11+
"require-dev": {
12+
"phpunit/phpunit": "^7"
13+
},
14+
"scripts": {
15+
"rector": "rector process src/ --config ../../../../rector-migrate.yml",
16+
"test": "phpunit"
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
bootstrap="vendor/autoload.php"
12+
>
13+
<testsuites>
14+
<testsuite name="Main test Suite">
15+
<directory>./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
</phpunit>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
glob('*');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
4+
use PHPUnit\Framework\TestCase;
5+
6+
class RectorTest extends TestCase
7+
{
8+
public function testRectorSucceeded()
9+
{
10+
$content = file_get_contents(__DIR__.'/../src/test.php');
11+
$this->assertContains('Safe', $content);
12+
}
13+
}

rector-migrate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This rector file is replacing all core PHP functions with the equivalent "safe" functions
22
services:
3-
Rector\Rector\Function_\FunctionReplaceRector:
3+
Rector\Rector\Function_\RenameFunctionRector:
44
$oldFunctionToNewFunction:
55
apache_get_version: 'Safe\apache_get_version'
66
apache_getenv: 'Safe\apache_getenv'

0 commit comments

Comments
 (0)