Skip to content

Commit

Permalink
add a check to ensure that a reflection object exists before trying t…
Browse files Browse the repository at this point in the history
…o fetch the doc comment; also expand on the quoting logic: add a better (token based) check to determine when an input string should be quoted
  • Loading branch information
scoates authored and ieure committed Nov 29, 2009
1 parent b2a3203 commit 78bf2b2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions PHP/Repl.php
Expand Up @@ -227,7 +227,11 @@ private function cleanup($input)
$input = $last;
}

if (substr($input, 0, 1) != '$') {
// if the input string contains anything but a single variable,
// wrap it in single-quotes
$tokens = token_get_all(rtrim("<php {$input}", "\t ;"));
if (!(count($tokens) == 2 && isset($tokens[1][0]) &&
$tokens[1][0] = T_VARIABLE)) {
$input = "'$input'";
}
return $this->cleanup("\$this->{$sugar[$m]}($input)");
Expand Down Expand Up @@ -381,8 +385,12 @@ protected function dir($thing)
*/
protected function doc($thing)
{
echo preg_replace('/^\s*\*/m', ' *',
$this->getReflection($thing)->getDocComment()) . "\n";
if ($r = $this->getReflection($thing)) {
echo preg_replace('/^\s*\*/m', ' *',
$r->getDocComment()) . "\n";
} else {
echo "(no doc)\n";
}
return "---";
}
}
Expand Down

0 comments on commit 78bf2b2

Please sign in to comment.