1--TEST-- 2ReflectionProperty::is{Private,Protected}Set 3--FILE-- 4<?php 5 6class Foo { 7 public private(set) int $bar; 8 public protected(set) int $baz; 9} 10 11function test($property) { 12 $reflectionProperty = new ReflectionProperty(Foo::class, $property); 13 var_dump($reflectionProperty->isPrivateSet()); 14 var_dump($reflectionProperty->isProtectedSet()); 15 var_dump(($reflectionProperty->getModifiers() & ReflectionProperty::IS_PRIVATE_SET) !== 0); 16 var_dump(($reflectionProperty->getModifiers() & ReflectionProperty::IS_PROTECTED_SET) !== 0); 17 echo $reflectionProperty; 18} 19 20test('bar'); 21test('baz'); 22 23?> 24--EXPECT-- 25bool(true) 26bool(false) 27bool(true) 28bool(false) 29Property [ public private(set) int $bar ] 30bool(false) 31bool(true) 32bool(false) 33bool(true) 34Property [ public protected(set) int $baz ] 35