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.
Exemplo n.º 1
0
 function testMostGeneralPossibleSignature()
 {
     $reflection = new SimpleReflection('AnyOldThing');
     $this->assertEqualIgnoringCase($reflection->getSignature('aMethod'), 'function &aMethod()');
 }
 function testParameterCreationForTypeHinting()
 {
     $reflection = new SimpleReflection('AnyOldTypeHintedClass');
     $function = $reflection->getSignature('aMethod');
     if (version_compare(phpversion(), '5.0.2', '<=')) {
         $this->assertEqual('function amethod(AnyOldInterface $argument)', $function);
     } else {
         $this->assertEqual('function aMethod(AnyOldInterface $argument)', $function);
     }
 }
 function testUnsetFunctionSignature()
 {
     $reflection = new SimpleReflection('AnyOldOverloadedClass');
     $function = $reflection->getSignature('__unset');
     if (version_compare(phpversion(), '5.1.0', '>=')) {
         $this->assertEqual('function __unset($key)', $function);
     } else {
         $this->assertEqual('function __unset()', $function);
     }
 }
 function testCanProperlyGenerateAbstractMethods()
 {
     $reflection = new SimpleReflection('AnyOldAbstractClassWithAbstractMethods');
     $this->assertEqual('function anAbstract()', $reflection->getSignature('anAbstract'));
     $this->assertEqual('function anAbstractWithParameter($foo)', $reflection->getSignature('anAbstractWithParameter'));
     $this->assertEqual('function anAbstractWithMultipleParameters($foo, $bar)', $reflection->getSignature('anAbstractWithMultipleParameters'));
 }
Exemplo n.º 5
0
 function testCopingWithSpecialMethodunsetPHP51()
 {
     $reflection = new SimpleReflection('AnyOldClassInvokingMethodsWithArgumentsInConstructor');
     $this->assertEqual('function __unset($key)', $reflection->getSignature('__unset'));
     $this->assertEqual('function __unset($key)', $reflection->getSignature('__unset', SIG_GEN_DECLARE));
     $this->assertEqual('parent::__unset($key)', $reflection->getSignature('__unset', SIG_GEN_INVOKE_AS_PARENT));
     $this->expectError(new PatternExpectation('/Reflection does not \\(yet\\) support mode ' . SIG_GEN_ASSIGN_ONLY_THE_ARGS . ' for __unset/'));
     $this->assertEqual('$key', $reflection->getSignature('__unset', SIG_GEN_DECLARE_ONLY_THE_ARGS));
     $this->assertEqual('$key', $reflection->getSignature('__unset', SIG_GEN_INVOKE_ONLY_THE_ARGS));
     $this->assertEqual('', $reflection->getSignature('__unset', SIG_GEN_ASSIGN_ONLY_THE_ARGS));
     $this->expectError(new PatternExpectation('/Reflection does not \\(yet\\) support mode ' . SIG_GEN_ASSIGN_ONLY_THE_ARGS . ' for __unset/'));
     $this->expectError(new PatternExpectation('/Reflection does not \\(yet\\) support mode ' . SIG_GEN_ASSIGN_ONLY_THE_ARGS . ' for __unset/'));
     $this->expectError(new PatternExpectation('/Reflection does not \\(yet\\) support mode ' . SIG_GEN_ASSIGN_ONLY_THE_ARGS . ' for __unset/'));
     $this->assertEqual('function __unset($key)', $reflection->getSignature('__unset', SIG_GEN_DECLARE, array('assign' => array('arg1' => 'A10', 'arg2' => 'B20'))));
     $this->assertEqual('parent::__unset($key)', $reflection->getSignature('__unset', SIG_GEN_INVOKE_AS_PARENT, array('assign' => array('arg1' => 'A10', 'arg2' => 'B20'))));
     $this->assertEqual('', $reflection->getSignature('__unset', SIG_GEN_ASSIGN_ONLY_THE_ARGS, array('assign' => array('arg1' => 'A10', 'arg2' => 'B20'))));
     $this->assertEqual('PREFIX::$key::POSTFIX', $reflection->getSignature('__unset', SIG_GEN_DECLARE_ONLY_THE_ARGS, array('prefix' => 'PREFIX::', 'postfix' => '::POSTFIX')));
     $this->assertEqual('PREFIX::$key::POSTFIX', $reflection->getSignature('__unset', SIG_GEN_INVOKE_ONLY_THE_ARGS, array('prefix' => 'PREFIX::', 'postfix' => '::POSTFIX')));
     $this->assertEqual('', $reflection->getSignature('__unset', SIG_GEN_ASSIGN_ONLY_THE_ARGS, array('prefix' => 'PREFIX::', 'postfix' => '::POSTFIX')));
     $this->assertEqual('', $reflection->getSignature('__unset', SIG_GEN_ASSIGN_ONLY_THE_ARGS, array('assign' => array('arg1' => 'A10', 'arg2' => 'B20'), 'prefix' => 'PREFIX::', 'postfix' => '::POSTFIX')));
     $this->assertEqual('PREFIX::$key::POSTFIX', $reflection->getSignature('__unset', SIG_GEN_DECLARE_ONLY_THE_ARGS, array('assign' => array('arg1' => 'A10'), 'prefix' => 'PREFIX::', 'postfix' => '::POSTFIX')));
 }
Exemplo n.º 6
0
 function testParameterCreationForTypeHinting()
 {
     $reflection = new SimpleReflection('AnyOldTypeHintedClass');
     $function = $reflection->getSignature('aMethod');
     $this->assertEqual('function aMethod(SimpleTest $argument)', $function);
 }