-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep comments in annotations when converting them to attributes (#5650)
* Keep comments in annotations when converting them to attributes * Also split comment using windows line ending * Better expression for end of line * Call parent function in function that prints attribute group * Better check for existence of comment and update of regex used to find the end of the values * Better check for existence of comment
- Loading branch information
Carlos Granados
committed
Feb 21, 2024
1 parent
a4445df
commit 7e741fe
Showing
13 changed files
with
127 additions
and
19 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
rules-tests/Php80/Rector/Class_/AnnotationToAttributeRector/Fixture/with_comment.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture; | ||
|
||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation; | ||
|
||
final class WithDescription | ||
{ | ||
/** | ||
* This comment is before the annotations | ||
* @GenericAnnotation this is a simple annotation | ||
* @GenericAnnotation(key="value") this annotation has parameters | ||
* @GenericAnnotation( | ||
* "some" = "item", | ||
* "summary" = "item", | ||
* ) this annotation is multi-line | ||
* @GenericAnnotation(key="value") (this comment is within parentheses) | ||
* @GenericAnnotation(key="value") "this comment is within quotes" | ||
* This comment does not belong to an annotation and will be ignored | ||
*/ | ||
protected $someColumn; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture; | ||
|
||
use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation; | ||
|
||
final class WithDescription | ||
{ | ||
/** | ||
* This comment is before the annotations | ||
*/ | ||
#[GenericAnnotation] // this is a simple annotation | ||
#[GenericAnnotation(key: 'value')] // this annotation has parameters | ||
#[GenericAnnotation(some: 'item', summary: 'item')] // this annotation is multi-line | ||
#[GenericAnnotation(key: 'value')] // (this comment is within parentheses) | ||
#[GenericAnnotation(key: 'value')] // "this comment is within quotes" | ||
protected $someColumn; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters