当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionMethod::getDeclaringClass方法代码示例

本文整理汇总了PHP中ReflectionMethod::getDeclaringClass方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::getDeclaringClass方法的具体用法?PHP ReflectionMethod::getDeclaringClass怎么用?PHP ReflectionMethod::getDeclaringClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionMethod的用法示例。


在下文中一共展示了ReflectionMethod::getDeclaringClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getClass

 /**
  * @return IReflectionReflection
  */
 public function getClass()
 {
     if ($this->reflectionReflection === null) {
         $this->reflectionReflection = new ReflectionReflection($this->reflectionMethod->getDeclaringClass());
     }
     return $this->reflectionReflection;
 }
开发者ID:edde-framework,项目名称:edde,代码行数:10,代码来源:MethodReflection.php

示例2: getOriginalClass

 /**
  * @return ClassParser
  */
 private function getOriginalClass()
 {
     if (is_null($this->originalClass)) {
         $this->originalClass = new ClassParser($this->reflector->getDeclaringClass()->name);
     }
     return $this->originalClass;
 }
开发者ID:mhamlet,项目名称:laravel-apidocs,代码行数:10,代码来源:MethodParser.php

示例3: methodData

function methodData(ReflectionMethod $method)
{
    $cname = strtolower($method->getDeclaringClass()->name);
    $mname = trim(str_replace("_", "-", strtolower($method->name)), "-");
    $ename = strtolower($method->getDeclaringClass()->getExtension()->name);
    $fname = DOCBOOK . "/{$ename}/{$cname}/{$mname}.xml";
    if (!file_exists($fname)) {
        //echo "No file $fname\n";
        return "";
    }
    $data = file_get_contents($fname);
    $data = preg_replace("/&[\\w.]+;/", "", $data);
    $xml = simplexml_load_string($data);
    $comment = (string) $xml->refnamediv->refpurpose;
    $return = (string) $xml->refsect1->methodsynopsis->type;
    $out = <<<END
/**
 * {$comment}

END;
    $args = array();
    foreach ($xml->refsect1->methodsynopsis->methodparam as $param) {
        $out .= " * @param {$param->type} \${$param->parameter}\n";
        $args[] = "\$" . $param->parameter;
    }
    if ($return) {
        $out .= " * @return {$return}\n";
    }
    $out .= " */\n";
    return array($out, $args);
}
开发者ID:smalyshev,项目名称:Reflector,代码行数:31,代码来源:reflector.php

示例4: execute

 public function execute($object)
 {
     $handler = $this->factory->getInstance($this->method->getDeclaringClass()->getName());
     $properties = $this->getProperties($object);
     $args = [];
     foreach ($this->method->getParameters() as $parameter) {
         $args[] = $properties[$parameter->getName()]->get($object);
     }
     return call_user_func_array([$handler, $this->method->getName()], $args);
 }
开发者ID:watoki,项目名称:qrator,代码行数:10,代码来源:MethodActionRepresenter.php

示例5: getAnnotationType

 private function getAnnotationType($annotation)
 {
     $matches = array();
     $found = preg_match('/@' . $annotation . '\\s+(\\S+)/', $this->reflection->getDocComment(), $matches);
     if (!$found) {
         return new UnknownType();
     }
     $type = new TypeFactory($this->reflection->getDeclaringClass());
     return $type->fromTypeHints(explode("|", $matches[1]));
 }
开发者ID:rtens,项目名称:mockster3,代码行数:10,代码来源:ReturnTypeInferer.php

示例6: handleMethodAnnotations

 /**
  * Handle method annotations
  *
  * @param mixed             $targetObj
  * @param \ReflectionMethod $reflection
  * @param array             $annotations
  *
  * @return mixed
  */
 public function handleMethodAnnotations(\ReflectionMethod $reflection, array $annotations, $targetObj = null)
 {
     if (isset($annotations['Route'])) {
         foreach ($annotations['Route'] as $route) {
             if ($route instanceof \stdClass && isset($route->path)) {
                 $symfonyRoute = new Route($route->path, isset($route->defaults) ? $route->defaults : [], isset($route->requirements) ? $route->requirements : [], isset($route->options) ? $route->options : [], isset($route->host) ? $route->host : '', isset($route->schemes) ? $route->schemes : [], isset($route->methods) ? $route->methods : []);
                 $symfonyRoute->setOption('karmaController', $reflection->getDeclaringClass()->getName());
                 $symfonyRoute->setOption('karmaAction', $reflection->getName());
                 $this->routeCollection->add(isset($route->name) ? $route->name : $reflection->getDeclaringClass()->getName() . ':' . $reflection->getName(), $symfonyRoute);
             }
         }
     }
 }
开发者ID:thinframe,项目名称:karma,代码行数:22,代码来源:RouteHandler.php

示例7: function

 function __call($func, $args)
 {
     $di = property_exists($this, 'di') && $this->di instanceof Di ? $this->di : Di::getInstance();
     if (substr($func, 0, 4) == 'call' && ctype_upper(substr($func, 4, 1)) && (method_exists($this, $m = lcfirst(substr($func, 4))) || method_exists($this, $m = '_' . $m))) {
         $params = $di->methodGetParams($this, $m, $args);
         $closure = function () use($m, $params) {
             return call_user_func_array([$this, $m], $params);
         };
         $closure->bindTo($this);
         return $closure();
     }
     $method = '_' . $func;
     if (method_exists($this, $method)) {
         if (!(new \ReflectionMethod($this, $method))->isPublic()) {
             throw new \RuntimeException("The called method is not public.");
         }
         return $di->method($this, $method, $args);
     }
     if (($c = get_parent_class($this)) && method_exists($c, __FUNCTION__)) {
         $m = new \ReflectionMethod($c, __FUNCTION__);
         $dc1 = $m->getDeclaringClass()->name;
         $dc2 = (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->name;
         $dc3 = get_class($this);
         if ($dc1 != $dc2 || $dc2 != $dc3 && $dc1 != $dc3) {
             return parent::__call($func, $args);
         }
     }
     throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '->' . $func);
 }
开发者ID:redcatphp,项目名称:ding,代码行数:29,代码来源:CallTrait.php

示例8: addMethod

 protected function addMethod(\ReflectionMethod $refMethod)
 {
     $class = $refMethod->getDeclaringClass();
     $params = $this->getParamsString($refMethod);
     $module = $class->getName();
     $body = '';
     $doc = $this->addDoc($class, $refMethod);
     $doc = str_replace('/**', '', $doc);
     $doc = trim(str_replace('*/', '', $doc));
     if (!$doc) {
         $doc = "*";
     }
     $conditionalDoc = $doc . "\n     * Conditional Assertion: Test won't be stopped on fail";
     $methodTemplate = (new Template($this->methodTemplate))->place('module', $module)->place('method', $refMethod->name)->place('params', $params);
     // generate conditional assertions
     if (0 === strpos($refMethod->name, 'see')) {
         $type = 'Assertion';
         $body .= $methodTemplate->place('doc', $conditionalDoc)->place('action', 'can' . ucfirst($refMethod->name))->place('step', 'ConditionalAssertion')->produce();
         // generate negative assertion
     } elseif (0 === strpos($refMethod->name, 'dontSee')) {
         $type = 'Assertion';
         $body .= $methodTemplate->place('doc', $conditionalDoc)->place('action', str_replace('dont', 'cant', $refMethod->name))->place('step', 'ConditionalAssertion')->produce();
     } elseif (0 === strpos($refMethod->name, 'am')) {
         $type = 'Condition';
     } else {
         $type = 'Action';
     }
     $body .= $methodTemplate->place('doc', $doc)->place('action', $refMethod->name)->place('step', $type)->produce();
     return $body;
 }
开发者ID:hilmysyarif,项目名称:erp,代码行数:30,代码来源:Actor.php

示例9: checkMethod

 public function checkMethod(\ReflectionMethod $method)
 {
     $class = $method->getDeclaringClass();
     if (!$class->isSubclassOf(self::BASE_CLASS_NAME)) {
         throw new \Exception(sprintf("%s with @(%s) must extends from class(%s)", \Dev::getMethodDeclaring($method), __CLASS__, self::BASE_CLASS_NAME));
     }
     if ($method->isPrivate() || $method->isPublic()) {
         throw new \Exception(sprintf("%s with @(%s) must be protected", \Dev::getMethodDeclaring($method), __CLASS__));
     }
     if ($method->isStatic()) {
         throw new \Exception(sprintf("%s with @(%s) can not be static", \Dev::getMethodDeclaring($method), __CLASS__));
     }
     if ($method->isAbstract()) {
         throw new \Exception(sprintf("%s with @(%s) can not be abstract", \Dev::getMethodDeclaring($method), __CLASS__));
     }
     if ($method->isConstructor()) {
         throw new \Exception(sprintf("%s with @(%s) can not be constructor", \Dev::getMethodDeclaring($method), __CLASS__));
     }
     if ($method->isDestructor()) {
         throw new \Exception(sprintf("%s with @(%s) can not be destructor", \Dev::getMethodDeclaring($method), __CLASS__));
     }
     $ps = $method->getParameters();
     if (count($ps) !== 0) {
         throw new \Exception(sprintf("%s with @(%s) can not has parameters", \Dev::getMethodDeclaring($method), __CLASS__));
     }
 }
开发者ID:symforce,项目名称:symforce-discuz,代码行数:26,代码来源:Action.php

示例10: getDeclaringClass

 /**
  * Get reflection of declaring class
  *
  * @return ClassReflection
  */
 public function getDeclaringClass()
 {
     $phpReflection = parent::getDeclaringClass();
     $zendReflection = new ClassReflection($phpReflection->getName());
     unset($phpReflection);
     return $zendReflection;
 }
开发者ID:zhangyuxiao,项目名称:qoros,代码行数:12,代码来源:MethodReflection.php

示例11: check

 /**
  * Checks if the value is typehinted with a class and if the current value can be coerced into that type
  *
  * It can either convert to datetime or attempt to fetched from the db by id
  *
  * @param  mixed   $obj    instance or class name
  * @param  string  $method
  * @param  string  $value
  * @param  integer $pNum
  * @return mixed
  */
 public function check($obj, $method, $value, $pNum = 0)
 {
     if (!is_numeric($value) && !is_string($value)) {
         return $value;
     }
     $reflection = new \ReflectionMethod($obj, $method);
     $params = $reflection->getParameters();
     if (!$params[$pNum]->getClass()) {
         return $value;
     }
     $hintedClass = $params[$pNum]->getClass()->getName();
     if ($hintedClass === 'DateTime') {
         try {
             if (preg_match('{^[0-9]+$}', $value)) {
                 $value = '@' . $value;
             }
             return new \DateTime($value);
         } catch (\Exception $e) {
             throw new \UnexpectedValueException('Could not convert ' . $value . ' to DateTime for ' . $reflection->getDeclaringClass()->getName() . '::' . $method, 0, $e);
         }
     }
     if ($hintedClass) {
         if (!$this->manager) {
             throw new \LogicException('To reference objects by id you must first set a Nelmio\\Alice\\PersisterInterface object on this instance');
         }
         $value = $this->manager->find($hintedClass, $value);
     }
     return $value;
 }
开发者ID:enumag,项目名称:alice,代码行数:40,代码来源:TypeHintChecker.php

示例12: vote

 /**
  * Iteratively check all given attributes by calling isGranted.
  *
  * This method terminates as soon as it is able to return ACCESS_GRANTED
  * If at least one attribute is supported, but access not granted, then ACCESS_DENIED is returned
  * Otherwise it will return ACCESS_ABSTAIN
  *
  * @param TokenInterface $token      A TokenInterface instance
  * @param object         $object     The object to secure
  * @param array          $attributes An array of attributes associated with the method being invoked
  *
  * @return int either ACCESS_GRANTED, ACCESS_ABSTAIN, or ACCESS_DENIED
  */
 public function vote(TokenInterface $token, $object, array $attributes)
 {
     if (!$object || !$this->supportsClass(get_class($object))) {
         return self::ACCESS_ABSTAIN;
     }
     // abstain vote by default in case none of the attributes are supported
     $vote = self::ACCESS_ABSTAIN;
     $reflector = new \ReflectionMethod($this, 'voteOnAttribute');
     $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AbstractVoter';
     if (!$isNewOverwritten) {
         @trigger_error(sprintf("The AbstractVoter::isGranted method is deprecated since 2.8 and won't be called anymore in 3.0. Override voteOnAttribute() instead.", $reflector->class), E_USER_DEPRECATED);
     }
     foreach ($attributes as $attribute) {
         if (!$this->supportsAttribute($attribute)) {
             continue;
         }
         // as soon as at least one attribute is supported, default is to deny access
         $vote = self::ACCESS_DENIED;
         if ($isNewOverwritten) {
             if ($this->voteOnAttribute($attribute, $object, $token)) {
                 // grant access as soon as at least one voter returns a positive response
                 return self::ACCESS_GRANTED;
             }
         } else {
             if ($this->isGranted($attribute, $object, $token->getUser())) {
                 // grant access as soon as at least one voter returns a positive response
                 return self::ACCESS_GRANTED;
             }
         }
     }
     return $vote;
 }
开发者ID:pierreleplatois,项目名称:sialab,代码行数:45,代码来源:AbstractVoter.php

示例13: convertMethodAnnotations

 public function convertMethodAnnotations(\ReflectionMethod $method, array $annotations)
 {
     $parameters = array();
     foreach ($method->getParameters() as $index => $parameter) {
         $parameters[$parameter->getName()] = $index;
     }
     $methodMetadata = new MethodMetadata($method->getDeclaringClass()->getName(), $method->getName());
     foreach ($annotations as $annotation) {
         if ($annotation instanceof Secure) {
             $methodMetadata->roles = $annotation->roles;
         } else {
             if ($annotation instanceof SecureParam) {
                 if (!isset($parameters[$annotation->name])) {
                     throw new \InvalidArgumentException(sprintf('The parameter "%s" does not exist for method "%s".', $annotation->name, $method->getName()));
                 }
                 $methodMetadata->addParamPermissions($parameters[$annotation->name], $annotation->permissions);
             } else {
                 if ($annotation instanceof SecureReturn) {
                     $methodMetadata->returnPermissions = $annotation->permissions;
                 } else {
                     if ($annotation instanceof SatisfiesParentSecurityPolicy) {
                         $methodMetadata->satisfiesParentSecurityPolicy = true;
                     } else {
                         if ($annotation instanceof RunAs) {
                             $methodMetadata->runAsRoles = $annotation->roles;
                         }
                     }
                 }
             }
         }
     }
     return $methodMetadata;
 }
开发者ID:rfc1483,项目名称:cascade,代码行数:33,代码来源:AnnotationConverter.php

示例14: storeMethod

 /**
  * Store ReflectionMethod object with computed key, the key is returned.
  * Method also stores the declaring class into class reflection collection.
  *
  * @param ReflectionMethod $reflection
  * @return string the key
  */
 public function storeMethod(ReflectionMethod $reflection)
 {
     $classReflection = $reflection->getDeclaringClass();
     if (!$this->classes->hasClass($classReflection->getName())) {
         $this->classes->storeClass($classReflection);
     }
     return $this->methods->storeMethod($reflection);
 }
开发者ID:juraj-blahunka,项目名称:Bachelor-Thesis,代码行数:15,代码来源:ReflectionCache.php

示例15:

 function it_generates_correct_message_based_on_function_and_parameter(\ReflectionParameter $parameter, \ReflectionMethod $function, \ReflectionClass $class)
 {
     $parameter->getPosition()->willReturn(2);
     $function->getDeclaringClass()->willReturn($class);
     $class->getName()->willReturn('Acme\\Foo');
     $function->getName()->willReturn('bar');
     $this->getMessage()->shouldStartWith('Collaborator must be an object: argument 2 defined in Acme\\Foo::bar.');
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:8,代码来源:InvalidCollaboratorTypeExceptionSpec.php


注:本文中的ReflectionMethod::getDeclaringClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。