/** * Create a syntax highlighted diagram of class functions, and optionally the current output of each method. * Only use the autofire if you are sure ALL METHODS perform a non-permanent functions. * * --== WARNING, USING AUTOFIRE IS DANGEROUS AND CAN DESTROY DATA PERMANENTLY ==-- * * For instance, autofiring a function called delete_all_users() ...will do exactly that! * * You have been warned! * * @param object $obj The object to explore. * @param boolean $autofire Fire each method, to acertain its current return value. * @return [type] [description] */ public static function methods($obj, $autofire = false) { echo self::$is_themed ? '' : self::$theme; $methods = get_class_methods($obj); asort($methods); echo "<pre class='obj_explorer'>" . PHP_EOL; self::classes($obj); $cnt = 0; foreach ($methods as $m) { echo "<div class='method'>"; $fnc = new \ReflectionMethod($obj, $m); $num = $fnc->getNumberOfParameters(); $req = $fnc->getNumberOfRequiredParameters(); $arg = $fnc->getParameters(); $mod = implode(' ', \Reflection::getModifierNames($fnc->getModifiers())) . ' '; $lin = self::get_func_url($fnc->getStartLine(), $fnc->getEndLine(), $fnc->getFileName()); $exp = $fnc->getEndLine(); $dbk = $fnc->getDocComment(); $nam = "function <b id='{$m}' class='nam'>{$m}</b>"; # Parse method arguments if ($num > 0) { $arg = implode($arg, ', '); preg_match_all('/\\[(.*?)\\]/', $arg, $arg); $arg = implode($arg[1], ','); # Remove optional required tags $arg = preg_replace('/<required>|<optional>|<head>/', "", $arg); # Strip double spaces $arg = preg_replace('/\\s+/', "", $arg); # Add nice spacing $arg = preg_replace('/,/', ', ', $arg); # Add Function brackets $arg = "({$arg})"; } else { # No arguments with this function, empty brackets $arg = '()'; } # Completed function string $function = $mod . $nam . $arg; # Docblock $dbk = self::clean_docblok($dbk); # Convert tabs to space $dbk = preg_replace('/\\t+/', ' ', $dbk); # Realign offset offset docbloks $dbk = preg_replace('/\\s\\s+\\*/', "\n *", $dbk); # Completed docblok string $dokblock = $dbk; # Return Defaults $result = 'autofire disabled '; $type = 'safemode'; # Parse return value if ($autofire) { if ($req) { $result = "<b class='com'>...Untested {$req} required argument(s) needed</b>"; } else { $result = $obj->{$m}(); $type = gettype($result); if ($type === "boolean") { $type = AlpStrings::boolstr($result); $result = ''; } if ($type === "integer") { } if ($type === "double") { } if ($type === "string") { $result = "'{$result}'"; } if ($type === "array") { $result = PHP_EOL . PHP_EOL . '{ARR}' . print_r($result, true) . '{/ARR}'; } if ($type === "object") { $result = 'object'; #recurse! } if ($type === "resource") { $result = $type; } if ($type === "NULL") { $result = "<b class='com'>...Check page src for possible function echo</b>"; } if ($type === "unknown type") { $result = $type; } } } #divider and Line Info # Completed return string $result = "<b class='ops'>" . trim("Returned </b>(<b class='dec'>{$type}</b>)") . " {$result}"; $method_info = $dokblock . PHP_EOL . PHP_EOL . $function . PHP_EOL . PHP_EOL . $result; $method_info = Syntax::php($method_info, 'all'); echo $lin; echo $method_info; echo "</div>"; } echo '</pre>'; return; /* #echo implode(' ', Reflection::getModifierNames($fnc->getModifiers())).PHP_EOL; #echo 'getParameters() : '.print_r( $fnc->getParameters()).PHP_EOL; #echo 'getStaticVariables() : '.print_r( $fnc->getStaticVariables()).PHP_EOL; #echo 'isAbstract() : '.AT::boolstr( $fnc->isAbstract()).PHP_EOL; #echo 'isConstructor() : '.AT::boolstr( $fnc->isConstructor()).PHP_EOL; #echo 'isDestructor() : '.AT::boolstr( $fnc->isDestructor()).PHP_EOL; #echo 'isFinal() : '.AT::boolstr( $fnc->isFinal()).PHP_EOL; #echo 'isPrivate() : '.AT::boolstr( $fnc->isPrivate()).PHP_EOL; #echo 'isProtected() : '.AT::boolstr( $fnc->isProtected()).PHP_EOL; #echo 'isPublic() : '.AT::boolstr( $fnc->isPublic()).PHP_EOL; #echo 'isStatic() : '.AT::boolstr( $fnc->isStatic()).PHP_EOL; #echo 'inNamespace() : '.AT::boolstr( $fnc->inNamespace()).PHP_EOL; #echo 'isClosure() : '.AT::boolstr( $fnc->isClosure()).PHP_EOL; #echo 'isDeprecated() : '.AT::boolstr( $fnc->isDeprecated()).PHP_EOL; #echo 'isGenerator() : '.AT::boolstr( $fnc->isGenerator()).PHP_EOL; #echo 'isInternal() : '.AT::boolstr( $fnc->isInternal()).PHP_EOL; #echo 'isUserDefined() : '.AT::boolstr( $fnc->isUserDefined()).PHP_EOL; #echo 'returnsReference() : '.AT::boolstr( $fnc->returnsReference()).PHP_EOL; #echo 'Name : '. $fnc->name.PHP_EOL; #echo 'Class : '. $fnc->class.PHP_EOL; #echo 'getModifiers() : '. implode(' ', Reflection::getModifierNames($fnc->getModifiers())).PHP_EOL; #echo 'getEndLine() : '. $fnc->getEndLine().PHP_EOL; #echo 'getNumberOfParameters() : '. $fnc->getNumberOfParameters().PHP_EOL; #echo 'getNumberOfRequiredParameters() : '. $fnc->getNumberOfRequiredParameters().PHP_EOL; #echo 'getStartLine() : '. $fnc->getStartLine().PHP_EOL; #echo 'getDocComment() : '. $fnc->getDocComment().PHP_EOL; #echo 'getExtensionName() : '. $fnc->getExtensionName().PHP_EOL; #echo 'getFileName() : '. $fnc->getFileName().PHP_EOL; #echo 'getName() : '. $fnc->getName().PHP_EOL; #echo 'getNamespaceName() : '. $fnc->getNamespaceName().PHP_EOL; #echo 'getShortName() : '. $fnc->getShortName().PHP_EOL; */ }