Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compatibility with PHP 8.2+ #638

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Imagick.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ public function key(): int {}
//# endif
#endif

#if PHP_VERSION_ID < 80200
/** @alias Imagick::nextImage
* @tentative-return-type
*/
Expand All @@ -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 {}
Expand Down
18 changes: 15 additions & 3 deletions ImagickKernel_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
8 changes: 7 additions & 1 deletion ImagickPixelIterator_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 48 additions & 1 deletion Imagick_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions imagick_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
*/
Expand Down
Loading