Updated Rector to commit 2800a83dad

2800a83dad [DX] Decouple AssignVariableNameResolver (#1427)
This commit is contained in:
Tomas Votruba 2021-12-08 15:55:52 +00:00
parent 495d9bbdc8
commit e20b5e5d47
42 changed files with 1412 additions and 184 deletions

View File

@ -0,0 +1,43 @@
<?php
declare (strict_types=1);
namespace Rector\Naming\AssignVariableNameResolver;
use PhpParser\Node;
use PhpParser\Node\Expr\New_;
use Rector\Core\Exception\NotImplementedYetException;
use Rector\Naming\Contract\AssignVariableNameResolverInterface;
use Rector\NodeNameResolver\NodeNameResolver;
/**
* @implements AssignVariableNameResolverInterface<New_>
*/
final class NewAssignVariableNameResolver implements \Rector\Naming\Contract\AssignVariableNameResolverInterface
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
{
$this->nodeNameResolver = $nodeNameResolver;
}
/**
* @param \PhpParser\Node $node
*/
public function match($node) : bool
{
return $node instanceof \PhpParser\Node\Expr\New_;
}
/**
* @param \PhpParser\Node $node
*/
public function resolve($node) : string
{
$className = $this->nodeNameResolver->getName($node->class);
if ($className === null) {
throw new \Rector\Core\Exception\NotImplementedYetException();
}
return $this->nodeNameResolver->getShortName($className);
}
}

View File

@ -0,0 +1,50 @@
<?php
declare (strict_types=1);
namespace Rector\Naming\AssignVariableNameResolver;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use Rector\Core\Exception\NotImplementedYetException;
use Rector\Naming\Contract\AssignVariableNameResolverInterface;
use Rector\NodeNameResolver\NodeNameResolver;
/**
* @implements AssignVariableNameResolverInterface<PropertyFetch>
*/
final class PropertyFetchAssignVariableNameResolver implements \Rector\Naming\Contract\AssignVariableNameResolverInterface
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
{
$this->nodeNameResolver = $nodeNameResolver;
}
/**
* @param \PhpParser\Node $node
*/
public function match($node) : bool
{
return $node instanceof \PhpParser\Node\Expr\PropertyFetch;
}
/**
* @param \PhpParser\Node $node
*/
public function resolve($node) : string
{
$varName = $this->nodeNameResolver->getName($node->var);
if (!\is_string($varName)) {
throw new \Rector\Core\Exception\NotImplementedYetException();
}
$propertyName = $this->nodeNameResolver->getName($node->name);
if (!\is_string($propertyName)) {
throw new \Rector\Core\Exception\NotImplementedYetException();
}
if ($varName === 'this') {
return $propertyName;
}
return $varName . \ucfirst($propertyName);
}
}

View File

@ -0,0 +1,20 @@
<?php
declare (strict_types=1);
namespace Rector\Naming\Contract;
use PhpParser\Node;
/**
* @template TNode as Node
*/
interface AssignVariableNameResolverInterface
{
/**
* @param \PhpParser\Node $node
*/
public function match($node) : bool;
/**
* @param \PhpParser\Node $node
*/
public function resolve($node) : string;
}

View File

@ -10,9 +10,7 @@ use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Cast;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Name;
@ -21,6 +19,7 @@ use PHPStan\Analyser\Scope;
use PHPStan\Type\ThisType;
use PHPStan\Type\Type;
use Rector\Core\Exception\NotImplementedYetException;
use Rector\Naming\Contract\AssignVariableNameResolverInterface;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\NodeTypeResolver;
use RectorPrefix20211208\Symfony\Component\String\UnicodeString;
@ -36,10 +35,19 @@ final class VariableNaming
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver)
/**
* @var \Rector\Naming\Contract\AssignVariableNameResolverInterface[]
* @readonly
*/
private $assignVariableNameResolvers;
/**
* @param AssignVariableNameResolverInterface[] $assignVariableNameResolvers
*/
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, array $assignVariableNameResolvers)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->nodeTypeResolver = $nodeTypeResolver;
$this->assignVariableNameResolvers = $assignVariableNameResolvers;
}
public function resolveFromNodeWithScopeCountAndFallbackName(\PhpParser\Node\Expr $expr, ?\PHPStan\Analyser\Scope $scope, string $fallbackName) : string
{
@ -100,15 +108,14 @@ final class VariableNaming
private function resolveBareFromNode(\PhpParser\Node $node) : ?string
{
$node = $this->unwrapNode($node);
if ($node instanceof \PhpParser\Node\Expr\PropertyFetch) {
return $this->resolveFromPropertyFetch($node);
foreach ($this->assignVariableNameResolvers as $assignVariableNameResolver) {
if ($assignVariableNameResolver->match($node)) {
return $assignVariableNameResolver->resolve($node);
}
}
if ($node !== null && ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\NullsafeMethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall)) {
return $this->resolveFromMethodCall($node);
}
if ($node instanceof \PhpParser\Node\Expr\New_) {
return $this->resolveFromNew($node);
}
if ($node instanceof \PhpParser\Node\Expr\FuncCall) {
return $this->resolveFromNode($node->name);
}
@ -124,21 +131,6 @@ final class VariableNaming
}
return null;
}
private function resolveFromPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : string
{
$varName = $this->nodeNameResolver->getName($propertyFetch->var);
if (!\is_string($varName)) {
throw new \Rector\Core\Exception\NotImplementedYetException();
}
$propertyName = $this->nodeNameResolver->getName($propertyFetch->name);
if (!\is_string($propertyName)) {
throw new \Rector\Core\Exception\NotImplementedYetException();
}
if ($varName === 'this') {
return $propertyName;
}
return $varName . \ucfirst($propertyName);
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\NullsafeMethodCall|\PhpParser\Node\Expr\StaticCall $node
*/
@ -153,14 +145,6 @@ final class VariableNaming
}
return $methodName;
}
private function resolveFromNew(\PhpParser\Node\Expr\New_ $new) : string
{
$className = $this->nodeNameResolver->getName($new->class);
if ($className === null) {
throw new \Rector\Core\Exception\NotImplementedYetException();
}
return $this->nodeNameResolver->getShortName($className);
}
private function unwrapNode(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ($node instanceof \PhpParser\Node\Arg) {

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'ee3ca5aeedaeade194bd1bdf4b4c0e2612733cda';
public const PACKAGE_VERSION = '2800a83dad2741b98977bf89b8f811e840522906';
/**
* @var string
*/
public const RELEASE_DATE = '2021-12-08 10:13:33';
public const RELEASE_DATE = '2021-12-08 15:39:38';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211208\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965::getLoader();
return ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13::getLoader();

View File

@ -327,6 +327,14 @@ return array(
'PhpParser\\PrettyPrinter\\Standard' => $vendorDir . '/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php',
'RectorPrefix20211208\\Clue\\React\\NDJson\\Decoder' => $vendorDir . '/clue/ndjson-react/src/Decoder.php',
'RectorPrefix20211208\\Clue\\React\\NDJson\\Encoder' => $vendorDir . '/clue/ndjson-react/src/Encoder.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchAllResult' => $vendorDir . '/composer/pcre/src/MatchAllResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchAllWithOffsetsResult' => $vendorDir . '/composer/pcre/src/MatchAllWithOffsetsResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchResult' => $vendorDir . '/composer/pcre/src/MatchResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchWithOffsetsResult' => $vendorDir . '/composer/pcre/src/MatchWithOffsetsResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\PcreException' => $vendorDir . '/composer/pcre/src/PcreException.php',
'RectorPrefix20211208\\Composer\\Pcre\\Preg' => $vendorDir . '/composer/pcre/src/Preg.php',
'RectorPrefix20211208\\Composer\\Pcre\\Regex' => $vendorDir . '/composer/pcre/src/Regex.php',
'RectorPrefix20211208\\Composer\\Pcre\\ReplaceResult' => $vendorDir . '/composer/pcre/src/ReplaceResult.php',
'RectorPrefix20211208\\Composer\\Semver\\Comparator' => $vendorDir . '/composer/semver/src/Comparator.php',
'RectorPrefix20211208\\Composer\\Semver\\CompilingMatcher' => $vendorDir . '/composer/semver/src/CompilingMatcher.php',
'RectorPrefix20211208\\Composer\\Semver\\Constraint\\Bound' => $vendorDir . '/composer/semver/src/Constraint/Bound.php',
@ -2107,6 +2115,9 @@ return array(
'Rector\\MysqlToMysqli\\Rector\\FuncCall\\MysqlFuncCallToMysqliRector' => $baseDir . '/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php',
'Rector\\MysqlToMysqli\\Rector\\FuncCall\\MysqlPConnectToMysqliConnectRector' => $baseDir . '/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php',
'Rector\\MysqlToMysqli\\Rector\\FuncCall\\MysqlQueryMysqlErrorWithLinkRector' => $baseDir . '/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php',
'Rector\\Naming\\AssignVariableNameResolver\\NewAssignVariableNameResolver' => $baseDir . '/rules/Naming/AssignVariableNameResolver/NewAssignVariableNameResolver.php',
'Rector\\Naming\\AssignVariableNameResolver\\PropertyFetchAssignVariableNameResolver' => $baseDir . '/rules/Naming/AssignVariableNameResolver/PropertyFetchAssignVariableNameResolver.php',
'Rector\\Naming\\Contract\\AssignVariableNameResolverInterface' => $baseDir . '/rules/Naming/Contract/AssignVariableNameResolverInterface.php',
'Rector\\Naming\\Contract\\Guard\\ConflictingNameGuardInterface' => $baseDir . '/rules/Naming/Contract/Guard/ConflictingNameGuardInterface.php',
'Rector\\Naming\\Contract\\RenameParamValueObjectInterface' => $baseDir . '/rules/Naming/Contract/RenameParamValueObjectInterface.php',
'Rector\\Naming\\Contract\\RenamePropertyValueObjectInterface' => $baseDir . '/rules/Naming/Contract/RenamePropertyValueObjectInterface.php',

View File

@ -7,8 +7,8 @@ $baseDir = dirname($vendorDir);
return array(
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php',
'9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',

View File

@ -74,6 +74,7 @@ return array(
'RectorPrefix20211208\\Doctrine\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector'),
'RectorPrefix20211208\\Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
'RectorPrefix20211208\\Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
'RectorPrefix20211208\\Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
'RectorPrefix20211208\\Clue\\React\\NDJson\\' => array($vendorDir . '/clue/ndjson-react/src'),
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
'PHPStan\\PhpDocParser\\' => array($vendorDir . '/phpstan/phpdoc-parser/src'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965
class ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitcc88079b4471f6b1f0d0e6807c331b13::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitcc88079b4471f6b1f0d0e6807c331b13::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire91ed481a3cfa0f01b87aed7ab257e965($fileIdentifier, $file);
composerRequirecc88079b4471f6b1f0d0e6807c331b13($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire91ed481a3cfa0f01b87aed7ab257e965($fileIdentifier, $file)
function composerRequirecc88079b4471f6b1f0d0e6807c331b13($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,12 +4,12 @@
namespace Composer\Autoload;
class ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965
class ComposerStaticInitcc88079b4471f6b1f0d0e6807c331b13
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php',
'9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
@ -99,6 +99,7 @@ class ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965
'RectorPrefix20211208\\Doctrine\\Inflector\\' => 40,
'RectorPrefix20211208\\Composer\\XdebugHandler\\' => 44,
'RectorPrefix20211208\\Composer\\Semver\\' => 37,
'RectorPrefix20211208\\Composer\\Pcre\\' => 35,
'RectorPrefix20211208\\Clue\\React\\NDJson\\' => 39,
),
'P' =>
@ -384,6 +385,10 @@ class ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965
array (
0 => __DIR__ . '/..' . '/composer/semver/src',
),
'RectorPrefix20211208\\Composer\\Pcre\\' =>
array (
0 => __DIR__ . '/..' . '/composer/pcre/src',
),
'RectorPrefix20211208\\Clue\\React\\NDJson\\' =>
array (
0 => __DIR__ . '/..' . '/clue/ndjson-react/src',
@ -724,6 +729,14 @@ class ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965
'PhpParser\\PrettyPrinter\\Standard' => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php',
'RectorPrefix20211208\\Clue\\React\\NDJson\\Decoder' => __DIR__ . '/..' . '/clue/ndjson-react/src/Decoder.php',
'RectorPrefix20211208\\Clue\\React\\NDJson\\Encoder' => __DIR__ . '/..' . '/clue/ndjson-react/src/Encoder.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchAllResult' => __DIR__ . '/..' . '/composer/pcre/src/MatchAllResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchAllWithOffsetsResult' => __DIR__ . '/..' . '/composer/pcre/src/MatchAllWithOffsetsResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchResult' => __DIR__ . '/..' . '/composer/pcre/src/MatchResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\MatchWithOffsetsResult' => __DIR__ . '/..' . '/composer/pcre/src/MatchWithOffsetsResult.php',
'RectorPrefix20211208\\Composer\\Pcre\\PcreException' => __DIR__ . '/..' . '/composer/pcre/src/PcreException.php',
'RectorPrefix20211208\\Composer\\Pcre\\Preg' => __DIR__ . '/..' . '/composer/pcre/src/Preg.php',
'RectorPrefix20211208\\Composer\\Pcre\\Regex' => __DIR__ . '/..' . '/composer/pcre/src/Regex.php',
'RectorPrefix20211208\\Composer\\Pcre\\ReplaceResult' => __DIR__ . '/..' . '/composer/pcre/src/ReplaceResult.php',
'RectorPrefix20211208\\Composer\\Semver\\Comparator' => __DIR__ . '/..' . '/composer/semver/src/Comparator.php',
'RectorPrefix20211208\\Composer\\Semver\\CompilingMatcher' => __DIR__ . '/..' . '/composer/semver/src/CompilingMatcher.php',
'RectorPrefix20211208\\Composer\\Semver\\Constraint\\Bound' => __DIR__ . '/..' . '/composer/semver/src/Constraint/Bound.php',
@ -2504,6 +2517,9 @@ class ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965
'Rector\\MysqlToMysqli\\Rector\\FuncCall\\MysqlFuncCallToMysqliRector' => __DIR__ . '/../..' . '/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php',
'Rector\\MysqlToMysqli\\Rector\\FuncCall\\MysqlPConnectToMysqliConnectRector' => __DIR__ . '/../..' . '/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php',
'Rector\\MysqlToMysqli\\Rector\\FuncCall\\MysqlQueryMysqlErrorWithLinkRector' => __DIR__ . '/../..' . '/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php',
'Rector\\Naming\\AssignVariableNameResolver\\NewAssignVariableNameResolver' => __DIR__ . '/../..' . '/rules/Naming/AssignVariableNameResolver/NewAssignVariableNameResolver.php',
'Rector\\Naming\\AssignVariableNameResolver\\PropertyFetchAssignVariableNameResolver' => __DIR__ . '/../..' . '/rules/Naming/AssignVariableNameResolver/PropertyFetchAssignVariableNameResolver.php',
'Rector\\Naming\\Contract\\AssignVariableNameResolverInterface' => __DIR__ . '/../..' . '/rules/Naming/Contract/AssignVariableNameResolverInterface.php',
'Rector\\Naming\\Contract\\Guard\\ConflictingNameGuardInterface' => __DIR__ . '/../..' . '/rules/Naming/Contract/Guard/ConflictingNameGuardInterface.php',
'Rector\\Naming\\Contract\\RenameParamValueObjectInterface' => __DIR__ . '/../..' . '/rules/Naming/Contract/RenameParamValueObjectInterface.php',
'Rector\\Naming\\Contract\\RenamePropertyValueObjectInterface' => __DIR__ . '/../..' . '/rules/Naming/Contract/RenamePropertyValueObjectInterface.php',
@ -3787,9 +3803,9 @@ class ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit91ed481a3cfa0f01b87aed7ab257e965::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitcc88079b4471f6b1f0d0e6807c331b13::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitcc88079b4471f6b1f0d0e6807c331b13::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitcc88079b4471f6b1f0d0e6807c331b13::$classMap;
}, null, ClassLoader::class);
}

View File

@ -67,6 +67,80 @@
],
"install-path": "..\/clue\/ndjson-react"
},
{
"name": "composer\/pcre",
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/composer\/pcre.git",
"reference": "3d322d715c43a1ac36c7fe215fa59336265500f2"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/composer\/pcre\/zipball\/3d322d715c43a1ac36c7fe215fa59336265500f2",
"reference": "3d322d715c43a1ac36c7fe215fa59336265500f2",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan\/phpstan": "^1",
"phpstan\/phpstan-strict-rules": "^1.1",
"symfony\/phpunit-bridge": "^4.2 || ^5"
},
"time": "2021-12-06T15:17:27+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"RectorPrefix20211208\\Composer\\Pcre\\": "src"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http:\/\/seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https:\/\/github.com\/composer\/pcre\/issues",
"source": "https:\/\/github.com\/composer\/pcre\/tree\/1.0.0"
},
"funding": [
{
"url": "https:\/\/packagist.com",
"type": "custom"
},
{
"url": "https:\/\/github.com\/composer",
"type": "github"
},
{
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/composer\/composer",
"type": "tidelift"
}
],
"install-path": ".\/pcre"
},
{
"name": "composer\/semver",
"version": "3.2.6",
@ -153,28 +227,30 @@
},
{
"name": "composer\/xdebug-handler",
"version": "2.0.2",
"version_normalized": "2.0.2.0",
"version": "2.0.3",
"version_normalized": "2.0.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/composer\/xdebug-handler.git",
"reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339"
"reference": "6555461e76962fd0379c444c46fd558a0fcfb65e"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/composer\/xdebug-handler\/zipball\/84674dd3a7575ba617f5a76d7e9e29a7d3891339",
"reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339",
"url": "https:\/\/api.github.com\/repos\/composer\/xdebug-handler\/zipball\/6555461e76962fd0379c444c46fd558a0fcfb65e",
"reference": "6555461e76962fd0379c444c46fd558a0fcfb65e",
"shasum": ""
},
"require": {
"composer\/pcre": "^1",
"php": "^5.3.2 || ^7.0 || ^8.0",
"psr\/log": "^1 || ^2 || ^3"
},
"require-dev": {
"phpstan\/phpstan": "^0.12.55",
"symfony\/phpunit-bridge": "^4.2 || ^5"
"phpstan\/phpstan": "^1.0",
"phpstan\/phpstan-strict-rules": "^1.1",
"symfony\/phpunit-bridge": "^4.2 || ^5.0 || ^6.0"
},
"time": "2021-07-31T17:03:58+00:00",
"time": "2021-12-08T13:07:32+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -200,7 +276,7 @@
"support": {
"irc": "irc:\/\/irc.freenode.org\/composer",
"issues": "https:\/\/github.com\/composer\/xdebug-handler\/issues",
"source": "https:\/\/github.com\/composer\/xdebug-handler\/tree\/2.0.2"
"source": "https:\/\/github.com\/composer\/xdebug-handler\/tree\/2.0.3"
},
"funding": [
{
@ -2495,21 +2571,20 @@
},
{
"name": "rector\/rector-symfony",
"version": "0.11.48",
"version_normalized": "0.11.48.0",
"version": "0.11.49",
"version_normalized": "0.11.49.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "5a24edfe3cf6f66766cbf2bc7eddc7340f06a800"
"reference": "e76ac4f58191b6419ec2e439ad6ed96a1d0aec95"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5a24edfe3cf6f66766cbf2bc7eddc7340f06a800",
"reference": "5a24edfe3cf6f66766cbf2bc7eddc7340f06a800",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/e76ac4f58191b6419ec2e439ad6ed96a1d0aec95",
"reference": "e76ac4f58191b6419ec2e439ad6ed96a1d0aec95",
"shasum": ""
},
"require": {
"danielstjules\/stringy": "^3.1",
"ext-xml": "*",
"php": ">=8.1",
"symfony\/string": "^6.0"
@ -2534,7 +2609,7 @@
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2021-12-08T07:34:28+00:00",
"time": "2021-12-08T12:40:56+00:00",
"type": "rector-extension",
"extra": {
"enable-patching": true,
@ -2560,7 +2635,7 @@
"description": "Rector upgrades rules for Symfony Framework",
"support": {
"issues": "https:\/\/github.com\/rectorphp\/rector-symfony\/issues",
"source": "https:\/\/github.com\/rectorphp\/rector-symfony\/tree\/0.11.48"
"source": "https:\/\/github.com\/rectorphp\/rector-symfony\/tree\/0.11.49"
},
"install-path": "..\/rector\/rector-symfony"
},
@ -2635,22 +2710,23 @@
},
{
"name": "ssch\/typo3-rector",
"version": "v0.11.31",
"version_normalized": "0.11.31.0",
"version": "v0.11.32",
"version_normalized": "0.11.32.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/sabbelasichon\/typo3-rector.git",
"reference": "ce3e55ebce3e70efb5d984d4f5951e2263440856"
"reference": "83e4eb922f3d6fb733e8893d1f870ec2731adcfb"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/ce3e55ebce3e70efb5d984d4f5951e2263440856",
"reference": "ce3e55ebce3e70efb5d984d4f5951e2263440856",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/83e4eb922f3d6fb733e8893d1f870ec2731adcfb",
"reference": "83e4eb922f3d6fb733e8893d1f870ec2731adcfb",
"shasum": ""
},
"require": {
"helmich\/typo3-typoscript-parser": "^2.3.1",
"php": ">=8.0",
"php": ">=8.1",
"symfony\/string": "^6.0",
"symfony\/var-exporter": "^5.3"
},
"conflict": {
@ -2659,10 +2735,10 @@
"require-dev": {
"phpspec\/prophecy-phpunit": "^2.0",
"phpstan\/extension-installer": "^1.1",
"phpstan\/phpstan": "^1.0",
"phpstan\/phpstan": "^1.2",
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.4.7",
"rector\/rector-generator": "^0.4.2",
"rector\/phpstan-rules": "^0.4.15",
"rector\/rector-generator": "^0.4.4",
"rector\/rector-src": "dev-main",
"symfony\/console": "^5.3",
"symplify\/coding-standard": "^10.0",
@ -2670,11 +2746,13 @@
"symplify\/phpstan-extensions": "^10.0",
"symplify\/phpstan-rules": "^10.0",
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0",
"tracy\/tracy": "^2.8"
},
"time": "2021-11-16T09:00:37+00:00",
"time": "2021-12-08T12:56:39+00:00",
"type": "rector-extension",
"extra": {
"enable-patching": true,
"rector": {
"includes": [
"config\/config.php"
@ -2704,7 +2782,7 @@
"description": "Instant fixes for your TYPO3 code by using Rector.",
"support": {
"issues": "https:\/\/github.com\/sabbelasichon\/typo3-rector\/issues",
"source": "https:\/\/github.com\/sabbelasichon\/typo3-rector\/tree\/v0.11.31"
"source": "https:\/\/github.com\/sabbelasichon\/typo3-rector\/tree\/v0.11.32"
},
"funding": [
{

File diff suppressed because one or more lines are too long

19
vendor/composer/pcre/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (C) 2021 Composer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

134
vendor/composer/pcre/README.md vendored Normal file
View File

@ -0,0 +1,134 @@
composer/pcre
=============
PCRE wrapping library that offers type-safe `preg_*` replacements.
This library gives you a way to ensure `preg_*` functions do not fail silently, returning
unexpected `null`s that may not be handled.
It also makes it easier ot work with static analysis tools like PHPStan or Psalm as it
simplifies and reduces the possible return values from all the `preg_*` functions which
are quite packed with edge cases.
This library is a thin wrapper around `preg_*` functions with [some limitations](#restrictions--limitations).
If you are looking for a richer API to handle regular expressions have a look at
[rawr/t-regx](https://packagist.org/packages/rawr/t-regx) instead.
[![Continuous Integration](https://github.com/composer/pcre/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/composer/pcre/actions)
Installation
------------
Install the latest version with:
```bash
$ composer require composer/pcre
```
Requirements
------------
* PHP 5.3.2 is required but using the latest version of PHP is highly recommended.
Basic usage
-----------
Instead of:
```php
if (preg_match('{fo+}', $string, $matches)) { ... }
if (preg_match('{fo+}', $string, $matches, PREG_OFFSET_CAPTURE)) { ... }
if (preg_match_all('{fo+}', $string, $matches)) { ... }
$newString = preg_replace('{fo+}', 'bar', $string);
$newString = preg_replace_callback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string);
$newString = preg_replace_callback_array(['{fo+}' => fn ($match) => strtoupper($match[0])], $string);
$filtered = preg_grep('{[a-z]}', $elements);
$array = preg_split('{[a-z]+}', $string);
```
You can now call these on the `Preg` class:
```php
use Composer\Pcre\Preg;
if (Preg::match('{fo+}', $string, $matches)) { ... }
if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { ... }
if (Preg::matchAll('{fo+}', $string, $matches)) { ... }
$newString = Preg::replace('{fo+}', 'bar', $string);
$newString = Preg::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string);
$newString = Preg::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string);
$filtered = Preg::grep('{[a-z]}', $elements);
$array = Preg::split('{[a-z]+}', $string);
```
The main difference is if anything fails to match/replace/.., it will throw a `Composer\Pcre\PcreException`
instead of returning `null` (or false in some cases), so you can now use the return values safely relying on
the fact that they can only be strings (for replace), ints (for match) or arrays (for grep/split).
Additionally the `Preg` class provides match methods that return `bool` rather than `int`, for stricter type safety
when the number of pattern matches is not useful:
```php
use Composer\Pcre\Preg;
if (Preg::isMatch('{fo+}', $string, $matches)) // bool
if (Preg::isMatchAll('{fo+}', $string, $matches)) // bool
```
If you would prefer a slightly more verbose usage, replacing by-ref arguments by result objects, you can use the `Regex` class:
```php
use Composer\Pcre\Regex;
// this is useful when you are just interested in knowing if something matched
// as it returns a bool instead of int(1/0) for match
$bool = Regex::isMatch('{fo+}', $string);
$result = Regex::match('{fo+}', $string);
if ($result->matched) { something($result->matches); }
$result = Regex::matchWithOffsets('{fo+}', $string);
if ($result->matched) { something($result->matches); }
$result = Regex::matchAll('{fo+}', $string);
if ($result->matched && $result->count > 3) { something($result->matches); }
$newString = Regex::replace('{fo+}', 'bar', $string)->result;
$newString = Regex::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string)->result;
$newString = Regex::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string)->result;
```
Note that `preg_grep` and `preg_split` are only callable via the `Preg` class as they do not have
complex return types warranting a specific result object.
See the [MatchResult](src/MatchResult.php), [MatchWithOffsetsResult](src/MatchWithOffsetsResult.php), [MatchAllResult](src/MatchAllResult.php),
[MatchAllWithOffsetsResult](src/MatchAllWithOffsetsResult.php), and [ReplaceResult](src/ReplaceResult.php) class sources for more details.
Restrictions / Limitations
--------------------------
Due to type safety requirements a few restrictions are in place.matchWithOffsets
- matching using `PREG_OFFSET_CAPTURE` is made available via `matchWithOffsets` and `matchAllWithOffsets`.
You cannot pass the flag to `match`/`matchAll`.
- `Preg::split` will also reject `PREG_SPLIT_OFFSET_CAPTURE` and you should use `splitWithOffsets`
instead.
- `matchAll` rejects `PREG_SET_ORDER` as it also changes the shape of the returned matches. There
is no alternative provided as you can fairly easily code around it.
- `preg_filter` is not supported as it has a rather crazy API, most likely you should rather
use `Preg::grep` in combination with some loop and `Preg::replace`.
- `replace`, `replaceCallback` and `replaceCallbackArray` do not support an array `$subject`,
only simple strings.
- in 2.x, we plan to always implicitly use `PREG_UNMATCHED_AS_NULL` for matching, which offers much
saner/predictable results. This is currently not doable due to the PHP version requirement and to
keep things working the same across all PHP versions. If you use the library on a PHP 7.2+ project
however we highly recommend using `PREG_UNMATCHED_AS_NULL` with all `match*` and `replaceCallback*`
methods.
License
-------
composer/pcre is licensed under the MIT License, see the LICENSE file for details.

46
vendor/composer/pcre/composer.json vendored Normal file
View File

@ -0,0 +1,46 @@
{
"name": "composer\/pcre",
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"type": "library",
"license": "MIT",
"keywords": [
"pcre",
"regex",
"preg",
"regular expression"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http:\/\/seld.be"
}
],
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"symfony\/phpunit-bridge": "^4.2 || ^5",
"phpstan\/phpstan": "^1",
"phpstan\/phpstan-strict-rules": "^1.1"
},
"autoload": {
"psr-4": {
"RectorPrefix20211208\\Composer\\Pcre\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"RectorPrefix20211208\\Composer\\Pcre\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
}
},
"scripts": {
"test": "SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor\/bin\/simple-phpunit",
"phpstan": "phpstan analyse"
}
}

View File

@ -0,0 +1,42 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
final class MatchAllResult
{
/**
* An array of match group => list of matched strings
*
* @readonly
* @var array<int|string, list<string|null>>
*/
public $matches;
/**
* @readonly
* @var int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param int $count
* @param array<array<string|null>> $matches
*/
public function __construct($count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
final class MatchAllWithOffsetsResult
{
/**
* An array of match group => list of matches, every match being a pair of string matched + offset in bytes (or -1 if no match)
*
* @readonly
* @var array<int|string, list<array{string|null, int}>>
* @phpstan-var array<int|string, list<array{string|null, int<-1, max>}>>
*/
public $matches;
/**
* @readonly
* @var int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param int $count
* @param array<int|string, list<array{string|null, int}>> $matches
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public function __construct($count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@ -0,0 +1,36 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
final class MatchResult
{
/**
* An array of match group => string matched
*
* @readonly
* @var array<int|string, string|null>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param int $count
* @param array<string|null> $matches
*/
public function __construct($count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@ -0,0 +1,38 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
final class MatchWithOffsetsResult
{
/**
* An array of match group => pair of string matched + offset in bytes (or -1 if no match)
*
* @readonly
* @var array<int|string, array{string|null, int}>
* @phpstan-var array<int|string, array{string|null, int<-1, max>}>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param int $count
* @param array<array{string|null, int}> $matches
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
public function __construct($count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@ -0,0 +1,52 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
class PcreException extends \RuntimeException
{
/**
* @param string $function
* @param string|string[] $pattern
* @return self
*/
public static function fromFunction($function, $pattern)
{
$code = \preg_last_error();
if (\is_array($pattern)) {
$pattern = \implode(', ', $pattern);
}
return new \RectorPrefix20211208\Composer\Pcre\PcreException($function . '(): failed executing "' . $pattern . '": ' . self::pcreLastErrorMessage($code), $code);
}
/**
* @param int $code
* @return string
*/
private static function pcreLastErrorMessage($code)
{
if (\PHP_VERSION_ID >= 80000) {
return \preg_last_error_msg();
}
// older php versions did not set the code properly in all cases
if (\PHP_VERSION_ID < 70201 && $code === 0) {
return 'UNDEFINED_ERROR';
}
$constants = \get_defined_constants(\true);
if (!isset($constants['pcre'])) {
return 'UNDEFINED_ERROR';
}
foreach ($constants['pcre'] as $const => $val) {
if ($val === $code && \substr($const, -6) === '_ERROR') {
return $const;
}
}
return 'UNDEFINED_ERROR';
}
}

275
vendor/composer/pcre/src/Preg.php vendored Normal file
View File

@ -0,0 +1,275 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
class Preg
{
const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
/**
* @param string $pattern
* @param string $subject
* @param array<string|null> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
*/
public static function match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchWithOffsets() instead');
}
$result = \preg_match($pattern, $subject, $matches, $flags, $offset);
if ($result === \false) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param string $subject
* @param array<int|string, array{string|null, int}> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
*
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function matchWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
{
$result = \preg_match($pattern, $subject, $matches, $flags | \PREG_OFFSET_CAPTURE, $offset);
if ($result === \false) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
/**
* @param string $pattern
* @param string $subject
* @param array<int|string, list<string|null>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
*/
public static function matchAll($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchAllWithOffsets() instead');
}
if (($flags & \PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
}
$result = \preg_match_all($pattern, $subject, $matches, $flags, $offset);
if ($result === \false || $result === null) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param string $subject
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
*
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function matchAllWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
{
$result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_OFFSET_CAPTURE, $offset);
if ($result === \false || $result === null) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
/**
* @param string|string[] $pattern
* @param string|string[] $replacement
* @param string $subject
* @param int $limit
* @param int $count Set by method
* @return string
*/
public static function replace($pattern, $replacement, $subject, $limit = -1, &$count = null)
{
if (\is_array($subject)) {
// @phpstan-ignore-line
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
$result = \preg_replace($pattern, $replacement, $subject, $limit, $count);
if ($result === null) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_replace', $pattern);
}
return $result;
}
/**
* @param string|string[] $pattern
* @param callable $replacement
* @param string $subject
* @param int $limit
* @param int $count Set by method
* @param int $flags PREG_OFFSET_CAPTURE or PREG_UNMATCHED_AS_NULL, only available on PHP 7.4+
* @return string
*/
public static function replaceCallback($pattern, $replacement, $subject, $limit = -1, &$count = null, $flags = 0)
{
if (\is_array($subject)) {
// @phpstan-ignore-line
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
if (\PHP_VERSION_ID >= 70400) {
$result = \preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags);
} else {
$result = \preg_replace_callback($pattern, $replacement, $subject, $limit, $count);
}
if ($result === null) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_replace_callback', $pattern);
}
return $result;
}
/**
* Available from PHP 7.0
*
* @param array<string, callable> $pattern
* @param string $subject
* @param int $limit
* @param int $count Set by method
* @param int $flags PREG_OFFSET_CAPTURE or PREG_UNMATCHED_AS_NULL, only available on PHP 7.4+
* @return string
*/
public static function replaceCallbackArray($pattern, $subject, $limit = -1, &$count = null, $flags = 0)
{
if (\is_array($subject)) {
// @phpstan-ignore-line
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
if (\PHP_VERSION_ID >= 70400) {
$result = \preg_replace_callback_array($pattern, $subject, $limit, $count, $flags);
} else {
$result = \preg_replace_callback_array($pattern, $subject, $limit, $count);
}
if ($result === null) {
$pattern = \array_keys($pattern);
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_replace_callback_array', $pattern);
}
return $result;
}
/**
* @param string $pattern
* @param string $subject
* @param int $limit
* @param int $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
* @return list<string>
*/
public static function split($pattern, $subject, $limit = -1, $flags = 0)
{
if (($flags & \PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
}
$result = \preg_split($pattern, $subject, $limit, $flags);
if ($result === \false) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
/**
* @param string $pattern
* @param string $subject
* @param int $limit
* @param int $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
* @return list<array{string, int}>
* @phpstan-return list<array{string, int<0, max>}>
*/
public static function splitWithOffsets($pattern, $subject, $limit = -1, $flags = 0)
{
$result = \preg_split($pattern, $subject, $limit, $flags | \PREG_SPLIT_OFFSET_CAPTURE);
if ($result === \false) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_split', $pattern);
}
// @phpstan-ignore-next-line See https://github.com/phpstan/phpstan/issues/6155
return $result;
}
/**
* @template T of string|\Stringable
* @param string $pattern
* @param array<T> $array
* @param int $flags PREG_GREP_INVERT
* @return array<T>
*/
public static function grep($pattern, $array, $flags = 0)
{
$result = \preg_grep($pattern, $array, $flags);
if ($result === \false) {
throw \RectorPrefix20211208\Composer\Pcre\PcreException::fromFunction('preg_grep', $pattern);
}
return $result;
}
/**
* @param string $pattern
* @param string $subject
* @param array<string|null> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return bool
*/
public static function isMatch($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
}
/**
* @param string $pattern
* @param string $subject
* @param array<int|string, list<string|null>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return bool
*/
public static function isMatchAll($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param string $subject
* @param array<int|string, array{string|null, int}> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return bool
*
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function isMatchWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
{
return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param string $subject
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return bool
*
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function isMatchAllWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
{
return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
}

125
vendor/composer/pcre/src/Regex.php vendored Normal file
View File

@ -0,0 +1,125 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
class Regex
{
/**
* @param string $pattern
* @param string $subject
* @param int $offset
* @return bool
*/
public static function isMatch($pattern, $subject, $offset = 0)
{
return (bool) \RectorPrefix20211208\Composer\Pcre\Preg::match($pattern, $subject, $matches, 0, $offset);
}
/**
* @param string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return MatchResult
*/
public static function match($pattern, $subject, $flags = 0, $offset = 0)
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchWithOffsets() instead');
}
$count = \RectorPrefix20211208\Composer\Pcre\Preg::match($pattern, $subject, $matches, $flags, $offset);
return new \RectorPrefix20211208\Composer\Pcre\MatchResult($count, $matches);
}
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return MatchWithOffsetsResult
*/
public static function matchWithOffsets($pattern, $subject, $flags = 0, $offset = 0)
{
$count = \RectorPrefix20211208\Composer\Pcre\Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new \RectorPrefix20211208\Composer\Pcre\MatchWithOffsetsResult($count, $matches);
}
/**
* @param string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return MatchAllResult
*/
public static function matchAll($pattern, $subject, $flags = 0, $offset = 0)
{
if (($flags & \PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchAllWithOffsets() instead');
}
if (($flags & \PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
}
$count = \RectorPrefix20211208\Composer\Pcre\Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
return new \RectorPrefix20211208\Composer\Pcre\MatchAllResult($count, $matches);
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return MatchAllWithOffsetsResult
*/
public static function matchAllWithOffsets($pattern, $subject, $flags = 0, $offset = 0)
{
$count = \RectorPrefix20211208\Composer\Pcre\Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new \RectorPrefix20211208\Composer\Pcre\MatchAllWithOffsetsResult($count, $matches);
}
/**
* @param string|string[] $pattern
* @param string|string[] $replacement
* @param string $subject
* @param int $limit
* @return ReplaceResult
*/
public static function replace($pattern, $replacement, $subject, $limit = -1)
{
$result = \RectorPrefix20211208\Composer\Pcre\Preg::replace($pattern, $replacement, $subject, $limit, $count);
return new \RectorPrefix20211208\Composer\Pcre\ReplaceResult($count, $result);
}
/**
* @param string|string[] $pattern
* @param callable $replacement
* @param string $subject
* @param int $limit
* @param int $flags PREG_OFFSET_CAPTURE or PREG_UNMATCHED_AS_NULL, only available on PHP 7.4+
* @return ReplaceResult
*/
public static function replaceCallback($pattern, $replacement, $subject, $limit = -1, $flags = 0)
{
$result = \RectorPrefix20211208\Composer\Pcre\Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
return new \RectorPrefix20211208\Composer\Pcre\ReplaceResult($count, $result);
}
/**
* Available from PHP 7.0
*
* @param array<string, callable> $pattern
* @param string $subject
* @param int $limit
* @param int $flags PREG_OFFSET_CAPTURE or PREG_UNMATCHED_AS_NULL, only available on PHP 7.4+
* @return ReplaceResult
*/
public static function replaceCallbackArray($pattern, $subject, $limit = -1, $flags = 0)
{
$result = \RectorPrefix20211208\Composer\Pcre\Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
return new \RectorPrefix20211208\Composer\Pcre\ReplaceResult($count, $result);
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace RectorPrefix20211208\Composer\Pcre;
final class ReplaceResult
{
/**
* @readonly
* @var string
*/
public $result;
/**
* @readonly
* @var int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param int $count
* @param string $result
*/
public function __construct($count, $result)
{
$this->count = $count;
$this->matched = (bool) $count;
$this->result = $result;
}
}

View File

@ -1,5 +1,8 @@
## [Unreleased]
## [2.0.3] - 2021-12-08
* Added: support, type annotations and refactoring for stricter PHPStan analysis.
## [2.0.2] - 2021-07-31
* Added: support for `xdebug_info('mode')` in Xdebug 3.1.
* Added: support for Psr\Log versions 2 and 3.
@ -91,7 +94,8 @@
* Break: the following class was renamed:
- `Composer\XdebugHandler` -> `Composer\XdebugHandler\XdebugHandler`
[Unreleased]: https://github.com/composer/xdebug-handler/compare/2.0.2...HEAD
[Unreleased]: https://github.com/composer/xdebug-handler/compare/2.0.3...HEAD
[2.0.3]: https://github.com/composer/xdebug-handler/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/composer/xdebug-handler/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/composer/xdebug-handler/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/composer/xdebug-handler/compare/1.4.6...2.0.0

View File

@ -19,11 +19,13 @@
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0",
"psr\/log": "^1 || ^2 || ^3"
"psr\/log": "^1 || ^2 || ^3",
"composer\/pcre": "^1"
},
"require-dev": {
"symfony\/phpunit-bridge": "^4.2 || ^5",
"phpstan\/phpstan": "^0.12.55"
"symfony\/phpunit-bridge": "^4.2 || ^5.0 || ^6.0",
"phpstan\/phpstan": "^1.0",
"phpstan\/phpstan-strict-rules": "^1.1"
},
"autoload": {
"psr-4": {
@ -32,7 +34,7 @@
},
"autoload-dev": {
"psr-4": {
"RectorPrefix20211208\\Composer\\XdebugHandler\\": "tests"
"RectorPrefix20211208\\Composer\\XdebugHandler\\Tests\\": "tests"
}
},
"scripts": {

View File

@ -12,13 +12,15 @@ namespace RectorPrefix20211208\Composer\XdebugHandler;
/**
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
*
* @phpstan-type restartData array{tmpIni: string, scannedInis: bool, scanDir: false|string, phprc: false|string, inis: string[], skipped: string}
*/
class PhpConfig
{
/**
* Use the original PHP configuration
*
* @return array PHP cli options
* @return string[] Empty array of PHP cli options
*/
public function useOriginal()
{
@ -28,11 +30,12 @@ class PhpConfig
/**
* Use standard restart settings
*
* @return array PHP cli options
* @return string[] PHP cli options
*/
public function useStandard()
{
if ($data = $this->getDataAndReset()) {
$data = $this->getDataAndReset();
if ($data !== null) {
return array('-n', '-c', $data['tmpIni']);
}
return array();
@ -40,11 +43,12 @@ class PhpConfig
/**
* Use environment variables to persist settings
*
* @return array PHP cli options
* @return string[] Empty array of PHP cli options
*/
public function usePersistent()
{
if ($data = $this->getDataAndReset()) {
$data = $this->getDataAndReset();
if ($data !== null) {
$this->updateEnv('PHPRC', $data['tmpIni']);
$this->updateEnv('PHP_INI_SCAN_DIR', '');
}
@ -54,10 +58,12 @@ class PhpConfig
* Returns restart data if available and resets the environment
*
* @return array|null
* @phpstan-return restartData|null
*/
private function getDataAndReset()
{
if ($data = \RectorPrefix20211208\Composer\XdebugHandler\XdebugHandler::getRestartSettings()) {
$data = \RectorPrefix20211208\Composer\XdebugHandler\XdebugHandler::getRestartSettings();
if ($data !== null) {
$this->updateEnv('PHPRC', $data['phprc']);
$this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
}
@ -68,6 +74,8 @@ class PhpConfig
*
* @param string $name
* @param string|false $value
*
* @return void
*/
private function updateEnv($name, $value)
{

View File

@ -10,6 +10,7 @@
*/
namespace RectorPrefix20211208\Composer\XdebugHandler;
use RectorPrefix20211208\Composer\Pcre\Preg;
/**
* Process utility functions
*
@ -35,9 +36,9 @@ class Process
return "'" . \str_replace("'", "'\\''", $arg) . "'";
}
$quote = \strpbrk($arg, " \t") !== \false || $arg === '';
$arg = \preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
$arg = \RectorPrefix20211208\Composer\Pcre\Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
if ($meta) {
$meta = $dquotes || \preg_match('/%[^%]+%/', $arg);
$meta = $dquotes || \RectorPrefix20211208\Composer\Pcre\Preg::isMatch('/%[^%]+%/', $arg);
if (!$meta) {
$quote = $quote || \strpbrk($arg, '^&|<>()') !== \false;
} elseif ($module && !$dquotes && $quote) {
@ -45,27 +46,31 @@ class Process
}
}
if ($quote) {
$arg = '"' . \preg_replace('/(\\\\*)$/', '$1$1', $arg) . '"';
$arg = '"' . \RectorPrefix20211208\Composer\Pcre\Preg::replace('/(\\\\*)$/', '$1$1', $arg) . '"';
}
if ($meta) {
$arg = \preg_replace('/(["^&|<>()%])/', '^$1', $arg);
$arg = \RectorPrefix20211208\Composer\Pcre\Preg::replace('/(["^&|<>()%])/', '^$1', $arg);
}
return $arg;
}
/**
* Escapes an array of arguments that make up a shell command
*
* @param array $args Argument list, with the module name first
* @param string[] $args Argument list, with the module name first
*
* @return string The escaped command line
*/
public static function escapeShellCommand($args)
{
$cmd = self::escape(\array_shift($args), \true, \true);
foreach ($args as $arg) {
$cmd .= ' ' . self::escape($arg);
$command = '';
$module = \array_shift($args);
if ($module !== null) {
$command = self::escape($module, \true, \true);
foreach ($args as $arg) {
$command .= ' ' . self::escape($arg);
}
}
return $cmd;
return $command;
}
/**
* Makes putenv environment changes available in $_SERVER and $_ENV

View File

@ -26,11 +26,17 @@ class Status
const RESTART = 'Restart';
const RESTARTING = 'Restarting';
const RESTARTED = 'Restarted';
/** @var bool */
private $debug;
/** @var string */
private $envAllowXdebug;
/** @var string|null */
private $loaded;
/** @var LoggerInterface|null */
private $logger;
/** @var bool */
private $modeOff;
/** @var float */
private $time;
/**
* Constructor
@ -42,12 +48,15 @@ class Status
{
$start = \getenv(self::ENV_RESTART);
\RectorPrefix20211208\Composer\XdebugHandler\Process::setEnv(self::ENV_RESTART);
$this->time = $start ? \round((\microtime(\true) - $start) * 1000) : 0;
$this->time = \is_numeric($start) ? \round((\microtime(\true) - $start) * 1000) : 0;
$this->envAllowXdebug = $envAllowXdebug;
$this->debug = $debug && \defined('STDERR');
$this->modeOff = \false;
}
/**
* @param LoggerInterface $logger
*
* @return void
*/
public function setLogger($logger)
{
@ -58,11 +67,19 @@ class Status
*
* @param string $op The handler constant
* @param null|string $data Data required by the handler
*
* @return void
* @throws \InvalidArgumentException If $op is not known
*/
public function report($op, $data)
{
if ($this->logger || $this->debug) {
\call_user_func(array($this, 'report' . $op), $data);
if ($this->logger !== null || $this->debug) {
$callable = array($this, 'report' . $op);
if (!\is_callable($callable)) {
throw new \InvalidArgumentException('Unknown op handler: ' . $op);
}
$params = $data !== null ? $data : array();
\call_user_func_array($callable, array($params));
}
}
/**
@ -70,56 +87,87 @@ class Status
*
* @param string $text
* @param string $level
*
* @return void
*/
private function output($text, $level = null)
{
if ($this->logger) {
$this->logger->log($level ?: \RectorPrefix20211208\Psr\Log\LogLevel::DEBUG, $text);
if ($this->logger !== null) {
$this->logger->log($level !== null ? $level : \RectorPrefix20211208\Psr\Log\LogLevel::DEBUG, $text);
}
if ($this->debug) {
\fwrite(\STDERR, \sprintf('xdebug-handler[%d] %s', \getmypid(), $text . \PHP_EOL));
}
}
/**
* @param string $loaded
*
* @return void
*/
private function reportCheck($loaded)
{
list($version, $mode) = \explode('|', $loaded);
if ($version) {
$this->loaded = '(' . $version . ')' . ($mode ? ' mode=' . $mode : '');
if ($version !== '') {
$this->loaded = '(' . $version . ')' . ($mode !== '' ? ' mode=' . $mode : '');
}
$this->modeOff = $mode === 'off';
$this->output('Checking ' . $this->envAllowXdebug);
}
/**
* @param string $error
*
* @return void
*/
private function reportError($error)
{
$this->output(\sprintf('No restart (%s)', $error), \RectorPrefix20211208\Psr\Log\LogLevel::WARNING);
}
/**
* @param string $info
*
* @return void
*/
private function reportInfo($info)
{
$this->output($info);
}
/**
* @return void
*/
private function reportNoRestart()
{
$this->output($this->getLoadedMessage());
if ($this->loaded) {
if ($this->loaded !== null) {
$text = \sprintf('No restart (%s)', $this->getEnvAllow());
if (!\getenv($this->envAllowXdebug)) {
if (!(bool) \getenv($this->envAllowXdebug)) {
$text .= ' Allowed by ' . ($this->modeOff ? 'mode' : 'application');
}
$this->output($text);
}
}
/**
* @return void
*/
private function reportRestart()
{
$this->output($this->getLoadedMessage());
\RectorPrefix20211208\Composer\XdebugHandler\Process::setEnv(self::ENV_RESTART, (string) \microtime(\true));
}
/**
* @return void
*/
private function reportRestarted()
{
$loaded = $this->getLoadedMessage();
$text = \sprintf('Restarted (%d ms). %s', $this->time, $loaded);
$level = $this->loaded ? \RectorPrefix20211208\Psr\Log\LogLevel::WARNING : null;
$level = $this->loaded !== null ? \RectorPrefix20211208\Psr\Log\LogLevel::WARNING : null;
$this->output($text, $level);
}
/**
* @param string $command
*
* @return void
*/
private function reportRestarting($command)
{
$text = \sprintf('Process restarting (%s)', $this->getEnvAllow());
@ -143,7 +191,7 @@ class Status
*/
private function getLoadedMessage()
{
$loaded = $this->loaded ? \sprintf('loaded %s', $this->loaded) : 'not loaded';
$loaded = $this->loaded !== null ? \sprintf('loaded %s', $this->loaded) : 'not loaded';
return 'The Xdebug extension is ' . $loaded;
}
}

View File

@ -10,9 +10,12 @@
*/
namespace RectorPrefix20211208\Composer\XdebugHandler;
use RectorPrefix20211208\Composer\Pcre\Preg;
use RectorPrefix20211208\Psr\Log\LoggerInterface;
/**
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
*
* @phpstan-import-type restartData from PhpConfig
*/
class XdebugHandler
{
@ -23,19 +26,31 @@ class XdebugHandler
const DEBUG = 'XDEBUG_HANDLER_DEBUG';
/** @var string|null */
protected $tmpIni;
/** @var bool */
private static $inRestart;
/** @var string */
private static $name;
/** @var string|null */
private static $skipped;
/** @var bool */
private static $xdebugActive;
/** @var bool */
private $cli;
/** @var string|null */
private $debug;
/** @var string */
private $envAllowXdebug;
/** @var string */
private $envOriginalInis;
/** @var string|null */
private $loaded;
/** @var string|null */
private $mode;
/** @var bool */
private $persistent;
/** @var string|null */
private $script;
/** @var Status|null */
/** @var Status */
private $statusWriter;
/**
* Constructor
@ -49,28 +64,21 @@ class XdebugHandler
*/
public function __construct($envPrefix)
{
if (!\is_string($envPrefix) || empty($envPrefix)) {
if (!\is_string($envPrefix) || $envPrefix === '') {
throw new \RuntimeException('Invalid constructor parameter');
}
self::$name = \strtoupper($envPrefix);
$this->envAllowXdebug = self::$name . self::SUFFIX_ALLOW;
$this->envOriginalInis = self::$name . self::SUFFIX_INIS;
if (\extension_loaded('xdebug')) {
$this->loaded = \phpversion('xdebug') ?: 'unknown';
if (\version_compare($this->loaded, '3.1', '>=')) {
/** @phpstan-ignore-next-line */
$modes = \xdebug_info('mode');
$this->mode = empty($modes) ? 'off' : \implode(',', $modes);
} elseif (\false !== ($mode = \ini_get('xdebug.mode'))) {
$this->mode = \getenv('XDEBUG_MODE') ?: ($mode ?: 'off');
if (\preg_match('/^,+$/', \str_replace(' ', '', $this->mode))) {
$this->mode = 'off';
}
}
$version = \phpversion('xdebug');
$this->loaded = $version !== \false ? $version : 'unknown';
$this->mode = $this->getXdebugMode($this->loaded);
}
self::$xdebugActive = $this->loaded && $this->mode !== 'off';
self::$xdebugActive = $this->loaded !== null && $this->mode !== 'off';
self::$inRestart = \false;
if ($this->cli = \PHP_SAPI === 'cli') {
$this->debug = \getenv(self::DEBUG);
$this->debug = (string) \getenv(self::DEBUG);
}
$this->statusWriter = new \RectorPrefix20211208\Composer\XdebugHandler\Status($this->envAllowXdebug, (bool) $this->debug);
}
@ -114,12 +122,14 @@ class XdebugHandler
* This behaviour can be disabled by setting the MYAPP_ALLOW_XDEBUG
* environment variable to 1. This variable is used internally so that
* the restarted process is created only once.
*
* @return void
*/
public function check()
{
$this->notify(\RectorPrefix20211208\Composer\XdebugHandler\Status::CHECK, $this->loaded . '|' . $this->mode);
$envArgs = \explode('|', (string) \getenv($this->envAllowXdebug));
if (empty($envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
if (!(bool) $envArgs[0] && $this->requiresRestart(self::$xdebugActive)) {
// Restart required
$this->notify(\RectorPrefix20211208\Composer\XdebugHandler\Status::RESTART);
if ($this->prepareRestart()) {
@ -133,7 +143,7 @@ class XdebugHandler
$this->notify(\RectorPrefix20211208\Composer\XdebugHandler\Status::RESTARTED);
\RectorPrefix20211208\Composer\XdebugHandler\Process::setEnv($this->envAllowXdebug);
self::$inRestart = \true;
if (!$this->loaded) {
if ($this->loaded === null) {
// Skipped version is only set if Xdebug is not loaded
self::$skipped = $envArgs[1];
}
@ -143,7 +153,8 @@ class XdebugHandler
return;
}
$this->notify(\RectorPrefix20211208\Composer\XdebugHandler\Status::NORESTART);
if ($settings = self::getRestartSettings()) {
$settings = self::getRestartSettings();
if ($settings !== null) {
// Called with existing settings, so sync our settings
$this->syncSettings($settings);
}
@ -154,18 +165,19 @@ class XdebugHandler
* The equivalent of calling php_ini_loaded_file then php_ini_scanned_files.
* The loaded ini location is the first entry and may be empty.
*
* @return array
* @return string[]
*/
public static function getAllIniFiles()
{
if (!empty(self::$name)) {
if (self::$name !== null) {
$env = \getenv(self::$name . self::SUFFIX_INIS);
if (\false !== $env) {
return \explode(\PATH_SEPARATOR, $env);
}
}
$paths = array((string) \php_ini_loaded_file());
if ($scanned = \php_ini_scanned_files()) {
$scanned = \php_ini_scanned_files();
if ($scanned !== \false) {
$paths = \array_merge($paths, \array_map('trim', \explode(',', $scanned)));
}
return $paths;
@ -177,6 +189,7 @@ class XdebugHandler
* called with the settings from an existing restart.
*
* @return array|null
* @phpstan-return restartData|null
*/
public static function getRestartSettings()
{
@ -226,7 +239,9 @@ class XdebugHandler
*
* Do not typehint for 1.x compatibility
*
* @param array $command
* @param string[] $command
*
* @return void
*/
protected function restart($command)
{
@ -235,7 +250,10 @@ class XdebugHandler
/**
* Executes the restarted command then deletes the tmp ini
*
* @param array $command
* @param string[] $command
*
* @return void
* @phpstan-return never
*/
private function doRestart(array $command)
{
@ -264,7 +282,7 @@ class XdebugHandler
if ($this->debug === '2') {
$this->notify(\RectorPrefix20211208\Composer\XdebugHandler\Status::INFO, 'Temp ini saved: ' . $this->tmpIni);
} else {
@\unlink($this->tmpIni);
@\unlink((string) $this->tmpIni);
}
exit($exitCode);
}
@ -280,7 +298,7 @@ class XdebugHandler
*/
private function prepareRestart()
{
$error = '';
$error = null;
$iniFiles = self::getAllIniFiles();
$scannedInis = \count($iniFiles) > 1;
$tmpDir = \sys_get_temp_dir();
@ -295,31 +313,32 @@ class XdebugHandler
} elseif (!$this->checkMainScript()) {
$error = 'Unable to access main script: ' . $this->script;
} elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
$error = $error ?: 'Unable to create temp ini file at: ' . $tmpDir;
$error = $error !== null ? $error : 'Unable to create temp ini file at: ' . $tmpDir;
} elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
$error = 'Unable to set environment variables';
}
if ($error) {
if ($error !== null) {
$this->notify(\RectorPrefix20211208\Composer\XdebugHandler\Status::ERROR, $error);
}
return empty($error);
return $error === null;
}
/**
* Returns true if the tmp ini file was written
*
* @param array $iniFiles All ini files used in the current process
* @param string[] $iniFiles All ini files used in the current process
* @param string $tmpDir The system temporary directory
* @param string $error Set by method if ini file cannot be read
* @param null|string $error Set by method if ini file cannot be read
*
* @return bool
*/
private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
{
if (!($this->tmpIni = @\tempnam($tmpDir, ''))) {
if (($tmpfile = @\tempnam($tmpDir, '')) === \false) {
return \false;
}
$this->tmpIni = $tmpfile;
// $iniFiles has at least one item and it may be empty
if (empty($iniFiles[0])) {
if ($iniFiles[0] === '') {
\array_shift($iniFiles);
}
$content = '';
@ -332,24 +351,27 @@ class XdebugHandler
return \false;
}
// Check and remove directives after HOST and PATH sections
if (\preg_match($sectionRegex, $data, $matches, \PREG_OFFSET_CAPTURE)) {
if (\RectorPrefix20211208\Composer\Pcre\Preg::isMatchWithOffsets($sectionRegex, $data, $matches, \PREG_OFFSET_CAPTURE)) {
$data = \substr($data, 0, $matches[0][1]);
}
$content .= \preg_replace($xdebugRegex, ';$1', $data) . \PHP_EOL;
$content .= \RectorPrefix20211208\Composer\Pcre\Preg::replace($xdebugRegex, ';$1', $data) . \PHP_EOL;
}
// Merge loaded settings into our ini content, if it is valid
if ($config = \parse_ini_string($content)) {
$loaded = \ini_get_all(null, \false);
$content .= $this->mergeLoadedConfig($loaded, $config);
$config = \parse_ini_string($content);
$loaded = \ini_get_all(null, \false);
if (\false === $config || \false === $loaded) {
$error = 'Unable to parse ini data';
return \false;
}
$content .= $this->mergeLoadedConfig($loaded, $config);
// Work-around for https://bugs.php.net/bug.php?id=75932
$content .= 'opcache.enable_cli=0' . \PHP_EOL;
return @\file_put_contents($this->tmpIni, $content);
return (bool) @\file_put_contents($this->tmpIni, $content);
}
/**
* Returns the command line arguments for the restart
*
* @return array
* @return string[]
*/
private function getCommand()
{
@ -367,7 +389,7 @@ class XdebugHandler
* No need to update $_SERVER since this is set in the restarted process.
*
* @param bool $scannedInis Whether there were scanned ini files
* @param array $iniFiles All ini files used in the current process
* @param string[] $iniFiles All ini files used in the current process
*
* @return bool
*/
@ -394,6 +416,8 @@ class XdebugHandler
*
* @param string $op Status handler constant
* @param null|string $data Optional data
*
* @return void
*/
private function notify($op, $data = null)
{
@ -402,8 +426,8 @@ class XdebugHandler
/**
* Returns default, changed and command-line ini settings
*
* @param array $loadedConfig All current ini settings
* @param array $iniConfig Settings from user ini files
* @param mixed[] $loadedConfig All current ini settings
* @param mixed[] $iniConfig Settings from user ini files
*
* @return string
*/
@ -436,10 +460,10 @@ class XdebugHandler
if (\file_exists($this->script = $_SERVER['argv'][0])) {
return \true;
}
// Use a backtrace to resolve Phar and chdir issues
$options = \PHP_VERSION_ID >= 50306 ? \DEBUG_BACKTRACE_IGNORE_ARGS : \false;
$trace = \debug_backtrace($options);
if (($main = \end($trace)) && isset($main['file'])) {
// Use a backtrace to resolve Phar and chdir issues.
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
$main = \end($trace);
if ($main !== \false && isset($main['file'])) {
return \file_exists($this->script = $main['file']);
}
return \false;
@ -448,6 +472,8 @@ class XdebugHandler
* Adds restart settings to the environment
*
* @param string[] $envArgs
*
* @return void
*/
private function setEnvRestartSettings($envArgs)
{
@ -458,6 +484,9 @@ class XdebugHandler
* Syncs settings and the environment if called with existing settings
*
* @param array $settings
* @phpstan-param restartData $settings
*
* @return void
*/
private function syncSettings(array $settings)
{
@ -478,7 +507,10 @@ class XdebugHandler
*/
private function checkScanDirConfig()
{
return !(\getenv('PHP_INI_SCAN_DIR') && !\PHP_CONFIG_FILE_SCAN_DIR && (\PHP_VERSION_ID < 70113 || \PHP_VERSION_ID === 70200));
if (\PHP_VERSION_ID >= 70113 && \PHP_VERSION_ID !== 70200) {
return \true;
}
return (string) \getenv('PHP_INI_SCAN_DIR') === '' || \PHP_CONFIG_FILE_SCAN_DIR !== '';
}
/**
* Returns true if there are no known configuration issues
@ -492,7 +524,7 @@ class XdebugHandler
$info = 'proc_open function is disabled';
return \false;
}
if (\extension_loaded('uopz') && !\ini_get('uopz.disable')) {
if (\extension_loaded('uopz') && !(bool) \ini_get('uopz.disable')) {
// uopz works at opcode level and disables exit calls
if (\function_exists('uopz_allow_exit')) {
@\uopz_allow_exit(\true);
@ -501,9 +533,14 @@ class XdebugHandler
return \false;
}
}
$workingDir = \getcwd();
if (0 === \strpos($workingDir, '\\\\')) {
if (\defined('PHP_WINDOWS_VERSION_BUILD') && \PHP_VERSION_ID < 70400) {
// Check UNC paths when using cmd.exe
if (\defined('PHP_WINDOWS_VERSION_BUILD') && \PHP_VERSION_ID < 70400) {
$workingDir = \getcwd();
if ($workingDir === \false) {
$info = 'unable to determine working directory';
return \false;
}
if (0 === \strpos($workingDir, '\\\\')) {
$info = 'cmd.exe does not support UNC paths: ' . $workingDir;
return \false;
}
@ -514,6 +551,8 @@ class XdebugHandler
* Enables async signals and control interrupts in the restarted process
*
* Available on Unix PHP 7.1+ with the pcntl extension and Windows PHP 7.4+.
*
* @return void
*/
private function tryEnableSignals()
{
@ -536,4 +575,35 @@ class XdebugHandler
});
}
}
/**
* Returns the Xdebug mode if available
*
* @param string $version
*
* @return string|null
*/
private function getXdebugMode($version)
{
if (\version_compare($version, '3.1', '>=')) {
$modes = \xdebug_info('mode');
return \count($modes) === 0 ? 'off' : \implode(',', $modes);
}
// See if xdebug.mode is supported in this version
$iniMode = \ini_get('xdebug.mode');
if ($iniMode === \false) {
return null;
}
// Environment value wins but cannot be empty
$envMode = (string) \getenv('XDEBUG_MODE');
if ($envMode !== '') {
$mode = $envMode;
} else {
$mode = $iniMode !== '' ? $iniMode : 'off';
}
// An empty comma-separated list is treated as mode 'off'
if (\RectorPrefix20211208\Composer\Pcre\Preg::isMatch('/^,+$/', \str_replace(' ', '', $mode))) {
$mode = 'off';
}
return $mode;
}
}

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.9'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.41'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.16'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.57'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.8'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.24'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.48'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'v0.11.31'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.9'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.41'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.16'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.57'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.8'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.24'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => '0.11.49'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'v0.11.32'));
private function __construct()
{
}

View File

@ -6,7 +6,6 @@
"require": {
"php": ">=8.1",
"ext-xml": "*",
"danielstjules\/stringy": "^3.1",
"symfony\/string": "^6.0"
},
"require-dev": {

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211208\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965', false) && !interface_exists('ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965', false) && !trait_exists('ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965', false)) {
spl_autoload_call('RectorPrefix20211208\ComposerAutoloaderInit91ed481a3cfa0f01b87aed7ab257e965');
if (!class_exists('ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13', false) && !interface_exists('ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13', false) && !trait_exists('ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13', false)) {
spl_autoload_call('RectorPrefix20211208\ComposerAutoloaderInitcc88079b4471f6b1f0d0e6807c331b13');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211208\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211208\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire91ed481a3cfa0f01b87aed7ab257e965')) {
function composerRequire91ed481a3cfa0f01b87aed7ab257e965() {
return \RectorPrefix20211208\composerRequire91ed481a3cfa0f01b87aed7ab257e965(...func_get_args());
if (!function_exists('composerRequirecc88079b4471f6b1f0d0e6807c331b13')) {
function composerRequirecc88079b4471f6b1f0d0e6807c331b13() {
return \RectorPrefix20211208\composerRequirecc88079b4471f6b1f0d0e6807c331b13(...func_get_args());
}
}
if (!function_exists('scanPath')) {

View File

@ -10,17 +10,18 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"helmich\/typo3-typoscript-parser": "^2.3.1",
"symfony\/var-exporter": "^5.3"
"symfony\/var-exporter": "^5.3",
"symfony\/string": "^6.0"
},
"require-dev": {
"phpspec\/prophecy-phpunit": "^2.0",
"phpstan\/extension-installer": "^1.1",
"phpstan\/phpstan": "^1.0",
"phpstan\/phpstan": "^1.2",
"phpunit\/phpunit": "^9.5",
"rector\/rector-generator": "^0.4.2",
"rector\/phpstan-rules": "^0.4.7",
"rector\/rector-generator": "^0.4.4",
"rector\/phpstan-rules": "^0.4.15",
"rector\/rector-src": "dev-main",
"symfony\/console": "^5.3",
"symplify\/coding-standard": "^10.0",
@ -28,7 +29,8 @@
"symplify\/phpstan-extensions": "^10.0",
"symplify\/phpstan-rules": "^10.0",
"symplify\/rule-doc-generator": "^10.0",
"tracy\/tracy": "^2.8"
"tracy\/tracy": "^2.8",
"symplify\/vendor-patches": "^10.0"
},
"autoload": {
"psr-4": {
@ -76,6 +78,7 @@
"update-composer-packages": "@php vendor\/bin\/rector add-composer-typo3-extensions-to-config"
},
"extra": {
"enable-patching": true,
"rector": {
"includes": [
"config\/config.php"

View File

@ -3,15 +3,20 @@
declare (strict_types=1);
namespace Ssch\TYPO3Rector\Helper;
use RectorPrefix20211208\Stringy\Stringy;
use function RectorPrefix20211208\Symfony\Component\String\u;
final class StringUtility
{
public static function prepareExtensionName(string $extensionName, int $delimiterPosition) : string
{
$extensionName = \substr($extensionName, $delimiterPosition + 1);
$stringy = new \RectorPrefix20211208\Stringy\Stringy($extensionName);
$underScoredExtensionName = (string) $stringy->underscored()->toLowerCase()->humanize();
$underScoredExtensionName = \ucwords($underScoredExtensionName);
$stringy = \RectorPrefix20211208\Symfony\Component\String\u($extensionName);
$underscores = $stringy->snake();
$lower = $underscores->lower();
$underScoredExtensionName = \str_replace('_', ' ', $lower->toString());
$stringy = \RectorPrefix20211208\Symfony\Component\String\u($underScoredExtensionName);
$trimmed = $stringy->trim();
$uppercase = $trimmed->title();
$underScoredExtensionName = \ucwords($uppercase->toString());
return \str_replace(' ', '', $underScoredExtensionName);
}
}

View File

@ -179,8 +179,10 @@ final class InitializeArgumentsClassMethodFactory
if (\property_exists($phpDocTagNode, 'value')) {
/** @var ParamTagValueNode $paramTagValueNode */
$paramTagValueNode = $phpDocTagNode->value;
$paramName = \ltrim($paramTagValueNode->parameterName, '$');
$paramTagsByName[$paramName] = $paramTagValueNode;
if (\is_string($paramTagValueNode->parameterName)) {
$paramName = \ltrim($paramTagValueNode->parameterName, '$');
$paramTagsByName[$paramName] = $paramTagValueNode;
}
}
}
return $paramTagsByName;

View File

@ -66,9 +66,13 @@ $instance = GeneralUtility::makeInstance(ExtractorRegistry::class);
CODE_SAMPLE
, self::EXAMPLE_CONFIGURATION)]);
}
/**
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
$classes = $configuration[self::CLASSES_GET_INSTANCE_TO_MAKE_INSTANCE] ?? [];
$classes = $configuration[self::CLASSES_GET_INSTANCE_TO_MAKE_INSTANCE] ?? $configuration;
\RectorPrefix20211208\Webmozart\Assert\Assert::isArray($classes);
\RectorPrefix20211208\Webmozart\Assert\Assert::allString($classes);
$this->classes = $classes;
}

View File

@ -107,11 +107,11 @@ CODE_SAMPLE
return $this->classRenamer->renameNode($node, $this->oldToNewClasses);
}
/**
* @param array<string, array<string, string>> $configuration
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
$classAliasMaps = $configuration[self::CLASS_ALIAS_MAPS] ?? [];
$classAliasMaps = $configuration[self::CLASS_ALIAS_MAPS] ?? $configuration;
foreach ($classAliasMaps as $file) {
$filePath = new \Symplify\SmartFileSystem\SmartFileInfo($file);
$classAliasMap = (require $filePath->getRealPath());

View File

@ -27,7 +27,7 @@ final class RemovePropertyExtensionNameRector extends \Rector\Core\Rector\Abstra
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController')) || !$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController'))) {
if ($this->shouldSkip($node)) {
return null;
}
if (!$this->isName($node, 'extensionName')) {
@ -68,4 +68,11 @@ class MyCommandController extends CommandController
CODE_SAMPLE
)]);
}
private function shouldSkip(\PhpParser\Node\Expr\PropertyFetch $node) : bool
{
if ($this->isObjectType($node->var, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\AbstractController'))) {
return \false;
}
return !$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController'));
}
}

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Stmt\Nop;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
use RectorPrefix20211208\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder;
use RectorPrefix20211208\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -26,6 +27,14 @@ final class ProvideCObjViaMethodRector extends \Rector\Core\Rector\AbstractRecto
* @var string
*/
private const COBJ = 'cObj';
/**
* @var \Rector\Privatization\NodeManipulator\VisibilityManipulator
*/
private $visibilityManipulator;
public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator)
{
$this->visibilityManipulator = $visibilityManipulator;
}
/**
* @return array<class-string<Node>>
*/

View File

@ -13,6 +13,7 @@ use Rector\Core\Rector\AbstractRector;
use Ssch\TYPO3Rector\Helper\TcaHelperTrait;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix20211208\Webmozart\Assert\Assert;
/**
* @changelog https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/8.4/Breaking-77630-RemoveWizardIcons.html
* @see \Ssch\TYPO3Rector\Tests\Rector\v8\v4\SubstituteOldWizardIconsRector\SubstituteOldWizardIconsRectorTest
@ -25,7 +26,7 @@ final class SubstituteOldWizardIconsRector extends \Rector\Core\Rector\AbstractR
*/
public const OLD_TO_NEW_FILE_LOCATIONS = 'old_to_new_file_locations';
/**
* @var string[]
* @var array<string, string>
*/
private $oldToNewFileLocations = [];
/**
@ -158,8 +159,15 @@ CODE_SAMPLE
}
return $hasAstBeenChanged ? $node : null;
}
/**
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
$this->oldToNewFileLocations = $configuration[self::OLD_TO_NEW_FILE_LOCATIONS] ?? [];
$oldToNewFileLocations = $configuration[self::OLD_TO_NEW_FILE_LOCATIONS] ?? $configuration;
\RectorPrefix20211208\Webmozart\Assert\Assert::isArray($oldToNewFileLocations);
\RectorPrefix20211208\Webmozart\Assert\Assert::allString(\array_keys($oldToNewFileLocations));
\RectorPrefix20211208\Webmozart\Assert\Assert::allString($oldToNewFileLocations);
$this->oldToNewFileLocations = $oldToNewFileLocations;
}
}

View File

@ -98,7 +98,7 @@ CODE_SAMPLE
*/
public function configure(array $configuration) : void
{
$this->oldToNewAnnotations = $configuration[self::OLD_TO_NEW_ANNOTATIONS] ?? [];
$this->oldToNewAnnotations = $configuration[self::OLD_TO_NEW_ANNOTATIONS] ?? $configuration;
}
private function prepareNewAnnotation(string $newAnnotation) : string
{