本文整理汇总了PHP中ReflectionMethod::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::__construct方法的具体用法?PHP ReflectionMethod::__construct怎么用?PHP ReflectionMethod::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionMethod
的用法示例。
在下文中一共展示了ReflectionMethod::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param mixed $class Classname or object (object of the class) that contains the method.
* @param string $name Name of the method
* @access public
* @return void
*/
public function __construct($class, $name)
{
parent::__construct($class, $name);
// get the annotations
$parser = new AnnotationParser($this->getDocComment());
$this->annotations = $parser->getAnnotationArray();
}
示例2: __construct
/**
* Construct a new reflection method object
* @param mixed $classOrName
* @param string $name name of the class
* @return null
*/
public function __construct($classOrName = null, $name = null)
{
parent::__construct($classOrName, $name);
if ($name) {
$this->className = $classOrName;
}
}
示例3: __construct
/**
* Constructs a new ReflectionMethod object.
*
* @param string|object $class
* @param string $name
* @throws ReflectionException
* @return ReflectionMethod
*/
public final function __construct($class, $name)
{
$bt = debug_backtrace();
if (!isset($bt[1]['class']) || $bt[1]['class'] !== __CLASS__) {
throw new ReflectionException('ReflectionClass\' constructor cannot be called from outside the class');
}
parent::__construct($class, $name);
}
示例4: __construct
/**
* @param mixed $class
* @param string $name
*
* @throws \LogicException
*/
public function __construct($class, $name)
{
parent::__construct($class, $name);
if (!$this->getDocComment()) {
throw new \LogicException(sprintf("Missing phpdoc on method '%s::%s()'", $this->getDeclaringClass()->getName(), $this->getName()));
}
$this->parsePhpDoc($this->getDocComment(), $this->getDeclaringClass()->getName(), $this->getName());
}
示例5: __construct
public function __construct($class, $name)
{
if (self::$adapterClass !== null) {
$this->adapter = new self::$adapterClass($class, $name);
} else {
parent::__construct($class, $name);
}
}
示例6: __construct
public function __construct($class, $name, $object, array $arguments = array())
{
parent::__construct($class, $name);
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object.');
}
$this->arguments = $arguments;
$this->object = $object;
}
示例7: __construct
/**
* Called when the object is constructed
*
* @param object $instance the method's instance
* @param string $name the method's name
* @return self
* @throws InvalidArgumentException if $instance is not an object
* @throws InvalidArgumentException if $name is not a string
* @throws OutOfBoundsException if method does not exist
* @throws OutOfBoundsException if method does exist but is not visible
* @throws ReflectionException if something else goes wrong
* @since 0.1.0
*/
public function __construct($instance, $name)
{
// if $instance is not an object, short-circuit
if (!is_object($instance)) {
throw new \InvalidArgumentException(__METHOD__ . "() expects parameter one, instance, to be an object");
}
// if $name is not a string, short-circuit
if (!is_string($name)) {
throw new \InvalidArgumentException(__METHOD__ . "() expects parameter two, name, to be a string");
}
// try to get the method
try {
$method = (new \ReflectionClass($instance))->getMethod($name);
// try to finish constructing the object
try {
// if the method is not visible, short-circuit
if ($method->isPrivate() && $method->class !== get_class($instance)) {
throw new \OutOfBoundsException("Method {$name}() is defined but not visible to " . get_class($instance));
}
// otherwise, chain the parent's constructor
parent::__construct($instance, $name);
// set the method's accessibility
// keep in mind, the method maintains its original visibility outside
// of this object's scope
//
$this->setAccessible(true);
// save the method's instance
$this->instance = $instance;
return;
} catch (\ReflectionException $e) {
// otherwise, something else went wrong
// re-throw the original ReflectionException
//
throw $e;
}
} catch (\ReflectionException $e) {
// otherwise, the method does not exist
// throw an OutOfBoundsException
//
throw new \OutOfBoundsException("Method {$name}() must be defined in class " . get_class($instance));
}
}
示例8: __construct
/**
* Constructs an new ezcReflectionMethod
*
* Usage Examples:
* <code>
* new ezcReflectionMethod( 'SomeClass', 'someMethod' );
* new ezcReflectionMethod( new ReflectionClass( 'SomeClass' ), 'someMethod' );
* new ezcReflectionMethod( 'SomeClass', new ReflectionMethod( 'SomeClass', 'someMethod' ) );
* new ezcReflectionMethod( new ReflectionClass( 'SomeClass' ), new ReflectionMethod( 'SomeClass', 'someMethod' ) );
* </code>
*
* The following way of creating an ezcReflectionMethod results in the
* current class being the declaring class, i.e., isInherited() and
* isIntroduced() may not return the expected results:
* <code>
* new ezcReflectionMethod( new ReflectionMethod( 'SomeClass', 'someMethod' ) );
* </code>
*
* @param string|ReflectionClass|ReflectionMethod $classOrSource
* Name of class, ReflectionClass, or ReflectionMethod of the method
* to be reflected
* @param string|ReflectionMethod $nameOrSource
* Name or ReflectionMethod instance of the method to be reflected
* Optional if $classOrSource is an instance of ReflectionMethod
*/
public function __construct($classOrSource, $nameOrSource = null)
{
if ($nameOrSource instanceof parent) {
$this->reflectionSource = $nameOrSource;
if ($classOrSource instanceof ReflectionClass) {
$this->currentClass = $classOrSource;
} else {
$this->currentClass = new ReflectionClass((string) $classOrSource);
}
} elseif ($classOrSource instanceof parent) {
$this->reflectionSource = $classOrSource;
$this->currentClass = new ReflectionClass($this->reflectionSource->class);
} elseif ($classOrSource instanceof ReflectionClass) {
parent::__construct($classOrSource->getName(), $nameOrSource);
$this->currentClass = $classOrSource;
} else {
parent::__construct($classOrSource, $nameOrSource);
$this->currentClass = new ReflectionClass((string) $classOrSource);
}
$this->docParser = ezcReflection::getDocCommentParser();
$this->docParser->parse($this->getDocComment());
}
示例9: __construct
public function __construct($name, $class)
{
parent::__construct($name, $class);
}
示例10:
function __construct($c, $m)
{
echo __METHOD__ . "\n";
parent::__construct($c, $m);
}
示例11: __construct
public function __construct($class, $name)
{
parent::__construct($class, $name);
$this->annotations = $this->createParser()->parse(AddendumCompatibility::getDocComment($this));
}
示例12: __construct
/**
* inits model
* @param string $class parsed class classname
* @param string $name parsed class methodname
*/
public function __construct($class, $name)
{
parent::__construct($class, $name);
$this->processComment();
}
示例13: __construct
public function __construct($name, $class)
{
parent::__construct($name, $class);
$this->annotation = Notoj::parseDocComment($this);
}
示例14: __construct
public function __construct(Type $type, $method, Reflection $reflection)
{
parent::__construct($type->name, $method);
$this->type = $type;
$this->reflection = $reflection;
}
示例15: __construct
/**
* Constructor.
*
* @param string|\TokenReflection\Php\ReflectionClass|\ReflectionClass $class Defining class
* @param string $methodName Method name
* @param \TokenReflection\Broker $broker Reflection broker
*/
public function __construct($class, $methodName, Broker $broker)
{
parent::__construct($class, $methodName);
$this->broker = $broker;
}