From 18980f9b5036876378f3471b2cf889e9538ac493 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 23 Nov 2021 21:06:51 +0545 Subject: [PATCH 1/2] Run PHP 8.1 in CI --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c56eae..126e30d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,8 @@ jobs: include: - php-versions: '7.1' cs-fixer: false + - php-versions: '8.1' + cs-fixer: false steps: - name: Checkout uses: actions/checkout@v2 From b8758d0e138898c2c67b40afbd7dff70a18ab42e Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 31 Dec 2021 12:14:41 +0100 Subject: [PATCH 2/2] Explicitly specify return types PHP 8.1 considers not specifying a return type as a type mismatch. --- Core/Frameworks/Flake/Core/Collection.php | 8 ++++---- .../Flake/Core/Datastructure/Chain.php | 4 ++-- .../Flake/Core/Datastructure/ChainLink.php | 18 ++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Core/Frameworks/Flake/Core/Collection.php b/Core/Frameworks/Flake/Core/Collection.php index 09ead65..0a5c490 100644 --- a/Core/Frameworks/Flake/Core/Collection.php +++ b/Core/Frameworks/Flake/Core/Collection.php @@ -39,15 +39,15 @@ class Collection extends \Flake\Core\FLObject implements \Iterator { return key($this->aCollection); } - function next() { - return next($this->aCollection); + function next(): void { + next($this->aCollection); } - function rewind() { + function rewind(): void { $this->reset(); } - function valid() { + function valid(): bool { $key = key($this->aCollection); return ($key !== null && $key !== false); diff --git a/Core/Frameworks/Flake/Core/Datastructure/Chain.php b/Core/Frameworks/Flake/Core/Datastructure/Chain.php index 1f1b54b..28cee23 100644 --- a/Core/Frameworks/Flake/Core/Datastructure/Chain.php +++ b/Core/Frameworks/Flake/Core/Datastructure/Chain.php @@ -31,12 +31,12 @@ namespace Flake\Core\Datastructure; * @extends \SplDoublyLinkedList<\Flake\Core\Datastructure\Chainable> */ class Chain extends \SplDoublyLinkedList { - function push($value) { + function push($value): void { $value->chain($this, $this->count()); parent::push($value); } - function offsetUnset($offset) { + function offsetUnset($offset): void { throw new \Exception("Cannot delete Chainable in Chain"); } diff --git a/Core/Frameworks/Flake/Core/Datastructure/ChainLink.php b/Core/Frameworks/Flake/Core/Datastructure/ChainLink.php index cc046d3..313569f 100644 --- a/Core/Frameworks/Flake/Core/Datastructure/ChainLink.php +++ b/Core/Frameworks/Flake/Core/Datastructure/ChainLink.php @@ -36,7 +36,7 @@ abstract class ChainLink implements \Flake\Core\Datastructure\Chainable { $this->__key = $key; } - function offsetSet($offset, $value) { + function offsetSet($offset, $value): void { if (is_null($this->__container)) { return; } @@ -44,7 +44,7 @@ abstract class ChainLink implements \Flake\Core\Datastructure\Chainable { $this->__container->offsetSet($offset, $value); } - function offsetExists($offset) { + function offsetExists($offset): bool { if (is_null($this->__container)) { return false; } @@ -52,7 +52,7 @@ abstract class ChainLink implements \Flake\Core\Datastructure\Chainable { return $this->__container->offsetExists($offset); } - function offsetUnset($offset) { + function offsetUnset($offset): void { if (is_null($this->__container)) { return; } @@ -70,7 +70,7 @@ abstract class ChainLink implements \Flake\Core\Datastructure\Chainable { return $oRes; } - function rewind() { + function rewind(): void { $this->__container->rewind(); } @@ -82,10 +82,8 @@ abstract class ChainLink implements \Flake\Core\Datastructure\Chainable { return $this->__container->key(); } - function &next() { - $oRes = $this->__container->next(); - - return $oRes; + function &next(): void { + $this->__container->next(); } function &prev() { @@ -94,11 +92,11 @@ abstract class ChainLink implements \Flake\Core\Datastructure\Chainable { return $oPrev; } - function valid() { + function valid(): bool { return $this->__container->valid(); } - function count() { + function count(): int { return $this->__container->count(); }