Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions config/sets/doctrine-code-quality.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Rector\Config\RectorConfig;
use Rector\Doctrine\Bundle230\Rector\Class_\AddAnnotationToRepositoryRector;
use Rector\Doctrine\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector;
use Rector\Doctrine\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromToOneRelationTypeRector;
Expand All @@ -16,8 +15,6 @@
$rectorConfig->rules([
CorrectDefaultTypesOnEntityPropertyRector::class,

RemoveEmptyTableAttributeRector::class,

// typed properties in entities from annotations/attributes
TypedPropertyFromColumnTypeRector::class,
TypedPropertyFromToOneRelationTypeRector::class,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use Rector\Doctrine\Enum\MappingClass;
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
use Rector\Exception\ShouldNotHappenException;
use Rector\Rector\AbstractRector;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector\RemoveEmptyTableAttributeRectorTest
* @deprecated as the removal has no effect on the mapping, while the missing attribute makes the entity harder to
* read. Keeping an explicit #[ORM\Table] is a valid style choice.
*/
final class RemoveEmptyTableAttributeRector extends AbstractRector implements MinPhpVersionInterface
final class RemoveEmptyTableAttributeRector extends AbstractRector implements DeprecatedInterface
{
public function getRuleDefinition(): RuleDefinition
{
Expand Down Expand Up @@ -64,36 +64,9 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$hasChanged = false;

foreach ($node->attrGroups as $attrGroupKey => $attrGroup) {
foreach ($attrGroup->attrs as $key => $attribute) {
if (! $this->isName($attribute, MappingClass::TABLE)) {
continue;
}

if ($attribute->args !== []) {
continue;
}

unset($attrGroup->attrs[$key]);
$hasChanged = true;
}

if ($attrGroup->attrs === []) {
unset($node->attrGroups[$attrGroupKey]);
}
}

if ($hasChanged) {
return $node;
}

return null;
}

public function provideMinPhpVersion(): int
{
return PhpVersionFeature::ATTRIBUTES;
throw new ShouldNotHappenException(sprintf(
'"%s" is deprecated and should not be used anymore. Remove it from your config files.',
self::class,
));
}
}
Loading