Skip to content

Commit f127149

Browse files
authored
[php 8.3] cover private abstract constants in AddTypeToConstRector (#7804)
* cover private abstract constants in AddTypeToConstRector * skip
1 parent b121808 commit f127149

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

phpstan.neon

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,5 +467,12 @@ parameters:
467467

468468
# false positive
469469
-
470-
identifier: phpstanApi.varTagAssumption
471-
path: rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForDimFetchArrayFromAssignsRector.php
470+
identifier: phpstanApi.varTagAssumption
471+
path: rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddReturnDocblockForDimFetchArrayFromAssignsRector.php
472+
473+
# bug, fix in symplify/phpstan-rules
474+
-
475+
identifier: symplify.noMissnamedDocTag
476+
paths:
477+
- rules/Php74/NodeAnalyzer/ClosureArrowFunctionAnalyzer.php
478+
- rules/TypeDeclarationDocblocks/TypeResolver/ConstantArrayTypeGeneralizer.php
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php83\Rector\ClassConst\AddTypeToConstRector\Fixture;
4+
5+
abstract class HandlePrivateAbstract
6+
{
7+
private const VALUE = 1000;
8+
}
9+
?>
10+
-----
11+
<?php
12+
13+
namespace Rector\Tests\Php83\Rector\ClassConst\AddTypeToConstRector\Fixture;
14+
15+
abstract class HandlePrivateAbstract
16+
{
17+
private const int VALUE = 1000;
18+
}
19+
?>

rules/Php83/Rector/ClassConst/AddTypeToConstRector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ public function refactor(Node $node): ?Class_
7878
return null;
7979
}
8080

81-
if ($node->isAbstract()) {
82-
return null;
83-
}
84-
8581
$classConsts = $node->getConstants();
8682
if ($classConsts === []) {
8783
return null;
@@ -99,6 +95,10 @@ public function refactor(Node $node): ?Class_
9995
}
10096

10197
foreach ($classConst->consts as $constNode) {
98+
if ($node->isAbstract() && ! $classConst->isPrivate()) {
99+
continue;
100+
}
101+
102102
if ($this->isConstGuardedByParents($constNode, $parentClassReflections)) {
103103
continue;
104104
}

0 commit comments

Comments
 (0)