File tree Expand file tree Collapse file tree 3 files changed +37
-10
lines changed
Expand file tree Collapse file tree 3 files changed +37
-10
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace DeepCopy \f014 ;
4+
5+ class ReadonlyObjectProperty
6+ {
7+ public readonly ReadonlyScalarProperty $ foo ;
8+
9+ public function __construct ()
10+ {
11+ $ this ->foo = new ReadonlyScalarProperty ();
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace DeepCopy \f014 ;
4+
5+ class ReadonlyScalarProperty
6+ {
7+ public readonly string $ foo ;
8+ public readonly int $ bar ;
9+ public readonly array $ baz ;
10+
11+ public function __construct ()
12+ {
13+ $ this ->foo = 'foo ' ;
14+ $ this ->bar = 1 ;
15+ $ this ->baz = [];
16+ }
17+ }
Original file line number Diff line number Diff line change 2121use DeepCopy \f011 ;
2222use DeepCopy \f012 \Suit ;
2323use DeepCopy \f013 ;
24+ use DeepCopy \f014 ;
2425use DeepCopy \Filter \ChainableFilter ;
2526use DeepCopy \Filter \Doctrine \DoctrineProxyFilter ;
2627use DeepCopy \Filter \KeepFilter ;
@@ -547,20 +548,16 @@ public function test_it_can_copy_property_after_applying_doctrine_proxy_filter_w
547548 */
548549 public function test_it_can_copy_object_with_readonly_property ()
549550 {
550- $ object = new class extends \stdClass {
551- public readonly string $ foo ;
552-
553- public function __construct ()
554- {
555- $ this ->foo = 'foo ' ;
556- }
557- };
551+ $ scalarProperties = new f014 \ReadonlyScalarProperty ();
552+ $ objectProperties = new f014 \ReadonlyObjectProperty ();
558553
559554 $ deepCopy = new DeepCopy ();
560555
561- $ copy = $ deepCopy ->copy ($ object );
556+ $ scalarPropertiesCopy = $ deepCopy ->copy ($ scalarProperties );
557+ $ objectPropertiesCopy = $ deepCopy ->copy ($ objectProperties );
562558
563- $ this ->assertEqualButNotSame ($ object , $ copy );
559+ $ this ->assertEqualButNotSame ($ scalarProperties , $ scalarPropertiesCopy );
560+ $ this ->assertEqualButNotSame ($ objectProperties , $ objectPropertiesCopy );
564561 }
565562
566563 private function assertEqualButNotSame ($ expected , $ val )
You can’t perform that action at this time.
0 commit comments