From 5e0646c0e01d75a317180b3138ec63f92033a824 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 ++++- ImagickKernel_arginfo.h | 18 ++++++++++--- ImagickPixelIterator_arginfo.h | 8 +++++- Imagick_arginfo.h | 49 +++++++++++++++++++++++++++++++++- imagick_class.c | 34 +++++++++++++++++++++++ 5 files changed, 109 insertions(+), 6 deletions(-) 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/ImagickKernel_arginfo.h b/ImagickKernel_arginfo.h index 67ddbfaa..0d14c683 100644 --- a/ImagickKernel_arginfo.h +++ b/ImagickKernel_arginfo.h @@ -140,15 +140,27 @@ ZEND_METHOD(ImagickKernel, separate); #endif -#if defined(IMAGICK_WITH_KERNEL) static const zend_function_entry class_ImagickKernel_methods[] = { +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, addKernel, arginfo_class_ImagickKernel_addKernel, ZEND_ACC_PUBLIC) +#endif +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, addUnityKernel, arginfo_class_ImagickKernel_addUnityKernel, ZEND_ACC_PUBLIC) +#endif +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, fromBuiltin, arginfo_class_ImagickKernel_fromBuiltin, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#endif +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, fromMatrix, arginfo_class_ImagickKernel_fromMatrix, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#endif +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, getMatrix, arginfo_class_ImagickKernel_getMatrix, ZEND_ACC_PUBLIC) +#endif +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, scale, arginfo_class_ImagickKernel_scale, ZEND_ACC_PUBLIC) +#endif +#if defined(IMAGICK_WITH_KERNEL) ZEND_ME(ImagickKernel, separate, arginfo_class_ImagickKernel_separate, ZEND_ACC_PUBLIC) +#endif ZEND_FE_END -}; -#endif \ No newline at end of file +}; \ No newline at end of file diff --git a/ImagickPixelIterator_arginfo.h b/ImagickPixelIterator_arginfo.h index 26237941..62945f06 100644 --- a/ImagickPixelIterator_arginfo.h +++ b/ImagickPixelIterator_arginfo.h @@ -85,7 +85,13 @@ ZEND_END_ARG_INFO() #define arginfo_class_ImagickPixelIterator_key arginfo_class_ImagickPixelIterator_getIteratorRow -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ImagickPixelIterator_next, 0, 0, IS_VOID, 0) + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ImagickPixelIterator_next, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickPixelIterator_next, 0, 0, 0) +#endif + ZEND_END_ARG_INFO() #define arginfo_class_ImagickPixelIterator_rewind arginfo_class_ImagickPixelIterator_next diff --git a/Imagick_arginfo.h b/Imagick_arginfo.h index 577bcb0b..565ade5a 100644 --- a/Imagick_arginfo.h +++ b/Imagick_arginfo.h @@ -5097,10 +5097,35 @@ ZEND_END_ARG_INFO() #define arginfo_class_Imagick_key arginfo_class_Imagick_getSizeOffset #endif -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_next, 0, 0, IS_VOID, 0) +#if PHP_VERSION_ID < 80200 + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_next, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_next, 0, 0, 0) +#endif + ZEND_END_ARG_INFO() +#endif +#if PHP_VERSION_ID < 80200 #define arginfo_class_Imagick_rewind arginfo_class_Imagick_next +#endif + +#if !(PHP_VERSION_ID < 80200) + +#if PHP_VERSION_ID >= 80000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_rewind, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_rewind, 0, 0, 0) +#endif + +ZEND_END_ARG_INFO() +#endif + +#if !(PHP_VERSION_ID < 80200) +#define arginfo_class_Imagick_next arginfo_class_Imagick_rewind +#endif #define arginfo_class_Imagick_valid arginfo_class_Imagick_removeImage @@ -6725,6 +6750,18 @@ ZEND_METHOD(Imagick, setResolution); ZEND_METHOD(Imagick, setSamplingFactors); ZEND_METHOD(Imagick, setSize); ZEND_METHOD(Imagick, setType); +#if PHP_VERSION_ID < 80200 +ZEND_METHOD(Imagick, nextImage); +#endif +#if PHP_VERSION_ID < 80200 +ZEND_METHOD(Imagick, setFirstIterator); +#endif +#if !(PHP_VERSION_ID < 80200) +ZEND_METHOD(Imagick, rewind); +#endif +#if !(PHP_VERSION_ID < 80200) +ZEND_METHOD(Imagick, next); +#endif ZEND_METHOD(Imagick, valid); ZEND_METHOD(Imagick, current); #if MagickLibVersion >= 0x659 @@ -7524,8 +7561,18 @@ static const zend_function_entry class_Imagick_methods[] = { #if MagickLibVersion > 0x628 ZEND_MALIAS(Imagick, key, getIteratorIndex, arginfo_class_Imagick_key, ZEND_ACC_PUBLIC) #endif +#if PHP_VERSION_ID < 80200 ZEND_MALIAS(Imagick, next, nextImage, arginfo_class_Imagick_next, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID < 80200 ZEND_MALIAS(Imagick, rewind, setFirstIterator, arginfo_class_Imagick_rewind, ZEND_ACC_PUBLIC) +#endif +#if !(PHP_VERSION_ID < 80200) + ZEND_ME(Imagick, rewind, arginfo_class_Imagick_rewind, ZEND_ACC_PUBLIC) +#endif +#if !(PHP_VERSION_ID < 80200) + ZEND_ME(Imagick, next, arginfo_class_Imagick_next, ZEND_ACC_PUBLIC) +#endif ZEND_ME(Imagick, valid, arginfo_class_Imagick_valid, ZEND_ACC_PUBLIC) ZEND_ME(Imagick, current, arginfo_class_Imagick_current, ZEND_ACC_PUBLIC) #if MagickLibVersion >= 0x659 diff --git a/imagick_class.c b/imagick_class.c index 22395b63..af983915 100644 --- a/imagick_class.c +++ b/imagick_class.c @@ -8352,6 +8352,23 @@ PHP_METHOD(Imagick, setFirstIterator) } /* }}} */ +/* {{{ proto bool Imagick::rewind() + Alias for "setFirstIterator" but retuns void +*/ +PHP_METHOD(Imagick, rewind) +{ + zval retval; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + 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 +8440,23 @@ PHP_METHOD(Imagick, nextImage) } /* }}} */ + +/* {{{ proto bool Imagick::next() + Alias for "nextImage" but retuns void +*/ +PHP_METHOD(Imagick, next) +{ + zval retval; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + 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 */