コード例 #1
0
 /**
  * Returns a method introspection instance.
  *
  * @param string $method
  *
  * @throws InvalidArgumentException
  *
  * @return MethodInspector
  */
 public function getMethod($method)
 {
     if (!$this->hasMethod($method)) {
         throw InvalidArgumentException::create('Method %s not found.', $method);
     }
     return $this->createMethodDefinition($this->reflection()->getName(), $method);
 }
コード例 #2
0
 /**
  * @param string $name
  *
  * @throws InvalidArgumentException
  *
  * @return PropertyInspector
  */
 public function getProperty($name)
 {
     if (!$this->hasProperty($name)) {
         throw InvalidArgumentException::create('Property %s not found.', $name);
     }
     return $this->createPropertyDefinition($this->reflection()->getName(), $name);
 }
コード例 #3
0
 /**
  * @param string $name
  *
  * @throws InvalidArgumentException
  *
  * @return ConstantInspector
  */
 public function getConstant($name)
 {
     if (!$this->hasConstant($name)) {
         throw InvalidArgumentException::create('Constant %s not found.', $name);
     }
     return $this->createConstantDefinition($this->reflection()->getName(), $name);
 }
コード例 #4
0
 /**
  * @param string $name
  *
  * @throws InvalidArgumentException
  *
  * @return InterfaceInspector
  */
 public function getInterface($name)
 {
     if (!$this->implementsInterface($name)) {
         throw InvalidArgumentException::create('Interface %s not found.', $name);
     }
     try {
         return $this->createInterfaceDefinition($name);
     } catch (InvalidArgumentException $e) {
         return $this->createInterfaceDefinition($this->namespaceName() . '\\' . $name);
     }
 }
コード例 #5
0
 /**
  * @todo Real implementation should be written
  *
  * @throws RuntimeException
  */
 public static function export($class, $name)
 {
     $constant = $class . '::' . $name;
     if (!defined($constant)) {
         throw InvalidArgumentException::create('Constant "%s" does not exist', $constant);
     }
     $reflect = new \ReflectionClass($class);
     $valOriginal = constant($constant);
     $valFormatted = $valOriginal;
     if (is_array($valOriginal)) {
         $valFormatted = '';
         foreach ($valOriginal as $key => $value) {
             $valFormatted .= '[' . $key . '] => ' . ($value ?: 'NULL') . ', ';
         }
         $valFormatted = substr($valFormatted, 0, strlen($valFormatted) - 2);
     } elseif (is_null($valOriginal)) {
         $valFormatted = 'NULL';
     }
     printf("Constant [ %s %s::%s ] {\n  %s\n}", gettype($valOriginal), $reflect->getName(), $name, $valFormatted);
 }
コード例 #6
0
 /**
  * @param mixed ...$for
  *
  * @return InvalidArgumentException
  */
 protected final function getConstructorException(...$for)
 {
     $message = [];
     foreach ($for as $i => $f) {
         $message[] = sprintf('parameter "%d" must be valid %s, got type "%s" containing "%s"', $i + 1, $f[0], gettype($f[1]), $f[1]);
     }
     return InvalidArgumentException::create('Invalid constructor parameters provided: %s', implode('; ', $message));
 }