Skip to content

Commit 2bf0e46

Browse files
committed
release PHP 7.2 downgraded
1 parent 1dc19f4 commit 2bf0e46

3,641 files changed

Lines changed: 340738 additions & 7414 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 0 additions & 9 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/vendor
1+
# we need the vendor
22
composer.lock
33

4-
/.phpunit.cache
4+
.phpunit.result.cache
55

66

77
# to keep local rector outside git repository

bin/ecs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php
3+
namespace ECSPrefix202501;
34

45
require __DIR__ . '/ecs.php';

bin/ecs.php

Lines changed: 39 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare (strict_types=1);
4+
namespace ECSPrefix202501;
45

56
// decoupled in own "*.php" file, so ECS, Rector and PHPStan works out of the box here
67
use PHP_CodeSniffer\Util\Tokens;
7-
use Symfony\Component\Console\Command\Command;
8-
use Symfony\Component\Console\Input\ArgvInput;
8+
use ECSPrefix202501\Symfony\Component\Console\Command\Command;
9+
use ECSPrefix202501\Symfony\Component\Console\Input\ArgvInput;
910
use Symplify\EasyCodingStandard\Console\EasyCodingStandardConsoleApplication;
1011
use Symplify\EasyCodingStandard\Console\Style\SymfonyStyleFactory;
1112
use Symplify\EasyCodingStandard\DependencyInjection\EasyCodingStandardContainerFactory;
1213
use Symplify\EasyCodingStandard\DependencyInjection\LazyContainerFactory;
13-
1414
// performance boost
15-
gc_disable();
16-
17-
define('__ECS_RUNNING__', true);
18-
15+
\gc_disable();
16+
\define('__ECS_RUNNING__', \true);
1917
# 1. autoload
2018
$autoloadIncluder = new ECSAutoloadIncluder();
21-
22-
if (file_exists(__DIR__ . '/../preload.php')) {
19+
if (\file_exists(__DIR__ . '/../preload.php')) {
2320
require_once __DIR__ . '/../preload.php';
2421
}
25-
2622
$autoloadIncluder->includeCwdVendorAutoloadIfExists();
2723
$autoloadIncluder->loadIfNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
2824
$autoloadIncluder->autoloadProjectAutoloaderFile('/../../autoload.php');
2925
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
3026
$autoloadIncluder->includePhpCodeSnifferAutoload();
31-
3227
/**
3328
* Inspired by https://github.com/rectorphp/rector/pull/2373/files#diff-0fc04a2bb7928cac4ae339d5a8bf67f3
3429
*/
@@ -45,118 +40,98 @@ final class ECSAutoloadIncluder
4540
// monorepo
4641
__DIR__ . '/../../../vendor',
4742
];
48-
4943
/**
5044
* @var string[]
5145
*/
52-
private array $alreadyLoadedAutoloadFiles = [];
53-
54-
public function includeCwdVendorAutoloadIfExists(): void
46+
private $alreadyLoadedAutoloadFiles = [];
47+
public function includeCwdVendorAutoloadIfExists() : void
5548
{
56-
$cwdVendorAutoload = getcwd() . '/vendor/autoload.php';
57-
if (! is_file($cwdVendorAutoload)) {
49+
$cwdVendorAutoload = \getcwd() . '/vendor/autoload.php';
50+
if (!\is_file($cwdVendorAutoload)) {
5851
return;
5952
}
60-
6153
$this->loadIfNotLoadedYet($cwdVendorAutoload);
6254
}
63-
64-
public function includeDependencyOrRepositoryVendorAutoloadIfExists(): void
55+
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
6556
{
6657
// ECS' vendor is already loaded
67-
if (class_exists(LazyContainerFactory::class)) {
58+
if (\class_exists(LazyContainerFactory::class)) {
6859
return;
6960
}
70-
7161
$devVendorAutoload = __DIR__ . '/../vendor/autoload.php';
72-
if (! is_file($devVendorAutoload)) {
62+
if (!\is_file($devVendorAutoload)) {
7363
return;
7464
}
75-
7665
$this->loadIfNotLoadedYet($devVendorAutoload);
7766
}
78-
79-
public function autoloadProjectAutoloaderFile(string $file): void
67+
public function autoloadProjectAutoloaderFile(string $file) : void
8068
{
81-
$path = dirname(__DIR__) . $file;
82-
if (! is_file($path)) {
69+
$path = \dirname(__DIR__) . $file;
70+
if (!\is_file($path)) {
8371
return;
8472
}
85-
8673
$this->loadIfNotLoadedYet($path);
8774
}
88-
89-
public function includePhpCodeSnifferAutoload(): void
75+
public function includePhpCodeSnifferAutoload() : void
9076
{
9177
// 1. autoload
9278
foreach (self::POSSIBLE_AUTOLOAD_PATHS as $possibleAutoloadPath) {
9379
$possiblePhpCodeSnifferAutoloadPath = $possibleAutoloadPath . '/squizlabs/php_codesniffer/autoload.php';
94-
if (! is_file($possiblePhpCodeSnifferAutoloadPath)) {
80+
if (!\is_file($possiblePhpCodeSnifferAutoloadPath)) {
9581
continue;
9682
}
97-
9883
require_once $possiblePhpCodeSnifferAutoloadPath;
9984
}
100-
10185
// initialize token with INT type, otherwise php-cs-fixer and php-parser breaks
102-
if (! defined('T_MATCH')) {
103-
define('T_MATCH', 5000);
86+
if (!\defined('T_MATCH')) {
87+
\define('T_MATCH', 5000);
10488
}
105-
106-
if (! defined('T_READONLY')) {
107-
define('T_READONLY', 5010);
89+
if (!\defined('T_READONLY')) {
90+
\define('T_READONLY', 5010);
10891
}
109-
110-
if (! defined('T_ENUM')) {
111-
define('T_ENUM', 5015);
92+
if (!\defined('T_ENUM')) {
93+
\define('T_ENUM', 5015);
11294
}
113-
114-
if (! defined('T_NULLSAFE_OBJECT_OPERATOR')) {
115-
define('T_NULLSAFE_OBJECT_OPERATOR', 5020);
95+
if (!\defined('T_NULLSAFE_OBJECT_OPERATOR')) {
96+
\define('T_NULLSAFE_OBJECT_OPERATOR', 5020);
11697
}
117-
11898
// for PHP_CodeSniffer
119-
define('PHP_CODESNIFFER_CBF', false);
120-
define('PHP_CODESNIFFER_VERBOSITY', 0);
121-
99+
\define('PHP_CODESNIFFER_CBF', \false);
100+
\define('PHP_CODESNIFFER_VERBOSITY', 0);
122101
new Tokens();
123102
}
124-
125-
public function loadIfNotLoadedYet(string $file): void
103+
public function loadIfNotLoadedYet(string $file) : void
126104
{
127-
if (! file_exists($file)) {
105+
if (!\file_exists($file)) {
128106
return;
129107
}
130-
131-
if (in_array($file, $this->alreadyLoadedAutoloadFiles, true)) {
108+
if (\in_array($file, $this->alreadyLoadedAutoloadFiles, \true)) {
132109
return;
133110
}
134-
135-
$realPath = realpath($file);
136-
if (! is_string($realPath)) {
111+
$realPath = \realpath($file);
112+
if (!\is_string($realPath)) {
137113
return;
138114
}
139-
140115
$this->alreadyLoadedAutoloadFiles[] = $realPath;
141116
require_once $file;
142117
}
143118
}
144-
119+
/**
120+
* Inspired by https://github.com/rectorphp/rector/pull/2373/files#diff-0fc04a2bb7928cac4ae339d5a8bf67f3
121+
*/
122+
\class_alias('ECSPrefix202501\\ECSAutoloadIncluder', 'ECSAutoloadIncluder', \false);
145123
try {
146124
$input = new ArgvInput();
147125
$ecsContainerFactory = new EasyCodingStandardContainerFactory();
148126
$container = $ecsContainerFactory->createFromFromInput($input);
149-
} catch (Throwable $throwable) {
127+
} catch (\Throwable $throwable) {
150128
$symfonyStyleFactory = new SymfonyStyleFactory();
151129
$symfonyStyle = $symfonyStyleFactory->create();
152-
153130
$symfonyStyle->error($throwable->getMessage());
154131
$symfonyStyle->writeln($throwable->getTraceAsString());
155132
exit(Command::FAILURE);
156133
}
157-
158134
/** @var EasyCodingStandardConsoleApplication $application */
159135
$application = $container->get(EasyCodingStandardConsoleApplication::class);
160-
161136
$statusCode = $application->run();
162137
exit($statusCode);
Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,63 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare (strict_types=1);
4+
namespace ECSPrefix202501;
45

56
use PhpCsFixer\RuleSet\RuleSets;
6-
use PhpParser\Modifiers;
7-
use PhpParser\Node\Expr\ArrayDimFetch;
8-
use PhpParser\Node\Expr\Assign;
9-
use PhpParser\Node\Expr\ConstFetch;
10-
use PhpParser\Node\Expr\PropertyFetch;
11-
use PhpParser\Node\Expr\Variable;
12-
use PhpParser\Node\Identifier;
13-
use PhpParser\Node\Name;
14-
use PhpParser\Node\Param;
15-
use PhpParser\Node\Scalar\String_;
16-
use PhpParser\Node\Stmt\ClassMethod;
17-
use PhpParser\Node\Stmt\Expression;
18-
use PhpParser\Node\Stmt\If_;
19-
use PhpParser\Node\Stmt\Return_;
20-
use PhpParser\PrettyPrinter\Standard;
21-
7+
use ECSPrefix202501\PhpParser\Modifiers;
8+
use ECSPrefix202501\PhpParser\Node\Expr\ArrayDimFetch;
9+
use ECSPrefix202501\PhpParser\Node\Expr\Assign;
10+
use ECSPrefix202501\PhpParser\Node\Expr\ConstFetch;
11+
use ECSPrefix202501\PhpParser\Node\Expr\PropertyFetch;
12+
use ECSPrefix202501\PhpParser\Node\Expr\Variable;
13+
use ECSPrefix202501\PhpParser\Node\Identifier;
14+
use ECSPrefix202501\PhpParser\Node\Name;
15+
use ECSPrefix202501\PhpParser\Node\Param;
16+
use ECSPrefix202501\PhpParser\Node\Scalar\String_;
17+
use ECSPrefix202501\PhpParser\Node\Stmt\ClassMethod;
18+
use ECSPrefix202501\PhpParser\Node\Stmt\Expression;
19+
use ECSPrefix202501\PhpParser\Node\Stmt\If_;
20+
use ECSPrefix202501\PhpParser\Node\Stmt\Return_;
21+
use ECSPrefix202501\PhpParser\PrettyPrinter\Standard;
2222
// this helper script generates the withPhpCsFixerSets() method for ECSConfigBuilder class
23-
2423
require __DIR__ . '/../vendor/autoload.php';
25-
2624
$setsDirectory = __DIR__ . '/../vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/';
27-
2825
$setDefinitions = RuleSets::getSetDefinitions();
29-
3026
$setNames = [];
3127
foreach ($setDefinitions as $setDefinition) {
3228
$setNames[] = $setDefinition->getName();
3329
}
34-
3530
// create withPhpCsFixerSets() method here
3631
$classMethod = new ClassMethod('withPhpCsFixerSets');
3732
$classMethod->flags = Modifiers::PUBLIC;
3833
$classMethod->returnType = new Name('self');
39-
4034
foreach ($setNames as $setName) {
4135
// convert to PHP variable name
42-
$paramName = ltrim($setName, '@');
43-
36+
$paramName = \ltrim($setName, '@');
4437
$paramName = lowercaseUntilFirstLower($paramName);
45-
$paramName = str_replace(':r', 'R', $paramName);
46-
$paramName = str_replace(['.', '-', '_'], '', $paramName);
47-
38+
$paramName = \str_replace(':r', 'R', $paramName);
39+
$paramName = \str_replace(['.', '-', '_'], '', $paramName);
4840
// lowercase only the first uppercase letters
49-
50-
$classMethod->params[] = new Param(
51-
new Variable($paramName),
52-
new ConstFetch(new Name('false')),
53-
new Identifier('bool')
54-
);
55-
41+
$classMethod->params[] = new Param(new Variable($paramName), new ConstFetch(new Name('false')), new Identifier('bool'));
5642
$dynamicSetsPropertyFetch = new PropertyFetch(new Variable('this'), 'dynamicSets');
57-
58-
$classMethod->stmts[] = new If_(new Variable($paramName), [
59-
'stmts' => [
60-
new Expression(new Assign(new ArrayDimFetch($dynamicSetsPropertyFetch), new String_($setName))),
61-
],
62-
]);
43+
$classMethod->stmts[] = new If_(new Variable($paramName), ['stmts' => [new Expression(new Assign(new ArrayDimFetch($dynamicSetsPropertyFetch), new String_($setName)))]]);
6344
}
64-
65-
function lowercaseUntilFirstLower($input): string
45+
function lowercaseUntilFirstLower($input) : string
6646
{
6747
$output = '';
68-
$foundLower = false;
69-
70-
for ($i = 0; $i < strlen((string) $input); $i++) {
48+
$foundLower = \false;
49+
for ($i = 0; $i < \strlen((string) $input); $i++) {
7150
$char = $input[$i];
72-
73-
if (! $foundLower && ctype_upper((string) $char)) {
74-
$output .= strtolower((string) $char);
51+
if (!$foundLower && \ctype_upper((string) $char)) {
52+
$output .= \strtolower((string) $char);
7553
} else {
7654
$output .= $char;
77-
$foundLower = true;
55+
$foundLower = \true;
7856
}
7957
}
80-
8158
return $output;
8259
}
83-
8460
// add dynamic set includes
85-
8661
$classMethod->stmts[] = new Return_(new Variable('this'));
87-
8862
$printerStandard = new Standard();
8963
echo $printerStandard->prettyPrint([$classMethod]);

build/rector-downgrade-php-72.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

build/target-repository/.gitignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

build/target-repository/composer.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)