Skip to content

Commit ed1a876

Browse files
authored
Merge pull request #28 from szymach/travis
Lowered PHP requirement to 5.4, lots of coding standard fixes
2 parents da5e1e2 + c327d11 commit ed1a876

16 files changed

+177
-162
lines changed

.scrutinizer.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
checks:
3+
php:
4+
code_rating: true
5+
duplication: true

.travis.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ cache:
77

88
sudo: false
99

10-
php:
11-
- 5.5
10+
matrix:
11+
include:
12+
- php: 5.4
13+
- php: 5.5
14+
- php: 5.6
15+
- php: 7.0
16+
- php: 7.1
17+
18+
19+
before_install:
20+
- phpenv config-rm xdebug.ini
21+
- composer self-update -n
1222

1323
before_script:
14-
- composer self-update -n
15-
- composer install -n --prefer-dist -v
16-
- nohup php -S localhost:8080 -t features/fixtures/web > server.log 2>&1 &
24+
- composer install -n --prefer-dist -v
25+
- nohup php -S localhost:8080 -t features/fixtures/web > server.log 2>&1 &
1726

1827
script:
19-
- bin/phpcs --standard=PSR2 --encoding=UTF-8 --ignore="*.db,*.color,*.ttf" src/
20-
- bin/behat --no-snippets --verbose --profile=travis -vvv
28+
- bin/phpcs --standard=PSR2 --encoding=UTF-8 --ignore="*.db,*.color,*.ttf" src/
29+
- bin/behat --no-snippets --verbose --profile=travis -vvv

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"files": ["src/Resources/data/constants.php"]
2323
},
2424
"require": {
25-
"php": ">=5.5",
25+
"php": ">=5.4",
2626
"ext-gd": "*"
2727
},
2828
"require-dev" : {
29-
"behat/behat": "~3.0",
30-
"behat/mink": "~1.7",
31-
"behat/mink-goutte-driver": "~1.2",
32-
"bossa/phpspec2-expect": "~1.0",
33-
"sensiolabs/behat-page-object-extension": "~2.0@dev",
34-
"squizlabs/php_codesniffer": "~2.3"
29+
"behat/behat": "^3.3",
30+
"behat/mink": "^1.7",
31+
"behat/mink-goutte-driver": "^1.2",
32+
"bossa/phpspec2-expect": "^1.0",
33+
"sensiolabs/behat-page-object-extension": "^2.0",
34+
"squizlabs/php_codesniffer": "^2.8"
3535
},
3636
"config": {
3737
"bin-dir": "bin"

src/Chart/BaseDraw.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ public function allocateColor($Picture, $R, $G, $B, $Alpha = 100)
295295

296296
/**
297297
* Convert apha to base 10
298-
* @param int |float $AlphaValue
299-
* @return int | float
298+
* @param int|float $AlphaValue
299+
* @return integer
300300
*/
301301
public function convertAlpha($AlphaValue)
302302
{
@@ -502,9 +502,9 @@ public function processScale($XMin, $XMax, $MaxDivs, array $Factors, $AxisID)
502502

503503
/**
504504
*
505-
* @param int | float $Value1
506-
* @param int | float $Value2
507-
* @return int | float
505+
* @param int|float $Value1
506+
* @param int|float $Value2
507+
* @return double
508508
*/
509509
public function modulo($Value1, $Value2)
510510
{
@@ -527,8 +527,8 @@ public function modulo($Value1, $Value2)
527527
/**
528528
* @param mixed $Value
529529
* @param mixed $LastValue
530-
* @param mixed $LabelingMethod
531-
* @param mixed $ID
530+
* @param integer $LabelingMethod
531+
* @param integer $ID
532532
* @param boolean $LabelSkip
533533
* @return boolean
534534
*/
@@ -574,23 +574,18 @@ public function countDrawableSeries()
574574
* @param int $Ya
575575
* @param int $Xb
576576
* @param int $Yb
577-
* @return array
577+
* @return integer[]
578578
*/
579579
public function fixBoxCoordinates($Xa, $Ya, $Xb, $Yb)
580580
{
581-
return array(
582-
min($Xa, $Xb),
583-
min($Ya, $Yb),
584-
max($Xa, $Xb),
585-
max($Ya, $Yb)
586-
);
581+
return array(min($Xa, $Xb), min($Ya, $Yb), max($Xa, $Xb), max($Ya, $Yb));
587582
}
588583

589584
/**
590585
* Apply AALias correction to the rounded box boundaries
591-
* @param int | float $Value
586+
* @param int|float $Value
592587
* @param int $Mode
593-
* @return int | float
588+
* @return int|float
594589
*/
595590
public function offsetCorrection($Value, $Mode)
596591
{
@@ -843,7 +838,7 @@ public function getRandomColor($Alpha = 100)
843838
/**
844839
* Validate a palette
845840
* @param mixed $Colors
846-
* @param int | float $Surrounding
841+
* @param int|float $Surrounding
847842
* @return array
848843
*/
849844
public function validatePalette($Colors, $Surrounding = null)
@@ -913,7 +908,7 @@ public function validatePalette($Colors, $Surrounding = null)
913908
* @param mixed $Values
914909
* @param array $Option
915910
* @param boolean $ReturnOnly0Height
916-
* @return array | int | float
911+
* @return int|float|array
917912
*/
918913
public function scaleComputeY($Values, array $Option = array(), $ReturnOnly0Height = false)
919914
{
@@ -1060,7 +1055,7 @@ public function scaleFormat($Value, $Mode = null, $Format = null, $Unit = null)
10601055
}
10611056

10621057
/**
1063-
* @return array | null
1058+
* @return array|null
10641059
*/
10651060
public function scaleGetXSettings()
10661061
{
@@ -1168,13 +1163,13 @@ public function writeBounds($Type = BOUND_BOTH, $Format = null)
11681163

11691164
if ($Type == BOUND_MAX || $Type == BOUND_BOTH) {
11701165
if ($MaxLabelPos == BOUND_LABEL_POS_TOP
1171-
|| ( $MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue >= 0)
1166+
|| ($MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue >= 0)
11721167
) {
11731168
$YPos = $PosArray[$MaxPos] - $DisplayOffset + 2;
11741169
$Align = TEXT_ALIGN_BOTTOMMIDDLE;
11751170
}
11761171
if ($MaxLabelPos == BOUND_LABEL_POS_BOTTOM
1177-
|| ( $MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue < 0)
1172+
|| ($MaxLabelPos == BOUND_LABEL_POS_AUTO && $MaxValue < 0)
11781173
) {
11791174
$YPos = $PosArray[$MaxPos] + $DisplayOffset + 2;
11801175
$Align = TEXT_ALIGN_TOPMIDDLE;

src/Chart/Bubble.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ public function writeBubbleLabel($SerieName, $SerieWeightName, $Points, $Format
466466
} else {
467467
$Description = "No description";
468468
}
469-
$Series = "";
470-
$Series[] = array("Format" => $Color, "Caption" => $Caption);
469+
$Series = [["Format" => $Color, "Caption" => $Caption]];
471470

472471
if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
473472
if ($XDivs == 0) {

src/Chart/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public function saveFromCache($ID, $Destination)
361361
/**
362362
* Get file from cache
363363
* @param string $ID
364-
* @return string | null
364+
* @return string|null
365365
*/
366366
public function getFromCache($ID)
367367
{

src/Chart/Data.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function reverseSerie($Series)
179179
/**
180180
* Return the sum of the serie values
181181
* @param string $Serie
182-
* @return int | null
182+
* @return int|null
183183
*/
184184
public function getSum($Serie)
185185
{
@@ -233,7 +233,7 @@ public function setSerieShape($Series, $Shape = SERIE_SHAPE_FILLEDCIRCLE)
233233

234234
/**
235235
* Set the description of a given serie
236-
* @param mixed $Series
236+
* @param string|array $Series
237237
* @param string $Description
238238
*/
239239
public function setSerieDescription($Series, $Description = "My serie")
@@ -250,7 +250,7 @@ public function setSerieDescription($Series, $Description = "My serie")
250250

251251
/**
252252
* Set a serie as "drawable" while calling a rendering public function
253-
* @param mixed $Series
253+
* @param string|array $Series
254254
* @param boolean $Drawable
255255
*/
256256
public function setSerieDrawable($Series, $Drawable = true)
@@ -489,21 +489,22 @@ public function drawAll()
489489
/**
490490
* Return the average value of the given serie
491491
* @param string $Serie
492-
* @return int | null
492+
* @return int|null
493493
*/
494494
public function getSerieAverage($Serie)
495495
{
496496
if (isset($this->Data["Series"][$Serie])) {
497497
$SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
498498
return array_sum($SerieData) / sizeof($SerieData);
499499
}
500+
500501
return null;
501502
}
502503

503504
/**
504505
* Return the geometric mean of the given serie
505506
* @param string $Serie
506-
* @return int | null
507+
* @return int|null
507508
*/
508509
public function getGeometricMean($Serie)
509510
{
@@ -515,13 +516,14 @@ public function getGeometricMean($Serie)
515516
}
516517
return pow($Seriesum, 1 / sizeof($SerieData));
517518
}
519+
518520
return null;
519521
}
520522

521523
/**
522524
* Return the harmonic mean of the given serie
523525
* @param string $Serie
524-
* @return int | null
526+
* @return int|null
525527
*/
526528
public function getHarmonicMean($Serie)
527529
{
@@ -540,7 +542,7 @@ public function getHarmonicMean($Serie)
540542
/**
541543
* Return the standard deviation of the given serie
542544
* @param string $Serie
543-
* @return int | float | null
545+
* @return double|null
544546
*/
545547
public function getStandardDeviation($Serie)
546548
{
@@ -560,7 +562,7 @@ public function getStandardDeviation($Serie)
560562
/**
561563
* Return the Coefficient of variation of the given serie
562564
* @param string $Serie
563-
* @return float | null
565+
* @return float|null
564566
*/
565567
public function getCoefficientOfVariation($Serie)
566568
{
@@ -578,7 +580,7 @@ public function getCoefficientOfVariation($Serie)
578580
/**
579581
* Return the median value of the given serie
580582
* @param string $Serie
581-
* @return int | float
583+
* @return int|float
582584
*/
583585
public function getSerieMedian($Serie)
584586
{
@@ -598,7 +600,7 @@ public function getSerieMedian($Serie)
598600
* Return the x th percentil of the given serie
599601
* @param string $Serie
600602
* @param int $Percentil
601-
* @return int | float | null
603+
* @return int|float| null
602604
*/
603605
public function getSeriePercentile($Serie = "Serie1", $Percentil = 95)
604606
{
@@ -645,7 +647,7 @@ public function addRandomValues($SerieName = "Serie1", array $Options = array())
645647

646648
/**
647649
* Test if we have valid data
648-
* @return boolean
650+
* @return boolean|null
649651
*/
650652
public function containsData()
651653
{
@@ -660,6 +662,8 @@ public function containsData()
660662
return true;
661663
}
662664
}
665+
666+
return null;
663667
}
664668

665669
/**
@@ -922,12 +926,12 @@ public function loadPalette($FileName, $Overwrite = false)
922926
/**
923927
* Initialise a given scatter serie
924928
* @param int $ID
925-
* @return null | int
929+
* @return null
926930
*/
927931
public function initScatterSerie($ID)
928932
{
929933
if (isset($this->Data["ScatterSeries"][$ID])) {
930-
return 0;
934+
return null;
931935
}
932936

933937
$this->Data["ScatterSeries"][$ID]["Description"] = "Scatter " . $ID;
@@ -1095,10 +1099,11 @@ public function importFromCSV($FileName, array $Options = array())
10951099

10961100
/**
10971101
* Create a dataset based on a formula
1102+
*
10981103
* @param string $SerieName
10991104
* @param string $Formula
11001105
* @param array $Options
1101-
* @return null | int
1106+
* @return null
11021107
*/
11031108
public function createFunctionSerie($SerieName, $Formula = "", array $Options = array())
11041109
{
@@ -1110,11 +1115,11 @@ public function createFunctionSerie($SerieName, $Formula = "", array $Options =
11101115
$AbscissaSerie = isset($Options["AbscissaSerie"]) ? $Options["AbscissaSerie"] : "Abscissa";
11111116

11121117
if ($Formula == "") {
1113-
return 0;
1118+
return null;
11141119
}
11151120

1116-
$Result = "";
1117-
$Abscissa = "";
1121+
$Result = [];
1122+
$Abscissa = [];
11181123
for ($i = $MinX; $i <= $MaxX; $i = $i + $XStep) {
11191124
$Expression = "\$return = '!'.(" . str_replace("z", $i, $Formula) . ");";
11201125
if (@eval($Expression) === false) {
@@ -1188,7 +1193,8 @@ public function getData()
11881193

11891194
/**
11901195
* Save a palette element
1191-
* @param id $ID
1196+
*
1197+
* @param integer $ID
11921198
* @param string $Color
11931199
*/
11941200
public function savePalette($ID, $Color)

0 commit comments

Comments
 (0)