Example #1
0
 function hasCallableMethod($method)
 {
     $class = $this->getName();
     $cache =& self::$mcCache[strtolower($class . ':' . $method)];
     if ($cache === NULL) {
         try {
             $cache = FALSE;
             $rm = NMethodReflection::from($class, $method);
             $cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic();
         } catch (ReflectionException $e) {
         }
     }
     return $cache;
 }
Example #2
0
	/**
	 * @return NMethodReflection
	 */
	public function getConstructor()
	{
		return ($ref = parent::getConstructor()) ? NMethodReflection::from($this->getName(), $ref->getName()) : NULL;
	}
Example #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 NInvalidLinkException
	 */
	private static function argsToParams($class, $method, & $args, $supplemental = array())
	{
		static $cache;
		$params = & $cache[strtolower($class . ':' . $method)];
		if ($params === NULL) {
			$params = NMethodReflection::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)) {
			$method = NMethodReflection::from($class, $method)->getName();
			throw new NInvalidLinkException("Passed more parameters than method $class::$method() expects.");
		}
	}
	/**
	 * Invokes function using named parameters.
	 * @param  array
	 * @return mixed
	 */
	public function invokeNamedArgs($args)
	{
		return $this->invokeArgs(NMethodReflection::combineArgs($this->getDefaultParameters(), $args));
	}
Example #5
0
File: loader.php Project: GE3/GE3
 function getDeclaringFunction()
 {
     return ($ref = parent::getDeclaringFunction()) instanceof ReflectionMethod ? NMethodReflection::import($ref) : NFunctionReflection::import($ref);
 }