Skip to content

Commit bd670fe

Browse files
committed
release PHP 7.2 downgraded
1 parent 4ecec39 commit bd670fe

File tree

3,336 files changed

+323954
-6830
lines changed

Some content is hidden

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

3,336 files changed

+323954
-6830
lines changed

.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 ECSPrefix202407;
34

45
require __DIR__ . '/ecs.php';

bin/ecs.php

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

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

56
// decoupled in own "*.php" file, so ECS, Rector and PHPStan works out of the box here
6-
77
use PHP_CodeSniffer\Util\Tokens;
8-
use Symfony\Component\Console\Command\Command;
9-
use Symfony\Component\Console\Input\ArgvInput;
8+
use ECSPrefix202407\Symfony\Component\Console\Command\Command;
9+
use ECSPrefix202407\Symfony\Component\Console\Input\ArgvInput;
1010
use Symplify\EasyCodingStandard\Console\EasyCodingStandardConsoleApplication;
1111
use Symplify\EasyCodingStandard\Console\Style\SymfonyStyleFactory;
1212
use Symplify\EasyCodingStandard\DependencyInjection\EasyCodingStandardContainerFactory;
13-
1413
// performance boost
15-
gc_disable();
16-
17-
define('__ECS_RUNNING__', true);
18-
14+
\gc_disable();
15+
\define('__ECS_RUNNING__', \true);
1916
# 1. autoload
2017
$autoloadIncluder = new AutoloadIncluder();
21-
22-
if (file_exists(__DIR__ . '/../preload.php')) {
18+
if (\file_exists(__DIR__ . '/../preload.php')) {
2319
require_once __DIR__ . '/../preload.php';
2420
}
25-
2621
$autoloadIncluder->includeCwdVendorAutoloadIfExists();
2722
$autoloadIncluder->loadIfNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
2823
$autoloadIncluder->autoloadProjectAutoloaderFile('/../../autoload.php');
2924
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
3025
$autoloadIncluder->includePhpCodeSnifferAutoload();
31-
3226
/**
3327
* Inspired by https://github.com/rectorphp/rector/pull/2373/files#diff-0fc04a2bb7928cac4ae339d5a8bf67f3
3428
*/
@@ -45,116 +39,98 @@ final class AutoloadIncluder
4539
// monorepo
4640
__DIR__ . '/../../../vendor',
4741
];
48-
4942
/**
5043
* @var string[]
5144
*/
52-
private array $alreadyLoadedAutoloadFiles = [];
53-
54-
public function includeCwdVendorAutoloadIfExists(): void
45+
private $alreadyLoadedAutoloadFiles = [];
46+
public function includeCwdVendorAutoloadIfExists() : void
5547
{
56-
$cwdVendorAutoload = getcwd() . '/vendor/autoload.php';
57-
if (! is_file($cwdVendorAutoload)) {
48+
$cwdVendorAutoload = \getcwd() . '/vendor/autoload.php';
49+
if (!\is_file($cwdVendorAutoload)) {
5850
return;
5951
}
6052
$this->loadIfNotLoadedYet($cwdVendorAutoload);
6153
}
62-
63-
public function includeDependencyOrRepositoryVendorAutoloadIfExists(): void
54+
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
6455
{
6556
// ECS' vendor is already loaded
66-
if (class_exists('Symplify\EasyCodingStandard\DependencyInjection\LazyContainerFactory')) {
57+
if (\class_exists('Symplify\\EasyCodingStandard\\DependencyInjection\\LazyContainerFactory')) {
6758
return;
6859
}
69-
7060
$devVendorAutoload = __DIR__ . '/../vendor/autoload.php';
71-
if (! is_file($devVendorAutoload)) {
61+
if (!\is_file($devVendorAutoload)) {
7262
return;
7363
}
74-
7564
$this->loadIfNotLoadedYet($devVendorAutoload);
7665
}
77-
78-
public function autoloadProjectAutoloaderFile(string $file): void
66+
public function autoloadProjectAutoloaderFile(string $file) : void
7967
{
80-
$path = dirname(__DIR__) . $file;
81-
if (! is_file($path)) {
68+
$path = \dirname(__DIR__) . $file;
69+
if (!\is_file($path)) {
8270
return;
8371
}
8472
$this->loadIfNotLoadedYet($path);
8573
}
86-
87-
public function includePhpCodeSnifferAutoload(): void
74+
public function includePhpCodeSnifferAutoload() : void
8875
{
8976
// 1. autoload
9077
foreach (self::POSSIBLE_AUTOLOAD_PATHS as $possibleAutoloadPath) {
9178
$possiblePhpCodeSnifferAutoloadPath = $possibleAutoloadPath . '/squizlabs/php_codesniffer/autoload.php';
92-
if (! is_file($possiblePhpCodeSnifferAutoloadPath)) {
79+
if (!\is_file($possiblePhpCodeSnifferAutoloadPath)) {
9380
continue;
9481
}
95-
9682
require_once $possiblePhpCodeSnifferAutoloadPath;
9783
}
98-
9984
// initialize token with INT type, otherwise php-cs-fixer and php-parser breaks
100-
if (! defined('T_MATCH')) {
101-
define('T_MATCH', 5000);
85+
if (!\defined('T_MATCH')) {
86+
\define('T_MATCH', 5000);
10287
}
103-
104-
if (! defined('T_READONLY')) {
105-
define('T_READONLY', 5010);
88+
if (!\defined('T_READONLY')) {
89+
\define('T_READONLY', 5010);
10690
}
107-
108-
if (! defined('T_ENUM')) {
109-
define('T_ENUM', 5015);
91+
if (!\defined('T_ENUM')) {
92+
\define('T_ENUM', 5015);
11093
}
111-
112-
if (! defined('T_NULLSAFE_OBJECT_OPERATOR')) {
113-
define('T_NULLSAFE_OBJECT_OPERATOR', 5020);
94+
if (!\defined('T_NULLSAFE_OBJECT_OPERATOR')) {
95+
\define('T_NULLSAFE_OBJECT_OPERATOR', 5020);
11496
}
115-
11697
// for PHP_CodeSniffer
117-
define('PHP_CODESNIFFER_CBF', false);
118-
define('PHP_CODESNIFFER_VERBOSITY', 0);
119-
98+
\define('PHP_CODESNIFFER_CBF', \false);
99+
\define('PHP_CODESNIFFER_VERBOSITY', 0);
120100
new Tokens();
121101
}
122-
123-
public function loadIfNotLoadedYet(string $file): void
102+
public function loadIfNotLoadedYet(string $file) : void
124103
{
125-
if (! file_exists($file)) {
104+
if (!\file_exists($file)) {
126105
return;
127106
}
128-
129-
if (in_array($file, $this->alreadyLoadedAutoloadFiles, true)) {
107+
if (\in_array($file, $this->alreadyLoadedAutoloadFiles, \true)) {
130108
return;
131109
}
132-
133-
$realPath = realpath($file);
134-
if (! is_string($realPath)) {
110+
$realPath = \realpath($file);
111+
if (!\is_string($realPath)) {
135112
return;
136113
}
137-
138114
$this->alreadyLoadedAutoloadFiles[] = $realPath;
139115
require_once $file;
140116
}
141117
}
142-
118+
/**
119+
* Inspired by https://github.com/rectorphp/rector/pull/2373/files#diff-0fc04a2bb7928cac4ae339d5a8bf67f3
120+
*/
121+
\class_alias('ECSPrefix202407\\AutoloadIncluder', 'AutoloadIncluder', \false);
143122
try {
144123
$input = new ArgvInput();
145124
$ecsContainerFactory = new EasyCodingStandardContainerFactory();
146125
$container = $ecsContainerFactory->createFromFromInput($input);
147-
} catch (Throwable $throwable) {
126+
} catch (\Throwable $throwable) {
148127
$symfonyStyleFactory = new SymfonyStyleFactory();
149128
$symfonyStyle = $symfonyStyleFactory->create();
150-
151129
$symfonyStyle->error($throwable->getMessage());
152130
$symfonyStyle->writeln($throwable->getTraceAsString());
153131
exit(Command::FAILURE);
154132
}
155-
156133
/** @var EasyCodingStandardConsoleApplication $application */
157134
$application = $container->get(EasyCodingStandardConsoleApplication::class);
158-
159135
$statusCode = $application->run();
160136
exit($statusCode);

bin/generate-php-cs-fixer-tests.php

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,48 @@
11
<?php
22

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

56
use PhpCsFixer\RuleSet\RuleSets;
6-
77
// this helper script generates the withPhpCsFixerSets() method for ECSConfigBuilder class
8-
98
require __DIR__ . '/../vendor/autoload.php';
10-
119
$setsDirectory = __DIR__ . '/../vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/';
12-
1310
$setDefinitions = RuleSets::getSetDefinitions();
14-
1511
$setNames = [];
1612
foreach ($setDefinitions as $setDefinition) {
1713
$setNames[] = $setDefinition->getName();
1814
}
19-
2015
// create withPhpCsFixerSets() method here
21-
$classMethod = new \PhpParser\Node\Stmt\ClassMethod('withPhpCsFixerSets');
22-
$classMethod->flags = \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC;
23-
$classMethod->returnType = new \PhpParser\Node\Name('self');
24-
16+
$classMethod = new \ECSPrefix202407\PhpParser\Node\Stmt\ClassMethod('withPhpCsFixerSets');
17+
$classMethod->flags = \ECSPrefix202407\PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC;
18+
$classMethod->returnType = new \ECSPrefix202407\PhpParser\Node\Name('self');
2519
foreach ($setNames as $setName) {
2620
// convert to PHP variable name
27-
$paramName = ltrim( $setName, '@');
28-
21+
$paramName = \ltrim($setName, '@');
2922
$paramName = lowercaseUntilFirstLower($paramName);
30-
$paramName = str_replace(':r', 'R', $paramName);
31-
$paramName = str_replace(['.', '-', '_'], '', $paramName);
32-
23+
$paramName = \str_replace(':r', 'R', $paramName);
24+
$paramName = \str_replace(['.', '-', '_'], '', $paramName);
3325
// lowercase only the first uppercase letters
34-
35-
$classMethod->params[] = new \PhpParser\Node\Param(
36-
new \PhpParser\Node\Expr\Variable($paramName),
37-
new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('false')),
38-
new \PhpParser\Node\Identifier('bool')
39-
);
40-
41-
$dynamicSetsPropertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), 'dynamicSets');
42-
43-
$classMethod->stmts[] = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\Variable($paramName), [
44-
'stmts' => [
45-
new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign(
46-
new \PhpParser\Node\Expr\ArrayDimFetch($dynamicSetsPropertyFetch),
47-
new \PhpParser\Node\Scalar\String_($setName)
48-
))
49-
]
50-
]);
26+
$classMethod->params[] = new \ECSPrefix202407\PhpParser\Node\Param(new \ECSPrefix202407\PhpParser\Node\Expr\Variable($paramName), new \ECSPrefix202407\PhpParser\Node\Expr\ConstFetch(new \ECSPrefix202407\PhpParser\Node\Name('false')), new \ECSPrefix202407\PhpParser\Node\Identifier('bool'));
27+
$dynamicSetsPropertyFetch = new \ECSPrefix202407\PhpParser\Node\Expr\PropertyFetch(new \ECSPrefix202407\PhpParser\Node\Expr\Variable('this'), 'dynamicSets');
28+
$classMethod->stmts[] = new \ECSPrefix202407\PhpParser\Node\Stmt\If_(new \ECSPrefix202407\PhpParser\Node\Expr\Variable($paramName), ['stmts' => [new \ECSPrefix202407\PhpParser\Node\Stmt\Expression(new \ECSPrefix202407\PhpParser\Node\Expr\Assign(new \ECSPrefix202407\PhpParser\Node\Expr\ArrayDimFetch($dynamicSetsPropertyFetch), new \ECSPrefix202407\PhpParser\Node\Scalar\String_($setName)))]]);
5129
}
52-
53-
54-
function lowercaseUntilFirstLower($input) {
30+
function lowercaseUntilFirstLower($input)
31+
{
5532
$output = '';
56-
$foundLower = false;
57-
58-
for ($i = 0; $i < strlen($input); $i++) {
33+
$foundLower = \false;
34+
for ($i = 0; $i < \strlen($input); $i++) {
5935
$char = $input[$i];
60-
61-
if (!$foundLower && ctype_upper($char)) {
62-
$output .= strtolower($char);
36+
if (!$foundLower && \ctype_upper($char)) {
37+
$output .= \strtolower($char);
6338
} else {
6439
$output .= $char;
65-
$foundLower = true;
40+
$foundLower = \true;
6641
}
6742
}
68-
6943
return $output;
7044
}
7145
// add dynamic set includes
72-
73-
$classMethod->stmts[] = new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Expr\Variable('this'));
74-
75-
76-
$printerStandard = new \PhpParser\PrettyPrinter\Standard();
46+
$classMethod->stmts[] = new \ECSPrefix202407\PhpParser\Node\Stmt\Return_(new \ECSPrefix202407\PhpParser\Node\Expr\Variable('this'));
47+
$printerStandard = new \ECSPrefix202407\PhpParser\PrettyPrinter\Standard();
7748
echo $printerStandard->prettyPrint([$classMethod]);
File renamed without changes.

build/rector-downgrade-php-72.php

Lines changed: 0 additions & 16 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)