@@ -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
@@ -265,25 +269,32 @@ public function testGetDocCommentReturnsNullWithNoComment(): void
265269 self ::assertNull ($ property ->getDocComment ());
266270 }
267271
268- /** @return list<array{0: non-empty-string, 1: int-mask-of<ReflectionPropertyAdapter::IS_*>}> */
272+ /** @return list<array{0: non-empty-string, 1: class-string, 2: non-empty-string, 3: int-mask-of<ReflectionPropertyAdapter::IS_*>}> */
269273 public static function modifierProvider (): array
270274 {
271275 return [
272- ['publicProperty ' , CoreReflectionProperty::IS_PUBLIC ],
273- ['protectedProperty ' , CoreReflectionProperty::IS_PROTECTED ],
274- ['privateProperty ' , CoreReflectionProperty::IS_PRIVATE ],
275- ['publicStaticProperty ' , CoreReflectionProperty::IS_PUBLIC | CoreReflectionProperty::IS_STATIC ],
276- ['readOnlyProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_READONLY | ReflectionPropertyAdapter::IS_PROTECTED_SET_COMPATIBILITY ],
277- ['finalPublicProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_FINAL_COMPATIBILITY ],
276+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'publicProperty ' , CoreReflectionProperty::IS_PUBLIC ],
277+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'protectedProperty ' , CoreReflectionProperty::IS_PROTECTED ],
278+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'privateProperty ' , CoreReflectionProperty::IS_PRIVATE ],
279+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'publicStaticProperty ' , CoreReflectionProperty::IS_PUBLIC | CoreReflectionProperty::IS_STATIC ],
280+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'readOnlyProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_READONLY | ReflectionPropertyAdapter::IS_PROTECTED_SET_COMPATIBILITY ],
281+ [__DIR__ . '/../Fixture/ExampleClass.php ' , 'Roave\BetterReflectionTest\Fixture\ExampleClass ' , 'finalPublicProperty ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_FINAL_COMPATIBILITY ],
282+ [__DIR__ . '/../Fixture/PropertyHooks.php ' , 'Roave\BetterReflectionTest\Fixture\AbstractPropertyHooks ' , 'hook ' , CoreReflectionProperty::IS_PUBLIC | ReflectionPropertyAdapter::IS_ABSTRACT_COMPATIBILITY | ReflectionPropertyAdapter::IS_VIRTUAL_COMPATIBILITY ],
278283 ];
279284 }
280285
281- /** @param non-empty-string $propertyName */
286+ /**
287+ * @param non-empty-string $fileName
288+ * @param class-string $className
289+ * @param non-empty-string $propertyName
290+ */
282291 #[DataProvider('modifierProvider ' )]
283- public function testGetModifiers (string $ propertyName , int $ expectedModifier ): void
292+ public function testGetModifiers (string $ fileName , string $ className , string $ propertyName , int $ expectedModifier ): void
284293 {
285- $ classInfo = $ this ->reflector ->reflectClass (ExampleClass::class);
286- $ property = $ classInfo ->getProperty ($ propertyName );
294+ $ reflector = new DefaultReflector (new SingleFileSourceLocator ($ fileName , $ this ->astLocator ));
295+ $ classInfo = $ reflector ->reflectClass ($ className );
296+
297+ $ property = $ classInfo ->getProperty ($ propertyName );
287298
288299 self ::assertSame ($ expectedModifier , $ property ->getModifiers ());
289300 }
@@ -972,25 +983,29 @@ public function testIsPrivateSet(): void
972983 self ::assertTrue ($ protectedPrivateSet ->isPrivateSet ());
973984 }
974985
975- /** @return list<array{0: non-empty-string, 1: bool}> */
986+ /** @return list<array{0: non-empty-string, 1: bool, 2: int-mask-of<ReflectionPropertyAdapter::IS_*> }> */
976987 public static function asymmetricVisibilityImplicitFinalProvider (): array
977988 {
978989 return [
979- ['publicPrivateSetIsFinal ' , true ],
980- ['protectedPrivateSetIsFinal ' , true ],
981- ['privatePrivateSetIsNotFinal ' , false ],
990+ ['publicPrivateSetIsFinal ' , true , ReflectionPropertyAdapter:: IS_PUBLIC | ReflectionPropertyAdapter:: IS_PRIVATE_SET_COMPATIBILITY | ReflectionPropertyAdapter:: IS_FINAL_COMPATIBILITY ],
991+ ['protectedPrivateSetIsFinal ' , true , ReflectionPropertyAdapter:: IS_PROTECTED | ReflectionPropertyAdapter:: IS_PRIVATE_SET_COMPATIBILITY | ReflectionPropertyAdapter:: IS_FINAL_COMPATIBILITY ],
992+ ['privatePrivateSetIsNotFinal ' , false , ReflectionPropertyAdapter:: IS_PRIVATE ],
982993 ];
983994 }
984995
985- /** @param non-empty-string $propertyName */
996+ /**
997+ * @param non-empty-string $propertyName
998+ * @param int-mask-of<ReflectionPropertyAdapter::IS_*> $modifiers
999+ */
9861000 #[DataProvider('asymmetricVisibilityImplicitFinalProvider ' )]
987- public function testAsymmetricVisibilityImplicitFinal (string $ propertyName , bool $ isFinal ): void
1001+ public function testAsymmetricVisibilityImplicitFinal (string $ propertyName , bool $ isFinal, int $ modifiers ): void
9881002 {
9891003 $ reflector = new DefaultReflector (new SingleFileSourceLocator (__DIR__ . '/../Fixture/AsymmetricVisibilityImplicitFinal.php ' , $ this ->astLocator ));
9901004 $ classInfo = $ reflector ->reflectClass ('Roave\BetterReflectionTest\Fixture\AsymmetricVisibilityImplicitFinal ' );
9911005 $ property = $ classInfo ->getProperty ($ propertyName );
9921006
9931007 self ::assertSame ($ isFinal , $ property ->isFinal ());
1008+ self ::assertSame ($ modifiers , $ property ->getModifiers ());
9941009 }
9951010
9961011 /** @return list<array{0: non-empty-string, 1: bool}> */
@@ -1023,6 +1038,7 @@ public function testIsAbstract(): void
10231038
10241039 $ hookProperty = $ classInfo ->getProperty ('hook ' );
10251040 self ::assertTrue ($ hookProperty ->isAbstract ());
1041+ self ::assertTrue ($ hookProperty ->isPublic ());
10261042 }
10271043
10281044 public function testIsAbstractInInterface (): void
@@ -1032,6 +1048,7 @@ public function testIsAbstractInInterface(): void
10321048
10331049 $ abstractProperty = $ classInfo ->getProperty ('abstractPropertyFromInterface ' );
10341050 self ::assertTrue ($ abstractProperty ->isAbstract ());
1051+ self ::assertTrue ($ abstractProperty ->isPublic ());
10351052 }
10361053
10371054 public function testNoHooks (): void
@@ -1212,6 +1229,20 @@ public function testExtendingHooks(): void
12121229 self ::assertSame ('Roave\BetterReflectionTest\Fixture\GetAndSetPropertyHook ' , $ getAndSetHookProperty ->getHook (ReflectionPropertyHookType::Set)->getDeclaringClass ()->getName ());
12131230 }
12141231
1232+ public function testExtendingHooks2 (): void
1233+ {
1234+ $ reflector = new DefaultReflector (new SingleFileSourceLocator (__DIR__ . '/../Fixture/PropertyHooks.php ' , $ this ->astLocator ));
1235+
1236+ $ classInfo = $ reflector ->reflectClass ('Roave\BetterReflectionTest\Fixture\ExtendedHooks ' );
1237+
1238+ $ getAndSetHookProperty = $ classInfo ->getProperty ('hook ' );
1239+ self ::assertCount (2 , $ getAndSetHookProperty ->getHooks ());
1240+ self ::assertTrue ($ getAndSetHookProperty ->hasHook (ReflectionPropertyHookType::Get));
1241+ self ::assertTrue ($ getAndSetHookProperty ->hasHook (ReflectionPropertyHookType::Set));
1242+ self ::assertSame ('Roave\BetterReflectionTest\Fixture\ExtendedHooks ' , $ getAndSetHookProperty ->getHook (ReflectionPropertyHookType::Get)->getDeclaringClass ()->getName ());
1243+ self ::assertSame ('Roave\BetterReflectionTest\Fixture\BothPropertyHooks ' , $ getAndSetHookProperty ->getHook (ReflectionPropertyHookType::Set)->getDeclaringClass ()->getName ());
1244+ }
1245+
12151246 public function testUseHookFromTrait (): void
12161247 {
12171248 $ reflector = new DefaultReflector (new SingleFileSourceLocator (__DIR__ . '/../Fixture/PropertyHooks.php ' , $ this ->astLocator ));
0 commit comments