nunomaduro / laravel-console-menu

🔘 Beautiful PHP CLI menus. Is a php-school/cli-menu wrapper for Laravel/Artisan Console Commands
MIT License
802 stars 40 forks source link

If option item text is greater than width, it has syntax error #8

Closed mikeerickson closed 6 years ago

mikeerickson commented 6 years ago

Using the following

$options = ['Item 1',str_repeat('-', 80),'Item 3'];
$option = $this->menu('Select', $options)
   ->setWidth(40);

produces the following error

 Whoops\Exception\ErrorException  : str_repeat(): Second argument has to be greater than or equal to 0

  at /Users/merickson/docker/localenv/m4-tools/vendor/php-school/cli-menu/src/CliMenu.php: 319
  315:                 str_repeat(' ', $this->style->getMargin()),
  316:                 $setColour,
  317:                 str_repeat(' ', $this->style->getPadding()),
  318:                 $row,
  319:                 str_repeat(' ', $this->style->getRightHandPadding(mb_strlen(s::stripAnsiEscapeSequence($row)))),
  320:                 $unsetColour,
  321:                 str_repeat(' ', $this->style->getMargin())
  322:             );
  323:         }, $rows);
  324:     }

  Exception trace:

  1   str_repeat(" ")
      /Users/merickson/docker/localenv/m4-tools/vendor/php-school/cli-menu/src/CliMenu.php : 319

  2   PhpSchool\CliMenu\CliMenu::PhpSchool\CliMenu\{closure}("  --------------------------------------------------------------------------------")
      [internal] : 0

  Please use the argument -v to see more details.
nunomaduro commented 6 years ago

Thanks, @mikeerickson. But I will close this issue due to the lack of activity.