Skip to content

Commit

Permalink
Fix lang.IndexOutOfBoundsException (Undefined array key 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 28, 2024
1 parent c8f4c69 commit 5ce5384
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/php/xp/command/CmdRunner.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ protected function commandUsage(Type $type) {
if ('' === (string)$comment) {
$markdown= '# '.$type->name()."\n\n";
$text= '';
} else if (false === ($p= strpos($comment, "\n"))) {
$markdown= '# '.$comment."\n\n";
$text= '';
} else {
@list($headline, $text)= explode("\n", $comment, 2);
$markdown= '# '.ltrim($headline, ' #')."\n\n";
$markdown= '# '.ltrim(substr($comment, 0, $p), ' #')."\n\n";
$text= substr($comment, $p + 1);
}

$markdown.= "- Usage\n ```sh\n$ xp cmd ".Commands::nameOf($type->class());
Expand Down

0 comments on commit 5ce5384

Please sign in to comment.