amphp / injector

A recursive dependency injector used to bootstrap and wire together S.O.L.I.D., object-oriented PHP applications.
MIT License
31 stars 7 forks source link

Adjust types due to php 8.1 deprecations #15

Closed thgs closed 2 years ago

thgs commented 2 years ago

Running the tests on php 8.1 gives deprecations like so

$ ./vendor/bin/phpunit test
PHPUnit 9.5.13 by Sebastian Bergmann and contributors.

PHP Deprecated:  Return type of Amp\Injector\Definitions::getIterator(): iterable should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /amphp/injector/src/Definitions.php on line 35
.
Deprecated: Return type of Amp\Injector\Definitions::getIterator(): iterable should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /amphp/injector/src/Definitions.php on line 35
......PHP Deprecated:  Return type of Amp\Injector\Container::getIterator(): iterable should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /amphp/injector/src/Container.php on line 20
.
Deprecated: Return type of Amp\Injector\Container::getIterator(): iterable should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /amphp/injector/src/Container.php on line 20
............................                              36 / 36 (100%)

Time: 00:00.268, Memory: 6.00 MB

OK (36 tests, 59 assertions)

If you want to keep return type as iterable maybe with a new method?

kelunik commented 2 years ago

Thanks!

thgs commented 2 years ago

@kelunik thanks as well!