SimpleReflection::getSignature PHP Method

getSignature() public method

Writes the source code matching the declaration of a method.
public getSignature ( string $name ) : string
$name string Method name.
return string Method signature up to last bracket.
    public function getSignature($name)
    {
        if ($name === '__set') {
            return 'function __set($key, $value)';
        }
        if ($name === '__call') {
            return 'function __call($method, $arguments)';
        }
        if ($name === '__get') {
            return 'function __get($key)';
        }
        if ($name === '__isset') {
            return 'function __isset($key)';
        }
        if ($name === '__unset') {
            return 'function __unset($key)';
        }
        if ($name === '__toString') {
            return 'function __toString()';
        }
        /**
         * @todo
         * 1) This wonky try-catch is a work around for a faulty method_exists()
         *    in early versions of PHP 5 which would return false for static methods.
         * 2) The Reflection classes work fine, but hasMethod() doesn't exist prior to PHP 5.1.0,
         *    so we need to use a more crude detection method.
         */
        try {
            $interface = new ReflectionClass($this->interface);
            $interface->getMethod($name);
        } catch (ReflectionException $e) {
            return "function {$name}()";
        }
        return $this->getFullSignature($name);
    }

Usage Example

Ejemplo n.º 1
0
 function testMostGeneralPossibleSignature()
 {
     $reflection = new SimpleReflection('AnyOldThing');
     $this->assertEqualIgnoringCase($reflection->getSignature('aMethod'), 'function &aMethod()');
 }
All Usage Examples Of SimpleReflection::getSignature