/**
	 * Is a method callable? It means class is instantiable and method has
	 * public visibility, is non-static and non-abstract.
	 * @param  string  method name
	 * @return bool
	 */
	public function hasCallableMethod($method)
	{
		$class = $this->getName();
		$cache = & self::$mcCache[strtolower($class . ':' . $method)];
		if ($cache === NULL) try {
			$cache = FALSE;
			$rm = Nette\Reflection\MethodReflection::from($class, $method);
			$cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic();
		} catch (\ReflectionException $e) {
		}
		return $cache;
	}
示例#2
0
 /**
  * @return Nette\Reflection\MethodReflection
  */
 public function getConstructor()
 {
     return ($ref = parent::getConstructor()) ? MethodReflection::import($ref) : NULL;
 }
示例#3
0
 /**
  * Converts list of arguments to named parameters.
  * @param  string  class name
  * @param  string  method name
  * @param  array   arguments
  * @param  array   supplemental arguments
  * @return void
  * @throws InvalidLinkException
  */
 private static function argsToParams($class, $method, &$args, $supplemental = array())
 {
     static $cache;
     $params =& $cache[strtolower($class . ':' . $method)];
     if ($params === NULL) {
         $params = Nette\Reflection\MethodReflection::from($class, $method)->getDefaultParameters();
     }
     $i = 0;
     foreach ($params as $name => $def) {
         if (array_key_exists($i, $args)) {
             $args[$name] = $args[$i];
             unset($args[$i]);
             $i++;
         } elseif (array_key_exists($name, $args)) {
             // continue with process
         } elseif (array_key_exists($name, $supplemental)) {
             $args[$name] = $supplemental[$name];
         } else {
             continue;
         }
         if ($def === NULL) {
             if ((string) $args[$name] === '') {
                 $args[$name] = NULL;
             }
             // value transmit is unnecessary
         } else {
             settype($args[$name], gettype($def));
             if ($args[$name] === $def) {
                 $args[$name] = NULL;
             }
         }
     }
     if (array_key_exists($i, $args)) {
         throw new InvalidLinkException("Extra parameter for signal '{$class}:{$method}'.");
     }
 }
示例#4
0
	/**
	 * @return Nette\Reflection\MethodReflection
	 */
	public function getConstructor()
	{
		return ($ref = parent::getConstructor()) ? MethodReflection::from($this->getName(), $ref->getName()) : NULL;
	}
示例#5
0
 /**
  * @return Nette\Reflection\MethodReflection
  */
 public function getMethod($name)
 {
     return MethodReflection::import(parent::getMethod($name));
 }
 /**
  * @return Nette\Reflection\MethodReflection | Nette\Reflection\FunctionReflection
  */
 public function getDeclaringFunction()
 {
     return ($ref = parent::getDeclaringFunction()) instanceof \ReflectionMethod ? MethodReflection::import($ref) : FunctionReflection::import($ref);
 }