30
30
use stdClass ;
31
31
32
32
use function current ;
33
+ use function next ;
33
34
34
35
/**
35
36
* @uses \phpDocumentor\Reflection\Php\Factory\PropertyIterator
@@ -105,6 +106,27 @@ public function testCreateWithDocBlock(): void
105
106
$ this ->assertSame ($ docBlock , $ property ->getDocBlock ());
106
107
}
107
108
109
+ public function testCreateMultipleInOneStatement (): void
110
+ {
111
+ $ property1 = new PropertyProperty ('property1 ' , new String_ ('MyDefault1 ' ));
112
+ $ property1 ->setAttribute ('fqsen ' , new Fqsen ('\myClass::$property1 ' ));
113
+ $ property2 = new PropertyProperty ('property2 ' , new String_ ('MyDefault2 ' ));
114
+ $ property2 ->setAttribute ('fqsen ' , new Fqsen ('\myClass::$property2 ' ));
115
+ $ node = new PropertyNode (
116
+ ClassNode::MODIFIER_PRIVATE | ClassNode::MODIFIER_STATIC ,
117
+ [$ property1 , $ property2 ]
118
+ );
119
+
120
+ $ class = $ this ->performCreate ($ node );
121
+ $ properties = $ class ->getProperties ();
122
+ $ property1 = current ($ properties );
123
+ next ($ properties );
124
+ $ property2 = current ($ properties );
125
+
126
+ $ this ->assertProperty ($ property1 , 'private ' , 'property1 ' , '\'MyDefault1 \'' );
127
+ $ this ->assertProperty ($ property2 , 'private ' , 'property2 ' , '\'MyDefault2 \'' );
128
+ }
129
+
108
130
private function buildPropertyMock (int $ modifier ): PropertyNode
109
131
{
110
132
$ property = new PropertyProperty ('property ' , new String_ ('MyDefault ' ));
@@ -113,12 +135,16 @@ private function buildPropertyMock(int $modifier): PropertyNode
113
135
return new PropertyNode ($ modifier | ClassNode::MODIFIER_STATIC , [$ property ]);
114
136
}
115
137
116
- private function assertProperty (PropertyDescriptor $ property , string $ visibility ): void
117
- {
138
+ private function assertProperty (
139
+ PropertyDescriptor $ property ,
140
+ string $ visibility ,
141
+ string $ name = 'property ' ,
142
+ ?string $ default = '\'MyDefault \''
143
+ ): void {
118
144
$ this ->assertInstanceOf (PropertyDescriptor::class, $ property );
119
- $ this ->assertEquals ('\myClass::$property ' , (string ) $ property ->getFqsen ());
145
+ $ this ->assertEquals ('\myClass::$ ' . $ name , (string ) $ property ->getFqsen ());
120
146
$ this ->assertTrue ($ property ->isStatic ());
121
- $ this ->assertEquals ('\' MyDefault \'' , $ property ->getDefault ());
147
+ $ this ->assertEquals ($ default , $ property ->getDefault ());
122
148
$ this ->assertEquals ($ visibility , (string ) $ property ->getVisibility ());
123
149
}
124
150
0 commit comments