Skip to content

Commit

Permalink
Fixed compatibility with PHP 8.2+
Browse files Browse the repository at this point in the history
It looks like 8.2 does not accept "tentative" void type
  • Loading branch information
Mikhail Galanin committed Nov 13, 2023
1 parent bc72c29 commit 59c5bcc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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
32 changes: 32 additions & 0 deletions imagick_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 59c5bcc

Please sign in to comment.