You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rector rules to upgrade a phpseclib v2.0 install to phpseclib v3.0
3
+
Rector rules to upgrade a phpseclib v2.0 install to phpseclib v3.0 or
4
+
to upgrade a phpseclib v3.0 install to phpseclib v4.0.
4
5
5
6
## Overview
6
7
7
-
You can use [phpseclib2_compat](https://github.com/phpseclib/phpseclib2_compat) to make all your phpseclib v2.0 calls use phpseclib v3.0, internally, under the hood, or you can use this [Rector](https://getrector.com/) rule to upgrade your phpseclib v2.0 calls to phpseclib v3.0 calls.
8
+
You can use [phpseclib2_compat](https://github.com/phpseclib/phpseclib2_compat) to make all your phpseclib v2.0 calls use phpseclib v3.0, internally, under the hood.
9
+
Or you can use this [Rector](https://getrector.com/) rule to upgrade your
10
+
phpseclib v2.0 calls to phpseclib v3.0 calls or your
11
+
phpseclib v3.0 calls to your phpseclib v4.0 calls.
8
12
9
13
## Installation
10
14
11
15
With [Composer](https://getcomposer.org/):
12
16
13
-
```
17
+
```bash
14
18
composer require phpseclib/rector_rules:~1.0
15
19
```
16
20
17
21
## Usage
18
22
19
23
Create a rector.php file with the following contents:
20
24
25
+
### v2 to v3 upgrade
26
+
21
27
```php
22
28
<?php
23
29
use Rector\Config\RectorConfig;
@@ -26,6 +32,20 @@ use phpseclib\rectorRules\Set\V2toV3Set;
26
32
return RectorConfig::configure()
27
33
->withSets([V2toV3Set::PATH]);
28
34
```
35
+
36
+
### v3 to v4 upgrade
37
+
38
+
```php
39
+
<?php
40
+
use Rector\Config\RectorConfig;
41
+
use phpseclib\rectorRules\Set\V3toV4Set;
42
+
43
+
return RectorConfig::configure()
44
+
->withSets([V3toV4Set::PATH]);
45
+
```
46
+
47
+
### Refactor
48
+
29
49
In the same directory where you created that file you can then run Rector by doing either of these commands:
30
50
31
51
```
@@ -38,13 +58,18 @@ The files in the `src/` directory will either be full on modified or (in the cas
38
58
39
59
To run all Retor tests, run
40
60
41
-
```
61
+
```bash
42
62
vendor/bin/phpunit tests
43
63
```
44
64
65
+
To run all tests of a ruleset, add the name of it, like
66
+
```bash
67
+
vendor/bin/phpunit tests --filter V2toV3
68
+
```
69
+
45
70
To run all tests of a single rector rule, add --filter to the test command.
| $default = new DES(); | $default = new DES('cbc'); |
227
-
| $des = new DES(DES::MODE_CBC); | $des = new DES('cbc'); |
228
-
| $rijndael = new Rijndael(Rijndael::MODE_ECB); | $rijndael = new Rijndael('ecb'); |
229
-
| $tripleDES = new TripleDES(TripleDES::MODE_CTR); | $tripleDES = new TripleDES('ctr'); |
230
-
| $blowfish = new Blowfish(Blowfish::MODE_CFB); | $blowfish = new Blowfish('cfb'); |
231
-
| $twofish = new Twofish(Twofish::MODE_CFB8); | $twofish = new Twofish('cfb8'); |
232
-
| $rc2 = new RC2(RC2::MODE_OFB); | $rc2 = new RC2('ofb'); |
233
-
| $aes = new AES(AES::MODE_OFB8); | $aes = new AES('ofb8'); |
234
-
| $aes2 = new AES(AES::MODE_GCM); | $aes2 = new AES('gcm'); |
98
+
Details of the rules are in separate Readme files for [phpseclib v2.0 to phpseclib v3.0](./src/Rector/V2toV3/README.md) and [phpseclib v3.0 to phpseclib v4.0](./src/Rector/V3toV4/README.md).
0 commit comments