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

Port to PHP 8 #7

Merged
merged 11 commits into from
Dec 22, 2024
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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', '8.4']
steps:
- name: Get source code
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Image_Canvas
*
* @abstract
*/
function Image_Canvas($params)
function __construct($params)
{
if (isset($params['left'])) {
$this->_left = $params['left'];
Expand Down Expand Up @@ -786,7 +786,7 @@ function toHtml($params)
* PEAR_Error on error
* @static
*/
function &factory($canvas, $params)
static function &factory($canvas, $params)
{
$canvas = strtoupper($canvas);

Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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])) {
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/GD.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/GD/JPG.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/GD/PNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Image/Canvas/ImageMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function save($params = false)
function toHtml($params)
{
if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '" id="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
return '<map name="' . $params['name'] . '" id="' . $params['name'] . '">' . "\n\t" . implode("\n\t", $this->_map) . "\n</map>";
}
return '';
}
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/PS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/SVG.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/SWF.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions Image/Canvas/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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 +
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Image/Canvas/WithMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"type": "library",
"require": {
"php": ">=5.6, < 8.0",
"php": ">=5.6",
"pear/pear_exception": "*",
"pear/image_color": "*"
}
Expand Down
Loading