diff --git a/composer.json b/composer.json index 67f9c628..71432283 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } }, "require": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "composer/package-versions-deprecated": "1.11.99.2", "elife/api-client": "^1.0", "guzzlehttp/promises": "^1.0", @@ -32,7 +32,7 @@ "mtdowling/jmespath.php": "^2.0", "phpspec/phpspec": "^5.1 || ^6.3 || ^7.5", "phpspec/prophecy": "^1.10", - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^7.5 || ^9.6", "psr/http-message": "^1.0", "squizlabs/php_codesniffer": "^3.5" }, diff --git a/src/ArrayFromIterator.php b/src/ArrayFromIterator.php index cdad00ad..ba47b6c3 100644 --- a/src/ArrayFromIterator.php +++ b/src/ArrayFromIterator.php @@ -65,7 +65,7 @@ final public function toArray() : array return $array; } - final private function all() : PromiseSequence + private function all() : PromiseSequence { return new PromiseSequence( $promise = new Promise( diff --git a/src/CanBeSliced.php b/src/CanBeSliced.php index 621ec671..95f7f5a0 100644 --- a/src/CanBeSliced.php +++ b/src/CanBeSliced.php @@ -14,7 +14,7 @@ trait CanBeSliced abstract public function slice(int $offset, int $length = null) : Sequence; - final private function getPage(int $page) : Sequence + private function getPage(int $page) : Sequence { if (empty($this->pages)) { for ($i = 0; $i < $this->count(); ++$i) { @@ -31,7 +31,7 @@ final private function getPage(int $page) : Sequence return $this->pages[$page]; } - final private function resetPages() + private function resetPages() { $this->pages = []; $this->pageBatch = 100; diff --git a/src/Collection/ArraySequence.php b/src/Collection/ArraySequence.php index 3fecfce2..314cb98e 100644 --- a/src/Collection/ArraySequence.php +++ b/src/Collection/ArraySequence.php @@ -141,6 +141,7 @@ public function offsetExists($offset) : bool return isset($this->array[$offset]); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { if (!isset($this->array[$offset])) { diff --git a/src/Collection/EmptySequence.php b/src/Collection/EmptySequence.php index 278e6811..4a3a555a 100644 --- a/src/Collection/EmptySequence.php +++ b/src/Collection/EmptySequence.php @@ -94,6 +94,7 @@ public function offsetExists($offset) : bool return false; } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return null; diff --git a/src/Collection/PromiseSequence.php b/src/Collection/PromiseSequence.php index b57e52b0..a996feda 100644 --- a/src/Collection/PromiseSequence.php +++ b/src/Collection/PromiseSequence.php @@ -191,6 +191,7 @@ public function offsetExists($offset) : bool return $this->wait()->offsetExists($offset); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->wait()->offsetGet($offset); diff --git a/src/ImmutableArrayAccess.php b/src/ImmutableArrayAccess.php index c7043e1e..e8d42440 100644 --- a/src/ImmutableArrayAccess.php +++ b/src/ImmutableArrayAccess.php @@ -6,12 +6,12 @@ trait ImmutableArrayAccess { - final public function offsetSet($offset, $value) + final public function offsetSet($offset, $value): void { throw new BadMethodCallException('Object is immutable'); } - final public function offsetUnset($offset) + final public function offsetUnset($offset): void { throw new BadMethodCallException('Object is immutable'); } diff --git a/src/Model/SearchSubjects.php b/src/Model/SearchSubjects.php index a7e6367e..60d765b4 100644 --- a/src/Model/SearchSubjects.php +++ b/src/Model/SearchSubjects.php @@ -19,33 +19,35 @@ public function __construct(array $subjects, array $results) $this->results = $results; } - public function count() + public function count(): int { return count($this->subjects); } + #[\ReturnTypeWillChange] public function current() { return current($this->results); } - public function next() + public function next(): void { next($this->subjects); next($this->results); } + #[\ReturnTypeWillChange] public function key() { return current($this->subjects); } - public function valid() + public function valid(): bool { return false !== $this->key(); } - public function rewind() + public function rewind(): void { reset($this->subjects); reset($this->results); diff --git a/src/Model/SearchTypes.php b/src/Model/SearchTypes.php index 0f9672eb..b600dadc 100644 --- a/src/Model/SearchTypes.php +++ b/src/Model/SearchTypes.php @@ -19,7 +19,7 @@ public function __construct(array $typesToResults) $this->typesToResults = $typesToResults; } - public function count() + public function count(): int { return count($this->typesToResults); } diff --git a/src/SlicedArrayAccess.php b/src/SlicedArrayAccess.php index e19c37fb..35d8c3e0 100644 --- a/src/SlicedArrayAccess.php +++ b/src/SlicedArrayAccess.php @@ -14,6 +14,7 @@ public function offsetExists($offset) : bool return null !== $this->offsetGet($offset); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { try { diff --git a/src/SlicedIterator.php b/src/SlicedIterator.php index 6aae7299..18ac3bca 100644 --- a/src/SlicedIterator.php +++ b/src/SlicedIterator.php @@ -10,6 +10,7 @@ trait SlicedIterator private $key = 1; + #[\ReturnTypeWillChange] final public function current() { $page = (int) ceil($this->key / $this->pageBatch); @@ -23,11 +24,12 @@ final public function current() return $pageContents[$inPage]; } - final public function next() + final public function next(): void { ++$this->key; } + #[\ReturnTypeWillChange] final public function key() { if ($this->key > $this->count()) { @@ -37,17 +39,17 @@ final public function key() return $this->key; } - final public function valid() + final public function valid(): bool { return $this->key <= $this->count(); } - final public function rewind() + final public function rewind(): void { $this->key = 1; } - final private function resetIterator() + private function resetIterator() { $this->rewind(); $this->resetPages(); diff --git a/test/ApiSdkTest.php b/test/ApiSdkTest.php index 68f04320..a2873e25 100644 --- a/test/ApiSdkTest.php +++ b/test/ApiSdkTest.php @@ -133,8 +133,7 @@ public function it_creates_community() $this->mockCommunityListCall(1, 1, 1); $this->mockBlogArticleCall('model-1', true); - $this->assertInternalType( - 'array', + $this->assertIsArray( $this->apiSdk->getSerializer()->normalize($this->apiSdk->community()[0]) ); } diff --git a/test/Client/DigestsTest.php b/test/Client/DigestsTest.php index 2f4e6d43..59615d39 100644 --- a/test/Client/DigestsTest.php +++ b/test/Client/DigestsTest.php @@ -126,7 +126,7 @@ public function it_gets_a_digest() $this->assertSame('Digest digest-7 text', $digest->getContent()[0]->getText()); $this->assertInstanceOf(ArticleVoR::class, $digest->getRelatedContent()[0]); - $this->assertContains('Homo naledi', $digest->getRelatedContent()[0]->getTitle()); + $this->assertStringContainsString('Homo naledi', $digest->getRelatedContent()[0]->getTitle()); $this->mockArticleCall('09560', true, true, 1); diff --git a/test/Client/SearchTest.php b/test/Client/SearchTest.php index 07a50dd5..b3724745 100644 --- a/test/Client/SearchTest.php +++ b/test/Client/SearchTest.php @@ -412,7 +412,7 @@ public function it_has_counters_for_types() $types = $this->search->types(); foreach ($types as $type => $counter) { - $this->assertInternalType('string', $type); + $this->assertIsString($type); $this->assertRegexp('/^[a-z-]+$/', $type); $this->assertGreaterThanOrEqual(0, $counter); } diff --git a/test/Model/ArticlePoATest.php b/test/Model/ArticlePoATest.php index 80e5ec86..d6964a13 100644 --- a/test/Model/ArticlePoATest.php +++ b/test/Model/ArticlePoATest.php @@ -7,7 +7,7 @@ final class ArticlePoATest extends ArticleVersionTest { - public function setUp() + public function setUp(): void { $this->builder = Builder::for(ArticlePoA::class); } diff --git a/test/Model/ArticleVoRTest.php b/test/Model/ArticleVoRTest.php index 801e2a8d..5c0fbad8 100644 --- a/test/Model/ArticleVoRTest.php +++ b/test/Model/ArticleVoRTest.php @@ -25,7 +25,7 @@ final class ArticleVoRTest extends ArticleVersionTest { - public function setUp() + public function setUp(): void { $this->builder = Builder::for(ArticleVoR::class); } diff --git a/test/Model/CollectionTest.php b/test/Model/CollectionTest.php index ffc4353b..e14857a6 100644 --- a/test/Model/CollectionTest.php +++ b/test/Model/CollectionTest.php @@ -32,7 +32,7 @@ final class CollectionTest extends TestCase { private $builder; - public function setUp() + public function setUp(): void { $this->builder = Builder::for(Collection::class); } diff --git a/test/Model/DigestTest.php b/test/Model/DigestTest.php index 019fce2a..fb532103 100644 --- a/test/Model/DigestTest.php +++ b/test/Model/DigestTest.php @@ -30,7 +30,7 @@ final class DigestTest extends TestCase { private $builder; - public function setUp() + public function setUp(): void { $this->builder = Builder::for(Digest::class); } diff --git a/test/Model/IdentifierTest.php b/test/Model/IdentifierTest.php index a27821cf..5597271f 100644 --- a/test/Model/IdentifierTest.php +++ b/test/Model/IdentifierTest.php @@ -13,7 +13,7 @@ final class IdentifierTest extends TestCase * @test * @dataProvider identifierProvider */ - public function it_has_a_type(string $method, string $type, string $id) + public function it_has_a_type(string $method, string $type, $id) { $identifier = Identifier::{$method}($id); @@ -24,7 +24,7 @@ public function it_has_a_type(string $method, string $type, string $id) * @test * @dataProvider identifierProvider */ - public function it_has_an_id(string $method, string $type, string $id) + public function it_has_an_id(string $method, string $type, $id) { $identifier = Identifier::{$method}($id); @@ -35,7 +35,7 @@ public function it_has_an_id(string $method, string $type, string $id) * @test * @dataProvider identifierProvider */ - public function it_can_be_created_from_a_string(string $method, string $type, string $id) + public function it_can_be_created_from_a_string(string $method, string $type, $id) { $identifier = Identifier::fromString("$type/$id"); diff --git a/test/Model/PressPackageTest.php b/test/Model/PressPackageTest.php index 57a5a421..ee5ee2c1 100644 --- a/test/Model/PressPackageTest.php +++ b/test/Model/PressPackageTest.php @@ -28,7 +28,7 @@ final class PressPackageTest extends TestCase { private $builder; - public function setUp() + public function setUp(): void { $this->builder = Builder::for(PressPackage::class); } diff --git a/test/Model/PromotionalCollectionTest.php b/test/Model/PromotionalCollectionTest.php index 4204169c..b08ea291 100644 --- a/test/Model/PromotionalCollectionTest.php +++ b/test/Model/PromotionalCollectionTest.php @@ -32,7 +32,7 @@ final class PromotionalCollectionTest extends TestCase { private $builder; - public function setUp() + public function setUp(): void { $this->builder = Builder::for(PromotionalCollection::class); } diff --git a/test/Model/ReviewedPreprintTest.php b/test/Model/ReviewedPreprintTest.php index 0f126374..67f400e9 100644 --- a/test/Model/ReviewedPreprintTest.php +++ b/test/Model/ReviewedPreprintTest.php @@ -25,7 +25,7 @@ final class ReviewedPreprintTest extends TestCase { private $builder; - public function setUp() + public function setUp(): void { $this->builder = Builder::for(ReviewedPreprint::class); } diff --git a/test/Model/SearchSubjectsTest.php b/test/Model/SearchSubjectsTest.php index 4466d48b..4fffde49 100644 --- a/test/Model/SearchSubjectsTest.php +++ b/test/Model/SearchSubjectsTest.php @@ -27,7 +27,7 @@ public function it_is_iterable_with_subjects_as_keys() foreach ($searchSubjects as $subject => $results) { $this->assertInstanceOf(Subject::class, $subject); $actualSubjects[] = $subject; - $this->assertInternalType('integer', $results); + $this->assertIsInt($results); $actualResults[] = $results; } diff --git a/test/TestCase.php b/test/TestCase.php index 76778cb0..b608014b 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -29,8 +29,8 @@ final protected function classNameProvider(string ...$classes) : Traversable final protected function assertObjectsAreEqual($expected, $actual, $detail = '') { - $this->assertInternalType('object', $expected, $detail); - $this->assertInternalType('object', $actual, $detail); + $this->assertIsObject($expected, $detail); + $this->assertIsObject($actual, $detail); $this->assertInstanceOf(get_class($expected), $actual, $detail); foreach (get_class_methods($actual) as $method) { @@ -59,7 +59,7 @@ private function assertItemsAreEqual($expected, $actual, $detail = null) if (is_object($actual)) { $this->assertObjectsAreEqual($expected, $actual, $detail); } elseif (is_array($actual)) { - $this->assertInternalType('array', $expected, "We are getting an array out of $detail but we were not expecting it"); + $this->assertIsArray($expected, "We are getting an array out of $detail but we were not expecting it"); $this->assertEquals(count($expected), count($actual), "Count of $detail doesn't match expected"); foreach ($actual as $key => $actualItem) { $this->assertItemsAreEqual($expected[$key], $actualItem, $detail.' '.$key);