nategood / commando

An Elegant CLI Library for PHP
MIT License
798 stars 80 forks source link

PHP 8.1.1 - PHP Deprecated Warning ReturnTypeWillChange #112

Closed stevenjcarr closed 4 months ago

stevenjcarr commented 2 years ago

$ php composer.phar info | grep commando nategood/commando 0.4.0 PHP CLI Commando Style

$ php -v PHP 8.1.1 (cli) (built: Dec 17 2021 23:49:52) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.1, Copyright (c) Zend Technologies with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies


When running one of my scripts I'm getting the deprecation messages below when executing the following commands:

$cmds = new Commando\Command(); $cmds->option('c')->aka('country')->describedAs('2 or 3 letter country code')->required(); $cmds->option('p')->aka('provinces')->describedAs('List provinces')->boolean();

PHP Deprecated: Return type of Commando\Command::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 842

PHP Deprecated: Return type of Commando\Command::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 853

PHP Deprecated: Return type of Commando\Command::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 869

PHP Deprecated: Return type of Commando\Command::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 878

PHP Deprecated: Return type of Commando\Command::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 895

PHP Deprecated: Return type of Commando\Command::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 912

PHP Deprecated: Return type of Commando\Command::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 904

PHP Deprecated: Return type of Commando\Command::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 921

PHP Deprecated: Return type of Commando\Command::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ***/vendor/nategood/commando/src/Commando/Command.php on line 886

bobdenotter commented 1 year ago

This repository seems abandoned. For our project we need an updated version, so i've forked it and created two releases: One for PHP 8.0+ (including 8.2), and one for PHP 7.2+. This means it's a simple drop-in replacement.

You can use it, by running composer req bobdenotter/commando, or by editing a current composer.json:

replace …

       "nategood/commando": "^0.4.0",

with …

        "bobdenotter/commando": "^0.4 || ^1.0",

… and run composer update.