From a110aa471e98b96c66d8f4d2e0394b97a9ea3cb8 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Tue, 2 Jul 2024 15:03:35 +0200 Subject: [PATCH] Suppress PHP 8.1 warnings "Return type mixed is not covariant with tentative return type mixed of method Iterator::key()" Summary: PHP 8.1 requires classes which implement `Iterator` to have all `Iterator` methods declared with appropriate return types or annotated with `#[\ReturnTypeWillChange]`. In my (limited) understanding we cannot declare return types while remaining backward-compatible, thus annotate. Closes T15835 Test Plan: Run PHPStan static code analyzer, see no warnings anymore. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15835 Differential Revision: https://we.phorge.it/D25711 --- src/applications/fact/extract/PhabricatorFactUpdateIterator.php | 1 + .../storage/build/HarbormasterBuildLogChunkIterator.php | 1 + src/infrastructure/storage/lisk/LiskMigrationIterator.php | 1 + src/infrastructure/storage/lisk/LiskRawMigrationIterator.php | 1 + src/infrastructure/storage/lisk/PhabricatorQueryIterator.php | 1 + 5 files changed, 5 insertions(+) diff --git a/src/applications/fact/extract/PhabricatorFactUpdateIterator.php b/src/applications/fact/extract/PhabricatorFactUpdateIterator.php index c0d229084f..910c3ffc7a 100644 --- a/src/applications/fact/extract/PhabricatorFactUpdateIterator.php +++ b/src/applications/fact/extract/PhabricatorFactUpdateIterator.php @@ -33,6 +33,7 @@ final class PhabricatorFactUpdateIterator extends PhutilBufferedIterator { } } + #[\ReturnTypeWillChange] public function key() { return $this->getCursorFromObject($this->current()); } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunkIterator.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunkIterator.php index 514ad7013c..b477dd7e31 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunkIterator.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunkIterator.php @@ -18,6 +18,7 @@ final class HarbormasterBuildLogChunkIterator $this->cursor = $this->min; } + #[\ReturnTypeWillChange] public function key() { return $this->current()->getID(); } diff --git a/src/infrastructure/storage/lisk/LiskMigrationIterator.php b/src/infrastructure/storage/lisk/LiskMigrationIterator.php index edd31c8123..2d2f8c98e9 100644 --- a/src/infrastructure/storage/lisk/LiskMigrationIterator.php +++ b/src/infrastructure/storage/lisk/LiskMigrationIterator.php @@ -26,6 +26,7 @@ final class LiskMigrationIterator extends PhutilBufferedIterator { $this->cursor = 0; } + #[\ReturnTypeWillChange] public function key() { return $this->current()->getID(); } diff --git a/src/infrastructure/storage/lisk/LiskRawMigrationIterator.php b/src/infrastructure/storage/lisk/LiskRawMigrationIterator.php index a7edbd7f91..3d8954a269 100644 --- a/src/infrastructure/storage/lisk/LiskRawMigrationIterator.php +++ b/src/infrastructure/storage/lisk/LiskRawMigrationIterator.php @@ -16,6 +16,7 @@ final class LiskRawMigrationIterator extends PhutilBufferedIterator { $this->cursor = 0; } + #[\ReturnTypeWillChange] public function key() { return idx($this->current(), $this->column); } diff --git a/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php b/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php index cc88678cdf..70e55509b9 100644 --- a/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php +++ b/src/infrastructure/storage/lisk/PhabricatorQueryIterator.php @@ -18,6 +18,7 @@ final class PhabricatorQueryIterator extends PhutilBufferedIterator { $this->pager = $pager; } + #[\ReturnTypeWillChange] public function key() { return $this->current()->getID(); }