File tree 3 files changed +37
-10
lines changed
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 21
21
use DeepCopy \f011 ;
22
22
use DeepCopy \f012 \Suit ;
23
23
use DeepCopy \f013 ;
24
+ use DeepCopy \f014 ;
24
25
use DeepCopy \Filter \ChainableFilter ;
25
26
use DeepCopy \Filter \Doctrine \DoctrineProxyFilter ;
26
27
use DeepCopy \Filter \KeepFilter ;
@@ -547,20 +548,16 @@ public function test_it_can_copy_property_after_applying_doctrine_proxy_filter_w
547
548
*/
548
549
public function test_it_can_copy_object_with_readonly_property ()
549
550
{
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 ();
558
553
559
554
$ deepCopy = new DeepCopy ();
560
555
561
- $ copy = $ deepCopy ->copy ($ object );
556
+ $ scalarPropertiesCopy = $ deepCopy ->copy ($ scalarProperties );
557
+ $ objectPropertiesCopy = $ deepCopy ->copy ($ objectProperties );
562
558
563
- $ this ->assertEqualButNotSame ($ object , $ copy );
559
+ $ this ->assertEqualButNotSame ($ scalarProperties , $ scalarPropertiesCopy );
560
+ $ this ->assertEqualButNotSame ($ objectProperties , $ objectPropertiesCopy );
564
561
}
565
562
566
563
private function assertEqualButNotSame ($ expected , $ val )
You can’t perform that action at this time.
0 commit comments