Skip to content

Commit 1ae8a56

Browse files
committed
Solved some deprecated messages from PHPlot. PHPlot seems a very slow project (last commit August 2023) and some PHP8 warnings appear and haven't been fixed in https://github.com/AJRepo/PHPlot
1 parent 707d793 commit 1ae8a56

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

includes/phplot/phplot.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -830,10 +830,10 @@ protected function GetColorIndex(&$color, $default_color_index = 0)
830830
protected function GetColorIndexArray($color_array, $max_colors)
831831
{
832832
$n = min(count($color_array), $max_colors);
833-
$Result = array();
833+
$result = array();
834834
for ($i = 0; $i < $n; $i++)
835-
$Result[] = $this->GetColorIndex($color_array[$i]);
836-
return $Result;
835+
$result[] = $this->GetColorIndex($color_array[$i]);
836+
return $result;
837837
}
838838

839839
/**
@@ -849,10 +849,10 @@ protected function GetColorIndexArray($color_array, $max_colors)
849849
protected function GetDarkColorIndexArray($color_array, $max_colors)
850850
{
851851
$n = min(count($color_array), $max_colors);
852-
$Result = array();
852+
$result = array();
853853
for ($i = 0; $i < $n; $i++)
854-
$Result[] = $this->GetDarkColorIndex($color_array[$i]);
855-
return $Result;
854+
$result[] = $this->GetDarkColorIndex($color_array[$i]);
855+
return $result;
856856
}
857857

858858
/**
@@ -1374,15 +1374,15 @@ function SetDefaultDashedStyle($which_style)
13741374
if (!preg_match('/^\d+-\d+(-\d+)*$/', $which_style)) {
13751375
return $this->PrintError("SetDefaultDashedStyle(): Wrong parameter '$which_style'.");
13761376
}
1377-
$Result = '';
1377+
$result = '';
13781378
$use_color = TRUE;
13791379
$transparent = ' ' . IMG_COLOR_TRANSPARENT;
13801380
// Expand the dashed line style specifier:
13811381
foreach (explode('-', $which_style) as $n) {
1382-
$Result .= str_repeat($use_color ? ' #' : $transparent, $n);
1382+
$result .= str_repeat($use_color ? ' #' : $transparent, $n);
13831383
$use_color = !$use_color; // Alternate color and transparent
13841384
}
1385-
$this->default_dashed_style = ltrim($Result);
1385+
$this->default_dashed_style = ltrim($result);
13861386
return TRUE;
13871387
}
13881388

@@ -1857,7 +1857,7 @@ protected function ProcessTextGD($draw_it, $font, $angle, $x, $y, $color, $text,
18571857
$y = $ypos - $r10 * $factor;
18581858

18591859
// Call ImageString or ImageStringUp:
1860-
$draw_func($this->img, $font_number, $x, $y, $lines[$i], $color);
1860+
$draw_func($this->img, $font_number, (int)$x, (int)$y, $lines[$i], $color);
18611861

18621862
// Step to the next line of text. This is a rotation of (x=0, y=interline_spacing)
18631863
$xpos += $r01 * $interline_step;
@@ -2866,13 +2866,13 @@ protected function CheckOption($which_opt, $which_acc, $which_func)
28662866
protected function CheckOptionArray($opt, $acc, $func)
28672867
{
28682868
$opt_array = (array)$opt;
2869-
$Result = array();
2869+
$result = array();
28702870
foreach ($opt_array as $option) {
28712871
$choice = $this->CheckOption($option, $acc, $func);
28722872
if (is_null($choice)) return NULL; // In case CheckOption error handler returns
2873-
$Result[] = $choice;
2873+
$result[] = $choice;
28742874
}
2875-
return $Result;
2875+
return $result;
28762876
}
28772877

28782878
/**
@@ -5421,8 +5421,8 @@ protected function TuneAutoRange($which, $zero_magnet, $adjust_mode, $adjust_amo
54215421
{
54225422
if (isset($zero_magnet) && $zero_magnet >= 0 && $zero_magnet <= 1.0)
54235423
$this->rangectl[$which]['zero_magnet'] = $zero_magnet;
5424-
if (isset($adjust_mode) && strpos('TRI', $adjust_mode[0]) !== FALSE)
5425-
$this->rangectl[$which]['adjust_mode'] = $adjust_mode;
5424+
if (isset($adjust_mode) && strpos('TRI', $adjust_mode) !== FALSE)
5425+
$this->rangectl[$which]['adjust_mode'] = $adjust_mode;
54265426
if (isset($adjust_amount) && $adjust_amount >= 0)
54275427
$this->rangectl[$which]['adjust_amount'] = $adjust_amount;
54285428
return TRUE;
@@ -7125,9 +7125,9 @@ protected function DrawDot($row, $column, $x_world, $y_world, $color)
71257125
{
71267126
$x = $this->xtr($x_world);
71277127
$y = $this->ytr($y_world);
7128-
$Result = $this->DrawShape($x, $y, $column, $color);
7128+
$result = $this->DrawShape($x, $y, $column, $color);
71297129
$this->DoCallback('data_points', 'dot', $row, $column, $x, $y);
7130-
return $Result;
7130+
return $result;
71317131
}
71327132

71337133
/**
@@ -7155,6 +7155,11 @@ protected function DrawDot($row, $column, $x_world, $y_world, $color)
71557155
protected function DrawBar($row, $column, $x1, $y1, $x2, $y2, $data_color, $shade_color, $border_color,
71567156
$shade_top = TRUE, $shade_side = TRUE)
71577157
{
7158+
$x1 = (int)$x1;
7159+
$y1 = (int)$y1;
7160+
$x2 = (int)$x2;
7161+
$y2 = (int)$y2;
7162+
71587163
// Sort the points so x1,y1 is upper left and x2,y2 is lower right. This
71597164
// is needed in order to get the shading right, and imagerectangle may require it.
71607165
if ($x1 > $x2) {

0 commit comments

Comments
 (0)