Skip to content

Commit

Permalink
Merge fb23b94 into 25510bf
Browse files Browse the repository at this point in the history
  • Loading branch information
gquemener committed Dec 26, 2021
2 parents 25510bf + fb23b94 commit 0a49a65
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
@@ -1,23 +1,18 @@
dist: focal
language: php

matrix:
fast_finish: true
include:
- php: 7.3
- php: 7.4
env:
- DEPENDENCIES=""
- XDEBUG_MODE="coverage"
- TEST_COVERAGE=true
- php: 7.3
- php: 7.4
env:
- DEPENDENCIES=""
- PHP_CS=true
- php: 7.3
env:
- DEPENDENCIES=""
- php: 7.3
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- php: 7.4
env:
- DEPENDENCIES=""
Expand All @@ -30,6 +25,12 @@ matrix:
- php: 8.0
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- php: 8.1.0
env:
- DEPENDENCIES=""
- php: 8.1.0
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"

cache:
directories:
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Expand Up @@ -24,9 +24,11 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.4 || ^8.0",
"marc-mabe/php-enum": "^2.3.1 || ^3.0.0 || ^4.0.0",
"prooph/common": "^4.5.0"
"prooph/common": "^4.5.0",
"ramsey/uuid": "^4.3",
"ramsey/collection": "^1.2"
},
"require-dev": {
"phpspec/prophecy": "^1.10.3",
Expand Down Expand Up @@ -75,6 +77,9 @@
"test": "phpunit"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true
}
}
}
1 change: 1 addition & 0 deletions src/StreamIterator/MergedStreamIterator.php
Expand Up @@ -72,6 +72,7 @@ public function next(): void
$this->prioritizeIterators();
}

#[\ReturnTypeWillChange]
public function current()
{
return $this->iterators[0][0]->current();
Expand Down
4 changes: 1 addition & 3 deletions src/Upcasting/UpcastingIterator.php
Expand Up @@ -91,9 +91,7 @@ public function next(): void
}
}

/**
* @return bool|int
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->innerIterator->key();
Expand Down
39 changes: 34 additions & 5 deletions tests/StreamIterator/AbstractStreamIteratorTest.php
Expand Up @@ -23,18 +23,47 @@ abstract class AbstractStreamIteratorTest extends TestCase
*/
public function it_implements_iterator(): void
{
$iterator = $this->getMockBuilder(StreamIterator::class)->getMock();

$this->assertInstanceOf(\Iterator::class, $iterator);
$this->assertInstanceOf(\Iterator::class, $this->getStreamIteratorMock());
}

/**
* @test
*/
public function it_implements_countable(): void
{
$iterator = $this->getMockBuilder(StreamIterator::class)->getMock();
$this->assertInstanceOf(\Countable::class, $this->getStreamIteratorMock());
}

private function getStreamIteratorMock(): StreamIterator
{
return new class() implements StreamIterator {
public function count(): int
{
return 0;
}

public function current(): mixed
{
return null;
}

public function key(): mixed
{
return null;
}

public function next(): void
{
}

public function rewind(): void
{
}

$this->assertInstanceOf(\Countable::class, $iterator);
public function valid(): bool
{
return false;
}
};
}
}
12 changes: 12 additions & 0 deletions tests/Upcasting/UpcastingIteratorTest.php
Expand Up @@ -131,6 +131,18 @@ public function it_iterates_over_empty_iterator(): void
$this->assertNull($upcastingIterator->current());
}

/**
* @test
*/
public function it_delegates_count_to_wrapped_iterator(): void
{
$iterator = new EmptyStreamIterator();

$upcastingIterator = new UpcastingIterator($this->createUpcaster(), $iterator);

$this->assertTrue(0 === \count($iterator));
}

protected function createUpcaster(): SingleEventUpcaster
{
return new class() extends SingleEventUpcaster {
Expand Down

0 comments on commit 0a49a65

Please sign in to comment.