mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 20:00:50 +00:00
Updated Rector to commit 092b6115b0e0642d0c20836673415ece4a3d0084
092b6115b0
Bump nikic/php-parser to 4.17 (#4781)
This commit is contained in:
parent
5034b0a7f0
commit
9891ab5633
|
@ -6,7 +6,7 @@ namespace Rector\NodeNameResolver\NodeNameResolver;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\Error;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ final class ClassConstFetchNameResolver implements NodeNameResolverInterface
|
|||
if ($node->class instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
if ($node->name instanceof Error) {
|
||||
if (!$node->name instanceof Identifier) {
|
||||
return null;
|
||||
}
|
||||
$class = $node->class->toString();
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '2970fa114ef632768f4704c8eefd2f5d0310703c';
|
||||
public const PACKAGE_VERSION = '092b6115b0e0642d0c20836673415ece4a3d0084';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-13 07:15:02';
|
||||
public const RELEASE_DATE = '2023-08-13 23:42:42';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit22cf5cfc1cfbfa321d3634568d4c2a88::getLoader();
|
||||
return ComposerAutoloaderInit4121cdca7a26a39791cc4143742fb7cb::getLoader();
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit22cf5cfc1cfbfa321d3634568d4c2a88
|
||||
class ComposerAutoloaderInit4121cdca7a26a39791cc4143742fb7cb
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit22cf5cfc1cfbfa321d3634568d4c2a88
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit22cf5cfc1cfbfa321d3634568d4c2a88', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4121cdca7a26a39791cc4143742fb7cb', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit22cf5cfc1cfbfa321d3634568d4c2a88', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4121cdca7a26a39791cc4143742fb7cb', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4121cdca7a26a39791cc4143742fb7cb::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit4121cdca7a26a39791cc4143742fb7cb::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88
|
||||
class ComposerStaticInit4121cdca7a26a39791cc4143742fb7cb
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2960,9 +2960,9 @@ class ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit22cf5cfc1cfbfa321d3634568d4c2a88::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4121cdca7a26a39791cc4143742fb7cb::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4121cdca7a26a39791cc4143742fb7cb::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4121cdca7a26a39791cc4143742fb7cb::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
73
vendor/composer/installed.json
vendored
73
vendor/composer/installed.json
vendored
|
@ -701,17 +701,17 @@
|
|||
},
|
||||
{
|
||||
"name": "nikic\/php-parser",
|
||||
"version": "v4.16.0",
|
||||
"version_normalized": "4.16.0.0",
|
||||
"version": "v4.17.0",
|
||||
"version_normalized": "4.17.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/nikic\/PHP-Parser.git",
|
||||
"reference": "19526a33fb561ef417e822e85f08a00db4059c17"
|
||||
"reference": "844c228bf2b34a25ea8fed58f7929d14cf0c068e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/nikic\/PHP-Parser\/zipball\/19526a33fb561ef417e822e85f08a00db4059c17",
|
||||
"reference": "19526a33fb561ef417e822e85f08a00db4059c17",
|
||||
"url": "https:\/\/api.github.com\/repos\/nikic\/PHP-Parser\/zipball\/844c228bf2b34a25ea8fed58f7929d14cf0c068e",
|
||||
"reference": "844c228bf2b34a25ea8fed58f7929d14cf0c068e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -722,7 +722,7 @@
|
|||
"ircmaxell\/php-yacc": "^0.0.7",
|
||||
"phpunit\/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"time": "2023-06-25T14:52:30+00:00",
|
||||
"time": "2023-08-13T14:53:08+00:00",
|
||||
"bin": [
|
||||
"bin\/php-parse"
|
||||
],
|
||||
|
@ -771,7 +771,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/nikic\/PHP-Parser\/issues",
|
||||
"source": "https:\/\/github.com\/nikic\/PHP-Parser\/tree\/v4.16.0"
|
||||
"source": "https:\/\/github.com\/nikic\/PHP-Parser\/tree\/v4.17.0"
|
||||
},
|
||||
"install-path": "..\/nikic\/php-parser"
|
||||
},
|
||||
|
@ -1849,12 +1849,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "d09e0f376731912f3fd76df176db68f2e357ebc3"
|
||||
"reference": "0b976ae78689b9ded3c79a00a506b833f3e75146"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/d09e0f376731912f3fd76df176db68f2e357ebc3",
|
||||
"reference": "d09e0f376731912f3fd76df176db68f2e357ebc3",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/0b976ae78689b9ded3c79a00a506b833f3e75146",
|
||||
"reference": "0b976ae78689b9ded3c79a00a506b833f3e75146",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1864,23 +1864,22 @@
|
|||
"doctrine\/orm": "^2.10",
|
||||
"phpstan\/extension-installer": "^1.3",
|
||||
"phpstan\/phpstan": "^1.10",
|
||||
"phpstan\/phpstan-strict-rules": "^1.1",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2",
|
||||
"phpunit\/phpunit": "^10.2",
|
||||
"phpunit\/phpunit": "^10.3",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-generator": "^0.6",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symplify\/easy-ci": "^11.2",
|
||||
"symplify\/easy-coding-standard": "^11.5",
|
||||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/phpstan-rules": "^11.1",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"tomasvotruba\/class-leak": "0.0.22.72",
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-08-06T15:51:10+00:00",
|
||||
"time": "2023-08-13T11:19:36+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -1918,12 +1917,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "44cec673c677071751bbf81c9184d8c52aea19be"
|
||||
"reference": "47f72d5d2b747a73cf30bee2c798dc9cf21e3411"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/44cec673c677071751bbf81c9184d8c52aea19be",
|
||||
"reference": "44cec673c677071751bbf81c9184d8c52aea19be",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/47f72d5d2b747a73cf30bee2c798dc9cf21e3411",
|
||||
"reference": "47f72d5d2b747a73cf30bee2c798dc9cf21e3411",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1942,14 +1941,14 @@
|
|||
"symplify\/easy-coding-standard": "^11.2",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/phpstan-rules": "^11.4",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"tomasvotruba\/class-leak": "0.0.22.72",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-08-06T00:03:41+00:00",
|
||||
"time": "2023-08-13T11:39:42+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -1987,12 +1986,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "14f0412eae74810120e4dd4916d49512e0fd5e60"
|
||||
"reference": "f2571b8cf102329c8373619c47bac582e7213c6a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/14f0412eae74810120e4dd4916d49512e0fd5e60",
|
||||
"reference": "14f0412eae74810120e4dd4916d49512e0fd5e60",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/f2571b8cf102329c8373619c47bac582e7213c6a",
|
||||
"reference": "f2571b8cf102329c8373619c47bac582e7213c6a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2008,20 +2007,20 @@
|
|||
"phpstan\/phpstan-webmozart-assert": "^1.2.2",
|
||||
"phpunit\/phpunit": "^10.2",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-generator": "^0.6.15",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"symplify\/easy-coding-standard": "^11.5",
|
||||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/phpstan-rules": "^11.4",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"tomasvotruba\/class-leak": "0.0.22.72",
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
"tomasvotruba\/unused-public": "^0.2"
|
||||
},
|
||||
"time": "2023-08-10T11:29:45+00:00",
|
||||
"time": "2023-08-13T11:24:00+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -2062,12 +2061,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "ba9b9f4de0a26b2a331c359a6c4d293041d6a1c9"
|
||||
"reference": "23bb5222530f6e48a5e4e3c095b0a76cb6b38e7b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/ba9b9f4de0a26b2a331c359a6c4d293041d6a1c9",
|
||||
"reference": "ba9b9f4de0a26b2a331c359a6c4d293041d6a1c9",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/23bb5222530f6e48a5e4e3c095b0a76cb6b38e7b",
|
||||
"reference": "23bb5222530f6e48a5e4e3c095b0a76cb6b38e7b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2081,7 +2080,7 @@
|
|||
"phpstan\/phpstan-webmozart-assert": "^1.2",
|
||||
"phpunit\/phpunit": "^10.3",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-generator": "^0.6",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symfony\/routing": "^6.1",
|
||||
"symfony\/security-core": "^6.2",
|
||||
|
@ -2091,14 +2090,14 @@
|
|||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/phpstan-rules": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"tomasvotruba\/class-leak": "0.1.1.72",
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.2"
|
||||
},
|
||||
"time": "2023-08-10T19:01:54+00:00",
|
||||
"time": "2023-08-13T10:21:14+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
14
vendor/nikic/php-parser/grammar/php7.y
vendored
14
vendor/nikic/php-parser/grammar/php7.y
vendored
|
@ -221,7 +221,10 @@ non_empty_class_const_list:
|
|||
;
|
||||
|
||||
class_const:
|
||||
identifier_maybe_reserved '=' expr { $$ = Node\Const_[$1, $3]; }
|
||||
T_STRING '=' expr
|
||||
{ $$ = Node\Const_[new Node\Identifier($1, stackAttributes(#1)), $3]; }
|
||||
| semi_reserved '=' expr
|
||||
{ $$ = Node\Const_[new Node\Identifier($1, stackAttributes(#1)), $3]; }
|
||||
;
|
||||
|
||||
inner_statement_list_ex:
|
||||
|
@ -722,6 +725,9 @@ class_statement:
|
|||
| optional_attributes method_modifiers T_CONST class_const_list semi
|
||||
{ $$ = new Stmt\ClassConst($4, $2, attributes(), $1);
|
||||
$this->checkClassConst($$, #2); }
|
||||
| optional_attributes method_modifiers T_CONST type_expr class_const_list semi
|
||||
{ $$ = new Stmt\ClassConst($5, $2, attributes(), $1, $4);
|
||||
$this->checkClassConst($$, #2); }
|
||||
| optional_attributes method_modifiers T_FUNCTION optional_ref identifier_maybe_reserved '(' parameter_list ')'
|
||||
optional_return_type method_body
|
||||
{ $$ = Stmt\ClassMethod[$5, ['type' => $2, 'byRef' => $4, 'params' => $7, 'returnType' => $9, 'stmts' => $10, 'attrGroups' => $1]];
|
||||
|
@ -943,8 +949,8 @@ expr:
|
|||
;
|
||||
|
||||
anonymous_class:
|
||||
optional_attributes T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}'
|
||||
{ $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $4, 'implements' => $5, 'stmts' => $7, 'attrGroups' => $1]], $3);
|
||||
optional_attributes class_entry_type ctor_arguments extends_from implements_list '{' class_statement_list '}'
|
||||
{ $$ = array(Stmt\Class_[null, ['type' => $2, 'extends' => $4, 'implements' => $5, 'stmts' => $7, 'attrGroups' => $1]], $3);
|
||||
$this->checkClass($$[0], -1); }
|
||||
;
|
||||
|
||||
|
@ -1040,6 +1046,8 @@ constant:
|
|||
class_constant:
|
||||
class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier_maybe_reserved
|
||||
{ $$ = Expr\ClassConstFetch[$1, $3]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}'
|
||||
{ $$ = Expr\ClassConstFetch[$1, $4]; }
|
||||
/* We interpret an isolated FOO:: as an unfinished class constant fetch. It could also be
|
||||
an unfinished static property fetch or unfinished scoped call. */
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM error
|
||||
|
|
|
@ -16,6 +16,8 @@ class ClassConst implements PhpParser\Builder
|
|||
protected $constants = [];
|
||||
/** @var Node\AttributeGroup[] */
|
||||
protected $attributeGroups = [];
|
||||
/** @var Identifier|Node\Name|Node\ComplexType */
|
||||
protected $type;
|
||||
/**
|
||||
* Creates a class constant builder
|
||||
*
|
||||
|
@ -103,6 +105,18 @@ class ClassConst implements PhpParser\Builder
|
|||
$this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Sets the constant type.
|
||||
*
|
||||
* @param string|Node\Name|Identifier|Node\ComplexType $type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = BuilderHelpers::normalizeType($type);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns the built class node.
|
||||
*
|
||||
|
@ -110,6 +124,6 @@ class ClassConst implements PhpParser\Builder
|
|||
*/
|
||||
public function getNode() : PhpParser\Node
|
||||
{
|
||||
return new Stmt\ClassConst($this->constants, $this->flags, $this->attributes, $this->attributeGroups);
|
||||
return new Stmt\ClassConst($this->constants, $this->flags, $this->attributes, $this->attributeGroups, $this->type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,14 +330,14 @@ class BuilderFactory
|
|||
/**
|
||||
* Creates a class constant fetch node.
|
||||
*
|
||||
* @param string|Name|Expr $class Class name
|
||||
* @param string|Identifier $name Constant name
|
||||
* @param string|Name|Expr $class Class name
|
||||
* @param string|Identifier|Expr $name Constant name
|
||||
*
|
||||
* @return Expr\ClassConstFetch
|
||||
*/
|
||||
public function classConstFetch($class, $name) : Expr\ClassConstFetch
|
||||
{
|
||||
return new Expr\ClassConstFetch(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), \PhpParser\BuilderHelpers::normalizeIdentifier($name));
|
||||
return new Expr\ClassConstFetch(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name));
|
||||
}
|
||||
/**
|
||||
* Creates nested Concat nodes from a list of expressions.
|
||||
|
|
|
@ -19,6 +19,8 @@ class PrintableNewAnonClassNode extends Expr
|
|||
{
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
/** @var int Modifiers */
|
||||
public $flags;
|
||||
/** @var Node\Arg[] Arguments */
|
||||
public $args;
|
||||
/** @var null|Node\Name Name of extended class */
|
||||
|
@ -27,10 +29,11 @@ class PrintableNewAnonClassNode extends Expr
|
|||
public $implements;
|
||||
/** @var Node\Stmt[] Statements */
|
||||
public $stmts;
|
||||
public function __construct(array $attrGroups, array $args, Node\Name $extends = null, array $implements, array $stmts, array $attributes)
|
||||
public function __construct(array $attrGroups, int $flags, array $args, Node\Name $extends = null, array $implements, array $stmts, array $attributes)
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
$this->attrGroups = $attrGroups;
|
||||
$this->flags = $flags;
|
||||
$this->args = $args;
|
||||
$this->extends = $extends;
|
||||
$this->implements = $implements;
|
||||
|
@ -42,7 +45,7 @@ class PrintableNewAnonClassNode extends Expr
|
|||
\assert($class instanceof Node\Stmt\Class_);
|
||||
// We don't assert that $class->name is null here, to allow consumers to assign unique names
|
||||
// to anonymous classes for their own purposes. We simplify ignore the name here.
|
||||
return new self($class->attrGroups, $newNode->args, $class->extends, $class->implements, $class->stmts, $newNode->getAttributes());
|
||||
return new self($class->attrGroups, $class->flags, $newNode->args, $class->extends, $class->implements, $class->stmts, $newNode->getAttributes());
|
||||
}
|
||||
public function getType() : string
|
||||
{
|
||||
|
@ -50,6 +53,6 @@ class PrintableNewAnonClassNode extends Expr
|
|||
}
|
||||
public function getSubNodeNames() : array
|
||||
{
|
||||
return ['attrGroups', 'args', 'extends', 'implements', 'stmts'];
|
||||
return ['attrGroups', 'flags', 'args', 'extends', 'implements', 'stmts'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ class ClassConstFetch extends Expr
|
|||
{
|
||||
/** @var Name|Expr Class name */
|
||||
public $class;
|
||||
/** @var Identifier|Error Constant name */
|
||||
/** @var Identifier|Expr|Error Constant name */
|
||||
public $name;
|
||||
/**
|
||||
* Constructs a class const fetch node.
|
||||
*
|
||||
* @param Name|Expr $class Class name
|
||||
* @param string|Identifier|Error $name Constant name
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Name|Expr $class Class name
|
||||
* @param string|Identifier|Expr|Error $name Constant name
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($class, $name, array $attributes = [])
|
||||
{
|
||||
|
|
|
@ -10,26 +10,30 @@ class ClassConst extends Node\Stmt
|
|||
public $flags;
|
||||
/** @var Node\Const_[] Constant declarations */
|
||||
public $consts;
|
||||
/** @var Node\AttributeGroup[] */
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
/** @var Node\Identifier|Node\Name|Node\ComplexType Type declaration */
|
||||
public $type;
|
||||
/**
|
||||
* Constructs a class const list node.
|
||||
*
|
||||
* @param Node\Const_[] $consts Constant declarations
|
||||
* @param int $flags Modifiers
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
|
||||
* @param Node\Const_[] $consts Constant declarations
|
||||
* @param int $flags Modifiers
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
|
||||
* @param null|string|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration
|
||||
*/
|
||||
public function __construct(array $consts, int $flags = 0, array $attributes = [], array $attrGroups = [])
|
||||
public function __construct(array $consts, int $flags = 0, array $attributes = [], array $attrGroups = [], $type = null)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
$this->flags = $flags;
|
||||
$this->consts = $consts;
|
||||
$this->attrGroups = $attrGroups;
|
||||
$this->type = $type;
|
||||
}
|
||||
public function getSubNodeNames() : array
|
||||
{
|
||||
return ['attrGroups', 'flags', 'consts'];
|
||||
return ['attrGroups', 'flags', 'type', 'consts'];
|
||||
}
|
||||
/**
|
||||
* Whether constant is explicitly or implicitly public.
|
||||
|
|
1075
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
1075
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
File diff suppressed because one or more lines are too long
|
@ -493,7 +493,7 @@ class Standard extends PrettyPrinterAbstract
|
|||
}
|
||||
protected function pExpr_StaticCall(Expr\StaticCall $node)
|
||||
{
|
||||
return $this->pDereferenceLhs($node->class) . '::' . ($node->name instanceof Expr ? $node->name instanceof Expr\Variable ? $this->p($node->name) : '{' . $this->p($node->name) . '}' : $node->name) . '(' . $this->pMaybeMultiline($node->args) . ')';
|
||||
return $this->pStaticDereferenceLhs($node->class) . '::' . ($node->name instanceof Expr ? $node->name instanceof Expr\Variable ? $this->p($node->name) : '{' . $this->p($node->name) . '}' : $node->name) . '(' . $this->pMaybeMultiline($node->args) . ')';
|
||||
}
|
||||
protected function pExpr_Empty(Expr\Empty_ $node)
|
||||
{
|
||||
|
@ -552,7 +552,7 @@ class Standard extends PrettyPrinterAbstract
|
|||
}
|
||||
protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node)
|
||||
{
|
||||
return $this->pDereferenceLhs($node->class) . '::' . $this->p($node->name);
|
||||
return $this->pStaticDereferenceLhs($node->class) . '::' . $this->pObjectProperty($node->name);
|
||||
}
|
||||
protected function pExpr_PropertyFetch(Expr\PropertyFetch $node)
|
||||
{
|
||||
|
@ -564,7 +564,7 @@ class Standard extends PrettyPrinterAbstract
|
|||
}
|
||||
protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node)
|
||||
{
|
||||
return $this->pDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
return $this->pStaticDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
}
|
||||
protected function pExpr_ShellExec(Expr\ShellExec $node)
|
||||
{
|
||||
|
@ -697,7 +697,7 @@ class Standard extends PrettyPrinterAbstract
|
|||
}
|
||||
protected function pStmt_ClassConst(Stmt\ClassConst $node)
|
||||
{
|
||||
return $this->pAttrGroups($node->attrGroups) . $this->pModifiers($node->flags) . 'const ' . $this->pCommaSeparated($node->consts) . ';';
|
||||
return $this->pAttrGroups($node->attrGroups) . $this->pModifiers($node->flags) . 'const ' . (null !== $node->type ? $this->p($node->type) . ' ' : '') . $this->pCommaSeparated($node->consts) . ';';
|
||||
}
|
||||
protected function pStmt_Function(Stmt\Function_ $node)
|
||||
{
|
||||
|
@ -911,6 +911,14 @@ class Standard extends PrettyPrinterAbstract
|
|||
return '(' . $this->p($node) . ')';
|
||||
}
|
||||
}
|
||||
protected function pStaticDereferenceLhs(Node $node)
|
||||
{
|
||||
if (!$this->staticDereferenceLhsRequiresParens($node)) {
|
||||
return $this->p($node);
|
||||
} else {
|
||||
return '(' . $this->p($node) . ')';
|
||||
}
|
||||
}
|
||||
protected function pCallLhs(Node $node)
|
||||
{
|
||||
if (!$this->callLhsRequiresParens($node)) {
|
||||
|
@ -919,10 +927,13 @@ class Standard extends PrettyPrinterAbstract
|
|||
return '(' . $this->p($node) . ')';
|
||||
}
|
||||
}
|
||||
protected function pNewVariable(Node $node)
|
||||
protected function pNewVariable(Node $node) : string
|
||||
{
|
||||
// TODO: This is not fully accurate.
|
||||
return $this->pDereferenceLhs($node);
|
||||
if (!$this->newOperandRequiresParens($node)) {
|
||||
return $this->p($node);
|
||||
} else {
|
||||
return '(' . $this->p($node) . ')';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
|
|
|
@ -28,6 +28,10 @@ abstract class PrettyPrinterAbstract
|
|||
// Name operand that may require ${} bracing
|
||||
const FIXUP_ENCAPSED = 6;
|
||||
// Encapsed string part
|
||||
const FIXUP_NEW = 7;
|
||||
// New/instanceof operand
|
||||
const FIXUP_STATIC_DEREF_LHS = 8;
|
||||
// LHS of static dereferencing operation
|
||||
protected $precedenceMap = [
|
||||
// [precedence, associativity]
|
||||
// where for precedence -1 is %left, 0 is %nonassoc and 1 is %right
|
||||
|
@ -869,6 +873,16 @@ abstract class PrettyPrinterAbstract
|
|||
return '(' . $this->p($subNode) . ')';
|
||||
}
|
||||
break;
|
||||
case self::FIXUP_STATIC_DEREF_LHS:
|
||||
if ($this->staticDereferenceLhsRequiresParens($subNode) && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
|
||||
return '(' . $this->p($subNode) . ')';
|
||||
}
|
||||
break;
|
||||
case self::FIXUP_NEW:
|
||||
if ($this->newOperandRequiresParens($subNode) && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
|
||||
return '(' . $this->p($subNode) . ')';
|
||||
}
|
||||
break;
|
||||
case self::FIXUP_BRACED_NAME:
|
||||
case self::FIXUP_VAR_BRACED_NAME:
|
||||
if ($subNode instanceof Expr && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) {
|
||||
|
@ -922,7 +936,7 @@ abstract class PrettyPrinterAbstract
|
|||
return !($node instanceof \PhpParser\Node\Name || $node instanceof Expr\Variable || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_);
|
||||
}
|
||||
/**
|
||||
* Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis.
|
||||
* Determines whether the LHS of an array/object operation must be wrapped in parentheses.
|
||||
*
|
||||
* @param Node $node LHS of dereferencing operation
|
||||
*
|
||||
|
@ -930,7 +944,39 @@ abstract class PrettyPrinterAbstract
|
|||
*/
|
||||
protected function dereferenceLhsRequiresParens(\PhpParser\Node $node) : bool
|
||||
{
|
||||
return !($node instanceof Expr\Variable || $node instanceof \PhpParser\Node\Name || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_ || $node instanceof Scalar\String_ || $node instanceof Expr\ConstFetch || $node instanceof Expr\ClassConstFetch);
|
||||
// A constant can occur on the LHS of an array/object deref, but not a static deref.
|
||||
return $this->staticDereferenceLhsRequiresParens($node) && !$node instanceof Expr\ConstFetch;
|
||||
}
|
||||
/**
|
||||
* Determines whether the LHS of a static operation must be wrapped in parentheses.
|
||||
*
|
||||
* @param Node $node LHS of dereferencing operation
|
||||
*
|
||||
* @return bool Whether parentheses are required
|
||||
*/
|
||||
protected function staticDereferenceLhsRequiresParens(\PhpParser\Node $node) : bool
|
||||
{
|
||||
return !($node instanceof Expr\Variable || $node instanceof \PhpParser\Node\Name || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_ || $node instanceof Scalar\String_ || $node instanceof Expr\ClassConstFetch);
|
||||
}
|
||||
/**
|
||||
* Determines whether an expression used in "new" or "instanceof" requires parentheses.
|
||||
*
|
||||
* @param Node $node New or instanceof operand
|
||||
*
|
||||
* @return bool Whether parentheses are required
|
||||
*/
|
||||
protected function newOperandRequiresParens(\PhpParser\Node $node) : bool
|
||||
{
|
||||
if ($node instanceof \PhpParser\Node\Name || $node instanceof Expr\Variable) {
|
||||
return \false;
|
||||
}
|
||||
if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch) {
|
||||
return $this->newOperandRequiresParens($node->var);
|
||||
}
|
||||
if ($node instanceof Expr\StaticPropertyFetch) {
|
||||
return $this->newOperandRequiresParens($node->class);
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* Print modifiers, including trailing whitespace.
|
||||
|
@ -1021,26 +1067,7 @@ abstract class PrettyPrinterAbstract
|
|||
if ($this->fixupMap) {
|
||||
return;
|
||||
}
|
||||
$this->fixupMap = [
|
||||
Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT],
|
||||
Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT],
|
||||
Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT],
|
||||
Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT],
|
||||
Expr\Instanceof_::class => ['expr' => self::FIXUP_PREC_LEFT, 'class' => self::FIXUP_PREC_RIGHT],
|
||||
Expr\Ternary::class => ['cond' => self::FIXUP_PREC_LEFT, 'else' => self::FIXUP_PREC_RIGHT],
|
||||
Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS],
|
||||
Expr\StaticCall::class => ['class' => self::FIXUP_DEREF_LHS],
|
||||
Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS],
|
||||
Expr\ClassConstFetch::class => ['var' => self::FIXUP_DEREF_LHS],
|
||||
Expr\New_::class => ['class' => self::FIXUP_DEREF_LHS],
|
||||
// TODO: FIXUP_NEW_VARIABLE
|
||||
Expr\MethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME],
|
||||
Expr\NullsafeMethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME],
|
||||
Expr\StaticPropertyFetch::class => ['class' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_VAR_BRACED_NAME],
|
||||
Expr\PropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME],
|
||||
Expr\NullsafePropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME],
|
||||
Scalar\Encapsed::class => ['parts' => self::FIXUP_ENCAPSED],
|
||||
];
|
||||
$this->fixupMap = [Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT], Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT], Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT], Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT], Expr\Instanceof_::class => ['expr' => self::FIXUP_PREC_LEFT, 'class' => self::FIXUP_NEW], Expr\Ternary::class => ['cond' => self::FIXUP_PREC_LEFT, 'else' => self::FIXUP_PREC_RIGHT], Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS], Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS], Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS], Expr\ClassConstFetch::class => ['class' => self::FIXUP_STATIC_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\New_::class => ['class' => self::FIXUP_NEW], Expr\MethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\NullsafeMethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\StaticPropertyFetch::class => ['class' => self::FIXUP_STATIC_DEREF_LHS, 'name' => self::FIXUP_VAR_BRACED_NAME], Expr\PropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Expr\NullsafePropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], Scalar\Encapsed::class => ['parts' => self::FIXUP_ENCAPSED]];
|
||||
$binaryOps = [BinaryOp\Pow::class, BinaryOp\Mul::class, BinaryOp\Div::class, BinaryOp\Mod::class, BinaryOp\Plus::class, BinaryOp\Minus::class, BinaryOp\Concat::class, BinaryOp\ShiftLeft::class, BinaryOp\ShiftRight::class, BinaryOp\Smaller::class, BinaryOp\SmallerOrEqual::class, BinaryOp\Greater::class, BinaryOp\GreaterOrEqual::class, BinaryOp\Equal::class, BinaryOp\NotEqual::class, BinaryOp\Identical::class, BinaryOp\NotIdentical::class, BinaryOp\Spaceship::class, BinaryOp\BitwiseAnd::class, BinaryOp\BitwiseXor::class, BinaryOp\BitwiseOr::class, BinaryOp\BooleanAnd::class, BinaryOp\BooleanOr::class, BinaryOp\Coalesce::class, BinaryOp\LogicalAnd::class, BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class];
|
||||
foreach ($binaryOps as $binaryOp) {
|
||||
$this->fixupMap[$binaryOp] = ['left' => self::FIXUP_PREC_LEFT, 'right' => self::FIXUP_PREC_RIGHT];
|
||||
|
@ -1071,7 +1098,7 @@ abstract class PrettyPrinterAbstract
|
|||
$stripDoubleArrow = ['right' => \T_DOUBLE_ARROW];
|
||||
$stripColon = ['left' => ':'];
|
||||
$stripEquals = ['left' => '='];
|
||||
$this->removalMap = ['Expr_ArrayDimFetch->dim' => $stripBoth, 'Expr_ArrayItem->key' => $stripDoubleArrow, 'Expr_ArrowFunction->returnType' => $stripColon, 'Expr_Closure->returnType' => $stripColon, 'Expr_Exit->expr' => $stripBoth, 'Expr_Ternary->if' => $stripBoth, 'Expr_Yield->key' => $stripDoubleArrow, 'Expr_Yield->value' => $stripBoth, 'Param->type' => $stripRight, 'Param->default' => $stripEquals, 'Stmt_Break->num' => $stripBoth, 'Stmt_Catch->var' => $stripLeft, 'Stmt_ClassMethod->returnType' => $stripColon, 'Stmt_Class->extends' => ['left' => \T_EXTENDS], 'Stmt_Enum->scalarType' => $stripColon, 'Stmt_EnumCase->expr' => $stripEquals, 'Expr_PrintableNewAnonClass->extends' => ['left' => \T_EXTENDS], 'Stmt_Continue->num' => $stripBoth, 'Stmt_Foreach->keyVar' => $stripDoubleArrow, 'Stmt_Function->returnType' => $stripColon, 'Stmt_If->else' => $stripLeft, 'Stmt_Namespace->name' => $stripLeft, 'Stmt_Property->type' => $stripRight, 'Stmt_PropertyProperty->default' => $stripEquals, 'Stmt_Return->expr' => $stripBoth, 'Stmt_StaticVar->default' => $stripEquals, 'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft, 'Stmt_TryCatch->finally' => $stripLeft];
|
||||
$this->removalMap = ['Expr_ArrayDimFetch->dim' => $stripBoth, 'Expr_ArrayItem->key' => $stripDoubleArrow, 'Expr_ArrowFunction->returnType' => $stripColon, 'Expr_Closure->returnType' => $stripColon, 'Expr_Exit->expr' => $stripBoth, 'Expr_Ternary->if' => $stripBoth, 'Expr_Yield->key' => $stripDoubleArrow, 'Expr_Yield->value' => $stripBoth, 'Param->type' => $stripRight, 'Param->default' => $stripEquals, 'Stmt_Break->num' => $stripBoth, 'Stmt_Catch->var' => $stripLeft, 'Stmt_ClassConst->type' => $stripRight, 'Stmt_ClassMethod->returnType' => $stripColon, 'Stmt_Class->extends' => ['left' => \T_EXTENDS], 'Stmt_Enum->scalarType' => $stripColon, 'Stmt_EnumCase->expr' => $stripEquals, 'Expr_PrintableNewAnonClass->extends' => ['left' => \T_EXTENDS], 'Stmt_Continue->num' => $stripBoth, 'Stmt_Foreach->keyVar' => $stripDoubleArrow, 'Stmt_Function->returnType' => $stripColon, 'Stmt_If->else' => $stripLeft, 'Stmt_Namespace->name' => $stripLeft, 'Stmt_Property->type' => $stripRight, 'Stmt_PropertyProperty->default' => $stripEquals, 'Stmt_Return->expr' => $stripBoth, 'Stmt_StaticVar->default' => $stripEquals, 'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft, 'Stmt_TryCatch->finally' => $stripLeft];
|
||||
}
|
||||
protected function initializeInsertionMap()
|
||||
{
|
||||
|
@ -1093,6 +1120,7 @@ abstract class PrettyPrinterAbstract
|
|||
'Stmt_Break->num' => [\T_BREAK, \false, ' ', null],
|
||||
'Stmt_Catch->var' => [null, \false, ' ', null],
|
||||
'Stmt_ClassMethod->returnType' => [')', \false, ' : ', null],
|
||||
'Stmt_ClassConst->type' => [\T_CONST, \false, ' ', null],
|
||||
'Stmt_Class->extends' => [null, \false, ' extends ', null],
|
||||
'Stmt_Enum->scalarType' => [null, \false, ' : ', null],
|
||||
'Stmt_EnumCase->expr' => [null, \false, ' = ', null],
|
||||
|
@ -1216,7 +1244,7 @@ abstract class PrettyPrinterAbstract
|
|||
if ($this->modifierChangeMap) {
|
||||
return;
|
||||
}
|
||||
$this->modifierChangeMap = ['Stmt_ClassConst->flags' => \T_CONST, 'Stmt_ClassMethod->flags' => \T_FUNCTION, 'Stmt_Class->flags' => \T_CLASS, 'Stmt_Property->flags' => \T_VARIABLE, 'Param->flags' => \T_VARIABLE];
|
||||
$this->modifierChangeMap = ['Stmt_ClassConst->flags' => \T_CONST, 'Stmt_ClassMethod->flags' => \T_FUNCTION, 'Stmt_Class->flags' => \T_CLASS, 'Stmt_Property->flags' => \T_VARIABLE, 'Expr_PrintableNewAnonClass->flags' => \T_CLASS, 'Param->flags' => \T_VARIABLE];
|
||||
// List of integer subnodes that are not modifiers:
|
||||
// Expr_Include->type
|
||||
// Stmt_GroupUse->type
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('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' => 'dev-main d09e0f3'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 44cec67'), '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' => 'dev-main 14f0412'), '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' => 'dev-main ba9b9f4'));
|
||||
public const EXTENSIONS = array('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' => 'dev-main 0b976ae'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 47f72d5'), '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' => 'dev-main f2571b8'), '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' => 'dev-main 23bb522'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
9
vendor/rector/rector-doctrine/composer.json
vendored
9
vendor/rector/rector-doctrine/composer.json
vendored
|
@ -10,21 +10,20 @@
|
|||
"phpstan\/extension-installer": "^1.3",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"phpstan\/phpstan": "^1.10",
|
||||
"phpunit\/phpunit": "^10.2",
|
||||
"phpunit\/phpunit": "^10.3",
|
||||
"symplify\/phpstan-rules": "^11.1",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/easy-coding-standard": "^11.5",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"doctrine\/orm": "^2.10",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2",
|
||||
"phpstan\/phpstan-strict-rules": "^1.1",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"rector\/rector-generator": "^0.6",
|
||||
"symplify\/easy-ci": "^11.2",
|
||||
"tomasvotruba\/unused-public": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/class-leak": "0.0.22.72"
|
||||
"tomasvotruba\/class-leak": "^0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 15 Rules Overview
|
||||
# 14 Rules Overview
|
||||
|
||||
## ChangeBigIntEntityPropertyToIntTypeRector
|
||||
|
||||
|
@ -72,29 +72,6 @@ Change default value types to match Doctrine annotation type
|
|||
|
||||
<br>
|
||||
|
||||
## DoctrineTargetEntityStringToClassConstantRector
|
||||
|
||||
Convert targetEntities defined as String to <class>::class Constants in Doctrine Entities.
|
||||
|
||||
- class: [`Rector\Doctrine\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector`](../rules/CodeQuality/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php)
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
- * @ORM\OneToMany(targetEntity="AnotherClass")
|
||||
+ * @ORM\OneToMany(targetEntity=\MyNamespace\Source\AnotherClass::class)
|
||||
*/
|
||||
private readonly ?Collection $items;
|
||||
|
||||
- #[ORM\ManyToOne(targetEntity: "AnotherClass")]
|
||||
+ #[ORM\ManyToOne(targetEntity: \MyNamespace\Source\AnotherClass::class)]
|
||||
private readonly ?Collection $items2;
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ImproveDoctrineCollectionDocTypeInEntityRector
|
||||
|
||||
Improve @var, `@param` and `@return` types for Doctrine collections to make them useful both for PHPStan and PHPStorm
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"symplify\/easy-coding-standard": "^11.2",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/phpstan-rules": "^11.4",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"tomasvotruba\/class-leak": "0.0.22.72",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 79 Rules Overview
|
||||
# 69 Rules Overview
|
||||
|
||||
## ArrowFunctionToAnonymousFunctionRector
|
||||
|
||||
|
@ -205,24 +205,6 @@ Refactor PHP attribute markers to annotations notation
|
|||
|
||||
- class: [`Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector`](../rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector;
|
||||
use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(DowngradeAttributeToAnnotationRector::class, [
|
||||
new DowngradeAttributeToAnnotation('Symfony\Component\Routing\Annotation\Route'),
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
|
@ -240,26 +222,6 @@ return static function (RectorConfig $rectorConfig): void {
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeClassConstantVisibilityRector
|
||||
|
||||
Downgrade class constant visibility
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector`](../rules/DowngradePhp71/Rector/ClassConst/DowngradeClassConstantVisibilityRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
- public const PUBLIC_CONST_B = 2;
|
||||
- protected const PROTECTED_CONST = 3;
|
||||
- private const PRIVATE_CONST = 4;
|
||||
+ const PUBLIC_CONST_B = 2;
|
||||
+ const PROTECTED_CONST = 3;
|
||||
+ const PRIVATE_CONST = 4;
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeClassOnObjectToGetClassRector
|
||||
|
||||
Change `$object::class` to get_class($object)
|
||||
|
@ -279,22 +241,6 @@ Change `$object::class` to get_class($object)
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeClosureFromCallableRector
|
||||
|
||||
Converts `Closure::fromCallable()` to compatible alternative.
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector`](../rules/DowngradePhp71/Rector/StaticCall/DowngradeClosureFromCallableRector.php)
|
||||
|
||||
```diff
|
||||
-$someClosure = \Closure::fromCallable('callable');
|
||||
+$callable = 'callable';
|
||||
+$someClosure = function () use ($callable) {
|
||||
+ return $callable(...func_get_args());
|
||||
+};
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeContravariantArgumentTypeRector
|
||||
|
||||
Remove contravariant argument type declarations
|
||||
|
@ -471,48 +417,6 @@ Downgrade `is_countable()` to former version
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeIsIterableRector
|
||||
|
||||
Change is_iterable with array and Traversable object type check
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector`](../rules/DowngradePhp71/Rector/FuncCall/DowngradeIsIterableRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run($obj)
|
||||
{
|
||||
- is_iterable($obj);
|
||||
+ is_array($obj) || $obj instanceof \Traversable;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeIterablePseudoTypeDeclarationRector
|
||||
|
||||
Remove the iterable pseudo type params and returns, add `@param` and `@return` tags instead
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector`](../rules/DowngradePhp71/Rector/FunctionLike/DowngradeIterablePseudoTypeDeclarationRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
- public function run(iterable $iterator): iterable
|
||||
+ /**
|
||||
+ * @param mixed[]|\Traversable $iterator
|
||||
+ * @return mixed[]|\Traversable
|
||||
+ */
|
||||
+ public function run($iterator)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeJsonDecodeNullAssociativeArgRector
|
||||
|
||||
Downgrade `json_decode()` with null associative argument function
|
||||
|
@ -535,27 +439,6 @@ Downgrade `json_decode()` with null associative argument function
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeKeysInListRector
|
||||
|
||||
Extract keys in list to its own variable assignment
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector`](../rules/DowngradePhp71/Rector/List_/DowngradeKeysInListRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
- public function run(array $data): void
|
||||
+ public function run(): void
|
||||
{
|
||||
- list("id" => $id1, "name" => $name1) = $data[0];
|
||||
+ $id1 = $data[0]["id"];
|
||||
+ $name1 = $data[0]["name"];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeListReferenceAssignmentRector
|
||||
|
||||
Convert the list reference assignment to its equivalent PHP 7.2 code
|
||||
|
@ -684,22 +567,6 @@ Remove named argument
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeNegativeStringOffsetToStrlenRector
|
||||
|
||||
Downgrade negative string offset to strlen
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector`](../rules/DowngradePhp71/Rector/String_/DowngradeNegativeStringOffsetToStrlenRector.php)
|
||||
|
||||
```diff
|
||||
-echo 'abcdef'[-2];
|
||||
+echo substr('abcdef', -2, 1);
|
||||
|
||||
-echo strpos($value, 'b', -3);
|
||||
+echo strpos($value, 'b', strlen($value) - 3);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeNeverTypeDeclarationRector
|
||||
|
||||
Remove "never" return type, add a `"@return` never" tag instead
|
||||
|
@ -775,28 +642,6 @@ Remove null coalescing operator ??=
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeNullableTypeDeclarationRector
|
||||
|
||||
Remove the nullable type params, add `@param` tags instead
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector`](../rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
- public function run(?string $input): ?string
|
||||
+ /**
|
||||
+ * @param string|null $input
|
||||
+ * @return string|null
|
||||
+ */
|
||||
+ public function run($input)
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeNullsafeToTernaryOperatorRector
|
||||
|
||||
Change nullsafe operator to ternary operator rector
|
||||
|
@ -805,9 +650,7 @@ Change nullsafe operator to ternary operator rector
|
|||
|
||||
```diff
|
||||
-$dateAsString = $booking->getStartDate()?->asDateTimeString();
|
||||
-$dateAsString = $booking->startDate?->dateTimeString;
|
||||
+$dateAsString = ($bookingGetStartDate = $booking->getStartDate()) ? $bookingGetStartDate->asDateTimeString() : null;
|
||||
+$dateAsString = ($bookingGetStartDate = $booking->startDate) ? $bookingGetStartDate->dateTimeString : null;
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -882,32 +725,6 @@ Change param type to match the lowest type in whole family tree
|
|||
|
||||
- class: [`Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector`](../rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(DowngradeParameterTypeWideningRector::class, [
|
||||
'ContainerInterface' => [
|
||||
'set',
|
||||
'get',
|
||||
'has',
|
||||
'initialized',
|
||||
],
|
||||
'SomeContainerInterface' => [
|
||||
'set',
|
||||
'has',
|
||||
],
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
interface SomeInterface
|
||||
{
|
||||
|
@ -927,19 +744,6 @@ return static function (RectorConfig $rectorConfig): void {
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradePhp71JsonConstRector
|
||||
|
||||
Remove Json constant that available only in php 7.1
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\ConstFetch\DowngradePhp71JsonConstRector`](../rules/DowngradePhp71/Rector/ConstFetch/DowngradePhp71JsonConstRector.php)
|
||||
|
||||
```diff
|
||||
-json_encode($content, JSON_UNESCAPED_LINE_TERMINATORS);
|
||||
+json_encode($content, 0);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradePhp72JsonConstRector
|
||||
|
||||
Remove Json constant that available only in php 7.2
|
||||
|
@ -1041,25 +845,6 @@ change instanceof Object to is_resource
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradePipeToMultiCatchExceptionRector
|
||||
|
||||
Downgrade single one | separated to multi catch exception
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector`](../rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php)
|
||||
|
||||
```diff
|
||||
try {
|
||||
// Some code...
|
||||
-} catch (ExceptionType1 | ExceptionType2 $exception) {
|
||||
+} catch (ExceptionType1 $exception) {
|
||||
+ $sameCode;
|
||||
+} catch (ExceptionType2 $exception) {
|
||||
$sameCode;
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradePregUnmatchedAsNullConstantRector
|
||||
|
||||
Remove PREG_UNMATCHED_AS_NULL from preg_match and set null value on empty string matched on each match
|
||||
|
@ -1300,6 +1085,27 @@ Downgrade `ReflectionProperty->getDefaultValue()`
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeSetAccessibleReflectionPropertyRector
|
||||
|
||||
Add `setAccessible()` on ReflectionProperty to allow reading private properties in PHP 8.0-
|
||||
|
||||
- class: [`Rector\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector`](../rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run($object)
|
||||
{
|
||||
$reflectionProperty = new ReflectionProperty($object, 'bar');
|
||||
+ $reflectionProperty->setAccessible(true);
|
||||
|
||||
return $reflectionProperty->getValue($object);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeStaticTypeDeclarationRector
|
||||
|
||||
Remove "static" return and param type, add a `"@param` `$this"` and `"@return` `$this"` tag instead
|
||||
|
@ -1603,27 +1409,6 @@ Removes union type property type definition, adding `@var` annotations instead.
|
|||
|
||||
<br>
|
||||
|
||||
## DowngradeVoidTypeDeclarationRector
|
||||
|
||||
Remove "void" return type, add a `"@return` void" tag instead
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector`](../rules/DowngradePhp71/Rector/FunctionLike/DowngradeVoidTypeDeclarationRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
- public function run(): void
|
||||
+ /**
|
||||
+ * @return void
|
||||
+ */
|
||||
+ public function run()
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## RemoveReturnTypeDeclarationFromCloneRector
|
||||
|
||||
Remove return type from `__clone()` method
|
||||
|
@ -1654,16 +1439,3 @@ Convert setcookie option array to arguments
|
|||
```
|
||||
|
||||
<br>
|
||||
|
||||
## SymmetricArrayDestructuringToListRector
|
||||
|
||||
Downgrade Symmetric array destructuring to `list()` function
|
||||
|
||||
- class: [`Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector`](../rules/DowngradePhp71/Rector/Array_/SymmetricArrayDestructuringToListRector.php)
|
||||
|
||||
```diff
|
||||
-[$id1, $name1] = $data;
|
||||
+list($id1, $name1) = $data;
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
10
vendor/rector/rector-phpunit/composer.json
vendored
10
vendor/rector/rector-phpunit/composer.json
vendored
|
@ -12,19 +12,19 @@
|
|||
"phpstan\/phpstan": "^1.10.25",
|
||||
"symplify\/phpstan-rules": "^11.4",
|
||||
"symplify\/phpstan-extensions": "^11.2",
|
||||
"symplify\/easy-coding-standard": "^11.5",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"phpstan\/extension-installer": "^1.3",
|
||||
"phpstan\/phpstan-strict-rules": "^1.5",
|
||||
"phpstan\/phpstan-webmozart-assert": "^1.2.2",
|
||||
"symplify\/vendor-patches": "^11.2.0",
|
||||
"symplify\/easy-ci": "^11.2.0",
|
||||
"rector\/rector-generator": "^0.6.15",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"tomasvotruba\/type-coverage": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.2",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/class-leak": "0.0.22.72"
|
||||
"tomasvotruba\/class-leak": "^0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 45 Rules Overview
|
||||
# 46 Rules Overview
|
||||
|
||||
## AddDoesNotPerformAssertionToNonAssertingTestRector
|
||||
|
||||
|
@ -77,27 +77,6 @@ Change annotations with value to attribute
|
|||
|
||||
- class: [`Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector`](../rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [
|
||||
new AnnotationWithValueToAttribute('backupGlobals', 'PHPUnit\Framework\Attributes\BackupGlobals', [
|
||||
true,
|
||||
false,
|
||||
]),
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
+use PHPUnit\Framework\Attributes\BackupGlobals;
|
||||
|
@ -977,6 +956,27 @@ Change `@testWith()` annotation to #[TestWith] attribute
|
|||
|
||||
<br>
|
||||
|
||||
## TicketAnnotationToAttributeRector
|
||||
|
||||
Change annotations with value to attribute
|
||||
|
||||
- class: [`Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\TicketAnnotationToAttributeRector`](../rules/AnnotationsToAttributes/Rector/Class_/TicketAnnotationToAttributeRector.php)
|
||||
|
||||
```diff
|
||||
use PHPUnit\Framework\TestCase;
|
||||
+use PHPUnit\Framework\Attributes\Ticket;
|
||||
|
||||
-/**
|
||||
- * @ticket 123
|
||||
- */
|
||||
+#[Ticket('123')]
|
||||
final class SomeTest extends TestCase
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## UseSpecificWillMethodRector
|
||||
|
||||
Changes `$mock->will()` call to more specific method
|
||||
|
|
6
vendor/rector/rector-symfony/composer.json
vendored
6
vendor/rector/rector-symfony/composer.json
vendored
|
@ -14,7 +14,7 @@
|
|||
"phpstan\/phpstan-webmozart-assert": "^1.2",
|
||||
"phpunit\/phpunit": "^10.3",
|
||||
"rector\/phpstan-rules": "^0.6",
|
||||
"rector\/rector-generator": "^0.6",
|
||||
"rector\/rector-generator": "^0.7",
|
||||
"rector\/rector-src": "dev-main",
|
||||
"symfony\/routing": "^6.1",
|
||||
"symfony\/security-core": "^6.2",
|
||||
|
@ -24,9 +24,9 @@
|
|||
"symplify\/easy-coding-standard": "^12.0",
|
||||
"symplify\/phpstan-extensions": "^11.1",
|
||||
"symplify\/phpstan-rules": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^11.2",
|
||||
"symplify\/rule-doc-generator": "^12.0",
|
||||
"symplify\/vendor-patches": "^11.2",
|
||||
"tomasvotruba\/class-leak": "0.1.1.72",
|
||||
"tomasvotruba\/class-leak": "^0.1",
|
||||
"tomasvotruba\/cognitive-complexity": "^0.1",
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.2"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 82 Rules Overview
|
||||
# 81 Rules Overview
|
||||
|
||||
## ActionSuffixRemoverRector
|
||||
|
||||
|
@ -22,7 +22,7 @@ Removes Action suffixes from methods in Symfony Controllers
|
|||
|
||||
Collect routes from Symfony project router and add Route annotation to controller action
|
||||
|
||||
- class: [`Rector\Symfony\Rector\ClassMethod\AddRouteAnnotationRector`](../src/Rector/ClassMethod/AddRouteAnnotationRector.php)
|
||||
- class: [`Rector\Symfony\Configs\Rector\ClassMethod\AddRouteAnnotationRector`](../rules/Configs/Rector/ClassMethod/AddRouteAnnotationRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -549,40 +549,6 @@ Changes createForm(new FormType), add(new FormType) to ones with "FormType::clas
|
|||
|
||||
<br>
|
||||
|
||||
## FormTypeWithDependencyToOptionsRector
|
||||
|
||||
Move constructor dependency from form type class to an `$options` parameter
|
||||
|
||||
- class: [`Rector\Symfony\Symfony30\Rector\Class_\FormTypeWithDependencyToOptionsRector`](../rules/Symfony30/Rector/Class_/FormTypeWithDependencyToOptionsRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final class FormTypeWithDependency extends AbstractType
|
||||
{
|
||||
- private Agent $agent;
|
||||
-
|
||||
- public function __construct(Agent $agent)
|
||||
+ public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
- $this->agent = $agent;
|
||||
- }
|
||||
+ $agent = $options['agent'];
|
||||
|
||||
- public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
- {
|
||||
- if ($this->agent) {
|
||||
+ if ($agent) {
|
||||
$builder->add('agent', TextType::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## GetCurrencyBundleMethodCallsToIntlRector
|
||||
|
||||
Intl static bundle method were changed to direct static calls
|
||||
|
@ -1314,26 +1280,6 @@ Replace defined `service()` argument in Symfony PHP config
|
|||
|
||||
- class: [`Rector\Symfony\Symfony60\Rector\FuncCall\ReplaceServiceArgumentRector`](../rules/Symfony60/Rector/FuncCall/ReplaceServiceArgumentRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Symfony\Symfony60\Rector\FuncCall\ReplaceServiceArgumentRector;
|
||||
use Rector\Symfony\ValueObject\ReplaceServiceArgument;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [
|
||||
new ReplaceServiceArgument('ContainerInterface', new String_('service_container', [
|
||||
])),
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
|
||||
|
@ -1444,7 +1390,7 @@ Change RouteCollectionBuilder to RoutingConfiguratorRector
|
|||
|
||||
Converts order-dependent arguments `args()` to named `arg()` call
|
||||
|
||||
- class: [`Rector\Symfony\Rector\Closure\ServiceArgsToServiceNamedArgRector`](../src/Rector/Closure/ServiceArgsToServiceNamedArgRector.php)
|
||||
- class: [`Rector\Symfony\Configs\Rector\Closure\ServiceArgsToServiceNamedArgRector`](../rules/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
@ -1464,7 +1410,7 @@ Converts order-dependent arguments `args()` to named `arg()` call
|
|||
|
||||
Change `$service->set()` string names to class-type-based names, to allow `$container->get()` by types in Symfony 2.8. Provide XML config via `$rectorConfig->symfonyContainerXml(...);`
|
||||
|
||||
- class: [`Rector\Symfony\Rector\Closure\ServiceSetStringNameToClassNameRector`](../src/Rector/Closure/ServiceSetStringNameToClassNameRector.php)
|
||||
- class: [`Rector\Symfony\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector`](../rules/Configs/Rector/Closure/ServiceSetStringNameToClassNameRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
@ -1483,7 +1429,7 @@ Change `$service->set()` string names to class-type-based names, to allow `$cont
|
|||
|
||||
Change `$services->set(...,` ...) to `$services->load(...,` ...) where meaningful
|
||||
|
||||
- class: [`Rector\Symfony\Rector\Closure\ServiceSettersToSettersAutodiscoveryRector`](../src/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector.php)
|
||||
- class: [`Rector\Symfony\Configs\Rector\Closure\ServiceSettersToSettersAutodiscoveryRector`](../rules/Configs/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
@ -1508,7 +1454,7 @@ Change `$services->set(...,` ...) to `$services->load(...,` ...) where meaningfu
|
|||
|
||||
Change `$services->set(...,` ...)->tag(...) to `$services->defaults()->autodiscovery()` where meaningful
|
||||
|
||||
- class: [`Rector\Symfony\Rector\Closure\ServiceTagsToDefaultsAutoconfigureRector`](../src/Rector/Closure/ServiceTagsToDefaultsAutoconfigureRector.php)
|
||||
- class: [`Rector\Symfony\Configs\Rector\Closure\ServiceTagsToDefaultsAutoconfigureRector`](../rules/Configs/Rector/Closure/ServiceTagsToDefaultsAutoconfigureRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
@ -1531,7 +1477,7 @@ Change `$services->set(...,` ...)->tag(...) to `$services->defaults()->autodisco
|
|||
|
||||
Change `$services->set("name_type",` SomeType::class) to bare type, useful since Symfony 3.4
|
||||
|
||||
- class: [`Rector\Symfony\Rector\Closure\ServicesSetNameToSetTypeRector`](../src/Rector/Closure/ServicesSetNameToSetTypeRector.php)
|
||||
- class: [`Rector\Symfony\Configs\Rector\Closure\ServicesSetNameToSetTypeRector`](../rules/Configs/Rector/Closure/ServicesSetNameToSetTypeRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
|
Loading…
Reference in New Issue
Block a user