File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -432,12 +432,13 @@ public function addConst($name, $value)
432
432
*/
433
433
public function setProperties (array $ props )
434
434
{
435
+ $ this ->properties = [];
435
436
foreach ($ props as $ v ) {
436
437
if (!$ v instanceof Property) {
437
438
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Property[]. ' );
438
439
}
440
+ $ this ->properties [$ v ->getName ()] = $ v ;
439
441
}
440
- $ this ->properties = $ props ;
441
442
return $ this ;
442
443
}
443
444
@@ -480,12 +481,13 @@ public function addProperty($name, $value = NULL)
480
481
*/
481
482
public function setMethods (array $ methods )
482
483
{
484
+ $ this ->methods = [];
483
485
foreach ($ methods as $ v ) {
484
486
if (!$ v instanceof Method) {
485
487
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Method[]. ' );
486
488
}
489
+ $ this ->methods [$ v ->getName ()] = $ v ;
487
490
}
488
- $ this ->methods = $ methods ;
489
491
return $ this ;
490
492
}
491
493
Original file line number Diff line number Diff line change @@ -164,12 +164,13 @@ public function getName()
164
164
*/
165
165
public function setParameters (array $ val )
166
166
{
167
+ $ this ->parameters = [];
167
168
foreach ($ val as $ v ) {
168
169
if (!$ v instanceof Parameter) {
169
170
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Parameter[]. ' );
170
171
}
172
+ $ this ->parameters [$ v ->getName ()] = $ v ;
171
173
}
172
- $ this ->parameters = $ val ;
173
174
return $ this ;
174
175
}
175
176
Original file line number Diff line number Diff line change @@ -65,3 +65,20 @@ $method->addParameter('res', NULL)
65
65
->setTypeHint ('array ' );
66
66
67
67
Assert::matchFile (__DIR__ . '/ClassType.expect ' , (string ) $ class );
68
+
69
+
70
+ // global setters & getters
71
+ $ methods = $ class ->getMethods ();
72
+ Assert::count (3 , $ methods );
73
+ $ class ->setMethods (array_values ($ methods ));
74
+ Assert::same ($ methods , $ class ->getMethods ());
75
+
76
+ $ properties = $ class ->getProperties ();
77
+ Assert::count (3 , $ properties );
78
+ $ class ->setProperties (array_values ($ properties ));
79
+ Assert::same ($ properties , $ class ->getProperties ());
80
+
81
+ $ parameters = $ method ->getParameters ();
82
+ Assert::count (2 , $ parameters );
83
+ $ method ->setParameters (array_values ($ parameters ));
84
+ Assert::same ($ parameters , $ method ->getParameters ());
You can’t perform that action at this time.
0 commit comments