-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrector.php
More file actions
45 lines (41 loc) · 1.97 KB
/
Copy pathrector.php
File metadata and controls
45 lines (41 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Rector configuration: downgrade the modern source under src/ to PHP 7.0
* syntax, so the released package installs and runs on the same floor as
* ext-rdump (PHP 7.0+).
*
* Development happens in modern PHP in src/; `composer downgrade` copies
* src/ to build/php70/src/ and rewrites it in place with the rules below.
* That downgraded tree is what a release ships.
*
* Pipeline (mirrors reli's rector-sidecar-client.php so both reliforp
* packages reach the same 7.0 floor the same way):
* 1. Rector's official downgrade level set covers PHP 8.x -> 7.1 via
* withDowngradeSets(php71: true): readonly, promoted properties, match,
* union types, str_contains/str_starts_with, arrow functions, typed
* properties, etc.
* 2. The 7.1 -> 7.0 gap (Rector ships no rules for it) is filled by our
* own rules under tools/rector/Downgrade*ToPhp70Rector:
* - nullable type hints (?T) : params get `= null`, returns dropped
* - void return type : dropped
* - class const visibility : private/protected/public stripped
* 3. The 0o<digits> octal literal syntax (PHP 8.1+) is rewritten by a sed
* pass in the composer "downgrade" script after Rector finishes, since
* Rector's pretty-printer preserves the original token for unmodified
* number nodes.
*/
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersion;
use Reliforp\PhpMemoryDump\Build\Rector\DowngradeConstVisibilityToPhp70Rector;
use Reliforp\PhpMemoryDump\Build\Rector\DowngradeNullableTypeToPhp70Rector;
use Reliforp\PhpMemoryDump\Build\Rector\DowngradeVoidReturnToPhp70Rector;
return RectorConfig::configure()
->withPaths([__DIR__ . '/build/php70/src'])
->withPhpVersion(PhpVersion::PHP_70)
->withDowngradeSets(php71: true)
->withRules([
DowngradeNullableTypeToPhp70Rector::class,
DowngradeVoidReturnToPhp70Rector::class,
DowngradeConstVisibilityToPhp70Rector::class,
]);