From 321cdce5e25db0ff216a7852e66b94e05d756645 Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Tue, 8 Feb 2022 14:37:04 +0200 Subject: [PATCH] Fixed deprecation notices on PHP 8.1 --- CHANGELOG.md | 3 +++ src/Record/Iterator/Recursive_Record_Iterator.php | 6 +++--- src/Record/Iterator/Timeline_Iterator.php | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 866aa94..64535c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - updated dependencies (Mustache.php, Pimple) - minimum required PHP version 7.2.5 (was de-facto required by dependencies before) +### Fixed +- deprecation notices on PHP 8.1 + ## 3.3.5 - 2021-09-28 ### Changed diff --git a/src/Record/Iterator/Recursive_Record_Iterator.php b/src/Record/Iterator/Recursive_Record_Iterator.php index c3a5804..5929d52 100644 --- a/src/Record/Iterator/Recursive_Record_Iterator.php +++ b/src/Record/Iterator/Recursive_Record_Iterator.php @@ -67,10 +67,10 @@ class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIter } /** - * @return static + * This should be `static` for possible subclassing, but problems hinting that for PHP <8, also don't subclass this. */ - public function getChildren() { + public function getChildren(): self { - return new static( $this->children ); + return new self( $this->children ); } } diff --git a/src/Record/Iterator/Timeline_Iterator.php b/src/Record/Iterator/Timeline_Iterator.php index 18cd245..3d75952 100644 --- a/src/Record/Iterator/Timeline_Iterator.php +++ b/src/Record/Iterator/Timeline_Iterator.php @@ -60,12 +60,14 @@ class Timeline_Iterator implements \Iterator { } /** + * Key is unused and is only type hinted to possible `int` for PHP 8.1 `mixed` type compatibility. + * * @codeCoverageIgnore * - * @return void + * @return null */ - public function key(): void { - + public function key(): ?int { + return null; } /**