From 73cb601a9901489be6685af86598d1134520c321 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sat, 5 Oct 2024 16:30:32 +0200 Subject: [PATCH 01/11] Add PHP 8 in composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8199897..91362b0 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ }, "type": "library", "require": { - "php": ">=5.6, < 8.0", + "php": ">=5.6", "pear/pear_exception": "*", "pear/image_color": "*" } From 50f44dd402add3b2bf72273a18cff96a9a703de4 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sat, 5 Oct 2024 02:55:15 +0200 Subject: [PATCH 02/11] Add PHP 8 in CI --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7905a61..65fc4b6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -23,7 +23,7 @@ jobs: strategy: matrix: operating-system: ['ubuntu-latest'] - php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Get source code uses: actions/checkout@v4 From 516de6e22957764cf544f7cf6b540c44a9c77c4f Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:40:35 +0200 Subject: [PATCH 03/11] Temporary use port_php8 branch of Image_Color (from duboism/Image_Color) --- composer.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 91362b0..4182748 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,12 @@ "require": { "php": ">=5.6", "pear/pear_exception": "*", - "pear/image_color": "*" - } + "pear/image_color": "dev-port_php8" + }, + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:duboism/image_color" + } + ] } From b4c4d0cd7f78c5302e6a7c3cdced2aac8a79c8d3 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:42:10 +0200 Subject: [PATCH 04/11] Update Image_Canvas_Color (correct constructor, static methods) --- Image/Canvas/Color.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Image/Canvas/Color.php b/Image/Canvas/Color.php index 4e6c5dc..63f6e5f 100644 --- a/Image/Canvas/Color.php +++ b/Image/Canvas/Color.php @@ -58,7 +58,7 @@ class Image_Canvas_Color extends Image_Color * @access public * @static */ - function allocateColor(&$img, $color) + static function allocateColor(&$img, $color) { $color = Image_Canvas_Color::color2RGB($color); @@ -81,7 +81,7 @@ function allocateColor(&$img, $color) * @access public * @static */ - function color2RGB($color) + static function color2RGB($color) { if (is_array($color)) { if (!is_numeric($color[0])) { From e4d010e4cd00c74070144079a827f2094c3c098b Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:43:11 +0200 Subject: [PATCH 05/11] Correctly declare static functions in class Image_Canvas_Tool --- Image/Canvas/Tool.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Image/Canvas/Tool.php b/Image/Canvas/Tool.php index 40e71f0..435fb4c 100644 --- a/Image/Canvas/Tool.php +++ b/Image/Canvas/Tool.php @@ -69,7 +69,7 @@ class Image_Canvas_Tool * @return string The filename of the font * @static */ - function fontMap($name, $type = '.ttf') + static function fontMap($name, $type = '.ttf') { static $_fontMap; @@ -126,7 +126,7 @@ function fontMap($name, $type = '.ttf') * @return double The average of P1 and P2 * @static */ - function mid($p1, $p2) + static function mid($p1, $p2) { return ($p1 + $p2) / 2; } @@ -142,7 +142,7 @@ function mid($p1, $p2) * @return double $p1 mirrored in $p2 by Factor * @static */ - function mirror($p1, $p2, $factor = 1) + static function mirror($p1, $p2, $factor = 1) { return $p2 + $factor * ($p2 - $p1); } @@ -159,7 +159,7 @@ function mirror($p1, $p2, $factor = 1) * @return double P1 mirrored in P2 by Factor * @static */ - function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75) + static function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75) { $sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor); $sb = Image_Canvas_Tool::mid($p2, $sa); @@ -185,7 +185,7 @@ function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75) * $p1 and $p4 to calculate control points * @static */ - function bezier($t, $p1, $p2, $p3, $p4) + static function bezier($t, $p1, $p2, $p3, $p4) { // (1-t)^3*p1 + 3*(1-t)^2*t*p2 + 3*(1-t)*t^2*p3 + t^3*p4 return pow(1 - $t, 3) * $p1 + @@ -205,7 +205,7 @@ function bezier($t, $p1, $p2, $p3, $p4) * @return double The angle in degrees of the line * @static */ - function getAngle($x0, $y0, $x1, $y1) + static function getAngle($x0, $y0, $x1, $y1) { $dx = ($x1 - $x0); From 10f7548e26812f477fea5ceca0a430aab6b3b13e Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:47:00 +0200 Subject: [PATCH 06/11] Correctly declare and call constructors in class Image_Canvas and subclasses --- Image/Canvas.php | 2 +- Image/Canvas/GD.php | 4 ++-- Image/Canvas/GD/JPG.php | 4 ++-- Image/Canvas/GD/PNG.php | 4 ++-- Image/Canvas/PDF.php | 4 ++-- Image/Canvas/PS.php | 4 ++-- Image/Canvas/SVG.php | 4 ++-- Image/Canvas/SWF.php | 4 ++-- Image/Canvas/WithMap.php | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Image/Canvas.php b/Image/Canvas.php index ecbe5aa..0dcc3a3 100644 --- a/Image/Canvas.php +++ b/Image/Canvas.php @@ -150,7 +150,7 @@ class Image_Canvas * * @abstract */ - function Image_Canvas($params) + function __construct($params) { if (isset($params['left'])) { $this->_left = $params['left']; diff --git a/Image/Canvas/GD.php b/Image/Canvas/GD.php index 8a6664c..0d57f95 100644 --- a/Image/Canvas/GD.php +++ b/Image/Canvas/GD.php @@ -151,11 +151,11 @@ class Image_Canvas_GD extends Image_Canvas_WithMap * * @param array $param Parameter array */ - function Image_Canvas_GD($param) + function __construct($param) { include_once 'Image/Canvas/Color.php'; - parent::Image_Canvas_WithMap($param); + parent::__construct($param); $this->_gd2 = ($this->_version() == 2); $this->_pxToPtFactor = ($this->_gd2 ? (72/96) : 1); diff --git a/Image/Canvas/GD/JPG.php b/Image/Canvas/GD/JPG.php index cb294a2..8a9e1d6 100644 --- a/Image/Canvas/GD/JPG.php +++ b/Image/Canvas/GD/JPG.php @@ -67,9 +67,9 @@ class Image_Canvas_GD_JPG extends Image_Canvas_GD * * @param array $param Parameter array */ - function Image_Canvas_GD_JPG($param) + function __construct($param) { - parent::Image_Canvas_GD($param); + parent::__construct($param); if (isset($param['quality'])) { $this->_quality = max(0, min(100, $param['quality'])); diff --git a/Image/Canvas/GD/PNG.php b/Image/Canvas/GD/PNG.php index cde659a..ec741db 100644 --- a/Image/Canvas/GD/PNG.php +++ b/Image/Canvas/GD/PNG.php @@ -54,9 +54,9 @@ class Image_Canvas_GD_PNG extends Image_Canvas_GD * * @param array $param Parameter array */ - function Image_Canvas_GD_PNG($param) + function __construct($param) { - parent::Image_Canvas_GD($param); + parent::__construct($param); if ((isset($param['transparent'])) && ($param['transparent']) && ($this->_gd2) diff --git a/Image/Canvas/PDF.php b/Image/Canvas/PDF.php index 8a1de48..16b7361 100644 --- a/Image/Canvas/PDF.php +++ b/Image/Canvas/PDF.php @@ -147,7 +147,7 @@ class Image_Canvas_PDF extends Image_Canvas * * @param array $param Parameter array */ - function Image_Canvas_PDF($param) + function __construct($param) { if (isset($param['page'])) { switch (strtoupper($param['page'])) { @@ -234,7 +234,7 @@ function Image_Canvas_PDF($param) $this->_pageHeight = $w; } - parent::Image_Canvas($param); + parent::__construct($param); if (!$this->_pageWidth) { $this->_pageWidth = $this->_width; diff --git a/Image/Canvas/PS.php b/Image/Canvas/PS.php index 6be138e..d9c1b0f 100644 --- a/Image/Canvas/PS.php +++ b/Image/Canvas/PS.php @@ -144,7 +144,7 @@ class Image_Canvas_PS extends Image_Canvas * * @param array $param Parameter array */ - function Image_Canvas_PS($param) + function __construct($param) { if (isset($param['page'])) { switch (strtoupper($param['page'])) { @@ -233,7 +233,7 @@ function Image_Canvas_PS($param) $this->_pageHeight = $w; } - parent::Image_Canvas($param); + parent::__construct($param); if (!$this->_pageWidth) { $this->_pageWidth = $this->_width; diff --git a/Image/Canvas/SVG.php b/Image/Canvas/SVG.php index e80a35f..79a5fd4 100644 --- a/Image/Canvas/SVG.php +++ b/Image/Canvas/SVG.php @@ -107,9 +107,9 @@ class Image_Canvas_SVG extends Image_Canvas * * @return void */ - function Image_Canvas_SVG($params) + function __construct($params) { - parent::Image_Canvas($params); + parent::__construct($params); $this->_reset(); if (isset($params['encoding'])) { diff --git a/Image/Canvas/SWF.php b/Image/Canvas/SWF.php index dbd4529..9a5adc1 100644 --- a/Image/Canvas/SWF.php +++ b/Image/Canvas/SWF.php @@ -88,9 +88,9 @@ class Image_Canvas_SWF extends Image_Canvas * * @return Image_Canvas_SWF */ - function Image_Canvas_SWF($params) + function __construct($params) { - parent::Image_Canvas($params); + parent::__construct($params); $this->_reset(); $version = (isset($params['version']) && $params['version'] <= 6) diff --git a/Image/Canvas/WithMap.php b/Image/Canvas/WithMap.php index 0b7b3aa..e74ac02 100644 --- a/Image/Canvas/WithMap.php +++ b/Image/Canvas/WithMap.php @@ -72,9 +72,9 @@ class Image_Canvas_WithMap extends Image_Canvas * * @abstract */ - function Image_Canvas_WithMap($params) + function __construct($params) { - parent::Image_Canvas($params); + parent::__construct($params); if ((isset($params['usemap'])) && ($params['usemap'] === true)) { $this->_imageMap =& Image_Canvas::factory( From 60aac90c44522ccf86b08fa2337633c149a6da8e Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:47:29 +0200 Subject: [PATCH 07/11] Correctly declare factory function as static --- Image/Canvas.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Image/Canvas.php b/Image/Canvas.php index 0dcc3a3..707122a 100644 --- a/Image/Canvas.php +++ b/Image/Canvas.php @@ -786,7 +786,7 @@ function toHtml($params) * PEAR_Error on error * @static */ - function &factory($canvas, $params) + static function &factory($canvas, $params) { $canvas = strtoupper($canvas); From 2fb88d9c54227dfc3c30f9c4e8d6ad90d9f9a021 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:48:42 +0200 Subject: [PATCH 08/11] Correctly call implode --- Image/Canvas/ImageMap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Image/Canvas/ImageMap.php b/Image/Canvas/ImageMap.php index b77fbf5..cba0a08 100644 --- a/Image/Canvas/ImageMap.php +++ b/Image/Canvas/ImageMap.php @@ -369,7 +369,7 @@ function save($params = false) function toHtml($params) { if (count($this->_map) > 0) { - return '' . "\n\t" . implode($this->_map, "\n\t") . "\n"; + return '' . "\n\t" . implode("\n\t", $this->_map) . "\n"; } return ''; } From e78faaf816247f01a53e6753771a84f42666bf27 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Fri, 29 Nov 2024 23:44:04 +0100 Subject: [PATCH 09/11] Temporary use master branch of Image_Color (from duboism/Image_Color) We're almost done --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4182748..9efa718 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": ">=5.6", "pear/pear_exception": "*", - "pear/image_color": "dev-port_php8" + "pear/image_color": "dev-master" }, "repositories": [ { From 4129c2c49ce730bceb6a2a893c71e966749cbc7a Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Fri, 29 Nov 2024 23:44:41 +0100 Subject: [PATCH 10/11] Add PHP 8.4 to CI --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 65fc4b6..fd8725d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -23,7 +23,7 @@ jobs: strategy: matrix: operating-system: ['ubuntu-latest'] - php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Get source code uses: actions/checkout@v4 From 3b4d4837c0c70b416ef6a26aa3bb10f90e6ec447 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sun, 8 Dec 2024 19:05:50 +0100 Subject: [PATCH 11/11] Switch to upstream pear/image_color --- composer.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 9efa718..91362b0 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,6 @@ "require": { "php": ">=5.6", "pear/pear_exception": "*", - "pear/image_color": "dev-master" - }, - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:duboism/image_color" - } - ] + "pear/image_color": "*" + } }