PHP 8.5.0 Alpha 4 available for testing

Voting

: four minus zero?
(Example: nine)

The Note You're Voting On

metamarkers at gmail dot com
12 years ago
If you're reflecting an object and get the declaring class of a property that's set but wasn't declared in any class, it returns the class of the instance.

<?php

class X {

}

$x = new X();
$x->foo = 'bar';
$reflection = new ReflectionObject($x);
echo
$reflection->getProperty('foo')->getDeclaringClass()->getName(); // X

?>

<< Back to user notes page

To Top