Skip to content

Commit

Permalink
Merge pull request #28 from szymach/travis
Browse files Browse the repository at this point in the history
Lowered PHP requirement to 5.4, lots of coding standard fixes
  • Loading branch information
szymach authored Mar 8, 2017
2 parents da5e1e2 + c327d11 commit ed1a876
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 162 deletions.
5 changes: 5 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
checks:
php:
code_rating: true
duplication: true
23 changes: 16 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
37 changes: 16 additions & 21 deletions src/Chart/BaseDraw.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
*/
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -1060,7 +1055,7 @@ public function scaleFormat($Value, $Mode = null, $Format = null, $Unit = null)
}

/**
* @return array | null
* @return array|null
*/
public function scaleGetXSettings()
{
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/Chart/Bubble.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Chart/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
42 changes: 24 additions & 18 deletions src/Chart/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -489,21 +489,22 @@ public function drawAll()
/**
* Return the average value of the given serie
* @param string $Serie
* @return int | null
* @return int|null
*/
public function getSerieAverage($Serie)
{
if (isset($this->Data["Series"][$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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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()
{
Expand All @@ -660,6 +662,8 @@ public function containsData()
return true;
}
}

return null;
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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())
{
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit ed1a876

Please sign in to comment.