Skip to content

Commit

Permalink
Updated Rector to commit 5647e1b818482552a447d7f79392c7e2f0dce86e
Browse files Browse the repository at this point in the history
rectorphp/rector-src@5647e1b [Naming] Fix dotted name on generics bug in RenameVariableToMatchMethodCallReturnTypeRector (#5250)
  • Loading branch information
TomasVotruba committed Nov 15, 2023
1 parent 9aef117 commit 4f6134d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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;
Expand Down Expand Up @@ -81,10 +82,10 @@ public function run()
*/
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)
Expand Down
6 changes: 1 addition & 5 deletions rules/Naming/Naming/ExpectedNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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;
Expand Down Expand Up @@ -113,10 +112,7 @@ public function resolveForCall($expr) : ?string
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,6 +166,9 @@ public function refactor(Node $node) : ?Node
}
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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

0 comments on commit 4f6134d

Please sign in to comment.