Skip to content

Commit

Permalink
Do not run ChangeReadOnlyPropertyWithDefaultValueToConstantRector o…
Browse files Browse the repository at this point in the history
…n properties with attributes (#1694)
  • Loading branch information
simPod committed Jan 18, 2022
1 parent 1c7460b commit 9d781bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Rector\Tests\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector\Fixture;

class SkipAttribute
{
#[ORM\Column(type: 'json')]
private string $parameters = '{}';
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Rector\Core\Rector\AbstractRector;
use Rector\Privatization\NodeFactory\ClassConstantFactory;
use Rector\Privatization\NodeReplacer\PropertyFetchWithConstFetchReplacer;
use Symplify\PHPStanRules\Reflection\PropertyAnalyzer;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand Down Expand Up @@ -130,6 +131,14 @@ private function shouldSkip(Property $property): bool
return true;
}

return $this->isObjectType($classLike, new ObjectType('PHP_CodeSniffer\Sniffs\Sniff'));
if ($property->attrGroups !== []) {
return true;
}

if ($this->isObjectType($classLike, new ObjectType('PHP_CodeSniffer\Sniffs\Sniff'))) {
return true;
}

return false;
}
}

0 comments on commit 9d781bb

Please sign in to comment.