@@ -192,10 +192,11 @@ public function testIsReadOnly(): void
192192
193193 $ notReadOnlyProperty = $ classInfo ->getProperty ('publicProperty ' );
194194 self ::assertFalse ($ notReadOnlyProperty ->isReadOnly ());
195+ self ::assertTrue ($ notReadOnlyProperty ->isPublic ());
195196
196197 $ readOnlyProperty = $ classInfo ->getProperty ('readOnlyProperty ' );
197- self ::assertTrue ($ readOnlyProperty ->isPublic ());
198198 self ::assertTrue ($ readOnlyProperty ->isReadOnly ());
199+ self ::assertTrue ($ readOnlyProperty ->isPublic ());
199200 }
200201
201202 public function testIsFinal (): void
@@ -204,6 +205,7 @@ public function testIsFinal(): void
204205
205206 $ notReadOnlyProperty = $ classInfo ->getProperty ('publicProperty ' );
206207 self ::assertFalse ($ notReadOnlyProperty ->isFinal ());
208+ self ::assertTrue ($ notReadOnlyProperty ->isPublic ());
207209
208210 $ finalPublicProperty = $ classInfo ->getProperty ('finalPublicProperty ' );
209211 self ::assertTrue ($ finalPublicProperty ->isFinal ());
@@ -215,6 +217,7 @@ public function testIsNotAbstract(): void
215217 $ classInfo = $ this ->reflector ->reflectClass (ExampleClass::class);
216218
217219 $ notAbstractProperty = $ classInfo ->getProperty ('publicProperty ' );
220+ self ::assertTrue ($ notAbstractProperty ->isPublic ());
218221 self ::assertFalse ($ notAbstractProperty ->isAbstract ());
219222 }
220223
@@ -227,6 +230,7 @@ public function testIsReadOnlyInReadOnlyClass(): void
227230 $ classInfo = $ reflector ->reflectClass ('\\Roave \\BetterReflectionTest \\Fixture \\ReadOnlyClass ' );
228231
229232 $ property = $ classInfo ->getProperty ('property ' );
233+ self ::assertTrue ($ property ->isPrivate ());
230234 self ::assertTrue ($ property ->isReadOnly ());
231235 }
232236
@@ -264,25 +268,32 @@ public function testGetDocCommentReturnsNullWithNoComment(): void
264268 self ::assertNull ($ property ->getDocComment ());
265269 }
266270
267- /** @return list<array{0: non-empty-string, 1: int-mask-of<ReflectionPropertyAdapter::IS_*>}> */
271+ /** @return list<array{0: non-empty-string, 1: class-string, 2: non-empty-string, 3: int-mask-of<ReflectionPropertyAdapter::IS_*>}> */
268272 public static function modifierProvider (): array
269273 {
270274 return [
271- ['publicProperty ' , CoreReflectionProperty::IS_PUBLIC ],
272- ['protectedProperty ' , CoreReflectionProperty::IS_PROTECTED ],
273- ['privateProperty ' , CoreReflectionProperty::IS_PRIVATE ],
274- ['publicStaticProperty ' , CoreReflectionProperty::IS_PUBLIC | CoreReflectionProperty::IS_STATIC ],
275- ['readOnlyProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_READONLY | ReflectionPropertyAdapter::IS_PROTECTED_SET_COMPATIBILITY ],
276- ['finalPublicProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_FINAL_COMPATIBILITY ],
275+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'publicProperty ' , CoreReflectionProperty::IS_PUBLIC ],
276+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'protectedProperty ' , CoreReflectionProperty::IS_PROTECTED ],
277+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'privateProperty ' , CoreReflectionProperty::IS_PRIVATE ],
278+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'publicStaticProperty ' , CoreReflectionProperty::IS_PUBLIC | CoreReflectionProperty::IS_STATIC ],
279+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'readOnlyProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_READONLY | ReflectionPropertyAdapter::IS_PROTECTED_SET_COMPATIBILITY ],
280+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'finalPublicProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_FINAL_COMPATIBILITY ],
281+ [__DIR__ . '/../Fixture/PropertyHooks.php ' , 'Roave\BetterReflectionTest\Fixture\AbstractPropertyHooks ' , 'hook ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_ABSTRACT_COMPATIBILITY | ReflectionPropertyAdapter::IS_VIRTUAL_COMPATIBILITY ],
277282 ];
278283 }
279284
280- /** @param non-empty-string $propertyName */
285+ /**
286+ * @param non-empty-string $fileName
287+ * @param class-string $className
288+ * @param non-empty-string $propertyName
289+ */
281290 #[DataProvider('modifierProvider ' )]
282- public function testGetModifiers (string $ propertyName , int $ expectedModifier ): void
291+ public function testGetModifiers (string $ fileName , string $ className , string $ propertyName , int $ expectedModifier ): void
283292 {
284- $ classInfo = $ this ->reflector ->reflectClass (ExampleClass::class);
285- $ property = $ classInfo ->getProperty ($ propertyName );
293+ $ reflector = new DefaultReflector (new SingleFileSourceLocator ($ fileName , $ this ->astLocator ));
294+ $ classInfo = $ reflector ->reflectClass ($ className );
295+
296+ $ property = $ classInfo ->getProperty ($ propertyName );
286297
287298 self ::assertSame ($ expectedModifier , $ property ->getModifiers ());
288299 }
@@ -968,25 +979,29 @@ public function testIsPrivateSet(): void
968979 self ::assertTrue ($ protectedPrivateSet ->isPrivateSet ());
969980 }
970981
971- /** @return list<array{0: non-empty-string, 1: bool}> */
982+ /** @return list<array{0: non-empty-string, 1: bool, 2: int-mask-of<ReflectionPropertyAdapter::IS_*> }> */
972983 public static function asymmetricVisibilityImplicitFinalProvider (): array
973984 {
974985 return [
975- ['publicPrivateSetIsFinal ' , true ],
976- ['protectedPrivateSetIsFinal ' , true ],
977- ['privatePrivateSetIsNotFinal ' , false ],
986+ ['publicPrivateSetIsFinal ' , true , ReflectionPropertyAdapter:: IS_PUBLIC | ReflectionPropertyAdapter:: IS_PRIVATE_SET_COMPATIBILITY | ReflectionPropertyAdapter:: IS_FINAL_COMPATIBILITY ],
987+ ['protectedPrivateSetIsFinal ' , true , ReflectionPropertyAdapter:: IS_PROTECTED | ReflectionPropertyAdapter:: IS_PRIVATE_SET_COMPATIBILITY | ReflectionPropertyAdapter:: IS_FINAL_COMPATIBILITY ],
988+ ['privatePrivateSetIsNotFinal ' , false , ReflectionPropertyAdapter:: IS_PRIVATE ],
978989 ];
979990 }
980991
981- /** @param non-empty-string $propertyName */
992+ /**
993+ * @param non-empty-string $propertyName
994+ * @param int-mask-of<ReflectionPropertyAdapter::IS_*> $modifiers
995+ */
982996 #[DataProvider('asymmetricVisibilityImplicitFinalProvider ' )]
983- public function testAsymmetricVisibilityImplicitFinal (string $ propertyName , bool $ isFinal ): void
997+ public function testAsymmetricVisibilityImplicitFinal (string $ propertyName , bool $ isFinal, int $ modifiers ): void
984998 {
985999 $ reflector = new DefaultReflector (new SingleFileSourceLocator (__DIR__ . '/../Fixture/AsymmetricVisibilityImplicitFinal.php ' , $ this ->astLocator ));
9861000 $ classInfo = $ reflector ->reflectClass ('Roave\BetterReflectionTest\Fixture\AsymmetricVisibilityImplicitFinal ' );
9871001 $ property = $ classInfo ->getProperty ($ propertyName );
9881002
9891003 self ::assertSame ($ isFinal , $ property ->isFinal ());
1004+ self ::assertSame ($ modifiers , $ property ->getModifiers ());
9901005 }
9911006
9921007 /** @return list<array{0: non-empty-string, 1: bool}> */
@@ -1019,6 +1034,7 @@ public function testIsAbstract(): void
10191034
10201035 $ hookProperty = $ classInfo ->getProperty ('hook ' );
10211036 self ::assertTrue ($ hookProperty ->isAbstract ());
1037+ self ::assertTrue ($ hookProperty ->isPublic ());
10221038 }
10231039
10241040 public function testIsAbstractInInterface (): void
@@ -1028,6 +1044,7 @@ public function testIsAbstractInInterface(): void
10281044
10291045 $ abstractProperty = $ classInfo ->getProperty ('abstractPropertyFromInterface ' );
10301046 self ::assertTrue ($ abstractProperty ->isAbstract ());
1047+ self ::assertTrue ($ abstractProperty ->isPublic ());
10311048 }
10321049
10331050 public function testNoHooks (): void
@@ -1206,6 +1223,20 @@ public function testExtendingHooks(): void
12061223 self ::assertSame ('Roave\BetterReflectionTest\Fixture\GetAndSetPropertyHook ' , $ getAndSetHookProperty ->getHook (ReflectionPropertyHookType::Set)->getDeclaringClass ()->getName ());
12071224 }
12081225
1226+ public function testExtendingHooks2 (): void
1227+ {
1228+ $ reflector = new DefaultReflector (new SingleFileSourceLocator (__DIR__ . '/../Fixture/PropertyHooks.php ' , $ this ->astLocator ));
1229+
1230+ $ classInfo = $ reflector ->reflectClass ('Roave\BetterReflectionTest\Fixture\ExtendedHooks ' );
1231+
1232+ $ getAndSetHookProperty = $ classInfo ->getProperty ('hook ' );
1233+ self ::assertCount (2 , $ getAndSetHookProperty ->getHooks ());
1234+ self ::assertTrue ($ getAndSetHookProperty ->hasHook (ReflectionPropertyHookType::Get));
1235+ self ::assertTrue ($ getAndSetHookProperty ->hasHook (ReflectionPropertyHookType::Set));
1236+ self ::assertSame ('Roave\BetterReflectionTest\Fixture\ExtendedHooks ' , $ getAndSetHookProperty ->getHook (ReflectionPropertyHookType::Get)->getDeclaringClass ()->getName ());
1237+ self ::assertSame ('Roave\BetterReflectionTest\Fixture\BothPropertyHooks ' , $ getAndSetHookProperty ->getHook (ReflectionPropertyHookType::Set)->getDeclaringClass ()->getName ());
1238+ }
1239+
12091240 public function testUseHookFromTrait (): void
12101241 {
12111242 $ reflector = new DefaultReflector (new SingleFileSourceLocator (__DIR__ . '/../Fixture/PropertyHooks.php ' , $ this ->astLocator ));
0 commit comments