File tree Expand file tree Collapse file tree 5 files changed +51
-1
lines changed
Expand file tree Collapse file tree 5 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
265265 $ prop ->setType ((string ) $ from ->getType ());
266266
267267 $ prop ->setInitialized ($ from ->hasType () && array_key_exists ($ prop ->getName (), $ defaults ));
268- $ prop ->setReadOnly (PHP_VERSION_ID >= 80100 ? $ from ->isReadOnly () : false );
268+ $ prop ->setReadOnly (PHP_VERSION_ID >= 80100 && $ from ->isReadOnly () && !( PHP_VERSION_ID >= 80200 && $ from -> getDeclaringClass ()-> isReadOnly ()) );
269269 $ prop ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
270270 $ prop ->setAttributes ($ this ->getAttributes ($ from ));
271271 return $ prop ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @phpVersion 8.2
5+ */
6+
7+ declare (strict_types=1 );
8+
9+ use Nette \PhpGenerator \ClassType ;
10+ use Nette \PhpGenerator \Extractor ;
11+ use Tester \Assert ;
12+
13+
14+ require __DIR__ . '/../bootstrap.php ' ;
15+ require __DIR__ . '/fixtures/classes.82.php ' ;
16+
17+ $ class = ClassType::from (new Abc \Class13 );
18+ Assert::false ($ class ->getProperty ('foo ' )->isReadOnly ());
19+ Assert::false ($ class ->getMethod ('__construct ' )->getParameter ('bar ' )->isReadOnly ());
20+
21+ $ file = (new Extractor (file_get_contents (__DIR__ . '/fixtures/classes.82.php ' )))->extractAll ();
22+ $ class = $ file ->getClasses ()[Abc \Class13::class];
23+ Assert::false ($ class ->getProperty ('foo ' )->isReadOnly ());
24+ Assert::false ($ class ->getMethod ('__construct ' )->getParameter ('bar ' )->isReadOnly ());
Original file line number Diff line number Diff line change 11readonly class Class13
22{
3+ public bool $foo;
4+
5+
6+ public function __construct(
7+ public bool $bar = true,
8+ ) {
9+ }
10+
11+
312 public function func(C|(X&D)|null $foo): (A&B)|null
413 {
514 }
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ namespace Abc;
66
77readonly class Class13
88{
9+ public bool $foo;
10+
11+
12+ public function __construct(
13+ private bool $bar = true,
14+ ) {
15+ }
16+
17+
918 public function func(C|(X&D)|null $foo): (A&B)|null
1019 {
1120 }
Original file line number Diff line number Diff line change 66
77readonly class Class13
88{
9+ public bool $ foo ;
10+
11+
12+ public function __construct (private bool $ bar = true )
13+ {
14+ }
15+
16+
917 public function func (C |(X &D )|null $ foo ): (A &B )|null
1018 {
1119 }
You can’t perform that action at this time.
0 commit comments