- assert: documentation ( source)
- var_dump: documentation ( source)
- get_object_vars: documentation ( source)
<?php
class A {
public ?string $foo;
public string $foobar;
public ?string $bar = '';
}
$vars = get_object_vars(new A);
var_dump(assert(array_key_exists('bar', $vars)) ? 'bar exists in $vars' : 'bar does not exist in $vars');
var_dump(assert(array_key_exists('foobar', $vars)) ? 'foobar exists in $vars' : 'foobar does not exist in $vars');
var_dump(assert(array_key_exists('foo', $vars)) ? 'foo exists in $vars' : 'foo does not exist in $vars');