proper scoping to callback structures + usage Information Method

This commit is contained in:
kremsy
2017-03-26 12:42:20 +02:00
parent 4effad8f6d
commit de3bae9029
16 changed files with 172 additions and 132 deletions

View File

@@ -3,8 +3,8 @@
namespace ManiaControl\Callbacks\Structures;
use ManiaControl\General\Dumpable;
use ManiaControl\ManiaControl;
use ReflectionClass;
/**
* Base Structure of all Callback Structures
@@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class BaseStructure implements Dumpable {
abstract class BaseStructure {
/** @var ManiaControl $maniaControl */
protected $maniaControl;
private $plainJsonObject;
@@ -31,10 +31,34 @@ abstract class BaseStructure implements Dumpable {
}
/**
* Var_Dump the Structure
* Gets Information about the Class, and a List of the Public Method
*/
public function dump() {
var_dump(json_decode(json_encode($this)));
var_dump("Class Name including Namespace: " . get_class($this));
public function getUsage() {
$reflection = new ReflectionClass(get_class($this));
echo $reflection->getDocComment();
echo "\nStructure Name of Class = " . get_class($this);
echo "\nMethods:\n";
$metody = $reflection->getMethods();
$methods = array_reverse($metody);
foreach ($methods as $key => $value) {
/** @var \ReflectionMethod $value */
//Don't print the Constructor
if ($value->isPublic() && $value->getName() != "__construct" && $value->getName() != "getUsage") {
echo "\n\n";
$txt = preg_replace('/\t/', '', $value->getDocComment());
echo $txt;
echo "\n \$result = " . $value->getName() . "();";
$parameters = $value->getParameters();
foreach ($parameters as $parameter) {
echo "\n" . $parameter;
}
echo "\n";
}
}
}
}