mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
[php-parser] upgrade to 4.10.5 - add src/constants.php to mimic new PHP 8.1 tokens; update test with unicode (#6325)
* add src/constants.php to mimic new PHP 8.1 tokens; update test with unicode * include preload in dev repository too * include preload function
This commit is contained in:
parent
a2bb65c272
commit
ac7a03f800
|
@ -9,7 +9,6 @@ use Rector\Core\DependencyInjection\RectorContainerFactory;
|
|||
use Rector\Core\HttpKernel\RectorKernel;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use Tracy\Debugger;
|
||||
|
||||
// @ intentionally: continue anyway
|
||||
@ini_set('memory_limit', '-1');
|
||||
|
@ -21,15 +20,17 @@ gc_disable();
|
|||
|
||||
define('__RECTOR_RUNNING__', true);
|
||||
|
||||
|
||||
// Require Composer autoload.php
|
||||
$autoloadIncluder = new AutoloadIncluder();
|
||||
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
|
||||
|
||||
if (file_exists(__DIR__ . '/../vendor/scoper-autoload.php')) {
|
||||
// make local php-parser a priority to avoid conflict
|
||||
if (should_include_preload()) {
|
||||
require_once __DIR__ . '/../preload.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../src/constants.php';
|
||||
|
||||
$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
|
||||
|
||||
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
||||
|
@ -40,11 +41,6 @@ $symfonyStyle = $symfonyStyleFactory->create();
|
|||
|
||||
$rectorConfigsResolver = new RectorConfigsResolver();
|
||||
|
||||
// for simpler debugging output
|
||||
if (class_exists(Debugger::class)) {
|
||||
Debugger::$maxDepth = 2;
|
||||
}
|
||||
|
||||
try {
|
||||
$bootstrapConfigs = $rectorConfigsResolver->provide();
|
||||
$rectorContainerFactory = new RectorContainerFactory();
|
||||
|
@ -126,3 +122,19 @@ final class AutoloadIncluder
|
|||
require_once $filePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// load local php-parser only in prefixed version or development repository
|
||||
function should_include_preload(): bool
|
||||
{
|
||||
if (file_exists(__DIR__ . '/../vendor/scoper-autoload.php')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! file_exists(__DIR__ . '/../composer.json')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$composerJsonFileContent = file_get_contents(__DIR__ . '/../composer.json');
|
||||
return strpos($composerJsonFileContent, '"name": "rector/rector"') !== false;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"nette/caching": "^3.1",
|
||||
"nette/robot-loader": "^3.4",
|
||||
"nette/utils": "^3.2",
|
||||
"nikic/php-parser": "4.10.4",
|
||||
"nikic/php-parser": "^4.10.5",
|
||||
"phpstan/phpdoc-parser": "^0.5.4",
|
||||
"phpstan/phpstan": "^0.12.83",
|
||||
"phpstan/phpstan-phpunit": "^0.12.18",
|
||||
|
|
|
@ -68,6 +68,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
__DIR__ . '/../src/Bootstrap',
|
||||
__DIR__ . '/../src/PhpParser/Node/CustomNode',
|
||||
__DIR__ . '/../src/functions',
|
||||
__DIR__ . '/../src/constants.php',
|
||||
]);
|
||||
|
||||
$services->alias(SymfonyApplication::class, ConsoleApplication::class);
|
||||
|
|
|
@ -473,3 +473,8 @@ parameters:
|
|||
-
|
||||
message: '#Use separate function calls with readable variable names#'
|
||||
path: src/Application/ActiveRectorsProvider.php
|
||||
|
||||
# skip for define()
|
||||
-
|
||||
message: '#Do not compare call directly, use a variable assign#'
|
||||
path: src/constants.php
|
||||
|
|
|
@ -21,7 +21,7 @@ class PregQuoted
|
|||
public function run($subject)
|
||||
{
|
||||
preg_replace_callback('/('.preg_quote("a", '/').')/', function ($matches) {
|
||||
return strtoupper("\1");
|
||||
return strtoupper("\x01");
|
||||
}, $subject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class Drupal
|
|||
public function run()
|
||||
{
|
||||
$replace = function ($m) {
|
||||
$r = "\0{$m[1]}ecursion_features";
|
||||
$r = "\x00{$m[1]}ecursion_features";
|
||||
return 's:' . strlen($r . $m[2]) . ':"' . $r . $m[2] . '";';
|
||||
};
|
||||
|
||||
|
|
13
src/constants.php
Normal file
13
src/constants.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// mimic missing T_ENUM constant on PHP 8.0-
|
||||
if (defined('T_ENUM') === false) {
|
||||
define('T_ENUM', 5000);
|
||||
}
|
||||
|
||||
// mimic missing T_NAME_RELATIVE constant on PHP 8.0-
|
||||
if (defined('T_NAME_RELATIVE') === false) {
|
||||
define('T_NAME_RELATIVE', 5001);
|
||||
}
|
|
@ -4,6 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
use Rector\Core\Stubs\PHPStanStubLoader;
|
||||
|
||||
require_once __DIR__ . '/../src/constants.php';
|
||||
|
||||
// make local php-parser a priority to avoid conflict
|
||||
require_once __DIR__ . '/../preload.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// silent deprecations, since we test them
|
||||
|
@ -12,8 +16,5 @@ error_reporting(E_ALL ^ E_DEPRECATED);
|
|||
// performance boost
|
||||
gc_disable();
|
||||
|
||||
// make local php-parser a priority to avoid conflict
|
||||
require_once __DIR__ . '/../preload.php';
|
||||
|
||||
$phpStanStubLoader = new PHPStanStubLoader();
|
||||
$phpStanStubLoader->loadStubs();
|
||||
|
|
Loading…
Reference in New Issue
Block a user