Skip to content

Commit f38c77c

Browse files
committed
Updated Rector to commit a6296aa93add2104e2a9ed42a56e2d749939be56
rectorphp/rector-src@a6296aa [Php83] Handle parent class consume trait on AddOverrideAttributeToOverriddenMethodsRector (#7868)
1 parent 4c87d52 commit f38c77c

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

rules/Php83/Rector/BooleanAnd/JsonValidateRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare (strict_types=1);
44
namespace Rector\Php83\Rector\BooleanAnd;
55

6+
use PhpParser\Node\Identifier;
67
use PhpParser\Node;
78
use PhpParser\Node\Arg;
89
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
@@ -88,7 +89,7 @@ public function refactor(Node $node): ?Node
8889
}
8990
// Remove associative argument (position 1 or named) - json_validate does not have this param
9091
foreach ($args as $index => $arg) {
91-
if ($arg instanceof Arg && ($arg->name !== null && $arg->name->toString() === 'associative' || $arg->name === null && $index === 1)) {
92+
if ($arg instanceof Arg && ($arg->name instanceof Identifier && $arg->name->toString() === 'associative' || !$arg->name instanceof Identifier && $index === 1)) {
9293
unset($funcCall->args[$index]);
9394
break;
9495
}

rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PhpParser\Node\Stmt\ClassMethod;
1616
use PhpParser\Node\Stmt\Expression;
1717
use PhpParser\Node\Stmt\Return_;
18+
use PhpParser\Node\Stmt\Trait_;
1819
use PHPStan\Reflection\ClassReflection;
1920
use PHPStan\Reflection\ReflectionProvider;
2021
use Rector\Contract\Rector\ConfigurableRectorInterface;
@@ -241,6 +242,9 @@ private function shouldSkipParentClassMethod(ClassReflection $parentClassReflect
241242
return \true;
242243
}
243244
$parentClassMethod = $parentClass->getMethod($classMethod->name->toString());
245+
if (!$parentClassMethod instanceof ClassMethod) {
246+
$parentClassMethod = $this->resolveClassMethodFromTraitUse($parentClass, $classMethod->name->toString());
247+
}
244248
if (!$parentClassMethod instanceof ClassMethod) {
245249
return \true;
246250
}
@@ -269,6 +273,22 @@ private function shouldSkipParentClassMethod(ClassReflection $parentClassReflect
269273
}
270274
return \false;
271275
}
276+
private function resolveClassMethodFromTraitUse(ClassLike $classLike, string $methodName): ?ClassMethod
277+
{
278+
foreach ($classLike->getTraitUses() as $traitUse) {
279+
foreach ($traitUse->traits as $traitName) {
280+
$traitClass = $this->astResolver->resolveClassFromName($traitName->__toString());
281+
if (!$traitClass instanceof Trait_) {
282+
continue;
283+
}
284+
$traitClassMethod = $traitClass->getMethod($methodName);
285+
if ($traitClassMethod instanceof ClassMethod) {
286+
return $traitClassMethod;
287+
}
288+
}
289+
}
290+
return null;
291+
}
272292
private function implementsStringable(Class_ $class): bool
273293
{
274294
foreach ($class->implements as $implement) {

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 = '9d02f92a2b31cf4d0944c4cc4ae9c024a26ca826';
22+
public const PACKAGE_VERSION = 'a6296aa93add2104e2a9ed42a56e2d749939be56';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-01-29 17:51:10';
27+
public const RELEASE_DATE = '2026-01-30 19:22:02';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)