pear2 / Net_RouterOS

This package allows you to read and write information from a RouterOS host using the MikroTik RouterOS API protocol.
http://pear2.php.net/PEAR2_Net_RouterOS
241 stars 115 forks source link

Fix deprecation errors in modern PHP #75

Closed miken32 closed 2 years ago

miken32 commented 2 years ago

Project seems dead, but whatever. Gets rid of these notices:

PHP Deprecated:  Return type of PEAR2\Net\RouterOS\Message::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/Message.php on line 183
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\Message::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/Message.php on line 193
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\Util::count(?PEAR2\Net\RouterOS\Query $query = null, $from = null) should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/Util.php on line 955
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::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 src/PEAR2/Net/RouterOS/ResponseCollection.php on line 311
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::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 src/PEAR2/Net/RouterOS/ResponseCollection.php on line 326
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::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 src/PEAR2/Net/RouterOS/ResponseCollection.php on line 348
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::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 src/PEAR2/Net/RouterOS/ResponseCollection.php on line 364
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::seek($position) should either be compatible with SeekableIterator::seek(int $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 389
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 419
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 407
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 456
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 466
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 374
PHP Deprecated:  Return type of PEAR2\Net\RouterOS\ResponseCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/PEAR2/Net/RouterOS/ResponseCollection.php on line 297
PHP Deprecated:  stream_get_line(): Passing null to parameter #2 ($length) of type int is deprecated in src/PEAR2/Net/RouterOS/Response.php on line 228

Used the #[\ReturnTypeWillChange] attribute in a few places since mixed is not available as a return type in the (technically) still supported PHP 7.4.

boenrobot commented 2 years ago

Please rebase this against the develop branch.

It's not that the project is dead, it's that I don't have time for it.

After this PR, I think I'll just make a composer only tag, as the biggest roadblock to a normal release is the phar production, which requires packages that are now dead.

miken32 commented 2 years ago

Thanks, just noticed there was a dev branch more recently updated. Will close and re-submit against dev