mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit d2ff17ea434ef68e13e62126ec463002e861eaba
d2ff17ea43
[Php81] Skip assigned after defined as constructor promotion on ReadOnlyPropertyRector (#2976)
This commit is contained in:
parent
65656583c8
commit
edf6290721
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"phpstan/phpstan": "^1.8.6"
|
||||
"phpstan/phpstan": "^1.8.7"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
|
|
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
|||
namespace Rector\Php70\Rector\FuncCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Name;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
|
@ -44,8 +45,12 @@ final class CallUserMethodRector extends AbstractRector implements MinPhpVersion
|
|||
if (!$this->isNames($node, $oldFunctionNames)) {
|
||||
return null;
|
||||
}
|
||||
if ($node->isFirstClassCallable()) {
|
||||
return null;
|
||||
}
|
||||
$newName = self::OLD_TO_NEW_FUNCTIONS[$this->getName($node)];
|
||||
$node->name = new Name($newName);
|
||||
/** @var Arg[] $oldArgs */
|
||||
$oldArgs = $node->args;
|
||||
unset($node->args[1]);
|
||||
$newArgs = [$this->nodeFactory->createArg([$oldArgs[1]->value, $oldArgs[0]->value])];
|
||||
|
|
|
@ -5,12 +5,20 @@ namespace Rector\Php81\Rector\Property;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\NodeTraverser;
|
||||
use Rector\Core\NodeAnalyzer\ParamAnalyzer;
|
||||
use Rector\Core\NodeManipulator\PropertyFetchAssignManipulator;
|
||||
use Rector\Core\NodeManipulator\PropertyManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\Core\ValueObject\Visibility;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
@ -154,7 +162,35 @@ CODE_SAMPLE
|
|||
if ($this->paramAnalyzer->isParamReassign($param)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->isPromotedPropertyAssigned($param)) {
|
||||
return null;
|
||||
}
|
||||
$this->visibilityManipulator->makeReadonly($param);
|
||||
return $param;
|
||||
}
|
||||
private function isPromotedPropertyAssigned(Param $param) : bool
|
||||
{
|
||||
$classLike = $this->betterNodeFinder->findParentType($param, ClassLike::class);
|
||||
if (!$classLike instanceof Class_) {
|
||||
return \false;
|
||||
}
|
||||
$constructClassMethod = $classLike->getMethod(MethodName::CONSTRUCT);
|
||||
if (!$constructClassMethod instanceof ClassMethod) {
|
||||
return \false;
|
||||
}
|
||||
if ($param->flags === 0) {
|
||||
return \false;
|
||||
}
|
||||
$propertyFetch = new PropertyFetch(new Variable('this'), $this->getName($param));
|
||||
$stmts = $classLike->stmts;
|
||||
$isAssigned = \false;
|
||||
$this->traverseNodesWithCallable($stmts, function (Node $node) use($propertyFetch, &$isAssigned) : ?int {
|
||||
if ($node instanceof Assign && $this->nodeComparator->areNodesEqual($propertyFetch, $node->var)) {
|
||||
$isAssigned = \true;
|
||||
return NodeTraverser::STOP_TRAVERSAL;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return $isAssigned;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f8e42e16e1f153548d727bda550330ceeca223a5';
|
||||
public const PACKAGE_VERSION = 'd2ff17ea434ef68e13e62126ec463002e861eaba';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-10-04 10:31:39';
|
||||
public const RELEASE_DATE = '2022-10-05 11:10:36';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\StaticReflection\SourceLocator;
|
||||
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PHPStan\BetterReflection\Identifier\Identifier;
|
||||
use PHPStan\BetterReflection\Identifier\IdentifierType;
|
||||
use PHPStan\BetterReflection\Reflection\Reflection;
|
||||
|
@ -57,7 +55,7 @@ final class ParentAttributeSourceLocator implements SourceLocator
|
|||
$class->namespacedName = new FullyQualified($identifierName);
|
||||
$fakeLocatedSource = new LocatedSource('virtual', null);
|
||||
$classReflector = new ClassReflector($this);
|
||||
return ReflectionClass::createFromNode($classReflector, $class, $fakeLocatedSource, new Namespace_(new Name('Symfony\\Component\\DependencyInjection\\Attribute')));
|
||||
return ReflectionClass::createFromNode($classReflector, $class, $fakeLocatedSource, 'Symfony\\Component\\DependencyInjection\\Attribute');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1d56f4a3a3eebb595788e1ba032c2af7::getLoader();
|
||||
return ComposerAutoloaderInit45fdab5520b0b6233450107260c3a6a8::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1d56f4a3a3eebb595788e1ba032c2af7
|
||||
class ComposerAutoloaderInit45fdab5520b0b6233450107260c3a6a8
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit1d56f4a3a3eebb595788e1ba032c2af7
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1d56f4a3a3eebb595788e1ba032c2af7', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit45fdab5520b0b6233450107260c3a6a8', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1d56f4a3a3eebb595788e1ba032c2af7', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit45fdab5520b0b6233450107260c3a6a8', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit45fdab5520b0b6233450107260c3a6a8::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit45fdab5520b0b6233450107260c3a6a8::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1d56f4a3a3eebb595788e1ba032c2af7($fileIdentifier, $file);
|
||||
composerRequire45fdab5520b0b6233450107260c3a6a8($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit1d56f4a3a3eebb595788e1ba032c2af7
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire1d56f4a3a3eebb595788e1ba032c2af7($fileIdentifier, $file)
|
||||
function composerRequire45fdab5520b0b6233450107260c3a6a8($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7
|
||||
class ComposerStaticInit45fdab5520b0b6233450107260c3a6a8
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3087,9 +3087,9 @@ class ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1d56f4a3a3eebb595788e1ba032c2af7::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit45fdab5520b0b6233450107260c3a6a8::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit45fdab5520b0b6233450107260c3a6a8::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit45fdab5520b0b6233450107260c3a6a8::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -733,17 +733,17 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan\/phpstan",
|
||||
"version": "1.8.6",
|
||||
"version_normalized": "1.8.6.0",
|
||||
"version": "1.8.7",
|
||||
"version_normalized": "1.8.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpstan.git",
|
||||
"reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618"
|
||||
"reference": "536ff0ed719b5679e9f09c17aeaee9b31969cb8e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/c386ab2741e64cc9e21729f891b28b2b10fe6618",
|
||||
"reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/536ff0ed719b5679e9f09c17aeaee9b31969cb8e",
|
||||
"reference": "536ff0ed719b5679e9f09c17aeaee9b31969cb8e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -752,7 +752,7 @@
|
|||
"conflict": {
|
||||
"phpstan\/phpstan-shim": "*"
|
||||
},
|
||||
"time": "2022-09-23T09:54:39+00:00",
|
||||
"time": "2022-10-04T14:09:33+00:00",
|
||||
"bin": [
|
||||
"phpstan",
|
||||
"phpstan.phar"
|
||||
|
@ -775,7 +775,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpstan\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/1.8.6"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/1.8.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -1,16 +1,16 @@
|
|||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmMtglMACgkQzxoQjQ56
|
||||
5yCU9g//cwPTwr8P0XM8XSTMvxVJQrxdCFpYAtoxiDYTM8ZG+6Tg/rntwfhnKBqV
|
||||
vqsf0LVROvYNEK/Oo4syE5Lb5BwfJm99XhIZoVnDL15cJgYHHVAZtc3jD+8FwdAk
|
||||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oNsDqhsfzniSYzoIMoxVVabLrm16v12s++4wIw6HrH
|
||||
uiHmvSiAME/emrIu0PM9mJfRT9md4v3Zk21jT9GOLo90OmTA8JnEQ5m4yJeGwSIl
|
||||
qJcpTMnV7hwTfjPsQrB+6B0KeZbN7ixsuJOKAVSvmyVLRsea4scfWhSHvUEoYp8m
|
||||
ariLjImnxNZLUgvTdzt+2HCqn4i88p5veMUtVAaaFoxScEDTmvZbgeXf/Ai9QQ1l
|
||||
/reZ8D+ZLZa94Np9J8wcOPMloZ+ITZjGIgM2sx1Yo+EwFio73OnCN1rVOWXroZxW
|
||||
LmCBOXdx4uxxBdY7Qd2jtPvzjy+YmbG4gYFFGd24FUk9AfqZUE4=
|
||||
=ttXB
|
||||
-----END PGP SIGNATURE-----
|
||||
|
|
Loading…
Reference in New Issue