Skip to content

Commit 3f9080e

Browse files
committed
Updated Rector to commit dfa70694d2cdbb5342ab784176ede1f8e27f18b4
rectorphp/rector-src@dfa7069 [TypeDeclarationDocblocks] Skip docblock already defined in parent on DocblockVarArrayFromPropertyDefaultsRector (#8085)
1 parent 407fbbf commit 3f9080e

23 files changed

Lines changed: 199 additions & 70 deletions

rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
declare (strict_types=1);
44
namespace Rector\TypeDeclarationDocblocks\Rector\Class_;
55

6+
use PhpParser\Comment\Doc;
67
use PhpParser\Node;
78
use PhpParser\Node\Expr\Array_;
89
use PhpParser\Node\Identifier;
10+
use PhpParser\Node\PropertyItem;
911
use PhpParser\Node\Stmt\Class_;
12+
use PhpParser\Node\Stmt\Property;
13+
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
14+
use PHPStan\Reflection\ClassReflection;
15+
use PHPStan\Reflection\Php\PhpPropertyReflection;
16+
use PHPStan\Type\Type;
1017
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
18+
use Rector\PHPStan\ScopeFetcher;
1119
use Rector\Rector\AbstractRector;
1220
use Rector\TypeDeclarationDocblocks\NodeDocblockTypeDecorator;
1321
use Rector\TypeDeclarationDocblocks\TagNodeAnalyzer\UsefulArrayTagNodeAnalyzer;
@@ -85,6 +93,9 @@ public function refactor(Node $node): ?Node
8593
if ($this->usefulArrayTagNodeAnalyzer->isUsefulArrayTag($propertyPhpDocInfo->getVarTagValueNode())) {
8694
continue;
8795
}
96+
if ($this->hasUsefulParentPropertyVarTag($node, $property, $propertyDefaultType)) {
97+
continue;
98+
}
8899
if ($this->nodeDocblockTypeDecorator->decorateGenericIterableVarType($propertyDefaultType, $propertyPhpDocInfo, $property)) {
89100
$hasChanged = \true;
90101
}
@@ -94,4 +105,50 @@ public function refactor(Node $node): ?Node
94105
}
95106
return $node;
96107
}
108+
private function hasUsefulParentPropertyVarTag(Class_ $class, Property $property, Type $propertyDefaultType): bool
109+
{
110+
$propertyName = $this->getName($property);
111+
if ($propertyName === null) {
112+
return \false;
113+
}
114+
// private property doesn't override parent property
115+
if ($property->isPrivate()) {
116+
return \false;
117+
}
118+
$scope = ScopeFetcher::fetch($class);
119+
$classReflection = $scope->getClassReflection();
120+
if (!$classReflection instanceof ClassReflection) {
121+
return \false;
122+
}
123+
foreach ($classReflection->getParents() as $parentClassReflection) {
124+
if (!$parentClassReflection->hasNativeProperty($propertyName)) {
125+
continue;
126+
}
127+
$parentPropertyReflection = $parentClassReflection->getNativeProperty($propertyName);
128+
if ($parentPropertyReflection->isPrivate()) {
129+
return \false;
130+
}
131+
if (!$parentPropertyReflection->hasPhpDocType()) {
132+
continue;
133+
}
134+
$varTagValueNode = $this->resolveVarTagValueNode($parentPropertyReflection);
135+
if (!$this->usefulArrayTagNodeAnalyzer->isUsefulArrayTag($varTagValueNode)) {
136+
continue;
137+
}
138+
if ($parentPropertyReflection->getPhpDocType()->isSuperTypeOf($propertyDefaultType)->yes()) {
139+
return \true;
140+
}
141+
}
142+
return \false;
143+
}
144+
private function resolveVarTagValueNode(PhpPropertyReflection $phpPropertyReflection): ?VarTagValueNode
145+
{
146+
$docComment = $phpPropertyReflection->getDocComment();
147+
if ($docComment === null) {
148+
return null;
149+
}
150+
$property = new Property(0, [new PropertyItem($phpPropertyReflection->getName())]);
151+
$property->setDocComment(new Doc($docComment));
152+
return $this->phpDocInfoFactory->createFromNodeOrEmpty($property)->getVarTagValueNode();
153+
}
97154
}

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 = 'b163af7942a0e7ba09a75238362eca373a915194';
22+
public const PACKAGE_VERSION = 'dfa70694d2cdbb5342ab784176ede1f8e27f18b4';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-06-26 17:57:17';
27+
public const RELEASE_DATE = '2026-06-27 14:40:46';
2828
/**
2929
* @var int
3030
*/

vendor/composer/installed.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,16 +1802,16 @@
18021802
"source": {
18031803
"type": "git",
18041804
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
1805-
"reference": "ee4dc09c2ef6e6699d66c59299a4f4c41e6c988d"
1805+
"reference": "b1f6d13de124aa4eb58923440e5a793cdb91d7f1"
18061806
},
18071807
"dist": {
18081808
"type": "zip",
1809-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/ee4dc09c2ef6e6699d66c59299a4f4c41e6c988d",
1810-
"reference": "ee4dc09c2ef6e6699d66c59299a4f4c41e6c988d",
1809+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/b1f6d13de124aa4eb58923440e5a793cdb91d7f1",
1810+
"reference": "b1f6d13de124aa4eb58923440e5a793cdb91d7f1",
18111811
"shasum": ""
18121812
},
18131813
"require": {
1814-
"php": ">=8.3"
1814+
"php": ">=8.4"
18151815
},
18161816
"conflict": {
18171817
"rector\/rector": "<2.0"
@@ -1835,7 +1835,7 @@
18351835
"tomasvotruba\/unused-public": "^2.2",
18361836
"tracy\/tracy": "^2.11"
18371837
},
1838-
"time": "2026-06-26T10:15:26+00:00",
1838+
"time": "2026-06-26T16:13:06+00:00",
18391839
"default-branch": true,
18401840
"type": "rector-extension",
18411841
"extra": {
@@ -2003,17 +2003,17 @@
20032003
},
20042004
{
20052005
"name": "symfony\/console",
2006-
"version": "v6.4.41",
2007-
"version_normalized": "6.4.41.0",
2006+
"version": "v6.4.42",
2007+
"version_normalized": "6.4.42.0",
20082008
"source": {
20092009
"type": "git",
20102010
"url": "https:\/\/github.com\/symfony\/console.git",
2011-
"reference": "d21b17ed158e79180fac3895ff751707970eeb57"
2011+
"reference": "9ef84af84a7b66396da483634227650506428639"
20122012
},
20132013
"dist": {
20142014
"type": "zip",
2015-
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/d21b17ed158e79180fac3895ff751707970eeb57",
2016-
"reference": "d21b17ed158e79180fac3895ff751707970eeb57",
2015+
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/9ef84af84a7b66396da483634227650506428639",
2016+
"reference": "9ef84af84a7b66396da483634227650506428639",
20172017
"shasum": ""
20182018
},
20192019
"require": {
@@ -2046,7 +2046,7 @@
20462046
"symfony\/stopwatch": "^5.4|^6.0|^7.0",
20472047
"symfony\/var-dumper": "^5.4|^6.0|^7.0"
20482048
},
2049-
"time": "2026-05-24T08:48:41+00:00",
2049+
"time": "2026-06-15T05:35:29+00:00",
20502050
"type": "library",
20512051
"installation-source": "dist",
20522052
"autoload": {
@@ -2080,7 +2080,7 @@
20802080
"terminal"
20812081
],
20822082
"support": {
2083-
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.41"
2083+
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.42"
20842084
},
20852085
"funding": [
20862086
{
@@ -2251,17 +2251,17 @@
22512251
},
22522252
{
22532253
"name": "symfony\/finder",
2254-
"version": "v6.4.34",
2255-
"version_normalized": "6.4.34.0",
2254+
"version": "v6.4.42",
2255+
"version_normalized": "6.4.42.0",
22562256
"source": {
22572257
"type": "git",
22582258
"url": "https:\/\/github.com\/symfony\/finder.git",
2259-
"reference": "9590e86be1d1c57bfbb16d0dd040345378c20896"
2259+
"reference": "0b73dac42493acbadbba644207a715b254e9b029"
22602260
},
22612261
"dist": {
22622262
"type": "zip",
2263-
"url": "https:\/\/api.github.com\/repos\/symfony\/finder\/zipball\/9590e86be1d1c57bfbb16d0dd040345378c20896",
2264-
"reference": "9590e86be1d1c57bfbb16d0dd040345378c20896",
2263+
"url": "https:\/\/api.github.com\/repos\/symfony\/finder\/zipball\/0b73dac42493acbadbba644207a715b254e9b029",
2264+
"reference": "0b73dac42493acbadbba644207a715b254e9b029",
22652265
"shasum": ""
22662266
},
22672267
"require": {
@@ -2270,7 +2270,7 @@
22702270
"require-dev": {
22712271
"symfony\/filesystem": "^6.0|^7.0"
22722272
},
2273-
"time": "2026-01-28T15:16:37+00:00",
2273+
"time": "2026-06-26T15:18:24+00:00",
22742274
"type": "library",
22752275
"installation-source": "dist",
22762276
"autoload": {
@@ -2298,7 +2298,7 @@
22982298
"description": "Finds files and directories via an intuitive fluent interface",
22992299
"homepage": "https:\/\/symfony.com",
23002300
"support": {
2301-
"source": "https:\/\/github.com\/symfony\/finder\/tree\/v6.4.34"
2301+
"source": "https:\/\/github.com\/symfony\/finder\/tree\/v6.4.42"
23022302
},
23032303
"funding": [
23042304
{
@@ -3087,17 +3087,17 @@
30873087
},
30883088
{
30893089
"name": "symfony\/yaml",
3090-
"version": "v7.4.13",
3091-
"version_normalized": "7.4.13.0",
3090+
"version": "v7.4.14",
3091+
"version_normalized": "7.4.14.0",
30923092
"source": {
30933093
"type": "git",
30943094
"url": "https:\/\/github.com\/symfony\/yaml.git",
3095-
"reference": "a7ec3b1156faf8815db7683ec7c1e7338e6f977c"
3095+
"reference": "f8f328665ace2370d1e10645b807ba1646dc7dcc"
30963096
},
30973097
"dist": {
30983098
"type": "zip",
3099-
"url": "https:\/\/api.github.com\/repos\/symfony\/yaml\/zipball\/a7ec3b1156faf8815db7683ec7c1e7338e6f977c",
3100-
"reference": "a7ec3b1156faf8815db7683ec7c1e7338e6f977c",
3099+
"url": "https:\/\/api.github.com\/repos\/symfony\/yaml\/zipball\/f8f328665ace2370d1e10645b807ba1646dc7dcc",
3100+
"reference": "f8f328665ace2370d1e10645b807ba1646dc7dcc",
31013101
"shasum": ""
31023102
},
31033103
"require": {
@@ -3111,7 +3111,7 @@
31113111
"require-dev": {
31123112
"symfony\/console": "^6.4|^7.0|^8.0"
31133113
},
3114-
"time": "2026-05-25T06:06:12+00:00",
3114+
"time": "2026-06-08T20:24:16+00:00",
31153115
"bin": [
31163116
"Resources\/bin\/yaml-lint"
31173117
],
@@ -3142,7 +3142,7 @@
31423142
"description": "Loads and dumps YAML files",
31433143
"homepage": "https:\/\/symfony.com",
31443144
"support": {
3145-
"source": "https:\/\/github.com\/symfony\/yaml\/tree\/v7.4.13"
3145+
"source": "https:\/\/github.com\/symfony\/yaml\/tree\/v7.4.14"
31463146
},
31473147
"funding": [
31483148
{

0 commit comments

Comments
 (0)