Skip to content

Commit

Permalink
[TypeDeclaration] Skip override trait method on StrictStringParamConc…
Browse files Browse the repository at this point in the history
…atRector
  • Loading branch information
samsonasik committed Feb 1, 2025
1 parent 11789be commit a2e5e4b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector\Fixture;

use Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector\Source\SomeTrait;

final class SkipOverrideTrait
{
use SomeTrait;

public function run($var): void
{
$var .= 'test';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector\Source;

trait SomeTrait
{
abstract public function run($var): void;
}
8 changes: 8 additions & 0 deletions src/VendorLocker/ParentClassMethodTypeOverrideGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ private function resolveParentClassMethod(ClassMethod|MethodReflection $classMet
return $interfaceReflection->getNativeMethod($methodName);
}

foreach ($classReflection->getTraits() as $traitReflection) {
if (! $traitReflection->hasNativeMethod($methodName)) {
continue;
}

return $traitReflection->getNativeMethod($methodName);
}

return null;
}

Expand Down

0 comments on commit a2e5e4b

Please sign in to comment.