BetterReflection\Reflection\ReflectionProperty::createFromInstance PHP Метод

createFromInstance() публичный статический Метод

Create a reflection of an instance's property by it's name
public static createFromInstance ( object $instance, string $propertyName ) : BetterReflection\Reflection\ReflectionMethod
$instance object
$propertyName string
Результат BetterReflection\Reflection\ReflectionMethod
    public static function createFromInstance($instance, $propertyName)
    {
        return ReflectionClass::createFromInstance($instance)->getProperty($propertyName);
    }

Usage Example

 public function testCreateFromInstance()
 {
     $property = ReflectionProperty::createFromInstance(new ClassForHinting(), 'someProperty');
     $this->assertInstanceOf(ReflectionProperty::class, $property);
     $this->assertSame('someProperty', $property->getName());
 }