php-school / cli-menu

🖥 Build beautiful PHP CLI menus. Simple yet Powerful. Expressive DSL.
http://www.phpschool.io
MIT License
1.94k stars 107 forks source link

Menu blink because deprecated warning. #249

Closed atomatis closed 2 years ago

atomatis commented 2 years ago

Hello,

Sorry by advence for my poor english.

I have a little blink before show menu, because many deprecated warning is write before like

Deprecated: array_fill(): Passing null to parameter #2 ($count) of type int is deprecated in /Users/alexandre/Tools/krg-env/vendor/php-school/cli-menu/src/MenuStyle.php on line 672

PHP Deprecated: str_repeat(): Passing null to parameter #2 ($times) of type int is deprecated in /Users/alexandre/Tools/krg-env/vendor/php-school/cli-menu/src/MenuStyle.php on line 493

How reproduce:

Environment: php8.1, Mac Os Big Sur, iterm2 with zsh

Require cli menu and launch basic use found in doc

$itemCallable = function (CliMenu $menu) {
    echo $menu->getSelectedItem()->getText();
};

$menu = (new CliMenuBuilder())
    ->setTitle('Basic CLI Menu')
    ->addItem('First Item', $itemCallable)
    ->addItem('Second Item', $itemCallable)
    ->addItem('Third Item', $itemCallable)
    ->addLineBreak('-')
    ->setBorder(1, 2, 'yellow')
    ->setPadding(2, 4)
    ->setMarginAuto()
    ->build();

$menu->open();

My proposition:

Add shortand $var ?? 0 on str_repeat() and array_fill() parameters. Maybe add a declare(strict_types=1); for renforce code?

I will propose a PR soon.

Temporary fix:

A bad but functional error_reporting(E_ALL ^ E_DEPRECATED); before use remove deprecated warning.

AydinHassan commented 2 years ago

Fixed with #252 - thanks for reporting!

AydinHassan commented 2 years ago

Will tag a new release soon, just doing a bit of housekeeping

AydinHassan commented 2 years ago

@atomatis tagged 4.3.0

atomatis commented 2 years ago

Great! TY :)