mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 5647e1b818482552a447d7f79392c7e2f0dce86e
5647e1b818
[Naming] Fix dotted name on generics bug in RenameVariableToMatchMethodCallReturnTypeRector (#5250)
This commit is contained in:
parent
9aef117ab1
commit
4f6134d1be
@ -14,6 +14,7 @@ use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use Rector\Core\NodeAnalyzer\VariableAnalyzer;
|
||||
use Rector\Core\Php\ReservedKeywordAnalyzer;
|
||||
@ -81,10 +82,10 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class, Stmt\Function_::class];
|
||||
return [ClassMethod::class, Function_::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod|Stmt\Function_ $node
|
||||
* @param ClassMethod|Function_ $node
|
||||
* @return null|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_
|
||||
*/
|
||||
public function refactorWithScope(Node $node, Scope $scope)
|
||||
|
@ -13,7 +13,6 @@ use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\UnionType;
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Naming\ExpectedNameResolver\MatchParamTypeExpectedNameResolver;
|
||||
@ -113,10 +112,7 @@ final class ExpectedNameResolver
|
||||
return null;
|
||||
}
|
||||
$returnedType = $this->nodeTypeResolver->getType($expr);
|
||||
if ($returnedType instanceof ArrayType) {
|
||||
return null;
|
||||
}
|
||||
if ($returnedType instanceof MixedType) {
|
||||
if (!$returnedType->isObject()->yes()) {
|
||||
return null;
|
||||
}
|
||||
if ($this->isDateTimeType($returnedType)) {
|
||||
|
@ -73,6 +73,11 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRect
|
||||
* @see https://regex101.com/r/JG5w9j/1
|
||||
*/
|
||||
private const OR_BETWEEN_WORDS_REGEX = '#[a-z]Or[A-Z]#';
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/TV8YXZ/1
|
||||
*/
|
||||
private const VALID_VARIABLE_NAME_REGEX = '#^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$#';
|
||||
public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, NamingConventionAnalyzer $namingConventionAnalyzer, VarTagValueNodeRenamer $varTagValueNodeRenamer, VariableAndCallAssignMatcher $variableAndCallAssignMatcher, VariableRenamer $variableRenamer, DocBlockUpdater $docBlockUpdater, PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->breakingVariableRenameGuard = $breakingVariableRenameGuard;
|
||||
@ -161,6 +166,9 @@ CODE_SAMPLE
|
||||
}
|
||||
private function shouldSkip(VariableAndCallAssign $variableAndCallAssign, string $expectedName) : bool
|
||||
{
|
||||
if (Strings::match($expectedName, self::VALID_VARIABLE_NAME_REGEX) === null) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->namingConventionAnalyzer->isCallMatchingVariableName($variableAndCallAssign->getCall(), $variableAndCallAssign->getVariableName(), $expectedName)) {
|
||||
return \true;
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7ec1be6b828042b27e3f40ed41b3285a6fe78502';
|
||||
public const PACKAGE_VERSION = '5647e1b818482552a447d7f79392c7e2f0dce86e';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-11-14 22:16:03';
|
||||
public const RELEASE_DATE = '2023-11-15 07:38:05';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -504,8 +504,8 @@
|
||||
},
|
||||
{
|
||||
"name": "illuminate\/container",
|
||||
"version": "v10.32.0",
|
||||
"version_normalized": "10.32.0.0",
|
||||
"version": "v10.32.1",
|
||||
"version_normalized": "10.32.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/illuminate\/container.git",
|
||||
@ -561,8 +561,8 @@
|
||||
},
|
||||
{
|
||||
"name": "illuminate\/contracts",
|
||||
"version": "v10.32.0",
|
||||
"version_normalized": "10.32.0.0",
|
||||
"version": "v10.32.1",
|
||||
"version_normalized": "10.32.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/illuminate\/contracts.git",
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user