mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
[Php80] Handle double quoted sql statement annotation on AnnotationToAttributeRector (#1516)
* Add test with SQL in nested annotation argument * update fixture namespace * Closes #1515 Fixes https://github.com/rectorphp/rector/issues/6859 * [ci-review] Rector Rectify * clean up * clean up Co-authored-by: Jacob Thomason <jacob@thomason.xxx> Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
0c26b042ab
commit
4e0a1ce694
|
@ -117,7 +117,10 @@ final class PlainValueParser
|
|||
|
||||
// keep the last ")"
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES);
|
||||
|
||||
if ($tokenIterator->currentTokenValue() === ')') {
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES);
|
||||
}
|
||||
|
||||
// keep original name to differentiate between short and FQN class
|
||||
$identifierTypeNode = new IdentifierTypeNode($annotationShortName);
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixturePhp81;
|
||||
|
||||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation;
|
||||
|
||||
/**
|
||||
* @GenericAnnotation(filters={
|
||||
* @GenericAnnotation(sql="
|
||||
* $this.id IN(
|
||||
* SELECT id
|
||||
* FROM foo
|
||||
* WHERE bar = 'baz'
|
||||
* )"
|
||||
* )
|
||||
* })
|
||||
*/
|
||||
class SqlStatement
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixturePhp81;
|
||||
|
||||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation;
|
||||
|
||||
#[GenericAnnotation(filters: [new GenericAnnotation(sql: '
|
||||
$this.id IN(
|
||||
SELECT id
|
||||
FROM foo
|
||||
WHERE bar = \'baz\'
|
||||
)')])]
|
||||
class SqlStatement
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
|
@ -6,6 +6,7 @@ use Rector\Core\Configuration\Option;
|
|||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation;
|
||||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\SourcePhp81\All;
|
||||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\SourcePhp81\Length;
|
||||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\SourcePhp81\NotNull;
|
||||
|
@ -25,6 +26,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
new AnnotationToAttribute(Length::class),
|
||||
new AnnotationToAttribute(NotNull::class),
|
||||
new AnnotationToAttribute(NotNumber::class),
|
||||
new AnnotationToAttribute(GenericAnnotation::class),
|
||||
],
|
||||
]);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user