diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..46b2435 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,5 @@ +--- +checks: + php: + code_rating: true + duplication: true diff --git a/.travis.yml b/.travis.yml index c306e88..0f88d2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,23 @@ cache: sudo: false -php: - - 5.5 +matrix: + include: + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 + + +before_install: + - phpenv config-rm xdebug.ini + - composer self-update -n before_script: - - composer self-update -n - - composer install -n --prefer-dist -v - - nohup php -S localhost:8080 -t features/fixtures/web > server.log 2>&1 & + - composer install -n --prefer-dist -v + - nohup php -S localhost:8080 -t features/fixtures/web > server.log 2>&1 & script: - - bin/phpcs --standard=PSR2 --encoding=UTF-8 --ignore="*.db,*.color,*.ttf" src/ - - bin/behat --no-snippets --verbose --profile=travis -vvv + - bin/phpcs --standard=PSR2 --encoding=UTF-8 --ignore="*.db,*.color,*.ttf" src/ + - bin/behat --no-snippets --verbose --profile=travis -vvv diff --git a/composer.json b/composer.json index 6a763fb..4b30990 100644 --- a/composer.json +++ b/composer.json @@ -22,16 +22,16 @@ "files": ["src/Resources/data/constants.php"] }, "require": { - "php": ">=5.5", + "php": ">=5.4", "ext-gd": "*" }, "require-dev" : { - "behat/behat": "~3.0", - "behat/mink": "~1.7", - "behat/mink-goutte-driver": "~1.2", - "bossa/phpspec2-expect": "~1.0", - "sensiolabs/behat-page-object-extension": "~2.0@dev", - "squizlabs/php_codesniffer": "~2.3" + "behat/behat": "^3.3", + "behat/mink": "^1.7", + "behat/mink-goutte-driver": "^1.2", + "bossa/phpspec2-expect": "^1.0", + "sensiolabs/behat-page-object-extension": "^2.0", + "squizlabs/php_codesniffer": "^2.8" }, "config": { "bin-dir": "bin" diff --git a/src/Chart/BaseDraw.php b/src/Chart/BaseDraw.php index 76c93b4..7674d96 100644 --- a/src/Chart/BaseDraw.php +++ b/src/Chart/BaseDraw.php @@ -295,8 +295,8 @@ public function allocateColor($Picture, $R, $G, $B, $Alpha = 100) /** * Convert apha to base 10 - * @param int |float $AlphaValue - * @return int | float + * @param int|float $AlphaValue + * @return integer */ public function convertAlpha($AlphaValue) { @@ -502,9 +502,9 @@ public function processScale($XMin, $XMax, $MaxDivs, array $Factors, $AxisID) /** * - * @param int | float $Value1 - * @param int | float $Value2 - * @return int | float + * @param int|float $Value1 + * @param int|float $Value2 + * @return double */ public function modulo($Value1, $Value2) { @@ -527,8 +527,8 @@ public function modulo($Value1, $Value2) /** * @param mixed $Value * @param mixed $LastValue - * @param mixed $LabelingMethod - * @param mixed $ID + * @param integer $LabelingMethod + * @param integer $ID * @param boolean $LabelSkip * @return boolean */ @@ -574,23 +574,18 @@ public function countDrawableSeries() * @param int $Ya * @param int $Xb * @param int $Yb - * @return array + * @return integer[] */ public function fixBoxCoordinates($Xa, $Ya, $Xb, $Yb) { - return array( - min($Xa, $Xb), - min($Ya, $Yb), - max($Xa, $Xb), - max($Ya, $Yb) - ); + return array(min($Xa, $Xb), min($Ya, $Yb), max($Xa, $Xb), max($Ya, $Yb)); } /** * Apply AALias correction to the rounded box boundaries - * @param int | float $Value + * @param int|float $Value * @param int $Mode - * @return int | float + * @return int|float */ public function offsetCorrection($Value, $Mode) { @@ -843,7 +838,7 @@ public function getRandomColor($Alpha = 100) /** * Validate a palette * @param mixed $Colors - * @param int | float $Surrounding + * @param int|float $Surrounding * @return array */ public function validatePalette($Colors, $Surrounding = null) @@ -913,7 +908,7 @@ public function validatePalette($Colors, $Surrounding = null) * @param mixed $Values * @param array $Option * @param boolean $ReturnOnly0Height - * @return array | int | float + * @return int|float|array */ public function scaleComputeY($Values, array $Option = array(), $ReturnOnly0Height = false) { @@ -1060,7 +1055,7 @@ public function scaleFormat($Value, $Mode = null, $Format = null, $Unit = null) } /** - * @return array | null + * @return array|null */ public function scaleGetXSettings() { @@ -1168,13 +1163,13 @@ public function writeBounds($Type = BOUND_BOTH, $Format = null) if ($Type == BOUND_MAX || $Type == BOUND_BOTH) { if ($MaxLabelPos == BOUND_LABEL_POS_TOP - || ( $MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue >= 0) + || ($MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue >= 0) ) { $YPos = $PosArray[$MaxPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_BOTTOMMIDDLE; } if ($MaxLabelPos == BOUND_LABEL_POS_BOTTOM - || ( $MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue < 0) + || ($MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue < 0) ) { $YPos = $PosArray[$MaxPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_TOPMIDDLE; diff --git a/src/Chart/Bubble.php b/src/Chart/Bubble.php index 7850387..7a1d56b 100644 --- a/src/Chart/Bubble.php +++ b/src/Chart/Bubble.php @@ -466,8 +466,7 @@ public function writeBubbleLabel($SerieName, $SerieWeightName, $Points, $Format } else { $Description = "No description"; } - $Series = ""; - $Series[] = array("Format" => $Color, "Caption" => $Caption); + $Series = [["Format" => $Color, "Caption" => $Caption]]; if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) { if ($XDivs == 0) { diff --git a/src/Chart/Cache.php b/src/Chart/Cache.php index 16d7475..d95fb7a 100644 --- a/src/Chart/Cache.php +++ b/src/Chart/Cache.php @@ -361,7 +361,7 @@ public function saveFromCache($ID, $Destination) /** * Get file from cache * @param string $ID - * @return string | null + * @return string|null */ public function getFromCache($ID) { diff --git a/src/Chart/Data.php b/src/Chart/Data.php index 5d60354..afa5330 100644 --- a/src/Chart/Data.php +++ b/src/Chart/Data.php @@ -179,7 +179,7 @@ public function reverseSerie($Series) /** * Return the sum of the serie values * @param string $Serie - * @return int | null + * @return int|null */ public function getSum($Serie) { @@ -233,7 +233,7 @@ public function setSerieShape($Series, $Shape = SERIE_SHAPE_FILLEDCIRCLE) /** * Set the description of a given serie - * @param mixed $Series + * @param string|array $Series * @param string $Description */ public function setSerieDescription($Series, $Description = "My serie") @@ -250,7 +250,7 @@ public function setSerieDescription($Series, $Description = "My serie") /** * Set a serie as "drawable" while calling a rendering public function - * @param mixed $Series + * @param string|array $Series * @param boolean $Drawable */ public function setSerieDrawable($Series, $Drawable = true) @@ -489,7 +489,7 @@ public function drawAll() /** * Return the average value of the given serie * @param string $Serie - * @return int | null + * @return int|null */ public function getSerieAverage($Serie) { @@ -497,13 +497,14 @@ public function getSerieAverage($Serie) $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); return array_sum($SerieData) / sizeof($SerieData); } + return null; } /** * Return the geometric mean of the given serie * @param string $Serie - * @return int | null + * @return int|null */ public function getGeometricMean($Serie) { @@ -515,13 +516,14 @@ public function getGeometricMean($Serie) } return pow($Seriesum, 1 / sizeof($SerieData)); } + return null; } /** * Return the harmonic mean of the given serie * @param string $Serie - * @return int | null + * @return int|null */ public function getHarmonicMean($Serie) { @@ -540,7 +542,7 @@ public function getHarmonicMean($Serie) /** * Return the standard deviation of the given serie * @param string $Serie - * @return int | float | null + * @return double|null */ public function getStandardDeviation($Serie) { @@ -560,7 +562,7 @@ public function getStandardDeviation($Serie) /** * Return the Coefficient of variation of the given serie * @param string $Serie - * @return float | null + * @return float|null */ public function getCoefficientOfVariation($Serie) { @@ -578,7 +580,7 @@ public function getCoefficientOfVariation($Serie) /** * Return the median value of the given serie * @param string $Serie - * @return int | float + * @return int|float */ public function getSerieMedian($Serie) { @@ -598,7 +600,7 @@ public function getSerieMedian($Serie) * Return the x th percentil of the given serie * @param string $Serie * @param int $Percentil - * @return int | float | null + * @return int|float| null */ public function getSeriePercentile($Serie = "Serie1", $Percentil = 95) { @@ -645,7 +647,7 @@ public function addRandomValues($SerieName = "Serie1", array $Options = array()) /** * Test if we have valid data - * @return boolean + * @return boolean|null */ public function containsData() { @@ -660,6 +662,8 @@ public function containsData() return true; } } + + return null; } /** @@ -922,12 +926,12 @@ public function loadPalette($FileName, $Overwrite = false) /** * Initialise a given scatter serie * @param int $ID - * @return null | int + * @return null */ public function initScatterSerie($ID) { if (isset($this->Data["ScatterSeries"][$ID])) { - return 0; + return null; } $this->Data["ScatterSeries"][$ID]["Description"] = "Scatter " . $ID; @@ -1095,10 +1099,11 @@ public function importFromCSV($FileName, array $Options = array()) /** * Create a dataset based on a formula + * * @param string $SerieName * @param string $Formula * @param array $Options - * @return null | int + * @return null */ public function createFunctionSerie($SerieName, $Formula = "", array $Options = array()) { @@ -1110,11 +1115,11 @@ public function createFunctionSerie($SerieName, $Formula = "", array $Options = $AbscissaSerie = isset($Options["AbscissaSerie"]) ? $Options["AbscissaSerie"] : "Abscissa"; if ($Formula == "") { - return 0; + return null; } - $Result = ""; - $Abscissa = ""; + $Result = []; + $Abscissa = []; for ($i = $MinX; $i <= $MaxX; $i = $i + $XStep) { $Expression = "\$return = '!'.(" . str_replace("z", $i, $Formula) . ");"; if (@eval($Expression) === false) { @@ -1188,7 +1193,8 @@ public function getData() /** * Save a palette element - * @param id $ID + * + * @param integer $ID * @param string $Color */ public function savePalette($ID, $Color) diff --git a/src/Chart/Draw.php b/src/Chart/Draw.php index 5db0490..49e542a 100644 --- a/src/Chart/Draw.php +++ b/src/Chart/Draw.php @@ -126,9 +126,9 @@ public function drawPolygon(array $Points, array $Format = array()) * @param int $Y1 * @param int $X2 * @param int $Y2 - * @param int | float $Radius + * @param int|float $Radius * @param array $Format - * @return null | 0 + * @return null|integer */ public function drawRoundedRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format = array()) { @@ -192,9 +192,9 @@ public function drawRoundedRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format * @param int $Y1 * @param int $X2 * @param int $Y2 - * @param int | float $Radius + * @param int|float $Radius * @param array $Format - * @return null | 0 + * @return null|integer */ public function drawRoundedFilledRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format = array()) { @@ -262,7 +262,7 @@ public function drawRoundedFilledRectangle($X1, $Y1, $X2, $Y2, $Radius, array $F $YBottom = $Y2 - $Radius; $Step = 360 / (2 * PI * $Radius); - $Positions = ""; + $Positions = []; $Radius--; $MinY = null; $MaxY = null; @@ -726,7 +726,7 @@ public function drawBezier($X1, $Y1, $X2, $Y2, $Xv1, $Yv1, $Xv2, $Yv2, array $Fo for ($j = 0; $j <= 3; $j++) { if (!isset($Q[$ID])) { - $Q[$ID] = ""; + $Q[$ID] = []; } if (!isset($Q[$ID]["X"])) { $Q[$ID]["X"] = 0; @@ -843,12 +843,12 @@ public function drawBezier($X1, $Y1, $X2, $Y2, $Xv1, $Yv1, $Xv2, $Yv2, array $Fo /** * Draw a line between two points - * @param int $X1 - * @param int $Y1 - * @param int $X2 - * @param int $Y2 + * @param int|float $X1 + * @param int|float $Y1 + * @param int|float $X2 + * @param int|float $Y2 * @param array $Format - * @return array | int + * @return array|int */ public function drawLine($X1, $Y1, $X2, $Y2, array $Format = array()) { @@ -995,8 +995,8 @@ public function drawLine($X1, $Y1, $X2, $Y2, array $Format = array()) * Draw a circle * @param int $Xc * @param int $Yc - * @param int | float $Height - * @param int | float $Width + * @param int|float $Height + * @param int|float $Width * @param array $Format */ public function drawCircle($Xc, $Yc, $Height, $Width, array $Format = array()) @@ -1088,7 +1088,7 @@ public function drawCircle($Xc, $Yc, $Height, $Width, array $Format = array()) * Draw a filled circle * @param int $X * @param int $Y - * @param int | float $Radius + * @param int|float $Radius * @param array $Format */ public function drawFilledCircle($X, $Y, $Radius, array $Format = array()) @@ -1177,8 +1177,8 @@ public function drawFilledCircle($X, $Y, $Radius, array $Format = array()) /** * Write text - * @param int $X - * @param int $Y + * @param int|float $X + * @param int|float $Y * @param string $Text * @param array $Format * @return array @@ -1324,7 +1324,7 @@ public function drawText($X, $Y, $Text, array $Format = array()) * @param int $Y2 * @param int $Direction * @param array $Format - * @return null + * @return null|integer */ public function drawGradientArea($X1, $Y1, $X2, $Y2, $Direction, array $Format = array()) { @@ -1440,7 +1440,7 @@ public function drawGradientArea($X1, $Y1, $X2, $Y2, $Direction, array $Format = * @param int $X * @param int $Y * @param array $Format - * @return int | null + * @return int|null */ public function drawAntialiasPixel($X, $Y, array $Format = array()) { @@ -1527,7 +1527,7 @@ public function drawAntialiasPixel($X, $Y, array $Format = array()) * @param int $R * @param int $G * @param int $B - * @return null + * @return null|integer */ public function drawAlphaPixel($X, $Y, $Alpha, $R, $G, $B) { @@ -1609,7 +1609,7 @@ public function drawFromJPG($X, $Y, $FileName) * @param string $FileName * @param int $X * @param int $Y - * @return null | 0 + * @return null|integer */ public function drawFromPicture($PicType, $FileName, $X, $Y) { @@ -1949,7 +1949,7 @@ public function drawArrowLabel($X1, $Y1, $Text, array $Format = array()) * Draw a progress bar filled with specified % * @param int $X * @param int $Y - * @param int | float $Percent + * @param int|float $Percent * @param array $Format */ public function drawProgress($X, $Y, $Percent, array $Format = array()) @@ -2557,7 +2557,7 @@ public function drawScale(array $Format = array()) $SkippedOuterTickWidth = isset($Format["SkippedOuterTickWidth"]) ? $Format["SkippedOuterTickWidth"] : 2; /* Floating scale require X & Y margins to be set manually */ - if ($Floating && ( $XMargin == AUTO || $YMargin == 0 )) { + if ($Floating && ($XMargin == AUTO || $YMargin == 0)) { $Floating = false; } @@ -4114,7 +4114,7 @@ public function drawScale(array $Format = array()) * Draw an X threshold * @param mixed $Value * @param boolean $Format - * @return array | null | 0 + * @return array|null|integer */ public function drawXThreshold($Value, array $Format = array()) { @@ -4202,7 +4202,7 @@ public function drawXThreshold($Value, array $Format = array()) } if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) { - $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] * 2 ) / $XScale[1]; + $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] * 2) / $XScale[1]; $XPos = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value; $YPos1 = $this->GraphAreaY1 + $Data["YMargin"]; $YPos2 = $this->GraphAreaY2 - $Data["YMargin"]; @@ -4268,7 +4268,7 @@ public function drawXThreshold($Value, array $Format = array()) return array("X" => $XPos); } } elseif ($Data["Orientation"] == SCALE_POS_TOPBOTTOM) { - $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] * 2 ) / $XScale[1]; + $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] * 2) / $XScale[1]; $XPos = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value; $YPos1 = $this->GraphAreaX1 + $Data["YMargin"]; $YPos2 = $this->GraphAreaX2 - $Data["YMargin"]; @@ -4342,7 +4342,7 @@ public function drawXThreshold($Value, array $Format = array()) * @param mixed $Value1 * @param mixed $Value2 * @param array $Format - * @return array | null + * @return array|null */ public function drawXThresholdArea($Value1, $Value2, array $Format = array()) { @@ -4377,7 +4377,7 @@ public function drawXThresholdArea($Value1, $Value2, array $Format = array()) $XScale = $this->scaleGetXSettings(); if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) { - $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] * 2 ) / $XScale[1]; + $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] * 2) / $XScale[1]; $XPos1 = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value1; $XPos2 = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value2; $YPos1 = $this->GraphAreaY1 + $Data["YMargin"]; @@ -4474,7 +4474,7 @@ public function drawXThresholdArea($Value1, $Value2, array $Format = array()) $this->Shadow = $RestoreShadow; return array("X1" => $XPos1, "X2" => $XPos2); } elseif ($Data["Orientation"] == SCALE_POS_TOPBOTTOM) { - $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] * 2 ) / $XScale[1]; + $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] * 2) / $XScale[1]; $XPos1 = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value1; $XPos2 = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value2; $YPos1 = $this->GraphAreaX1 + $Data["YMargin"]; @@ -4562,7 +4562,7 @@ public function drawXThresholdArea($Value1, $Value2, array $Format = array()) * Draw an Y threshold with the computed scale * @param mixed $Value * @param array $Format - * @return array | int + * @return array|int */ public function drawThreshold($Value, array $Format = array()) { @@ -4783,7 +4783,7 @@ public function drawThreshold($Value, array $Format = array()) * @param mixed $Value1 * @param mixed $Value2 * @param array $Format - * @return array | int | null + * @return array|int|null */ public function drawThresholdArea($Value1, $Value2, array $Format = array()) { @@ -6122,7 +6122,7 @@ public function drawLineChart(array $Format = array()) * @param string $SerieA * @param string $SerieB * @param array $Format - * @return null | 0 + * @return null|integer */ public function drawZoneChart($SerieA, $SerieB, array $Format = array()) { @@ -7077,7 +7077,7 @@ public function drawAreaChart(array $Format = array()) if ($this->Shadow) { $ShadowArea = array(); foreach ($Areas as $Key => $Points) { - $ShadowArea[$Key] = ""; + $ShadowArea[$Key] = []; foreach ($Points as $Key2 => $Value) { if ($Key2 % 2 == 0) { $ShadowArea[$Key][] = $Value + $this->ShadowX; @@ -7209,7 +7209,7 @@ public function drawAreaChart(array $Format = array()) if ($this->Shadow) { $ShadowArea = array(); foreach ($Areas as $Key => $Points) { - $ShadowArea[$Key] = ""; + $ShadowArea[$Key] = []; foreach ($Points as $Key2 => $Value) { if ($Key2 % 2 == 0) { $ShadowArea[$Key][] = $Value + $this->ShadowX; @@ -8148,7 +8148,7 @@ public function drawStackedBarChart(array $Format = array()) } if (!isset($LastY[$Key])) { - $LastY[$Key] = ""; + $LastY[$Key] = []; } if (!isset($LastY[$Key][$Pos])) { $LastY[$Key][$Pos] = $YZero; @@ -8325,7 +8325,7 @@ public function drawStackedBarChart(array $Format = array()) } if ($DisplayOrientation == ORIENTATION_VERTICAL - || ( $DisplayOrientation == ORIENTATION_AUTO && !$Done) + || ($DisplayOrientation == ORIENTATION_AUTO && !$Done) ) { if ($TxtHeight < $BarWidth && $TxtWidth < $BarHeight) { $this->drawText( @@ -8386,7 +8386,7 @@ public function drawStackedBarChart(array $Format = array()) } if (!isset($LastX[$Key])) { - $LastX[$Key] = ""; + $LastX[$Key] = []; } if (!isset($LastX[$Key][$Pos])) { $LastX[$Key][$Pos] = $YZero; @@ -8529,7 +8529,7 @@ public function drawStackedBarChart(array $Format = array()) $TxtHeight = abs($TxtPos[2]["Y"] - $TxtPos[0]["Y"]); $TxtWidth = abs($TxtPos[1]["X"] - $TxtPos[0]["X"]); - $XCenter = ( $X2 - $X1 ) / 2 + $X1; + $XCenter = ($X2 - $X1) / 2 + $X1; $YCenter = (($Y + $YOffset + $YSize) - ($Y + $YOffset)) / 2 + $Y + $YOffset; $Done = false; @@ -8560,7 +8560,7 @@ public function drawStackedBarChart(array $Format = array()) } if ($DisplayOrientation == ORIENTATION_VERTICAL - || ( $DisplayOrientation == ORIENTATION_AUTO && !$Done) + || ($DisplayOrientation == ORIENTATION_AUTO && !$Done) ) { if ($TxtHeight < $BarWidth && $TxtWidth < $BarHeight) { $this->drawText( @@ -8627,7 +8627,6 @@ public function drawStackedAreaChart(array $Format = array()) $this->Shadow = false; /* Build the offset data series */ - $OffsetData = ""; $OverallOffset = ""; $SerieOrder = ""; foreach ($Data["Series"] as $SerieName => $Serie) { @@ -9890,11 +9889,11 @@ public function drawLabelBox($X, $Y, $Title, array $Captions, array $Format = ar * @param int $R * @param int $G * @param int $B - * @param int | float $Alpha + * @param int|float $Alpha * @param int $BorderR * @param int $BorderG * @param int $BorderB - * @param int | float $BorderAlpha + * @param int|float $BorderAlpha */ public function drawShape( $X, @@ -10059,7 +10058,7 @@ public function drawShape( * * @param array $Points * @param array $Format - * @return null + * @return null|integer */ public function drawPolygonChart(array $Points, array $Format = array()) { @@ -10180,9 +10179,9 @@ public function drawPolygonChart(array $Points, array $Format = array()) $YStep = 1; if (!$NoFill) { - //if ( $DebugLine ) { $MinY = $DebugLine; $MaxY = $DebugLine; } + //if ($DebugLine ) { $MinY = $DebugLine; $MaxY = $DebugLine; } for ($Y = $MinY; $Y <= $MaxY; $Y = $Y + $YStep) { - $Intersections = ""; + $Intersections = []; $LastSlope = null; $RestoreLast = "-"; foreach ($Segments as $Key => $Coords) { @@ -10195,7 +10194,7 @@ public function drawPolygonChart(array $Points, array $Format = array()) if ($Y1 == $Y2) { $X = $X1; } else { - $X = $X1 + (($Y - $Y1) * $X2 - ($Y - $Y1) * $X1 ) / ($Y2 - $Y1); + $X = $X1 + (($Y - $Y1) * $X2 - ($Y - $Y1) * $X1) / ($Y2 - $Y1); } $X = floor($X); @@ -10236,7 +10235,7 @@ public function drawPolygonChart(array $Points, array $Format = array()) if (is_array($Intersections) && in_array($X, $Intersections) && $LastSlope == "=" - && ($Slope == "-" ) + && ($Slope == "-") ) { $Intersections[] = $X; } diff --git a/src/Chart/Image.php b/src/Chart/Image.php index 81f9b1a..46c96ea 100644 --- a/src/Chart/Image.php +++ b/src/Chart/Image.php @@ -89,7 +89,7 @@ public function setShadow($Enabled = true, array $Format = array()) * @param int $Y1 * @param int $X2 * @param int $Y2 - * @return int | null + * @return int|null */ public function setGraphArea($X1, $Y1, $X2, $Y2) { @@ -369,9 +369,10 @@ public function initialiseImageMap( /** * Add a zone to the image map - * @param mixed $Type - * @param mixed $Plots - * @param mixed $Color + * + * @param string $Type + * @param string $Plots + * @param string|null $Color * @param string $Title * @param string $Message * @param boolean $HTMLEncode @@ -459,8 +460,8 @@ public function removeVOIDFromArray($SerieName, array $Values) /** * Replace the title of one image map serie * @param string $OldTitle - * @param string | array $NewTitle - * @return null | int + * @param string|array $NewTitle + * @return null|int */ public function replaceImageMapTitle($OldTitle, $NewTitle) { @@ -547,7 +548,7 @@ public function replaceImageMapTitle($OldTitle, $NewTitle) * Replace the values of the image map contents * @param string $Title * @param array $Values - * @return null | int + * @return null|int */ public function replaceImageMapValues($Title, array $Values) { diff --git a/src/Chart/Indicator.php b/src/Chart/Indicator.php index aa7ab7b..0150235 100644 --- a/src/Chart/Indicator.php +++ b/src/Chart/Indicator.php @@ -32,12 +32,13 @@ public function __construct(Image $pChartObject) /** * Draw an indicator + * * @param int $X * @param int $Y * @param int $Width * @param int $Height * @param array $Format - * @return null | int + * @return null|int */ public function draw($X, $Y, $Width, $Height, array $Format = array()) { @@ -105,7 +106,7 @@ public function draw($X, $Y, $Width, $Height, array $Format = array()) $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; if ($Key == 0 && $DrawLeftHead) { - $Poly = ""; + $Poly = []; $Poly[] = $X1 - 1; $Poly[] = $Y; $Poly[] = $X1 - 1; diff --git a/src/Chart/Pie.php b/src/Chart/Pie.php index 585c40c..f8671a8 100644 --- a/src/Chart/Pie.php +++ b/src/Chart/Pie.php @@ -15,7 +15,6 @@ * * You can find the whole class documentation on the pChart web site. */ - class Pie { /** @@ -380,7 +379,7 @@ public function draw2DPie($X, $Y, array $Format = array()) } if ($WriteValues == PIE_VALUE_PERCENTAGE) { - $Display = round(( 100 / $SerieSum ) * $Value, $Precision) . "%"; + $Display = round((100 / $SerieSum) * $Value, $Precision) . "%"; } elseif ($WriteValues == PIE_VALUE_NATURAL) { $Display = $Value . $ValueSuffix; } @@ -555,16 +554,16 @@ public function draw3DPie($X, $Y, array $Format = array()) $Xc = cos(($i - 90) * PI / 180) * $Radius + $X; $Yc = sin(($i - 90) * PI / 180) * $Radius * $SkewFactor + $Y; - if (($SecondPass || $RestoreShadow ) && ( $i < 90 )) { + if (($SecondPass || $RestoreShadow) && ($i < 90)) { $Yc++; } - if (($SecondPass || $RestoreShadow ) && ( $i > 90 && $i < 180 )) { + if (($SecondPass || $RestoreShadow) && ($i > 90 && $i < 180)) { $Xc++; } - if (($SecondPass || $RestoreShadow ) && ( $i > 180 && $i < 270 )) { + if (($SecondPass || $RestoreShadow) && ($i > 180 && $i < 270)) { $Xc++; } - if (($SecondPass || $RestoreShadow ) && ( $i >= 270 )) { + if (($SecondPass || $RestoreShadow) && ($i >= 270)) { $Xc++; $Yc++; } @@ -580,7 +579,7 @@ public function draw3DPie($X, $Y, array $Format = array()) } /* Draw the bottom shadow if needed */ - if ($RestoreShadow && ($this->pChartObject->ShadowX != 0 || $this->pChartObject->ShadowY != 0 )) { + if ($RestoreShadow && ($this->pChartObject->ShadowX != 0 || $this->pChartObject->ShadowY != 0)) { foreach ($Slices as $SliceID => $Plots) { $ShadowPie = array(); for ($i = 0; $i < count($Plots); $i = $i + 2) { @@ -651,9 +650,9 @@ public function draw3DPie($X, $Y, array $Format = array()) $SliceColors = array_reverse($SliceColors); foreach ($Slices as $SliceID => $Plots) { $Settings = $SliceColors[$SliceID]; - $Settings["R"]+= 10; - $Settings["G"]+= 10; - $Settings["B"]+= 10; + $Settings["R"] += 10; + $Settings["G"] += 10; + $Settings["B"] += 10; $Settings["NoBorder"] = true; /* Empty error handling */ if ($Visible[$SliceID]["Start"] && isset($Plots[2])) { @@ -681,9 +680,9 @@ public function draw3DPie($X, $Y, array $Format = array()) $SliceColors = array_reverse($SliceColors); foreach ($Slices as $SliceID => $Plots) { $Settings = $SliceColors[$SliceID]; - $Settings["R"]+= 10; - $Settings["G"]+= 10; - $Settings["B"]+= 10; + $Settings["R"] += 10; + $Settings["G"] += 10; + $Settings["B"] += 10; $Settings["NoBorder"] = true; if ($Visible[$SliceID]["End"]) { $this->pChartObject->drawLine( @@ -710,9 +709,9 @@ public function draw3DPie($X, $Y, array $Format = array()) /* Draw the rounded edges */ foreach ($Slices as $SliceID => $Plots) { $Settings = $SliceColors[$SliceID]; - $Settings["R"]+= 10; - $Settings["G"]+= 10; - $Settings["B"]+= 10; + $Settings["R"] += 10; + $Settings["G"] += 10; + $Settings["B"] += 10; $Settings["NoBorder"] = true; for ($j = 2; $j < count($Plots) - 2; $j = $j + 2) { @@ -734,9 +733,9 @@ public function draw3DPie($X, $Y, array $Format = array()) if ($SecondPass) { $Settings = $SliceColors[$SliceID]; if (count($Border)) { - $Settings["R"]+= 30; - $Settings["G"]+= 30; - $Settings["B"]+= 30; + $Settings["R"] += 30; + $Settings["G"] += 30; + $Settings["B"] += 30; } /* Empty error handling */ @@ -779,9 +778,9 @@ public function draw3DPie($X, $Y, array $Format = array()) /* Draw the top splice */ foreach ($Slices as $SliceID => $Plots) { $Settings = $SliceColors[$SliceID]; - $Settings["R"]+= 20; - $Settings["G"]+= 20; - $Settings["B"]+= 20; + $Settings["R"] += 20; + $Settings["G"] += 20; + $Settings["B"] += 20; $Top = array(); for ($j = 0; $j < count($Plots); $j = $j + 2) { @@ -906,7 +905,7 @@ public function draw3DPie($X, $Y, array $Format = array()) } if ($WriteValues == PIE_VALUE_PERCENTAGE) { - $Display = round(( 100 / $SerieSum ) * $Value, $Precision) . "%"; + $Display = round((100 / $SerieSum) * $Value, $Precision) . "%"; } elseif ($WriteValues == PIE_VALUE_NATURAL) { $Display = $Value . $ValueSuffix; } @@ -1180,7 +1179,7 @@ public function setSliceColor($SliceID, array $Format = array()) * @param int $X * @param int $Y * @param string $Label - * @param int | float $Angle + * @param int|float $Angle * @param array $Settings * @param boolean $Stacked * @param int $Xc @@ -1302,7 +1301,7 @@ public function shift($StartAngle, $EndAngle, $Offset, $Reversed) /** * Internally used to write the re-computed labels - * @return null | int + * @return null|int */ public function writeShiftedLabels() { @@ -1643,7 +1642,7 @@ public function draw2DRing($X, $Y, array $Format = array()) } if ($WriteValues == PIE_VALUE_PERCENTAGE) { - $Display = round(( 100 / $SerieSum ) * $Value, $Precision) . "%"; + $Display = round((100 / $SerieSum) * $Value, $Precision) . "%"; } elseif ($WriteValues == PIE_VALUE_NATURAL) { $Display = $Value . $ValueSuffix; } else { @@ -1996,7 +1995,7 @@ public function draw3DRing($X, $Y, array $Format = array()) if ($Angle == VOID) { $Outer = false; $Inner = true; - } elseif ($Inner && ($Angle < 90 || $Angle > 270 ) && isset($Plots["BottomPoly"][$ID * 2])) { + } elseif ($Inner && ($Angle < 90 || $Angle > 270) && isset($Plots["BottomPoly"][$ID * 2])) { $Xo = $Plots["BottomPoly"][$ID * 2]; $Yo = $Plots["BottomPoly"][$ID * 2 + 1]; @@ -2112,7 +2111,7 @@ public function draw3DRing($X, $Y, array $Format = array()) if ($Angle == VOID) { $Outer = false; $Inner = true; - } elseif ($Outer && ($Angle > 90 && $Angle < 270 ) && isset($Plots["BottomPoly"][$ID * 2])) { + } elseif ($Outer && ($Angle > 90 && $Angle < 270) && isset($Plots["BottomPoly"][$ID * 2])) { $Xo = $Plots["BottomPoly"][$ID * 2]; $Yo = $Plots["BottomPoly"][$ID * 2 + 1]; @@ -2209,7 +2208,7 @@ public function draw3DRing($X, $Y, array $Format = array()) $Label = ""; if ($WriteValues == PIE_VALUE_PERCENTAGE) { - $Label = $Display = round(( 100 / $SerieSum ) * $Value, $Precision) . "%"; + $Label = $Display = round((100 / $SerieSum) * $Value, $Precision) . "%"; } elseif ($WriteValues == PIE_VALUE_NATURAL) { $Label = $Data["Series"][$Data["Abscissa"]]["Data"][$Key]; } diff --git a/src/Chart/Scatter.php b/src/Chart/Scatter.php index dae439c..a65a456 100644 --- a/src/Chart/Scatter.php +++ b/src/Chart/Scatter.php @@ -42,7 +42,7 @@ public function __construct(Image $pChartObject, Data $pDataObject) /** * Prepare the scale * @param array $Format - * @return null | int + * @return null|int * @throws Exception */ public function drawScatterScale(array $Format = array()) @@ -1735,7 +1735,7 @@ public function drawScatterBestFit(array $Format = array()) * @param string $ScatterSerieID * @param mixed $Points * @param array $Format - * @return null | int + * @return null|int */ public function writeScatterLabel($ScatterSerieID, $Points, array $Format = array()) { @@ -2037,8 +2037,8 @@ public function drawScatterThreshold($Value, array $Format = array()) /** * Draw a Scatter threshold area - * @param int | float $Value1 - * @param int | float $Value2 + * @param int|float $Value1 + * @param int|float $Value2 * @param array $Format * @return type */ diff --git a/src/Chart/Split.php b/src/Chart/Split.php index e48a65d..515b4cd 100644 --- a/src/Chart/Split.php +++ b/src/Chart/Split.php @@ -105,7 +105,6 @@ public function drawSplitPath(Image $Object, Data $Values, array $Format = array "Surrounding" => $Surrounding ); - $PolyGon = ""; $Angle = $Object->getAngle($X2, $RightY1, $X1, $LeftY1); $VectorX1 = cos(deg2rad($Angle + 90)) * $Force + ($X2 - $X1) / 2 + $X1; @@ -124,6 +123,8 @@ public function drawSplitPath(Image $Object, Data $Values, array $Format = array $VectorY2, $Settings ); + + $PolyGon = []; foreach ($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; diff --git a/src/Chart/Spring.php b/src/Chart/Spring.php index f963ddb..0998fa6 100644 --- a/src/Chart/Spring.php +++ b/src/Chart/Spring.php @@ -70,7 +70,7 @@ class Spring /** * @var boolean */ - public $AutoComputeFreeZone= false; + public $AutoComputeFreeZone = false; public function __construct() { @@ -168,7 +168,7 @@ public function autoFreeZone() * @param int $FromNode * @param int $ToNode * @param array $Settings - * @return null | int + * @return null|int */ public function linkProperties($FromNode, $ToNode, array $Settings) { @@ -262,7 +262,7 @@ public function setNodeDefaults(array $Settings = array()) * Add a node * @param int $NodeID * @param array $Settings - * @return null | int + * @return null|int */ public function addNode($NodeID, array $Settings = array()) { @@ -332,7 +332,7 @@ public function addNode($NodeID, array $Settings = array()) /** * Set color attribute for a list of nodes - * @param array | string $Nodes + * @param array|string $Nodes * @param array $Settings */ public function setNodesColor($Nodes, array $Settings = array()) @@ -415,9 +415,9 @@ public function dumpNodes() /** * Check if a connection exists and create it if required - * @param string | int $SourceID - * @param string | int $TargetID - * @return boolean | null + * @param string|int $SourceID + * @param string|int $TargetID + * @return boolean|null */ public function checkConnection($SourceID, $TargetID) { @@ -721,7 +721,7 @@ public function doPass() } /** - * @return int | float + * @return int|float */ public function lastPass() { @@ -790,7 +790,7 @@ public function lastPass() $X4 = $Link["X2"]; $Y4 = $Link["Y2"]; - if (!($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 )) { + if (!($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4)) { if ($this->intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4)) { if ($Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] @@ -1105,7 +1105,7 @@ public function drawSpring(Image $Object, array $Settings = array()) * @param int $Y1 * @param int $X2 * @param int $Y2 - * @return int | float + * @return int|float */ public function getDistance($X1, $Y1, $X2, $Y2) { @@ -1118,7 +1118,7 @@ public function getDistance($X1, $Y1, $X2, $Y2) * @param int $Y1 * @param int $X2 * @param int $Y2 - * @return int | float + * @return int|float */ public function getAngle($X1, $Y1, $X2, $Y2) { diff --git a/src/Chart/Stock.php b/src/Chart/Stock.php index 6c09e1b..880366b 100644 --- a/src/Chart/Stock.php +++ b/src/Chart/Stock.php @@ -40,7 +40,7 @@ public function __construct(Image $pChartObject, Data $pDataObject) /** * Draw a stock chart * @param array $Format - * @return type + * @return integer|null */ public function drawStockChart(array $Format = array()) { diff --git a/src/Chart/Surface.php b/src/Chart/Surface.php index 67097bc..db5d29f 100644 --- a/src/Chart/Surface.php +++ b/src/Chart/Surface.php @@ -66,7 +66,7 @@ public function setGrid($XSize = 10, $YSize = 10) * Add a point on the grid * @param int $X * @param int $Y - * @param int | float $Value + * @param int|float $Value * @param boolean $Force * @return null */ @@ -91,7 +91,7 @@ public function addPoint($X, $Y, $Value, $Force = true) /** * Write the X labels * @param array $Format - * @return null | int + * @return null|int */ public function writeXLabels(array $Format = array()) { @@ -194,7 +194,7 @@ public function writeYLabels(array $Format = array()) /** * Draw the area arround the specified Threshold - * @param int | float $Threshold + * @param int|float $Threshold * @param array $Format */ public function drawContour($Threshold, array $Format = array()) @@ -344,7 +344,7 @@ public function drawSurface(array $Format = array()) */ public function computeMissing() { - $Missing = ""; + $Missing = []; for ($X = 0; $X <= $this->GridSizeX; $X++) { for ($Y = 0; $Y <= $this->GridSizeY; $Y++) { if ($this->Points[$X][$Y] == UNKNOWN) { @@ -354,7 +354,7 @@ public function computeMissing() } shuffle($Missing); - foreach ($Missing as $Key => $Pos) { + foreach ($Missing as $Pos) { $Pos = preg_split("/,/", $Pos); $X = $Pos[0]; $Y = $Pos[1];