Skip to content

Commit 4c6535f

Browse files
committed
Updated Rector to commit 27c0087701a3668d9418f063f186ecdc3e561aa1
rectorphp/rector-src@27c0087 [TypeDeclarationDocblocks] Skip overridden methods in DocblockReturnArrayFromDirectArrayInstanceRector (#7995)
1 parent 5e27326 commit 4c6535f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

rules/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Rector\TypeDeclarationDocblocks\NodeFinder\ReturnNodeFinder;
1919
use Rector\TypeDeclarationDocblocks\TagNodeAnalyzer\UsefulArrayTagNodeAnalyzer;
2020
use Rector\TypeDeclarationDocblocks\TypeResolver\ConstantArrayTypeGeneralizer;
21+
use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard;
2122
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
2223
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
2324
/**
@@ -45,13 +46,18 @@ final class DocblockReturnArrayFromDirectArrayInstanceRector extends AbstractRec
4546
* @readonly
4647
*/
4748
private UsefulArrayTagNodeAnalyzer $usefulArrayTagNodeAnalyzer;
48-
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, ConstantArrayTypeGeneralizer $constantArrayTypeGeneralizer, ReturnNodeFinder $returnNodeFinder, UsefulArrayTagNodeAnalyzer $usefulArrayTagNodeAnalyzer)
49+
/**
50+
* @readonly
51+
*/
52+
private ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard;
53+
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, ConstantArrayTypeGeneralizer $constantArrayTypeGeneralizer, ReturnNodeFinder $returnNodeFinder, UsefulArrayTagNodeAnalyzer $usefulArrayTagNodeAnalyzer, ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard)
4954
{
5055
$this->phpDocInfoFactory = $phpDocInfoFactory;
5156
$this->phpDocTypeChanger = $phpDocTypeChanger;
5257
$this->constantArrayTypeGeneralizer = $constantArrayTypeGeneralizer;
5358
$this->returnNodeFinder = $returnNodeFinder;
5459
$this->usefulArrayTagNodeAnalyzer = $usefulArrayTagNodeAnalyzer;
60+
$this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard;
5561
}
5662
public function getNodeTypes(): array
5763
{
@@ -94,6 +100,10 @@ public function refactor(Node $node): ?Node
94100
if ($node->stmts === null) {
95101
return null;
96102
}
103+
// skip overridden methods to not conflict with parent/interface @return docblock
104+
if ($node instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) {
105+
return null;
106+
}
97107
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
98108
if ($this->usefulArrayTagNodeAnalyzer->isUsefulArrayTag($phpDocInfo->getReturnTagValue())) {
99109
return null;

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 = '4a063f8f8fb0140aba23b0e222c477e58cd37675';
22+
public const PACKAGE_VERSION = '27c0087701a3668d9418f063f186ecdc3e561aa1';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-05-17 09:30:21';
27+
public const RELEASE_DATE = '2026-05-18 08:22:07';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)