mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-28 21:53:31 +00:00
[Php80] Do not remove Assert with no arg in AnnotationToAttributeRector (#733)
This commit is contained in:
parent
ea9cddd31b
commit
d72a5999ef
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixtureAutoImported;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=27)
|
||||||
|
* @Assert\NotBlank()
|
||||||
|
* @Assert\Length(max=27)
|
||||||
|
*/
|
||||||
|
private string $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
-----
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixtureAutoImported;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping\Column;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Assert\NotBlank()
|
||||||
|
* @Assert\Length(max=27)
|
||||||
|
*/
|
||||||
|
#[Column(type: 'string', length: 27)]
|
||||||
|
private string $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -57,7 +57,12 @@ final class ConvertedAnnotationToAttributeParentRemover
|
||||||
DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode,
|
DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode,
|
||||||
array $annotationsToAttributes
|
array $annotationsToAttributes
|
||||||
): bool {
|
): bool {
|
||||||
foreach ($doctrineAnnotationTagValueNode->getValues() as $nodeValue) {
|
$nodeValues = $doctrineAnnotationTagValueNode->getValues();
|
||||||
|
if ($nodeValues === []) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($nodeValues as $nodeValue) {
|
||||||
if (! $nodeValue instanceof CurlyListNode) {
|
if (! $nodeValue instanceof CurlyListNode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user