Skip to content

Commit 677c032

Browse files
authored
Merge pull request #114 from moufmouf/rector0.4
Migrating to Rector 0.4
2 parents 9a4dbc5 + cdcd3c6 commit 677c032

File tree

11 files changed

+73
-10
lines changed

11 files changed

+73
-10
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 generator/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:

generated/ldap.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ function ldap_add($link_identifier, string $dn, array $entry, array $serverctrls
6161
* @param resource $link_identifier
6262
* @param string $bind_rdn
6363
* @param string $bind_password
64+
* @param array $serverctrls
6465
* @return resource Returns an LDAP result identifier.
6566
* @throws LdapException
6667
*
6768
*/
68-
function ldap_bind_ext($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null)
69+
function ldap_bind_ext($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null, array $serverctrls = null)
6970
{
7071
error_clear_last();
71-
$result = \ldap_bind_ext($link_identifier, $bind_rdn, $bind_password);
72+
$result = \ldap_bind_ext($link_identifier, $bind_rdn, $bind_password, $serverctrls);
7273
if ($result === false) {
7374
throw LdapException::createFromPhpError();
7475
}
@@ -82,13 +83,14 @@ function ldap_bind_ext($link_identifier, ?string $bind_rdn = null, ?string $bind
8283
* @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
8384
* @param string $bind_rdn
8485
* @param string $bind_password
86+
* @param array $serverctrls Array of LDAP Controls to send with the request.
8587
* @throws LdapException
8688
*
8789
*/
88-
function ldap_bind($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null): void
90+
function ldap_bind($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null, array $serverctrls = null): void
8991
{
9092
error_clear_last();
91-
$result = \ldap_bind($link_identifier, $bind_rdn, $bind_password);
93+
$result = \ldap_bind($link_identifier, $bind_rdn, $bind_password, $serverctrls);
9294
if ($result === false) {
9395
throw LdapException::createFromPhpError();
9496
}

generator/phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<testsuites>
1414
<testsuite name="Main test Suite">
1515
<directory>./tests/</directory>
16+
<exclude>
17+
<directory>./tests/rector</directory>
18+
</exclude>
1619
</testsuite>
1720
</testsuites>
1821
<filter>

generator/src/FileCreator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ public function generateRectorFile(array $functions, string $path): void
125125
if ($stream === false) {
126126
throw new \RuntimeException('Unable to write to '.$path);
127127
}
128-
fwrite($stream, "# This rector file is replacing all core PHP functions with the equivalent \"safe\" functions
128+
fwrite($stream, "# This rector file is replacing all core PHP functions with the equivalent \"safe\" functions
129+
# It is targetting Rector 0.4.x versions.
130+
# If you are using Rector 0.3, please upgrade your Rector version
129131
services:
130-
Rector\Rector\Function_\FunctionReplaceRector:
132+
Rector\Rector\Function_\RenameFunctionRector:
131133
\$oldFunctionToNewFunction:
132134
");
133135
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+
}

0 commit comments

Comments
 (0)