1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/reflection/tests/asymmetric_visibility_flags.phpt
Daniel Scherzer 81f143e71f Reflection: indicate final and abstract properties in string output
Add "final" and "abstract" to the result of `_property_string()` when
outputting the string representation of a `ReflectionClass` or
`ReflectionProperty` instance

Closes GH-17827
2025-02-25 12:21:15 +01:00

35 lines
799 B
PHP

--TEST--
ReflectionProperty::is{Private,Protected}Set
--FILE--
<?php
class Foo {
public private(set) int $bar;
public protected(set) int $baz;
}
function test($property) {
$reflectionProperty = new ReflectionProperty(Foo::class, $property);
var_dump($reflectionProperty->isPrivateSet());
var_dump($reflectionProperty->isProtectedSet());
var_dump(($reflectionProperty->getModifiers() & ReflectionProperty::IS_PRIVATE_SET) !== 0);
var_dump(($reflectionProperty->getModifiers() & ReflectionProperty::IS_PROTECTED_SET) !== 0);
echo $reflectionProperty;
}
test('bar');
test('baz');
?>
--EXPECT--
bool(true)
bool(false)
bool(true)
bool(false)
Property [ final public private(set) int $bar ]
bool(false)
bool(true)
bool(false)
bool(true)
Property [ public protected(set) int $baz ]