Skip to content

Commit 73299b3

Browse files
Add Mixin attribute
1 parent 488ed90 commit 73299b3

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ These are the available attributes and their corresponding PHPDoc annotations:
116116
| [Internal](https://github.com/php-static-analysis/attributes/blob/main/doc/Internal.md) | `@internal` |
117117
| [IsReadOnly](https://github.com/php-static-analysis/attributes/blob/main/doc/IsReadOnly.md) | `@readonly` |
118118
| [Method](https://github.com/php-static-analysis/attributes/blob/main/doc/Method.md) | `@method` |
119+
| [Mixin](https://github.com/php-static-analysis/attributes/blob/main/doc/Mixin.md) | `@mixin` |
119120
| [Param](https://github.com/php-static-analysis/attributes/blob/main/doc/Param.md) | `@param` |
120121
| [Property](https://github.com/php-static-analysis/attributes/blob/main/doc/Property.md) | `@property` `@var` |
121122
| [PropertyRead](https://github.com/php-static-analysis/attributes/blob/main/doc/PropertyRead.md) | `@property-read` |

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"require": {
2929
"php": ">=8.0",
3030
"cweagans/composer-patches": "^1.7",
31-
"php-static-analysis/attributes": "^0.1.9 || dev-main",
31+
"php-static-analysis/attributes": "^0.1.10 || dev-main",
3232
"rector/rector": "^0.19 || ^1.0"
3333
},
3434
"require-dev": {

config/sets/php-static-analysis-annotations-to-attributes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpStaticAnalysis\Attributes\Deprecated;
66
use PhpStaticAnalysis\Attributes\Internal;
77
use PhpStaticAnalysis\Attributes\Method;
8+
use PhpStaticAnalysis\Attributes\Mixin;
89
use PhpStaticAnalysis\Attributes\PropertyRead;
910
use PhpStaticAnalysis\Attributes\PropertyWrite;
1011
use PhpStaticAnalysis\Attributes\TemplateContravariant;
@@ -26,6 +27,7 @@
2627
new AnnotationToAttribute('deprecated', Deprecated::class),
2728
new AnnotationToAttribute('internal', Internal::class),
2829
new AnnotationToAttribute('method', Method::class),
30+
new AnnotationToAttribute('mixin', Mixin::class),
2931
new AnnotationToAttribute('param', Param::class),
3032
new AnnotationToAttribute('property', Property::class),
3133
new AnnotationToAttribute('property_read', PropertyRead::class),

src/AnnotationsToAttributesRector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode;
1515
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
1616
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
17+
use PHPStan\PhpDocParser\Ast\PhpDoc\MixinTagValueNode;
1718
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
1819
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
1920
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
@@ -257,6 +258,7 @@ private function processAnnotations(PhpDocInfo $phpDocInfo): array
257258
];
258259
$attributeComment = $tagValueNode->description;
259260
break;
261+
case $tagValueNode instanceof MixinTagValueNode:
260262
case $tagValueNode instanceof ReturnTagValueNode:
261263
case $tagValueNode instanceof VarTagValueNode:
262264
$args = [
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace test\PhpStaticAnalysis\RectorRule\Fixture;
4+
5+
use PhpStaticAnalysis\Attributes\Template;
6+
7+
/**
8+
* @codeCoverageIgnore
9+
* @mixin A
10+
* @mixin B the proxied class
11+
*/
12+
#[Template('T')]
13+
class MixinAttributeTest
14+
{
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace test\PhpStaticAnalysis\RectorRule\Fixture;
22+
23+
use PhpStaticAnalysis\Attributes\Template;
24+
25+
/**
26+
* @codeCoverageIgnore
27+
*/
28+
#[Template('T')]
29+
#[\PhpStaticAnalysis\Attributes\Mixin('A')]
30+
#[\PhpStaticAnalysis\Attributes\Mixin('B')] // the proxied class
31+
class MixinAttributeTest
32+
{
33+
}
34+
35+
?>

0 commit comments

Comments
 (0)