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 @@ -414,12 +414,13 @@ public function addConst($name, $value)
414
414
*/
415
415
public function setProperties (array $ props )
416
416
{
417
+ $ this ->properties = array ();
417
418
foreach ($ props as $ v ) {
418
419
if (!$ v instanceof Property) {
419
420
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Property[]. ' );
420
421
}
422
+ $ this ->properties [$ v ->getName ()] = $ v ;
421
423
}
422
- $ this ->properties = $ props ;
423
424
return $ this ;
424
425
}
425
426
@@ -463,12 +464,13 @@ public function addProperty($name, $value = NULL)
463
464
*/
464
465
public function setMethods (array $ methods )
465
466
{
467
+ $ this ->methods = array ();
466
468
foreach ($ methods as $ v ) {
467
469
if (!$ v instanceof Method) {
468
470
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Method[]. ' );
469
471
}
472
+ $ this ->methods [$ v ->getName ()] = $ v ;
470
473
}
471
- $ this ->methods = $ methods ;
472
474
return $ this ;
473
475
}
474
476
Original file line number Diff line number Diff line change @@ -156,12 +156,13 @@ public function getName()
156
156
*/
157
157
public function setParameters (array $ val )
158
158
{
159
+ $ this ->parameters = array ();
159
160
foreach ($ val as $ v ) {
160
161
if (!$ v instanceof Parameter) {
161
162
throw new Nette \InvalidArgumentException ('Argument must be Nette\PhpGenerator\Parameter[]. ' );
162
163
}
164
+ $ this ->parameters [$ v ->getName ()] = $ v ;
163
165
}
164
- $ this ->parameters = $ val ;
165
166
return $ this ;
166
167
}
167
168
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