Last active
August 29, 2015 14:04
-
-
Save jk/b1bfb94c7f276f53f46b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameter #0 [ <required> BaseClass $baseClass ] | |
array(4) { | |
'type hinted class' => | |
string(9) "BaseClass" | |
'position' => | |
int(0) | |
'default value available?' => | |
bool(false) | |
'variable / param name' => | |
string(9) "baseClass" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BaseClass { | |
function baseMethod($param) { | |
return $this; | |
} | |
} | |
class MyClass extends BaseClass { | |
function __construct() { | |
return $this; | |
} | |
function myMethod(BaseClass $baseClass, $other, $default = 'default') { | |
return $this; | |
} | |
} | |
$c1 = new ReflectionClass('BaseClass'); | |
$c2 = new ReflectionClass('MyClass'); | |
$c2m = $c2->getMethod('myMethod'); | |
$c2mp = $c2m->getParameters(); | |
$param = $c2mp[0]; | |
$info = [ | |
'type hinted class' => $param->getClass()->getName(), | |
'position' => $param->getPosition(), | |
'default value available?' => $param->isDefaultValueAvailable(), | |
'variable / param name' => $param->getName() | |
]; | |
Reflection::export($param); | |
var_dump($info); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment