cli : If the provided argument is -?, display the variable with the phpdoc associated
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3070 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
28
cli.php
28
cli.php
@@ -295,8 +295,8 @@ class cli
|
|||||||
$paramsConst = array ();
|
$paramsConst = array ();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$r = new ReflectionMethod ($class, "__construct");
|
$r1 = new ReflectionMethod ($class, "__construct");
|
||||||
$paramsConst = $r->getParameters();
|
$paramsConst = $r1->getParameters();
|
||||||
$min = $max = count ($paramsConst);
|
$min = $max = count ($paramsConst);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
@@ -304,15 +304,33 @@ class cli
|
|||||||
// No constructor available in class
|
// No constructor available in class
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = new ReflectionMethod ($class, $method);
|
$r2 = new ReflectionMethod ($class, $method);
|
||||||
$params = $r->getParameters();
|
$params = $r2->getParameters();
|
||||||
foreach ($params as $param)
|
foreach ($params as $param)
|
||||||
{
|
{
|
||||||
if (!$param->isOptional())
|
if (!$param->isOptional())
|
||||||
$min++;
|
$min++;
|
||||||
$max++;
|
$max++;
|
||||||
}
|
}
|
||||||
unset ($r);
|
|
||||||
|
if (in_array ("-?", $argv))
|
||||||
|
{
|
||||||
|
// Question mark display the PHPDoc of the method
|
||||||
|
$comment = trim (substr ($r1->getDocComment (), 3, -2));
|
||||||
|
if ($comment !== "") $comment .= "\n";
|
||||||
|
$comment .= trim (substr ($r2->getDocComment (), 3, -2));
|
||||||
|
$comment = preg_replace ("#^\s*\*\s*#m", "", $comment);
|
||||||
|
$comment = preg_replace ("#@param .+ \\$(\w+) #U", "<\\1> ", $comment);
|
||||||
|
$params = "";
|
||||||
|
foreach ($r1->getParameters() as $param)
|
||||||
|
$params .= "<".$param->name."> ";
|
||||||
|
foreach ($r2->getParameters() as $param)
|
||||||
|
$params .= "<".$param->name."> ";
|
||||||
|
echo "Parameters : $params\n$comment\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
unset ($r1);
|
||||||
|
unset ($r2);
|
||||||
|
|
||||||
if (count ($argv) < $min)
|
if (count ($argv) < $min)
|
||||||
die ("Not enough parameters provided to method\n");
|
die ("Not enough parameters provided to method\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user