/**
  * @param string $className
  * @param string $methodName
  * @param Factory $factory <-
  */
 public function __construct($className, $methodName, Factory $factory)
 {
     parent::__construct(self::asClass($className, $methodName), $factory);
     $this->method = new \ReflectionMethod($className, $methodName);
     $this->createClassDefinition();
     $this->setName(ucfirst(preg_replace('/([a-z])([A-Z])/', '$1 $2', $this->method->getShortName())));
 }
Example #2
0
 /**
  * @param $callable
  *
  * @return string
  */
 public function getCallableName($callable)
 {
     $name = '(Unknown)';
     if (is_array($callable)) {
         $method = new \ReflectionMethod($callable[0], $callable[1]);
         $className = $method->getDeclaringClass()->getName();
         $className = str_replace('Ciconia\\Extension\\', '', $className);
         $name = $className . ':' . $method->getShortName();
     }
     return $name;
 }
 /**
  * @param \ReflectionMethod $reflectionMethod
  * @param \Donquixote\HastyReflectionCommon\Reflection\FunctionLike\MethodReflectionInterface $methodReflection
  */
 private function assertEqualMethods(\ReflectionMethod $reflectionMethod, MethodReflectionInterface $methodReflection)
 {
     $this->assertEquals($reflectionMethod->isAbstract(), $methodReflection->isAbstract());
     $this->assertEquals($reflectionMethod->getDeclaringClass()->getName(), $methodReflection->getDeclaringClassName());
     $this->assertEquals($reflectionMethod->getDocComment(), $methodReflection->getDocComment());
     $this->assertEquals($reflectionMethod->getShortName(), $methodReflection->getName());
     $this->assertEquals($reflectionMethod->getName(), $methodReflection->getName());
     $this->assertEquals($reflectionMethod->class . '::' . $reflectionMethod->getName(), $methodReflection->getQualifiedName());
     $this->assertEquals($reflectionMethod->returnsReference(), $methodReflection->isByReference());
     $this->assertEquals($reflectionMethod->isPrivate(), $methodReflection->isPrivate());
     $this->assertEquals($reflectionMethod->isProtected(), $methodReflection->isProtected());
     $this->assertEquals($reflectionMethod->isPublic(), $methodReflection->isPublic());
     $this->assertEquals($reflectionMethod->isStatic(), $methodReflection->isStatic());
 }
 /**
  * Add a method to the reflected class.
  *
  * @param ReflectionMethod $method
  */
 public function addMethod(ReflectionMethod $method)
 {
     $this->methods[$method->getShortName()] = $method;
     $method->setDeclaringClassLike($this);
     $method->setFilename($this->getFileName());
     return $this;
 }
Example #5
0
 /**
  * @param \ReflectionMethod $method
  * @return string
  * @todo ¿Quizás moverlo al Inflector?
  */
 private static function fieldFromInjector(\ReflectionMethod $method)
 {
     $name = substr($method->getShortName(), strlen('inject'));
     return Inflector::hyphenate($name);
 }
    $staticX++;
    $x = $staticX;
    return $x;
}
class Test
{
    public function test()
    {
    }
}
$rf = new \ReflectionFunction('\\foo\\bar\\f');
print "--- getShortName(\"\\foo\\bar\\f\") ---\n";
var_dump($rf->getShortName());
print "\n";
print "--- getNamespaceName(\"\\foo\\bar\\f\") ---\n";
var_dump($rf->getNamespaceName());
print "\n";
$rf = new \ReflectionMethod('\\foo\\bar\\Test', 'test');
print "--- getShortName(\"\\foo\\bar\\Test::test\") ---\n";
var_dump($rf->getShortName());
print "\n";
print "--- getNamespaceName(\"\\foo\\bar\\Test::test\") ---\n";
var_dump($rf->getNamespaceName());
print "\n";
$rf = new \ReflectionFunction('\\strlen');
print "--- getShortName(\"strlen\") ---\n";
var_dump($rf->getShortName());
print "\n";
print "--- getNamespaceName(\"strlen\") ---\n";
var_dump($rf->getNamespaceName());
print "\n";
 /**
  * handle custom metadata for method annotation
  *
  * @param ClassMetadata $metadata
  * @param \ReflectionMethod $method
  */
 public function processMetadataForMethod(ClassMetadata $metadata, \ReflectionMethod $method)
 {
     $metadata->tags[$this->key] = $this->value;
     $metadata->tags[$this->key . '.target'] = $method->getShortName();
 }
Example #8
0
 private static function isMethod(\ReflectionMethod $method, $prefix)
 {
     return $method->isPublic() && !$method->isStatic() && 0 === $method->getNumberOfRequiredParameters() && $prefix === substr($method->getShortName(), 0, strlen($prefix));
 }