BetterReflection\Reflection\ReflectionClass::createFromInstance PHP Method

createFromInstance() public static method

This is simply a helper method that calls ReflectionObject::createFromInstance().
See also: ReflectionObject::createFromInstance
public static createFromInstance ( object $instance ) : ReflectionClass
$instance object
return ReflectionClass
    public static function createFromInstance($instance)
    {
        if (gettype($instance) !== 'object') {
            throw new \InvalidArgumentException('Instance must be an instance of an object');
        }
        return ReflectionObject::createFromInstance($instance);
    }

Usage Example

Beispiel #1
0
 /**
  * createFromPlaceholder extracts the methods of a placeholder that can be called from a template.
  *
  * Methods must be public and take a Call object as the first argument.
  *
  * @return \nochso\WriteMe\Reflection\Method[]
  */
 public function createFromPlaceholder(Placeholder $placeholder)
 {
     $methods = [];
     $class = Reflection\ReflectionClass::createFromInstance($placeholder);
     foreach ($class->getMethods() as $method) {
         if ($this->isCallable($method)) {
             $methods[] = new Method($placeholder, $method);
         }
     }
     return $methods;
 }
All Usage Examples Of BetterReflection\Reflection\ReflectionClass::createFromInstance