File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -442,4 +442,13 @@ private function validate(array $names): void
442
442
}
443
443
}
444
444
}
445
+
446
+
447
+ public function __clone ()
448
+ {
449
+ $ clone = function ($ item ) { return clone $ item ; };
450
+ $ this ->consts = array_map ($ clone , $ this ->consts );
451
+ $ this ->properties = array_map ($ clone , $ this ->properties );
452
+ $ this ->methods = array_map ($ clone , $ this ->methods );
453
+ }
445
454
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ use Nette \PhpGenerator \ClassType ;
6
+ use Tester \Assert ;
7
+
8
+
9
+ require __DIR__ . '/../bootstrap.php ' ;
10
+
11
+
12
+ $ class = new ClassType ('Example ' );
13
+
14
+ $ class ->addConstant ('A ' , 10 );
15
+ $ class ->addProperty ('a ' );
16
+ $ class ->addMethod ('a ' );
17
+
18
+ $ dolly = clone $ class ;
19
+
20
+ Assert::notSame ($ dolly ->getConstants (), $ class ->getConstants ());
21
+ Assert::notSame ($ dolly ->getProperty ('a ' ), $ class ->getProperty ('a ' ));
22
+ Assert::notSame ($ dolly ->getMethod ('a ' ), $ class ->getMethod ('a ' ));
You can’t perform that action at this time.
0 commit comments