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
265
265
$ prop ->setType ((string ) $ from ->getType ());
266
266
267
267
$ 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 ()) );
269
269
$ prop ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
270
270
$ prop ->setAttributes ($ this ->getAttributes ($ from ));
271
271
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 1
1
readonly class Class13
2
2
{
3
+ public bool $foo;
4
+
5
+
6
+ public function __construct(
7
+ public bool $bar = true,
8
+ ) {
9
+ }
10
+
11
+
3
12
public function func(C|(X&D)|null $foo): (A&B)|null
4
13
{
5
14
}
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ namespace Abc;
6
6
7
7
readonly class Class13
8
8
{
9
+ public bool $foo;
10
+
11
+
12
+ public function __construct(
13
+ private bool $bar = true,
14
+ ) {
15
+ }
16
+
17
+
9
18
public function func(C|(X&D)|null $foo): (A&B)|null
10
19
{
11
20
}
Original file line number Diff line number Diff line change 6
6
7
7
readonly class Class13
8
8
{
9
+ public bool $ foo ;
10
+
11
+
12
+ public function __construct (private bool $ bar = true )
13
+ {
14
+ }
15
+
16
+
9
17
public function func (C |(X &D )|null $ foo ): (A &B )|null
10
18
{
11
19
}
You can’t perform that action at this time.
0 commit comments