Created
June 20, 2014 23:39
-
-
Save scintill/841e8643112bd1fb38a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Extract an interface definition from an existing class. | |
* | |
* Found while cleaning up old files -- I am only assuming it works. :) | |
*/ | |
$class = new ReflectionClass($className); | |
foreach ($class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC) as $method) { | |
if ($method->isPublic()) echo 'public '; | |
if ($method->isStatic()) echo 'static '; | |
echo 'function ', $method->getName(), '('; | |
foreach ($method->getParameters() as $i => $param) { | |
if ($i) { | |
echo ', '; | |
} | |
if ($param->isArray()) { | |
echo 'array '; | |
} | |
echo '$', $param->getName(); | |
if ($param->isDefaultValueAvailable()) { | |
echo ' = ', var_export($param->getDefaultValue(), true); | |
} | |
} | |
echo ");\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment