Skip to content

Commit 55e8da6

Browse files
committed
Updated Rector to commit 21b60910ad5526c24c3b812c7dec754e1be9ef52
rectorphp/rector-src@21b6091 [CodeQuality] Handle property fetch and common nodes crash on InlineArrayReturnAssignRector (#7437)
1 parent 045c19d commit 55e8da6

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
4545
$namespace = $scope instanceof Scope ? $scope->getNamespace() : null;
4646
$namespace = strtolower((string) $namespace);
4747
$shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered();
48-
$fullyQualifiedObjectTypeNamespace = strtolower(substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) ?: '');
48+
$subClassName = substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1);
49+
$fullyQualifiedObjectTypeNamespace = strtolower((string) $subClassName);
4950
foreach ($classLikeNames as $classLikeName) {
5051
if (strtolower($classLikeName) !== $shortNameLowered) {
5152
continue;

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '24b76ca1eead8bb095d9dd769a5ace4dfde79915';
22+
public const PACKAGE_VERSION = '21b60910ad5526c24c3b812c7dec754e1be9ef52';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-10-06 20:29:26';
27+
public const RELEASE_DATE = '2025-10-07 04:09:59';
2828
/**
2929
* @var int
3030
*/

src/PhpParser/Node/NodeFactory.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@
2222
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
2323
use PhpParser\Node\Expr\Cast;
2424
use PhpParser\Node\Expr\ClassConstFetch;
25+
use PhpParser\Node\Expr\Clone_;
2526
use PhpParser\Node\Expr\ConstFetch;
2627
use PhpParser\Node\Expr\FuncCall;
28+
use PhpParser\Node\Expr\Instanceof_;
2729
use PhpParser\Node\Expr\MethodCall;
2830
use PhpParser\Node\Expr\New_;
31+
use PhpParser\Node\Expr\NullsafeMethodCall;
32+
use PhpParser\Node\Expr\NullsafePropertyFetch;
2933
use PhpParser\Node\Expr\PropertyFetch;
3034
use PhpParser\Node\Expr\StaticCall;
3135
use PhpParser\Node\Expr\StaticPropertyFetch;
@@ -43,7 +47,6 @@
4347
use PHPStan\Type\Type;
4448
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
4549
use Rector\Enum\ObjectReference;
46-
use Rector\Exception\NotImplementedYetException;
4750
use Rector\Exception\ShouldNotHappenException;
4851
use Rector\NodeDecorator\PropertyTypeDecorator;
4952
use Rector\NodeTypeResolver\Node\AttributeKey;
@@ -346,7 +349,7 @@ public function createReprintedNode(Node $node): Node
346349
private function createArrayItem($item, $key = null): ArrayItem
347350
{
348351
$arrayItem = null;
349-
if ($item instanceof Variable || $item instanceof MethodCall || $item instanceof StaticCall || $item instanceof FuncCall || $item instanceof Concat || $item instanceof Scalar || $item instanceof Cast || $item instanceof ConstFetch) {
352+
if ($item instanceof Variable || $item instanceof MethodCall || $item instanceof StaticCall || $item instanceof FuncCall || $item instanceof Concat || $item instanceof Scalar || $item instanceof Cast || $item instanceof ConstFetch || $item instanceof PropertyFetch || $item instanceof StaticPropertyFetch || $item instanceof NullsafePropertyFetch || $item instanceof NullsafeMethodCall || $item instanceof Clone_ || $item instanceof Instanceof_) {
350353
$arrayItem = new ArrayItem($item);
351354
} elseif ($item instanceof Identifier) {
352355
$string = new String_($item->toString());
@@ -376,8 +379,16 @@ private function createArrayItem($item, $key = null): ArrayItem
376379
$this->decorateArrayItemWithKey($key, $arrayItem);
377380
return $arrayItem;
378381
}
379-
$nodeClass = is_object($item) ? get_class($item) : $item;
380-
throw new NotImplementedYetException(sprintf('Not implemented yet. Go to "%s()" and add check for "%s" node.', __METHOD__, (string) $nodeClass));
382+
// fallback to other nodes
383+
if ($item instanceof Expr) {
384+
$arrayItem = new ArrayItem($item);
385+
$this->decorateArrayItemWithKey($key, $arrayItem);
386+
return $arrayItem;
387+
}
388+
$itemValue = BuilderHelpers::normalizeValue($item);
389+
$arrayItem = new ArrayItem($itemValue);
390+
$this->decorateArrayItemWithKey($key, $arrayItem);
391+
return $arrayItem;
381392
}
382393
/**
383394
* @param int|string|null $key

0 commit comments

Comments
 (0)