Skip to content

Commit

Permalink
Add test and parameter handling for Imagick::newImage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danack committed Jul 1, 2024
1 parent 6526e1f commit 1bb6184
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
30 changes: 15 additions & 15 deletions Imagick_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,14 @@ ZEND_END_ARG_INFO()

#define arginfo_class_Imagick_setLastIterator arginfo_class_Imagick_transposeImage

#define arginfo_class_Imagick_resetIterator arginfo_class_Imagick_transposeImage

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_resetIterator, 0, 0, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_resetIterator, 0, 0, 0)
#endif

ZEND_END_ARG_INFO()

#define arginfo_class_Imagick_previousImage arginfo_class_Imagick_transposeImage

Expand Down Expand Up @@ -4899,16 +4906,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_key, 0, 0, 0)
ZEND_END_ARG_INFO()
#endif

#define arginfo_class_Imagick_next arginfo_class_Imagick_resetIterator

#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()

#define arginfo_class_Imagick_rewind arginfo_class_Imagick_next
#define arginfo_class_Imagick_rewind arginfo_class_Imagick_resetIterator

#define arginfo_class_Imagick_valid arginfo_class_Imagick_transposeImage

Expand Down Expand Up @@ -5128,7 +5128,7 @@ ZEND_END_ARG_INFO()


#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_setAntialias, 0, 1, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_setAntialias, 0, 1, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_setAntialias, 0, 0, 1)
#endif
Expand Down Expand Up @@ -5163,7 +5163,7 @@ ZEND_END_ARG_INFO()
#if MagickLibVersion >= 0x687

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_optimizeImageTransparency, 0, 0, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_optimizeImageTransparency, 0, 0, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_optimizeImageTransparency, 0, 0, 0)
#endif
Expand All @@ -5174,7 +5174,7 @@ ZEND_END_ARG_INFO()
#if MagickLibVersion >= 0x660

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_autoGammaImage, 0, 0, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_autoGammaImage, 0, 0, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_autoGammaImage, 0, 0, 0)
#endif
Expand All @@ -5186,7 +5186,7 @@ ZEND_END_ARG_INFO()
#if MagickLibVersion >= 0x692

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_autoOrient, 0, 0, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_autoOrient, 0, 0, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_autoOrient, 0, 0, 0)
#endif
Expand Down Expand Up @@ -5276,7 +5276,7 @@ ZEND_END_ARG_INFO()
#if IM_HAVE_IMAGICK_GETSETIMAGEMASK

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_setImageMask, 0, 2, _IS_BOOL, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_setImageMask, 0, 2, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_setImageMask, 0, 0, 2)
#endif
Expand Down
2 changes: 1 addition & 1 deletion imagick_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -4585,7 +4585,7 @@ PHP_METHOD(Imagick, newImage)
zend_bool allocated;

/* Parse parameters given to function */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz|s", &columns, &rows, &param, &format, &format_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz|s!", &columns, &rows, &param, &format, &format_len) == FAILURE) {
RETURN_THROWS();
}

Expand Down
32 changes: 32 additions & 0 deletions tests/330_Imagick_newImage.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
Test Imagick, newImage
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');

?>
--FILE--
<?php


$image = new Imagick();
$image->newImage(100, 100, new ImagickPixel('red'), 'png');
echo $image->getImageFormat();
echo "\n";

$image = new Imagick();
$image->newImage(100, 100, 'blue', null);

try {
$image->getImageFormat();
}
catch (ImagickException $ie) {
echo $ie->getMessage() . "\n";
}

echo "Ok";
?>
--EXPECTF--
PNG
Image has no format
Ok

0 comments on commit 1bb6184

Please sign in to comment.