Skip to content

Commit d12063e

Browse files
committed
Use private fields to verify non-public access also works
1 parent cf4fa81 commit d12063e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/test/php/lang/ast/syntax/php/unittest/StaticInitializerTest.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class StaticInitializerTest extends EmittingTest {
99
#[Test]
1010
public function static_initializer_called() {
1111
$t= $this->type('class <T> {
12-
public static $initialized= false;
12+
private static $initialized= false;
1313
1414
static {
1515
self::$initialized= true;
1616
}
1717
}');
18-
Assert::true($t->getField('initialized')->get(null));
18+
Assert::true($t->getField('initialized')->setAccessible(true)->get(null));
1919
}
2020

2121
#[Test]
2222
public function can_have_multiple_blocks() {
2323
$t= $this->type('class <T> {
24-
public static $initialized= [];
24+
private static $initialized= [];
2525
2626
static {
2727
self::$initialized[]= 1;
@@ -30,7 +30,7 @@ public function can_have_multiple_blocks() {
3030
self::$initialized[]= 2;
3131
}
3232
}');
33-
Assert::equals([1, 2], $t->getField('initialized')->get(null));
33+
Assert::equals([1, 2], $t->getField('initialized')->setAccessible(true)->get(null));
3434
}
3535

3636
#[Test, Expect(class: Errors::class, withMessage: 'Expected static modifier, have none in static initializer')]

0 commit comments

Comments
 (0)