File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -74,11 +74,24 @@ public function testSettersAndGettersForClass(): void
7474
7575 $ this ->assertSame ("foo " , $ inst ->getFoo ());
7676 $ this ->assertSame ("bar " , $ inst ->getBar ());
77- $ this ->assertSame ("snafu " , $ inst ->getSnafu ());
7877 $ this ->assertSame ("foobar " , $ inst ->getFoobar ());
7978 }
8079
8180
81+ public function testGetSnafuModifierOverridden (): void
82+ {
83+ $ inst = $ this ->createClassWithSetterAndGetterAttributes ([
84+ "foo " => "Hello World " ,
85+ "bar " => "World Hello "
86+ ]);
87+
88+ $ this ->expectException (BadMethodCallException::class);
89+
90+ /* @phpstan-ignore-next-line */
91+ $ inst ->getSnafu ();
92+ }
93+
94+
8295 public function testAccessorTraitWithDifferentValues (): void
8396 {
8497 $ this ->expectException (ValueError::class);
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class ClassHasAttributes
2727 #[Setter]
2828 public string $ foobar = "Ok " ;
2929
30- #[Getter]
30+ #[Getter(Modifier:: PRIVATE ) ]
3131 private string $ snafu ;
3232
3333 public function __construct (
Original file line number Diff line number Diff line change @@ -245,10 +245,9 @@ private function cachePropertiesWithAccessorAttribute(string $accessorClass): ar
245245 continue ;
246246 }
247247
248- $ accessorAttribute = $ classAccessorAttribute ;
249-
248+ $ accessorAttribute = $ property ->getAttributes ($ accessorClass );
250249 if (empty ($ accessorAttribute )) {
251- $ accessorAttribute = $ property -> getAttributes ( $ accessorClass ) ;
250+ $ accessorAttribute = $ classAccessorAttribute ;
252251 }
253252
254253 if (!empty ($ accessorAttribute ) && ($ property instanceof ReflectionProperty)) {
You can’t perform that action at this time.
0 commit comments