From 59c5bcc38188c6ae5df04f44b628009a69ec4ac0 Mon Sep 17 00:00:00 2001 From: Mikhail Galanin Date: Mon, 13 Nov 2023 13:15:28 +0000 Subject: [PATCH] Fixed compatibility with PHP 8.2+ It looks like 8.2 does not accept "tentative" void type --- Imagick.stub.php | 6 +++++- imagick_class.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Imagick.stub.php b/Imagick.stub.php index 804c0152..67f1ac03 100644 --- a/Imagick.stub.php +++ b/Imagick.stub.php @@ -1271,6 +1271,7 @@ public function key(): int {} //# endif #endif +#if PHP_VERSION_ID < 80200 /** @alias Imagick::nextImage * @tentative-return-type */ @@ -1280,7 +1281,10 @@ public function next(): void {} * @tentative-return-type */ public function rewind(): void {} - +#else + public function rewind(): void {} + public function next(): void {} +#endif public function valid(): bool {} public function current(): Imagick {} diff --git a/imagick_class.c b/imagick_class.c index 22395b63..2d23e3f8 100644 --- a/imagick_class.c +++ b/imagick_class.c @@ -8352,6 +8352,22 @@ PHP_METHOD(Imagick, setFirstIterator) } /* }}} */ +/* {{{ proto bool Imagick::rewind() + Alias for "setFirstIterator" but retuns void +*/ +PHP_METHOD(Imagick, rewind) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zval retval; + ZVAL_UNDEF(retval); + zend_call_method_with_0_params(Z_OBJ_P(getThis()), Z_OBJCE_P(getThis()), NULL, "setFirstIterator", &retval); +} +/* }}} */ + + /* {{{ proto bool Imagick::setLastIterator() Sets the wand iterator to the last image. */ @@ -8423,6 +8439,22 @@ PHP_METHOD(Imagick, nextImage) } /* }}} */ + +/* {{{ proto bool Imagick::next() + Alias for "nextImage" but retuns void +*/ +PHP_METHOD(Imagick, next) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zval retval; + ZVAL_UNDEF(retval); + zend_call_method_with_0_params(Z_OBJ_P(getThis()), Z_OBJCE_P(getThis()), NULL, "nextImage", &retval); +} +/* }}} */ + /* {{{ proto bool Imagick::hasPreviousImage() Returns true if the wand has more images when traversing the list in the reverse direction */