예제 #1
0
	/**
	 * @return NMethodReflection
	 */
	public function getConstructor()
	{
		return ($ref = parent::getConstructor()) ? NMethodReflection::from($this->getName(), $ref->getName()) : NULL;
	}
예제 #2
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;
 }
예제 #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.");
		}
	}