Skip to content

PHP 8.3 compatibility (and 8.x prototypes fixes) #616

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

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
581acc4
Fix Imagick::getResourceLimit() proto
remicollet May 31, 2023
ab33ea0
Fix Imagick::evaluateImages() proto
remicollet May 31, 2023
47b415a
Fix Imagick::optimizeImageLayers() proto
remicollet May 31, 2023
98c7a4a
review object_handlers
remicollet May 31, 2023
d021813
Fix Imagick::getImageBlob() proto
remicollet May 31, 2023
451c176
Fix Imagick::getRegistry() proto
remicollet May 31, 2023
957b48a
Fix ImagickPixelIterator::getNextIteratorRow() proto
remicollet May 31, 2023
20ea362
Fix ImagickKernel::fromMatrix() proto
remicollet May 31, 2023
7233874
Fix Imagick::convolveImage() proto
remicollet May 31, 2023
a1d8c0b
Fix Imagick::subimageMatch() proto
remicollet May 31, 2023
6d02d99
Fix Imagick::setImageMask() proto
remicollet May 31, 2023
af0634a
unalias next/rewind for return type
remicollet May 31, 2023
8b48dc3
Fix Imagick::resetIterator() proto
remicollet May 31, 2023
0cf0083
unalias next/rewind for return type
remicollet May 31, 2023
d45e478
Fix Imagick::autoGammaImage() and autoOrient() proto
remicollet May 31, 2023
529bb5d
Fix Imagick::localContrastImage proto
remicollet May 31, 2023
a16c885
Fix Imagick::optimizeimagetransparency proto
remicollet May 31, 2023
c4aa095
regen
remicollet May 31, 2023
118db29
remove null case (as exception is raised
remicollet May 31, 2023
2fc8465
fix ImagickDraw
remicollet May 31, 2023
91c6092
handle ZEND_ARG_INFO_WITH_DEFAULT_VALUE in regen script
remicollet May 31, 2023
af1dcbd
try to fix -Werror=unused-parameter
remicollet May 31, 2023
3bd35ea
fix [-Wunused-but-set-variable]
remicollet May 31, 2023
3cbbc56
fix Imagick::convolveImage() proto for IM6
remicollet May 31, 2023
b4ede5d
add IMAGICK_NOT_EMPTY macro
remicollet Jun 1, 2023
d9bf728
Fix MagickPixel
remicollet Jun 1, 2023
dc300a2
Fix ImagickPixelIterator
remicollet Jun 1, 2023
c70071d
Fix ImagickKernel
remicollet Jun 1, 2023
ce164ce
use IMAGICK_NOT_EMPTY for Imagick class
remicollet Jun 1, 2023
797b71c
Fix Imagick class: use RETURN_THROWS after zpp and exception
remicollet Jun 1, 2023
9df9261
Fix [-Werror=unused-parameter]
remicollet Jun 1, 2023
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: 3 additions & 3 deletions Imagick.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Imagick
{
#if MagickLibVersion > 0x628
public function optimizeImageLayers(): bool {}
public function optimizeImageLayers(): Imagick {}

// METRIC_*
public function compareImageLayers(int $metric): Imagick {}
Expand Down Expand Up @@ -834,7 +834,7 @@ public function evaluateImage(int $evaluate, float $constant, int $channel = Ima
//http://www.imagemagick.org/Usage/layers/#evaluate-sequence

// EVALUATE_*
public function evaluateImages(int $evaluate): bool {}
public function evaluateImages(int $evaluate): Imagick {}

#endif

Expand Down Expand Up @@ -1220,7 +1220,7 @@ public static function getReleaseDate(): string {}

public static function getResource(int $type): int {}

public static function getResourceLimit(int $type): int {}
public static function getResourceLimit(int $type): float {}

public function getSamplingFactors(): array {}

Expand Down
32 changes: 26 additions & 6 deletions Imagick_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#if MagickLibVersion > 0x628

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_optimizeImageLayers, 0, 0, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Imagick_optimizeImageLayers, 0, 0, Imagick, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_optimizeImageLayers, 0, 0, 0)
#endif
Expand Down Expand Up @@ -72,11 +72,18 @@ ZEND_END_ARG_INFO()
#endif

#if MagickLibVersion > 0x628
#define arginfo_class_Imagick_transposeImage arginfo_class_Imagick_optimizeImageLayers

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_transposeImage, 0, 0, _IS_BOOL, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_transposeImage, 0, 0, 0)
#endif

ZEND_END_ARG_INFO()
#endif

#if MagickLibVersion > 0x628
#define arginfo_class_Imagick_transverseImage arginfo_class_Imagick_optimizeImageLayers
#define arginfo_class_Imagick_transverseImage arginfo_class_Imagick_transposeImage
#endif

#if MagickLibVersion > 0x628
Expand Down Expand Up @@ -184,7 +191,7 @@ ZEND_END_ARG_INFO()
#endif

#if MagickLibVersion > 0x628
#define arginfo_class_Imagick_uniqueImageColors arginfo_class_Imagick_optimizeImageLayers
#define arginfo_class_Imagick_uniqueImageColors arginfo_class_Imagick_transposeImage
#endif

#if MagickLibVersion > 0x628 && !defined(MAGICKCORE_EXCLUDE_DEPRECATED) && MagickLibVersion < 0x700
Expand Down Expand Up @@ -3718,7 +3725,7 @@ ZEND_END_ARG_INFO()
#if MagickLibVersion >= 0x687

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_evaluateImages, 0, 1, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Imagick_evaluateImages, 0, 1, Imagick, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_evaluateImages, 0, 0, 1)
#endif
Expand Down Expand Up @@ -4995,7 +5002,20 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_getResource, 0, 0, 1)
#endif
ZEND_END_ARG_INFO()

#define arginfo_class_Imagick_getResourceLimit arginfo_class_Imagick_getResource

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_getResourceLimit, 0, 1, IS_DOUBLE, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_getResourceLimit, 0, 0, 1)
#endif


#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
#else
ZEND_ARG_INFO(0, type)
#endif
ZEND_END_ARG_INFO()

#define arginfo_class_Imagick_getSamplingFactors arginfo_class_Imagick_getImageGeometry

Expand Down
43 changes: 40 additions & 3 deletions imagick.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ static zend_object_value php_imagick_object_new_ex(zend_class_entry *class_type,
object_properties_init(&intern->zo, class_type);

#if PHP_VERSION_ID >= 70000
#if PHP_VERSION_ID < 80300
intern->zo.handlers = &imagick_object_handlers;
#endif
return &intern->zo;
#else
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_imagick_object_free_storage, NULL TSRMLS_CC);
Expand Down Expand Up @@ -321,7 +323,9 @@ static zend_object_value php_imagickdraw_object_new_ex(zend_class_entry *class_t

zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
object_properties_init(&intern->zo, class_type);
#if PHP_VERSION_ID < 80300
intern->zo.handlers = &imagickdraw_object_handlers;
#endif
#else
zend_object_value retval;
intern = (php_imagickdraw_object *) emalloc(sizeof(php_imagickdraw_object));
Expand Down Expand Up @@ -398,8 +402,9 @@ static zend_object_value php_imagickpixeliterator_object_new(zend_class_entry *c
object_properties_init(&intern->zo, class_type);

#if PHP_VERSION_ID >= 70000
#if PHP_VERSION_ID < 80300
intern->zo.handlers = &imagickpixeliterator_object_handlers;

#endif
return &intern->zo;
#else
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_imagickpixeliterator_object_free_storage, NULL TSRMLS_CC);
Expand Down Expand Up @@ -439,8 +444,9 @@ static zend_object_value php_imagickpixel_object_new_ex(zend_class_entry *class_
object_properties_init(&intern->zo, class_type);

#if PHP_VERSION_ID >= 70000
#if PHP_VERSION_ID < 80300
intern->zo.handlers = &imagickpixel_object_handlers;

#endif
return &intern->zo;
#else
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_imagickpixel_object_free_storage, NULL TSRMLS_CC);
Expand Down Expand Up @@ -494,8 +500,9 @@ static zend_object_value php_imagickkernel_object_new_ex(zend_class_entry *class
object_properties_init(&intern->zo, class_type);

#if PHP_VERSION_ID >= 70000
#if PHP_VERSION_ID < 80300
intern->zo.handlers = &imagickkernel_object_handlers;

#endif
return &intern->zo;
#else
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_imagickkernel_object_free_storage, NULL TSRMLS_CC);
Expand Down Expand Up @@ -1041,7 +1048,9 @@ PHP_MINIT_FUNCTION(imagick)
Initialize the class (Imagick)
*/
INIT_CLASS_ENTRY(ce, PHP_IMAGICK_SC_NAME, php_imagick_class_methods);
#if PHP_VERSION_ID < 80300
ce.create_object = php_imagick_object_new;
#endif
imagick_object_handlers.clone_obj = php_imagick_clone_imagick_object;
imagick_object_handlers.read_property = php_imagick_read_property;
imagick_object_handlers.count_elements = php_imagick_count_elements;
Expand All @@ -1051,52 +1060,76 @@ PHP_MINIT_FUNCTION(imagick)
#endif

php_imagick_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
#if PHP_VERSION_ID >= 80300
php_imagick_sc_entry->create_object = php_imagick_object_new;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create object affectation can be done this way at least since 8.1, just wanted to reduce complexity and avoid additional conditions.

php_imagick_sc_entry->default_object_handlers = &imagick_object_handlers;
#endif
zend_class_implements(php_imagick_sc_entry TSRMLS_CC, 2, zend_ce_iterator, im_ce_countable);

/*
Initialize the class (ImagickDraw)
*/
INIT_CLASS_ENTRY(ce, PHP_IMAGICKDRAW_SC_NAME, php_imagickdraw_class_methods);
#if PHP_VERSION_ID < 80300
ce.create_object = php_imagickdraw_object_new;
#endif
imagickdraw_object_handlers.clone_obj = php_imagick_clone_imagickdraw_object;
#if PHP_VERSION_ID >= 70000
imagickdraw_object_handlers.offset = XtOffsetOf(php_imagickdraw_object, zo);
imagickdraw_object_handlers.free_obj = php_imagickdraw_object_free_storage;
#endif
php_imagickdraw_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
#if PHP_VERSION_ID >= 80300
php_imagickdraw_sc_entry->create_object = php_imagickdraw_object_new;
php_imagickdraw_sc_entry->default_object_handlers = &imagickdraw_object_handlers;
#endif

/*
Initialize the class (ImagickPixelIterator)
*/
INIT_CLASS_ENTRY(ce, PHP_IMAGICKPIXELITERATOR_SC_NAME, php_imagickpixeliterator_class_methods);
#if PHP_VERSION_ID < 80300
ce.create_object = php_imagickpixeliterator_object_new;
#endif
imagickpixeliterator_object_handlers.clone_obj = NULL;
#if PHP_VERSION_ID >= 70000
imagickpixeliterator_object_handlers.offset = XtOffsetOf(php_imagickpixeliterator_object, zo);
imagickpixeliterator_object_handlers.free_obj = php_imagickpixeliterator_object_free_storage;
#endif
php_imagickpixeliterator_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
#if PHP_VERSION_ID >= 80300
php_imagickpixeliterator_sc_entry->create_object = php_imagickpixeliterator_object_new;
php_imagickpixeliterator_sc_entry->default_object_handlers = &imagickpixeliterator_object_handlers;
#endif
zend_class_implements(php_imagickpixeliterator_sc_entry TSRMLS_CC, 1, zend_ce_iterator);

/*
Initialize the class (ImagickPixel)
*/
INIT_CLASS_ENTRY(ce, PHP_IMAGICKPIXEL_SC_NAME, php_imagickpixel_class_methods);
#if PHP_VERSION_ID < 80300
ce.create_object = php_imagickpixel_object_new;
#endif
imagickpixel_object_handlers.clone_obj = php_imagick_clone_imagickpixel_object;
#if PHP_VERSION_ID >= 70000
imagickpixel_object_handlers.offset = XtOffsetOf(php_imagickpixel_object, zo);
imagickpixel_object_handlers.free_obj = php_imagickpixel_object_free_storage;
#endif

php_imagickpixel_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
#if PHP_VERSION_ID >= 80300
php_imagickpixel_sc_entry->create_object = php_imagickpixel_object_new;
php_imagickpixel_sc_entry->default_object_handlers = &imagickpixel_object_handlers;
#endif

#ifdef IMAGICK_WITH_KERNEL
/*
Initialize the class (ImagickKernel)
*/
INIT_CLASS_ENTRY(ce, PHP_IMAGICKKERNEL_SC_NAME, php_imagickkernel_class_methods);
#if PHP_VERSION_ID < 80300
ce.create_object = php_imagickkernel_object_new;
#endif
// Disabled until can be compiled under wall correctly
imagickkernel_object_handlers.get_debug_info = php_imagickkernel_get_debug_info;
imagickkernel_object_handlers.clone_obj = php_imagick_clone_imagickkernel_object;
Expand All @@ -1106,6 +1139,10 @@ PHP_MINIT_FUNCTION(imagick)
#endif

php_imagickkernel_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
#if PHP_VERSION_ID >= 80300
php_imagickkernel_sc_entry->create_object = php_imagickkernel_object_new;
php_imagickkernel_sc_entry->default_object_handlers = &imagickkernel_object_handlers;
#endif
#endif

php_imagick_initialize_constants (TSRMLS_C);
Expand Down