mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-22 02:52:23 +00:00
fix sniff fro ChangeReadOnlyPropertyWithDefaultValueToConstantRector
This commit is contained in:
parent
d375cdc6f3
commit
22a55b85e1
|
@ -99,7 +99,7 @@ PHP
|
|||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (count($node->props) !== 1) {
|
||||
if ($this->shouldSkip($node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -185,4 +185,18 @@ PHP
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function shouldSkip(Property $property): bool
|
||||
{
|
||||
if (count($property->props) !== 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$class = $property->getAttribute(AttributeKey::CLASS_NODE);
|
||||
if (! $class instanceof Class_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->isObjectType($class, 'PHP_CodeSniffer\Sniffs\Sniff');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\SOLID\Tests\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector\Fixture;
|
||||
|
||||
use PHP_CodeSniffer\Files\File;
|
||||
use PHP_CodeSniffer\Sniffs\Sniff;
|
||||
|
||||
final class SkipSniff implements Sniff
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $magicMethods = [
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
foreach ($this->magicMethods as $magicMethod) {
|
||||
echo $magicMethod;
|
||||
}
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
// TODO: Implement register() method.
|
||||
}
|
||||
|
||||
public function process(File $phpcsFile, $stackPtr)
|
||||
{
|
||||
// TODO: Implement process() method.
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user