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 | |
return | BetterReflection\Reflection\ReflectionMethod |
public function testCreateFromInstance() { $property = ReflectionProperty::createFromInstance(new ClassForHinting(), 'someProperty'); $this->assertInstanceOf(ReflectionProperty::class, $property); $this->assertSame('someProperty', $property->getName()); }