From 28508a8b376a866a653ae4fba5d920d8277c83a3 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 21 Jul 2021 10:53:38 +0200 Subject: [PATCH] fix for PHP 8.1.0beta1 --- Imagick.stub.php | 12 ++++++++---- ImagickPixelIterator.stub.php | 14 +++++++++----- ImagickPixelIterator_arginfo.h | 5 +++-- Imagick_arginfo.h | 5 +++-- regen_arginfo.sh | 4 ++-- shim_php7_to_php8.h | 7 ++++++- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Imagick.stub.php b/Imagick.stub.php index b1189b64..7fe3ed82 100644 --- a/Imagick.stub.php +++ b/Imagick.stub.php @@ -1223,11 +1223,15 @@ public function key(): int {} //# endif //#endif - /** @alias Imagick::nextImage */ - public function next(): bool {} + /** @alias Imagick::nextImage + * @tentative-return-type + */ + public function next(): void {} - /** @alias Imagick::setFirstIterator */ - public function rewind(): bool {} + /** @alias Imagick::setFirstIterator + * @tentative-return-type + */ + public function rewind(): void {} public function valid(): bool {} diff --git a/ImagickPixelIterator.stub.php b/ImagickPixelIterator.stub.php index 8a5b7cde..96072333 100644 --- a/ImagickPixelIterator.stub.php +++ b/ImagickPixelIterator.stub.php @@ -30,11 +30,15 @@ public function getPreviousIteratorRow(): array {} /** @alias ImagickPixelIterator::getIteratorRow */ public function key(): int {} - /** @alias ImagickPixelIterator::getNextIteratorRow */ - public function next(): array {} + /** @alias ImagickPixelIterator::getNextIteratorRow + * @tentative-return-type + */ + public function next(): void {} - /** @alias ImagickPixelIterator::resetIterator */ - public function rewind(): bool {} + /** @alias ImagickPixelIterator::resetIterator + * @tentative-return-type + */ + public function rewind(): void {} /** @alias ImagickPixelIterator::getCurrentIteratorRow */ public function current(): array {} @@ -59,4 +63,4 @@ public function setIteratorRow(int $row): bool {} public function syncIterator(): bool {} public function valid(): bool {} -} \ No newline at end of file +} diff --git a/ImagickPixelIterator_arginfo.h b/ImagickPixelIterator_arginfo.h index ef20a02e..26237941 100644 --- a/ImagickPixelIterator_arginfo.h +++ b/ImagickPixelIterator_arginfo.h @@ -85,9 +85,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_ImagickPixelIterator_key arginfo_class_ImagickPixelIterator_getIteratorRow -#define arginfo_class_ImagickPixelIterator_next arginfo_class_ImagickPixelIterator_getCurrentIteratorRow +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ImagickPixelIterator_next, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_ImagickPixelIterator_rewind arginfo_class_ImagickPixelIterator_clear +#define arginfo_class_ImagickPixelIterator_rewind arginfo_class_ImagickPixelIterator_next #define arginfo_class_ImagickPixelIterator_current arginfo_class_ImagickPixelIterator_getCurrentIteratorRow diff --git a/Imagick_arginfo.h b/Imagick_arginfo.h index db2b2ee5..2df4076c 100644 --- a/Imagick_arginfo.h +++ b/Imagick_arginfo.h @@ -4786,11 +4786,12 @@ ZEND_END_ARG_INFO() #endif #if MagickLibVersion > 0x628 -#define arginfo_class_Imagick_next arginfo_class_Imagick_optimizeImageLayers +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_next, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() #endif #if MagickLibVersion > 0x628 -#define arginfo_class_Imagick_rewind arginfo_class_Imagick_optimizeImageLayers +#define arginfo_class_Imagick_rewind arginfo_class_Imagick_next #endif #if MagickLibVersion > 0x628 diff --git a/regen_arginfo.sh b/regen_arginfo.sh index 96c24cea..1df4ade5 100755 --- a/regen_arginfo.sh +++ b/regen_arginfo.sh @@ -2,9 +2,9 @@ VER=0$(php-config --vernum 2>/dev/null) -if [ $VER -lt 70100 ]; then +if [ $VER -lt 80100 ]; then - echo "You need php >= 7.1 to run this script" + echo "You need php >= 8.1 to run this script" elif [ ! -f build/gen_stub.php ]; then diff --git a/shim_php7_to_php8.h b/shim_php7_to_php8.h index 5f8d89b4..7c4e92c7 100644 --- a/shim_php7_to_php8.h +++ b/shim_php7_to_php8.h @@ -1,5 +1,10 @@ +#if PHP_VERSION_ID < 80100 +#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ + ZEND_BEGIN_ARG_INFO_EX(name, return_reference, required_num_args, allow_null) +#endif + #if PHP_VERSION_ID < 80000 // Allow the generated stubs to work on previous versions of PHP @@ -11,4 +16,4 @@ #define MAY_BE_STRING "" -#endif \ No newline at end of file +#endif