From 5ec3bfe8468f9efadbc33d2765100c8b710c65ae Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 21 Jan 2022 16:47:31 +0100 Subject: [PATCH] Fix for #50 - added `ReturnTypeWillChange` to `ArrayStack#getIterator()`, to comply with PHP 8.1 requirements Also marked any future detected deprecations as failures --- phpunit.xml.dist | 6 ++++-- src/ArrayStack.php | 2 ++ test/ArrayStackTest.php | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 test/ArrayStackTest.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index afc76c8a..4ac939cb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,9 +1,11 @@ - + colors="true" + convertDeprecationsToExceptions="true" +> ./src diff --git a/src/ArrayStack.php b/src/ArrayStack.php index 2198288e..d25ba5a6 100644 --- a/src/ArrayStack.php +++ b/src/ArrayStack.php @@ -6,6 +6,7 @@ use ArrayIterator; use ArrayObject as PhpArrayObject; +use ReturnTypeWillChange; use function array_reverse; @@ -22,6 +23,7 @@ class ArrayStack extends PhpArrayObject * * @return ArrayIterator */ + #[ReturnTypeWillChange] public function getIterator() { $array = $this->getArrayCopy(); diff --git a/test/ArrayStackTest.php b/test/ArrayStackTest.php new file mode 100644 index 00000000..5a2df140 --- /dev/null +++ b/test/ArrayStackTest.php @@ -0,0 +1,22 @@ +