From cfb9135ac6d24345246f5321bdf7ebae13fd2d7d Mon Sep 17 00:00:00 2001 From: Zimzat Date: Thu, 27 Feb 2025 16:01:22 -0500 Subject: [PATCH] property_exists: Update example to show more scenarios. The main thing to highlight is that property visibility and `__get` and `__isset` is not checked. --- .../classobj/functions/property-exists.xml | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/reference/classobj/functions/property-exists.xml b/reference/classobj/functions/property-exists.xml index b8f2e54d7c6f..eb9c9c687d26 100644 --- a/reference/classobj/functions/property-exists.xml +++ b/reference/classobj/functions/property-exists.xml @@ -65,26 +65,55 @@ instanced = 'abc'; + +foreach (['$instance' => $instance, 'MyClass::class' => MyClass::class] as $type => $value) { + foreach (['public', 'protectedStatic', 'private', 'undefined', 'instanced'] as $property) { + printf( + "property_exists(%s, %s) === %s\n", + $type, + var_export($property, true), + var_export(property_exists($value, $property), true), + ); + } +} ?> ]]> + &example.outputs; + + +