Source for file InlineHelp.php
Documentation is available at InlineHelp.php
require_once "PHP/Shell/Extensions.php";
require_once "PHP/Shell/Extensions/Prototypes.php";
class PHP_Shell_Extensions_InlineHelp implements PHP_Shell_Extension {
public function register () {
$cmd = PHP_Shell_Commands ::getInstance ();
$cmd->registerCommand ('#^\? #', $this, 'cmdHelp', '? <var>',
'show the DocComment a Class, Method or Function'.PHP_EOL.
' e.g.: ? fopen(), ? PHP_Shell, ? $__shell');
* handle the '?' commands
* With the help of the Reflection Class we extract the DocComments and display them
* For internal Functions we extract the prototype from the php source.
* The license of the PHP_Shell class
* @return string the help text
public function cmdHelp ($l) {
if (preg_match('#^([A-Za-z0-9_]+)::([a-zA-Z0-9_]+)\(\s*\)\s*#', $str, $a)) {
if (false !== ($proto = PHP_ShellPrototypes ::getInstance ()->get ($class. '::'. $method))) {
$cmd = sprintf("/**\n* %s\n\n* @params %s\n* @return %s\n*/\n",
$c = new ReflectionClass ($class);
if ($c->hasMethod ($method)) {
$cmd = $c->getMethod ($method)->getDocComment ();
} else if (preg_match('#^\$([A-Za-z0-9_]+)->([a-zA-Z0-9_]+)\(\s*\)\s*#', $str, $a)) {
if (isset ($GLOBALS[$a[1 ]]) && is_object($GLOBALS[$a[1 ]])) {
$c = new ReflectionClass ($class);
if ($c->hasMethod ($method)) {
$cmd = $c->getMethod ($method)->getDocComment ();
} else if (preg_match('#^([A-Za-z0-9_]+)::([a-zA-Z0-9_]+)\s*$#', $str, $a)) {
$c = new ReflectionClass ($class);
if ($c->hasProperty ($property)) {
$cmd = $c->getProperty ($property)->getDocComment ();
} else if (preg_match('#^\$([A-Za-z0-9_]+)->([a-zA-Z0-9_]+)\s*$#', $str, $a)) {
if (isset ($GLOBALS[$a[1 ]]) && is_object($GLOBALS[$a[1 ]])) {
$c = new ReflectionClass ($class);
if ($c->hasProperty ($property)) {
$cmd = $c->getProperty ($property)->getDocComment ();
} else if (preg_match('#^([A-Za-z0-9_]+)$#', $str, $a)) {
$c = new ReflectionClass ($a[1 ]);
$cmd = $c->getDocComment ();
} else if (preg_match('#^\$([A-Za-z0-9_]+)$#', $str, $a)) {
if (isset ($GLOBALS[$obj]) && is_object($GLOBALS[$obj])) {
$c = new ReflectionClass ($class);
$cmd = $c->getDocComment ();
} else if (preg_match('#^([A-Za-z0-9_]+)\(\s*\)$#', $str, $a)) {
if (false !== ($proto = PHP_ShellPrototypes ::getInstance ()->get ($func))) {
$cmd = sprintf("/**\n* %s\n*\n* @params %s\n* @return %s\n*/\n",
$c = new ReflectionFunction ($func);
$cmd = $c->getDocComment ();
Documentation generated on Mon, 11 Mar 2019 14:40:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|