Skip to content

Commit

Permalink
Merge pull request #54 from Ocramius/fix/#50-correct-arraystack-getit…
Browse files Browse the repository at this point in the history
…erator-php-8.1-deprecation

Fix for #50 - added `ReturnTypeWillChange` to `ArrayStack#getIterator()`, to comply with PHP 8.1 requirements
  • Loading branch information
Ocramius authored Jan 21, 2022
2 parents d0c4bfd + 5ec3bfe commit bcd869e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 4 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
colors="true"
convertDeprecationsToExceptions="true"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
Expand Down
2 changes: 2 additions & 0 deletions src/ArrayStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use ArrayIterator;
use ArrayObject as PhpArrayObject;
use ReturnTypeWillChange;

use function array_reverse;

Expand All @@ -22,6 +23,7 @@ class ArrayStack extends PhpArrayObject
*
* @return ArrayIterator
*/
#[ReturnTypeWillChange]
public function getIterator()
{
$array = $this->getArrayCopy();
Expand Down
22 changes: 22 additions & 0 deletions test/ArrayStackTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace LaminasTest\Stdlib;

use Laminas\Stdlib\ArrayStack;
use PHPUnit\Framework\TestCase;

use function iterator_to_array;

/** @covers \Laminas\Stdlib\ArrayStack */
final class ArrayStackTest extends TestCase
{
public function testIteration(): void
{
self::assertSame(
['c', 'b', 'a'],
iterator_to_array(new ArrayStack(['a', 'b', 'c']))
);
}
}

0 comments on commit bcd869e

Please sign in to comment.