From d62c46398b0baa3610807e25910a9c4a9fc9e160 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Sun, 2 Sep 2018 22:16:55 +0200 Subject: [PATCH 01/23] Moved duplicate logic to trait. --- src/Delegate/StringUtils.php | 25 +++++++++++++++++++++++++ src/Options/Scales/GridLines.php | 26 +++++--------------------- 2 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 src/Delegate/StringUtils.php diff --git a/src/Delegate/StringUtils.php b/src/Delegate/StringUtils.php new file mode 100644 index 0000000..b6e8820 --- /dev/null +++ b/src/Delegate/StringUtils.php @@ -0,0 +1,25 @@ +color = $color; + $this->color = $this->recursiveToString($color); } else { $this->color = is_null($color) ? null : strval($color); } @@ -140,13 +136,7 @@ public function getBorderDash() public function setBorderDash($borderDash) { if (is_array($borderDash)) { - array_walk_recursive( - $borderDash, - function (&$value) { - $value = floatval($value); - } - ); - $this->borderDash = $borderDash; + $this->borderDash = $this->recursiveToString($borderDash); } return $this; @@ -188,13 +178,7 @@ public function getLineWidth() public function setLineWidth($lineWidth) { if (is_array($lineWidth)) { - array_walk_recursive( - $lineWidth, - function (&$value) { - $value = intval($value); - } - ); - $this->lineWidth = $lineWidth; + $this->lineWidth = $this->recursiveToString($lineWidth); } else { $this->lineWidth = is_null($lineWidth) ? null : intval($lineWidth); } From 1526f881ba04c9bc9e2fcec169d22d8237a879c9 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Fri, 14 Dec 2018 15:24:52 +0100 Subject: [PATCH 02/23] Add click support --- src/ConfigDefaults/ClickConfig.php | 8 ++ src/ConfigDefaults/GlobalConfig.php | 17 +++ src/Options.php | 20 +++ src/Options/Click.php | 135 ++++++++++++++++++ src/Options/Hover.php | 10 ++ src/Options/Legend.php | 26 ++++ src/Options/Legend/Labels.php | 10 ++ src/Options/Scale.php | 18 +++ src/Options/Scales/GridLines.php | 64 +++++++-- src/Options/Scales/ScaleLabel.php | 22 ++- src/Options/Scales/Ticks.php | 78 +++++++--- src/Options/Title.php | 36 +++-- src/Options/Tooltips.php | 88 +++++++----- test/unit/ConfigDefaults/GlobalConfigTest.php | 10 ++ test/unit/Options/ClickTest.php | 98 +++++++++++++ test/unit/OptionsTest.php | 10 ++ 16 files changed, 573 insertions(+), 77 deletions(-) create mode 100644 src/ConfigDefaults/ClickConfig.php create mode 100644 src/Options/Click.php create mode 100644 test/unit/Options/ClickTest.php diff --git a/src/ConfigDefaults/ClickConfig.php b/src/ConfigDefaults/ClickConfig.php new file mode 100644 index 0000000..d92167f --- /dev/null +++ b/src/ConfigDefaults/ClickConfig.php @@ -0,0 +1,8 @@ +hover; } + /** + * @return ClickConfig + */ + public function click() + { + if (is_null($this->click)) { + $this->click = new ClickConfig(); + } + + return $this->click; + } + /** * @return AnimationConfig */ diff --git a/src/Options.php b/src/Options.php index 2731843..2300a22 100644 --- a/src/Options.php +++ b/src/Options.php @@ -4,6 +4,7 @@ use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\Options\Animation; +use Halfpastfour\PHPChartJS\Options\Click; use Halfpastfour\PHPChartJS\Options\Hover; use Halfpastfour\PHPChartJS\Options\Layout; use Halfpastfour\PHPChartJS\Options\Legend; @@ -36,6 +37,11 @@ class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonS */ protected $hover; + /** + * @var Click + */ + protected $click; + /** * @var Scales */ @@ -92,6 +98,18 @@ public function getHover() return $this->hover; } + /** + * @return Click + */ + public function getCLick() + { + if (is_null($this->click)) { + $this->click = new Click(); + } + + return $this->click; + } + /** * @return Scales */ @@ -142,6 +160,8 @@ public function getTooltips() /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Click.php b/src/Options/Click.php new file mode 100644 index 0000000..c380425 --- /dev/null +++ b/src/Options/Click.php @@ -0,0 +1,135 @@ +mode; + } + + /** + * @param string $mode + * + * @return $this + */ + public function setMode($mode) + { + $this->mode = strval($mode); + + return $this; + } + + /** + * @return bool + */ + public function isIntersect() + { + return $this->intersect; + } + + /** + * @return bool + */ + public function getIntersect() + { + return $this->intersect; + } + + /** + * @param bool $intersect + * + * @return $this + */ + public function setIntersect($intersect) + { + $this->intersect = ! ! $intersect; + + return $this; + } + + /** + * @return int + */ + public function getAnimationDuration() + { + return $this->animationDuration; + } + + /** + * @param int $animationDuration + * + * @return $this + */ + public function setAnimationDuration($animationDuration) + { + $this->animationDuration = intval($animationDuration); + + return $this; + } + + /** + * @return \Zend\Json\Expr + */ + public function getOnClick() + { + return $this->onClick; + } + + /** + * @param Expr $onClick + * + * @return $this + */ + public function setOnClick($onClick) + { + $this->onClick = new Expr(strval($onClick)); + + return $this; + } + + /** + * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception + */ + public function jsonSerialize() + { + return Json::encode($this->getArrayCopy()); + } +} diff --git a/src/Options/Hover.php b/src/Options/Hover.php index 62d129b..48a6095 100644 --- a/src/Options/Hover.php +++ b/src/Options/Hover.php @@ -63,6 +63,14 @@ public function isIntersect() return $this->intersect; } + /** + * @return bool + */ + public function getIntersect() + { + return $this->intersect; + } + /** * @param bool $intersect * @@ -117,6 +125,8 @@ public function setOnHover($onHover) /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Legend.php b/src/Options/Legend.php index 07960c3..8747f6c 100644 --- a/src/Options/Legend.php +++ b/src/Options/Legend.php @@ -59,6 +59,14 @@ public function isDisplay() return $this->display; } + /** + * @return bool + */ + public function getDisplay() + { + return $this->display; + } + /** * @param bool $display * @@ -99,6 +107,14 @@ public function isFullWidth() return $this->fullWidth; } + /** + * @return bool + */ + public function getFullWidth() + { + return $this->fullWidth; + } + /** * @param bool $fullWidth * @@ -171,6 +187,14 @@ public function isReverse() return $this->reverse; } + /** + * @return bool + */ + public function getReverse() + { + return $this->reverse; + } + /** * @param bool $reverse * @@ -185,6 +209,8 @@ public function setReverse($reverse) /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Legend/Labels.php b/src/Options/Legend/Labels.php index 758a269..122f036 100644 --- a/src/Options/Legend/Labels.php +++ b/src/Options/Legend/Labels.php @@ -203,6 +203,14 @@ public function isUsePointStyle() return $this->usePointStyle; } + /** + * @return bool + */ + public function getUsePointStyle() + { + return $this->usePointStyle; + } + /** * @param bool $usePointStyle * @@ -217,6 +225,8 @@ public function setUsePointStyle($usePointStyle) /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Scale.php b/src/Options/Scale.php index 52fe175..6feeac1 100644 --- a/src/Options/Scale.php +++ b/src/Options/Scale.php @@ -160,6 +160,14 @@ public function isDisplay() return $this->display; } + /** + * @return bool + */ + public function getDisplay() + { + return $this->display; + } + /** * @param bool $display * @@ -200,6 +208,14 @@ public function isStacked() return $this->stacked; } + /** + * @return bool + */ + public function getStacked() + { + return $this->stacked; + } + /** * @param bool $stacked * @@ -594,6 +610,8 @@ public function ticks() /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index 6dbcc03..149f290 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -18,62 +18,62 @@ class GridLines implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - private $display; + protected $display; /** * @var string|string[] */ - private $color; + protected $color; /** * @var float[] */ - private $borderDash; + protected $borderDash; /** * @var float */ - private $borderDashOffset; + protected $borderDashOffset; /** * @var int|int[] */ - private $lineWidth; + protected $lineWidth; /** * @var bool */ - private $drawBorder; + protected $drawBorder; /** * @var bool */ - private $drawOnChartArea; + protected $drawOnChartArea; /** * @var bool */ - private $drawTicks; + protected $drawTicks; /** * @var int */ - private $tickMarkLength; + protected $tickMarkLength; /** * @var int */ - private $zeroLineWidth; + protected $zeroLineWidth; /** * @var string */ - private $zeroLineColor; + protected $zeroLineColor; /** * @var bool */ - private $offsetGridLines; + protected $offsetGridLines; /** * @return bool @@ -83,6 +83,14 @@ public function isDisplay() return $this->display; } + /** + * @return bool + */ + public function getDisplay() + { + return $this->display; + } + /** * @param bool $display * @@ -211,6 +219,14 @@ public function isDrawBorder() return $this->drawBorder; } + /** + * @return bool + */ + public function getDrawBorder() + { + return $this->drawBorder; + } + /** * @param bool $drawBorder * @@ -231,6 +247,14 @@ public function isDrawOnChartArea() return $this->drawOnChartArea; } + /** + * @return bool + */ + public function getDrawOnChartArea() + { + return $this->drawOnChartArea; + } + /** * @param bool $drawOnChartArea * @@ -243,6 +267,14 @@ public function setDrawOnChartArea($drawOnChartArea) return $this; } + /** + * @return bool + */ + public function getDrawTicks() + { + return $this->drawTicks; + } + /** * @return bool */ @@ -331,6 +363,14 @@ public function isOffsetGridLines() return $this->offsetGridLines; } + /** + * @return bool + */ + public function getOffsetGridLines() + { + return $this->offsetGridLines; + } + /** * @param bool $offsetGridLines * diff --git a/src/Options/Scales/ScaleLabel.php b/src/Options/Scales/ScaleLabel.php index 4bddbe1..caa1796 100644 --- a/src/Options/Scales/ScaleLabel.php +++ b/src/Options/Scales/ScaleLabel.php @@ -17,32 +17,32 @@ class ScaleLabel implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - private $display; + protected $display; /** * @var string */ - private $labelString; + protected $labelString; /** * @var string */ - private $fontColor; + protected $fontColor; /** * @var string */ - private $fontFamily; + protected $fontFamily; /** * @var int */ - private $fontSize; + protected $fontSize; /** * @var string */ - private $fontStyle; + protected $fontStyle; /** * @return bool @@ -52,6 +52,14 @@ public function isDisplay() return $this->display; } + /** + * @return bool + */ + public function getDisplay() + { + return $this->display; + } + /** * @param bool $display * @@ -166,6 +174,8 @@ public function setFontStyle($fontStyle) /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Scales/Ticks.php b/src/Options/Scales/Ticks.php index 685544f..6c582e8 100644 --- a/src/Options/Scales/Ticks.php +++ b/src/Options/Scales/Ticks.php @@ -19,92 +19,92 @@ class Ticks implements ArraySerializableInterface, \JsonSerializable /** * @var float */ - private $suggestedMin; + protected $suggestedMin; /** * @var bool */ - private $beginAtZero; + protected $beginAtZero; /** * @var float */ - private $stepSize; + protected $stepSize; /** * @var bool */ - private $autoSkip; + protected $autoSkip; /** * @var int */ - private $autoSkipPadding; + protected $autoSkipPadding; /** * @var Expr */ - private $callback; + protected $callback; /** * @var bool */ - private $display; + protected $display; /** * @var string */ - private $fontColor; + protected $fontColor; /** * @var string */ - private $fontFamily; + protected $fontFamily; /** * @var int */ - private $fontSize; + protected $fontSize; /** * @var string */ - private $fontStyle; + protected $fontStyle; /** * @var int */ - private $labelOffset; + protected $labelOffset; /** * @var int */ - private $maxRotation; + protected $maxRotation; /** * @var int */ - private $minRotation; + protected $minRotation; /** * @var bool */ - private $mirror; + protected $mirror; /** * @var int */ - private $padding; + protected $padding; /** * @var bool */ - private $reverse; + protected $reverse; /** * @var int */ - private $max; + protected $max; /** * @return float @@ -134,6 +134,14 @@ public function isBeginAtZero() return $this->beginAtZero; } + /** + * @return bool + */ + public function getBeginAtZero() + { + return $this->beginAtZero; + } + /** * @param bool $beginAtZero * @@ -174,6 +182,14 @@ public function isAutoSkip() return $this->autoSkip; } + /** + * @return bool + */ + public function getAutoSkip() + { + return $this->autoSkip; + } + /** * @param bool $autoSkip * @@ -234,6 +250,14 @@ public function isDisplay() return $this->display; } + /** + * @return bool + */ + public function getDisplay() + { + return $this->display; + } + /** * @param bool $display * @@ -394,6 +418,14 @@ public function isMirror() return $this->mirror; } + /** + * @return bool + */ + public function getMirror() + { + return $this->mirror; + } + /** * @param bool $mirror * @@ -434,6 +466,14 @@ public function isReverse() return $this->reverse; } + /** + * @return bool + */ + public function getReverse() + { + return $this->reverse; + } + /** * @param bool $reverse * @@ -468,6 +508,8 @@ public function setMax($max) /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Title.php b/src/Options/Title.php index 9be63c9..33a928a 100644 --- a/src/Options/Title.php +++ b/src/Options/Title.php @@ -17,47 +17,47 @@ class Title implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - private $display; + protected $display; /** * @var string */ - private $position; + protected $position; /** * @var bool */ - private $fullWidth; + protected $fullWidth; /** * @var int */ - private $fontSize; + protected $fontSize; /** * @var string */ - private $fontFamily; + protected $fontFamily; /** * @var string */ - private $fontColor; + protected $fontColor; /** * @var string */ - private $fontStyle; + protected $fontStyle; /** * @var int */ - private $padding; + protected $padding; /** * @var string */ - private $text; + protected $text; /** * @return bool @@ -67,6 +67,14 @@ public function isDisplay() return $this->display; } + /** + * @return bool + */ + public function getDisplay() + { + return $this->display; + } + /** * @param bool $display * @@ -107,6 +115,14 @@ public function isFullWidth() return $this->fullWidth; } + /** + * @return bool + */ + public function getFullWidth() + { + return $this->fullWidth; + } + /** * @param bool $fullWidth * @@ -241,6 +257,8 @@ public function setText($text) /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { diff --git a/src/Options/Tooltips.php b/src/Options/Tooltips.php index 939a621..0ede6bc 100644 --- a/src/Options/Tooltips.php +++ b/src/Options/Tooltips.php @@ -19,162 +19,162 @@ class Tooltips implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - private $enabled; + protected $enabled; /** * @var Expr */ - private $custom; + protected $custom; /** * @var string */ - private $mode; + protected $mode; /** * @var bool */ - private $intersect; + protected $intersect; /** * @var string */ - private $position; + protected $position; /** * @var Expr */ - private $itemSort; + protected $itemSort; /** * @var Expr */ - private $filter; + protected $filter; /** * @var string */ - private $backgroundColor; + protected $backgroundColor; /** * @var string */ - private $titleFontFamily; + protected $titleFontFamily; /** * @var int */ - private $titleFontSize; + protected $titleFontSize; /** * @var string */ - private $titleFontStyle; + protected $titleFontStyle; /** * @var string */ - private $titleFontColor; + protected $titleFontColor; /** * @var int */ - private $titleSpacing; + protected $titleSpacing; /** * @var int */ - private $titleMarginBottom; + protected $titleMarginBottom; /** * @var string */ - private $bodyFontFamily; + protected $bodyFontFamily; /** * @var int */ - private $bodyFontSize; + protected $bodyFontSize; /** * @var string */ - private $bodyFontStyle; + protected $bodyFontStyle; /** * @var string */ - private $bodyFontColor; + protected $bodyFontColor; /** * @var int */ - private $bodySpacing; + protected $bodySpacing; /** * @var string */ - private $footerFontFamily; + protected $footerFontFamily; /** * @var int */ - private $footerFontSize; + protected $footerFontSize; /** * @var string */ - private $footerFontStyle; + protected $footerFontStyle; /** * @var string */ - private $footerFontColor; + protected $footerFontColor; /** * @var int */ - private $footerSpacing; + protected $footerSpacing; /** * @var int */ - private $footerMarginTop; + protected $footerMarginTop; /** * @var int */ - private $xPadding; + protected $xPadding; /** * @var int */ - private $yPadding; + protected $yPadding; /** * @var int */ - private $caretSize; + protected $caretSize; /** * @var int */ - private $cornerRadius; + protected $cornerRadius; /** * @var string */ - private $multiKeyBackground; + protected $multiKeyBackground; /** * @var bool */ - private $displayColors; + protected $displayColors; /** * @var Callbacks */ - private $callbacks; + protected $callbacks; /** * @return bool @@ -184,6 +184,14 @@ public function isEnabled() return $this->enabled; } + /** + * @return bool + */ + public function getEnabled() + { + return $this->enabled; + } + /** * @param bool $enabled * @@ -244,6 +252,14 @@ public function isIntersect() return $this->intersect; } + /** + * @return bool + */ + public function getIntersect() + { + return $this->intersect; + } + /** * @param bool $intersect * @@ -784,6 +800,14 @@ public function isDisplayColors() return $this->displayColors; } + /** + * @return bool + */ + public function getDisplayColors() + { + return $this->displayColors; + } + /** * @param bool $displayColors * diff --git a/test/unit/ConfigDefaults/GlobalConfigTest.php b/test/unit/ConfigDefaults/GlobalConfigTest.php index 1870781..b52955f 100644 --- a/test/unit/ConfigDefaults/GlobalConfigTest.php +++ b/test/unit/ConfigDefaults/GlobalConfigTest.php @@ -3,6 +3,7 @@ namespace Test\ConfigDefaults; use Halfpastfour\PHPChartJS\ConfigDefaults\AnimationConfig; +use Halfpastfour\PHPChartJS\ConfigDefaults\ClickConfig; use Halfpastfour\PHPChartJS\ConfigDefaults\ElementsConfig; use Halfpastfour\PHPChartJS\ConfigDefaults\GlobalConfig; use Halfpastfour\PHPChartJS\ConfigDefaults\HoverConfig; @@ -107,6 +108,15 @@ public function testHover() self::assertInstanceOf(HoverConfig::class, $result); } + /** + * + */ + public function testClick() + { + $result = $this->config->click(); + self::assertInstanceOf(ClickConfig::class, $result); + } + /** * */ diff --git a/test/unit/Options/ClickTest.php b/test/unit/Options/ClickTest.php new file mode 100644 index 0000000..cdef0f9 --- /dev/null +++ b/test/unit/Options/ClickTest.php @@ -0,0 +1,98 @@ + '', + 'intersect' => false, + 'animationDuration' => 1, + 'onClick' => '', + ]; + + /** + * @var array + */ + private $input_data_no_expressions = [ + 'mode' => 'mode', + 'intersect' => true, + 'animationDuration' => 2, + 'onClick' => null, + ]; + + /** + * @var array + */ + private $input_data_with_expressions = [ + 'mode' => 'mode', + 'intersect' => true, + 'animationDuration' => 2, + 'onClick' => 'function(event, array) { echo "onClick"; }', + ]; + + /** + * @var array + */ + private $empty_data = [ + 'mode' => null, + 'intersect' => null, + 'animationDuration' => null, + 'onClick' => null, + ]; + + /** + * + */ + public function setUp() + { + $this->click = new Click(); + } + + /** + * + */ + public function testEmpty() + { + $expected = $this->empty_data; + $result = TestUtils::getAttributes($this->click, $this->data_types); + self::assertEquals($expected, $result); + } + + /** + * + */ + public function testGetAndSetWithExpressions() + { + $expected = $this->input_data_with_expressions; + TestUtils::setAttributes($this->click, $this->input_data_with_expressions); + $result = TestUtils::getAttributes($this->click, $this->data_types); + self::assertEquals($expected, $result); + } + + /** + * + */ + public function testJsonSerializeWithoutExpressions() + { + $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); + TestUtils::setAttributes($this->click, $this->input_data_no_expressions); + $result = json_decode($this->click->jsonSerialize(), true); + self::assertSame($expected, $result); + } +} diff --git a/test/unit/OptionsTest.php b/test/unit/OptionsTest.php index 9232d5d..1259e88 100644 --- a/test/unit/OptionsTest.php +++ b/test/unit/OptionsTest.php @@ -3,6 +3,7 @@ namespace Test; use Halfpastfour\PHPChartJS\Options; +use Halfpastfour\PHPChartJS\Options\Click; use Halfpastfour\PHPChartJS\Options\Layout; use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Animation; @@ -71,6 +72,15 @@ public function testHover() self::assertInstanceOf(Hover::class, $hover); } + /** + * + */ + public function testClick() + { + $click = $this->options->getCLick(); + self::assertInstanceOf(Click::class, $click); + } + /** * */ From 13580158fae5090258ad65f9da068697bd7404fb Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Fri, 14 Dec 2018 16:27:43 +0100 Subject: [PATCH 03/23] Flatten onClick --- src/ConfigDefaults/ClickConfig.php | 8 -- src/ConfigDefaults/GlobalConfig.php | 17 --- src/Options.php | 25 ++-- src/Options/Click.php | 135 ------------------ test/unit/ConfigDefaults/GlobalConfigTest.php | 10 -- test/unit/Options/ClickTest.php | 62 +++----- test/unit/OptionsTest.php | 11 +- 7 files changed, 34 insertions(+), 234 deletions(-) delete mode 100644 src/ConfigDefaults/ClickConfig.php delete mode 100644 src/Options/Click.php diff --git a/src/ConfigDefaults/ClickConfig.php b/src/ConfigDefaults/ClickConfig.php deleted file mode 100644 index d92167f..0000000 --- a/src/ConfigDefaults/ClickConfig.php +++ /dev/null @@ -1,8 +0,0 @@ -hover; } - /** - * @return ClickConfig - */ - public function click() - { - if (is_null($this->click)) { - $this->click = new ClickConfig(); - } - - return $this->click; - } - /** * @return AnimationConfig */ diff --git a/src/Options.php b/src/Options.php index 2300a22..f8e99ba 100644 --- a/src/Options.php +++ b/src/Options.php @@ -11,6 +11,7 @@ use Halfpastfour\PHPChartJS\Options\Scales; use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Tooltips; +use Zend\Json\Expr; use Zend\Json\Json; /** @@ -38,9 +39,9 @@ class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonS protected $hover; /** - * @var Click + * @var \Zend\Json\Expr */ - protected $click; + protected $onClick; /** * @var Scales @@ -99,15 +100,23 @@ public function getHover() } /** - * @return Click + * @return \Zend\Json\Expr */ - public function getCLick() + public function getOnClick() { - if (is_null($this->click)) { - $this->click = new Click(); - } + return $this->onClick; + } + + /** + * @param Expr $onClick + * + * @return $this + */ + public function setOnClick($onClick) + { + $this->onClick = new Expr(strval($onClick)); - return $this->click; + return $this; } /** diff --git a/src/Options/Click.php b/src/Options/Click.php deleted file mode 100644 index c380425..0000000 --- a/src/Options/Click.php +++ /dev/null @@ -1,135 +0,0 @@ -mode; - } - - /** - * @param string $mode - * - * @return $this - */ - public function setMode($mode) - { - $this->mode = strval($mode); - - return $this; - } - - /** - * @return bool - */ - public function isIntersect() - { - return $this->intersect; - } - - /** - * @return bool - */ - public function getIntersect() - { - return $this->intersect; - } - - /** - * @param bool $intersect - * - * @return $this - */ - public function setIntersect($intersect) - { - $this->intersect = ! ! $intersect; - - return $this; - } - - /** - * @return int - */ - public function getAnimationDuration() - { - return $this->animationDuration; - } - - /** - * @param int $animationDuration - * - * @return $this - */ - public function setAnimationDuration($animationDuration) - { - $this->animationDuration = intval($animationDuration); - - return $this; - } - - /** - * @return \Zend\Json\Expr - */ - public function getOnClick() - { - return $this->onClick; - } - - /** - * @param Expr $onClick - * - * @return $this - */ - public function setOnClick($onClick) - { - $this->onClick = new Expr(strval($onClick)); - - return $this; - } - - /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception - */ - public function jsonSerialize() - { - return Json::encode($this->getArrayCopy()); - } -} diff --git a/test/unit/ConfigDefaults/GlobalConfigTest.php b/test/unit/ConfigDefaults/GlobalConfigTest.php index b52955f..1870781 100644 --- a/test/unit/ConfigDefaults/GlobalConfigTest.php +++ b/test/unit/ConfigDefaults/GlobalConfigTest.php @@ -3,7 +3,6 @@ namespace Test\ConfigDefaults; use Halfpastfour\PHPChartJS\ConfigDefaults\AnimationConfig; -use Halfpastfour\PHPChartJS\ConfigDefaults\ClickConfig; use Halfpastfour\PHPChartJS\ConfigDefaults\ElementsConfig; use Halfpastfour\PHPChartJS\ConfigDefaults\GlobalConfig; use Halfpastfour\PHPChartJS\ConfigDefaults\HoverConfig; @@ -108,15 +107,6 @@ public function testHover() self::assertInstanceOf(HoverConfig::class, $result); } - /** - * - */ - public function testClick() - { - $result = $this->config->click(); - self::assertInstanceOf(ClickConfig::class, $result); - } - /** * */ diff --git a/test/unit/Options/ClickTest.php b/test/unit/Options/ClickTest.php index cdef0f9..6e2cdc5 100644 --- a/test/unit/Options/ClickTest.php +++ b/test/unit/Options/ClickTest.php @@ -2,8 +2,9 @@ namespace Test\Options; -use Halfpastfour\PHPChartJS\Options\Click; +use Halfpastfour\PHPChartJS\Options; use Test\TestUtils; +use Zend\Json\Expr; /** * Class ClickTest @@ -12,56 +13,24 @@ class ClickTest extends \PHPUnit_Framework_TestCase { /** - * @var Click + * @var Options */ - private $click; + private $options; - /** - * @var array - */ private $data_types = [ - 'mode' => '', - 'intersect' => false, - 'animationDuration' => 1, - 'onClick' => '', + 'onClick' => null, ]; - /** - * @var array - */ - private $input_data_no_expressions = [ - 'mode' => 'mode', - 'intersect' => true, - 'animationDuration' => 2, - 'onClick' => null, - ]; - - /** - * @var array - */ - private $input_data_with_expressions = [ - 'mode' => 'mode', - 'intersect' => true, - 'animationDuration' => 2, - 'onClick' => 'function(event, array) { echo "onClick"; }', - ]; - - /** - * @var array - */ - private $empty_data = [ - 'mode' => null, - 'intersect' => null, - 'animationDuration' => null, - 'onClick' => null, - ]; + private $input_data_no_expressions = ['onClick' => null]; + private $input_data_with_expressions = null; /** * */ public function setUp() { - $this->click = new Click(); + $this->options = new Options(); + $this->input_data_with_expressions = ['onClick' => new Expr('function(event, array) { echo "onClick"; }')]; } /** @@ -69,8 +38,9 @@ public function setUp() */ public function testEmpty() { - $expected = $this->empty_data; - $result = TestUtils::getAttributes($this->click, $this->data_types); + $expected = $this->input_data_no_expressions; + TestUtils::setAttributes($this->options, $this->input_data_no_expressions); + $result = TestUtils::getAttributes($this->options, $this->data_types); self::assertEquals($expected, $result); } @@ -80,8 +50,8 @@ public function testEmpty() public function testGetAndSetWithExpressions() { $expected = $this->input_data_with_expressions; - TestUtils::setAttributes($this->click, $this->input_data_with_expressions); - $result = TestUtils::getAttributes($this->click, $this->data_types); + TestUtils::setAttributes($this->options, $this->input_data_with_expressions); + $result = TestUtils::getAttributes($this->options, $this->data_types); self::assertEquals($expected, $result); } @@ -91,8 +61,8 @@ public function testGetAndSetWithExpressions() public function testJsonSerializeWithoutExpressions() { $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); - TestUtils::setAttributes($this->click, $this->input_data_no_expressions); - $result = json_decode($this->click->jsonSerialize(), true); + TestUtils::setAttributes($this->options, $this->input_data_no_expressions); + $result = json_decode($this->options->jsonSerialize(), true); self::assertSame($expected, $result); } } diff --git a/test/unit/OptionsTest.php b/test/unit/OptionsTest.php index 1259e88..1848c80 100644 --- a/test/unit/OptionsTest.php +++ b/test/unit/OptionsTest.php @@ -3,7 +3,6 @@ namespace Test; use Halfpastfour\PHPChartJS\Options; -use Halfpastfour\PHPChartJS\Options\Click; use Halfpastfour\PHPChartJS\Options\Layout; use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Animation; @@ -11,6 +10,7 @@ use Halfpastfour\PHPChartJS\Options\Scales; use Halfpastfour\PHPChartJS\Options\Tooltips; use Halfpastfour\PHPChartJS\Options\Legend; +use Zend\Json\Expr; /** * Class OptionsTest @@ -72,15 +72,6 @@ public function testHover() self::assertInstanceOf(Hover::class, $hover); } - /** - * - */ - public function testClick() - { - $click = $this->options->getCLick(); - self::assertInstanceOf(Click::class, $click); - } - /** * */ From 7dac59d9087dee6bdbfdec7b146c3d80939bb192 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Fri, 14 Dec 2018 16:32:02 +0100 Subject: [PATCH 04/23] Restore private properties --- src/Options/Scales/GridLines.php | 24 ++++++------ src/Options/Scales/ScaleLabel.php | 12 +++--- src/Options/Scales/Ticks.php | 36 ++++++++--------- src/Options/Title.php | 18 ++++----- src/Options/Tooltips.php | 64 +++++++++++++++---------------- 5 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index 149f290..f7b30e8 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -18,62 +18,62 @@ class GridLines implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - protected $display; + private $display; /** * @var string|string[] */ - protected $color; + private $color; /** * @var float[] */ - protected $borderDash; + private $borderDash; /** * @var float */ - protected $borderDashOffset; + private $borderDashOffset; /** * @var int|int[] */ - protected $lineWidth; + private $lineWidth; /** * @var bool */ - protected $drawBorder; + private $drawBorder; /** * @var bool */ - protected $drawOnChartArea; + private $drawOnChartArea; /** * @var bool */ - protected $drawTicks; + private $drawTicks; /** * @var int */ - protected $tickMarkLength; + private $tickMarkLength; /** * @var int */ - protected $zeroLineWidth; + private $zeroLineWidth; /** * @var string */ - protected $zeroLineColor; + private $zeroLineColor; /** * @var bool */ - protected $offsetGridLines; + private $offsetGridLines; /** * @return bool diff --git a/src/Options/Scales/ScaleLabel.php b/src/Options/Scales/ScaleLabel.php index caa1796..2328d33 100644 --- a/src/Options/Scales/ScaleLabel.php +++ b/src/Options/Scales/ScaleLabel.php @@ -17,32 +17,32 @@ class ScaleLabel implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - protected $display; + private $display; /** * @var string */ - protected $labelString; + private $labelString; /** * @var string */ - protected $fontColor; + private $fontColor; /** * @var string */ - protected $fontFamily; + private $fontFamily; /** * @var int */ - protected $fontSize; + private $fontSize; /** * @var string */ - protected $fontStyle; + private $fontStyle; /** * @return bool diff --git a/src/Options/Scales/Ticks.php b/src/Options/Scales/Ticks.php index 6c582e8..3093860 100644 --- a/src/Options/Scales/Ticks.php +++ b/src/Options/Scales/Ticks.php @@ -19,92 +19,92 @@ class Ticks implements ArraySerializableInterface, \JsonSerializable /** * @var float */ - protected $suggestedMin; + private $suggestedMin; /** * @var bool */ - protected $beginAtZero; + private $beginAtZero; /** * @var float */ - protected $stepSize; + private $stepSize; /** * @var bool */ - protected $autoSkip; + private $autoSkip; /** * @var int */ - protected $autoSkipPadding; + private $autoSkipPadding; /** * @var Expr */ - protected $callback; + private $callback; /** * @var bool */ - protected $display; + private $display; /** * @var string */ - protected $fontColor; + private $fontColor; /** * @var string */ - protected $fontFamily; + private $fontFamily; /** * @var int */ - protected $fontSize; + private $fontSize; /** * @var string */ - protected $fontStyle; + private $fontStyle; /** * @var int */ - protected $labelOffset; + private $labelOffset; /** * @var int */ - protected $maxRotation; + private $maxRotation; /** * @var int */ - protected $minRotation; + private $minRotation; /** * @var bool */ - protected $mirror; + private $mirror; /** * @var int */ - protected $padding; + private $padding; /** * @var bool */ - protected $reverse; + private $reverse; /** * @var int */ - protected $max; + private $max; /** * @return float diff --git a/src/Options/Title.php b/src/Options/Title.php index 33a928a..3edc97a 100644 --- a/src/Options/Title.php +++ b/src/Options/Title.php @@ -17,47 +17,47 @@ class Title implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - protected $display; + private $display; /** * @var string */ - protected $position; + private $position; /** * @var bool */ - protected $fullWidth; + private $fullWidth; /** * @var int */ - protected $fontSize; + private $fontSize; /** * @var string */ - protected $fontFamily; + private $fontFamily; /** * @var string */ - protected $fontColor; + private $fontColor; /** * @var string */ - protected $fontStyle; + private $fontStyle; /** * @var int */ - protected $padding; + private $padding; /** * @var string */ - protected $text; + private $text; /** * @return bool diff --git a/src/Options/Tooltips.php b/src/Options/Tooltips.php index 0ede6bc..07bcac0 100644 --- a/src/Options/Tooltips.php +++ b/src/Options/Tooltips.php @@ -19,162 +19,162 @@ class Tooltips implements ArraySerializableInterface, \JsonSerializable /** * @var bool */ - protected $enabled; + private $enabled; /** * @var Expr */ - protected $custom; + private $custom; /** * @var string */ - protected $mode; + private $mode; /** * @var bool */ - protected $intersect; + private $intersect; /** * @var string */ - protected $position; + private $position; /** * @var Expr */ - protected $itemSort; + private $itemSort; /** * @var Expr */ - protected $filter; + private $filter; /** * @var string */ - protected $backgroundColor; + private $backgroundColor; /** * @var string */ - protected $titleFontFamily; + private $titleFontFamily; /** * @var int */ - protected $titleFontSize; + private $titleFontSize; /** * @var string */ - protected $titleFontStyle; + private $titleFontStyle; /** * @var string */ - protected $titleFontColor; + private $titleFontColor; /** * @var int */ - protected $titleSpacing; + private $titleSpacing; /** * @var int */ - protected $titleMarginBottom; + private $titleMarginBottom; /** * @var string */ - protected $bodyFontFamily; + private $bodyFontFamily; /** * @var int */ - protected $bodyFontSize; + private $bodyFontSize; /** * @var string */ - protected $bodyFontStyle; + private $bodyFontStyle; /** * @var string */ - protected $bodyFontColor; + private $bodyFontColor; /** * @var int */ - protected $bodySpacing; + private $bodySpacing; /** * @var string */ - protected $footerFontFamily; + private $footerFontFamily; /** * @var int */ - protected $footerFontSize; + private $footerFontSize; /** * @var string */ - protected $footerFontStyle; + private $footerFontStyle; /** * @var string */ - protected $footerFontColor; + private $footerFontColor; /** * @var int */ - protected $footerSpacing; + private $footerSpacing; /** * @var int */ - protected $footerMarginTop; + private $footerMarginTop; /** * @var int */ - protected $xPadding; + private $xPadding; /** * @var int */ - protected $yPadding; + private $yPadding; /** * @var int */ - protected $caretSize; + private $caretSize; /** * @var int */ - protected $cornerRadius; + private $cornerRadius; /** * @var string */ - protected $multiKeyBackground; + private $multiKeyBackground; /** * @var bool */ - protected $displayColors; + private $displayColors; /** * @var Callbacks */ - protected $callbacks; + private $callbacks; /** * @return bool From bbbca8cf2378b017c9c6030f16e06534d74a99e3 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Sat, 15 Dec 2018 10:49:19 +0100 Subject: [PATCH 05/23] Set dev-master --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5f6638c..303ed6c 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ ], "homepage": "http://github.com/halfpastfouram/PHPChartJS", "type": "package", - "version": "v1.1.0", - "license": "AGPL-3.0-or-later", + "version": "dev-master", + "license": "AGPL 3.0", "authors": [ { "name": "Bob Kruithof" From 79fd747dc3b077d0ce62aaeb6dc7959a92d23ca2 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Sat, 15 Dec 2018 11:02:01 +0100 Subject: [PATCH 06/23] Pass GridLinesTest --- src/Delegate/StringUtils.php | 28 ++++++++++++++++++++++++++++ src/Options/Scales/GridLines.php | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Delegate/StringUtils.php b/src/Delegate/StringUtils.php index b6e8820..430ff6d 100644 --- a/src/Delegate/StringUtils.php +++ b/src/Delegate/StringUtils.php @@ -22,4 +22,32 @@ public function recursiveToString(array $input) return $input; } + + /** + * @param array $input + * + * @return array + */ + public function recursiveToFloat(array $input) + { + array_walk_recursive($input, function (&$value) { + $value = floatval($value); + }); + + return $input; + } + + /** + * @param array $input + * + * @return array + */ + public function recursiveToInt(array $input) + { + array_walk_recursive($input, function (&$value) { + $value = intval($value); + }); + + return $input; + } } diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index fe73876..b0e857b 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -145,7 +145,7 @@ public function getBorderDash() public function setBorderDash($borderDash) { if (is_array($borderDash)) { - $this->borderDash = $this->recursiveToString($borderDash); + $this->borderDash = $this->recursiveToFloat($borderDash); } return $this; @@ -187,7 +187,7 @@ public function getLineWidth() public function setLineWidth($lineWidth) { if (is_array($lineWidth)) { - $this->lineWidth = $this->recursiveToString($lineWidth); + $this->lineWidth = $this->recursiveToInt($lineWidth); } else { $this->lineWidth = is_null($lineWidth) ? null : intval($lineWidth); } From f36d2337988b5ccc9f6d0c8fc62da2e1ec963cee Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Mon, 15 Jul 2019 18:35:16 +0200 Subject: [PATCH 07/23] Move number methods from StringUtils to a new NumberUtils trait --- composer.json | 3 ++- src/Delegate/NumberUtils.php | 40 ++++++++++++++++++++++++++++++++ src/Delegate/StringUtils.php | 28 ---------------------- src/Options/Scales/GridLines.php | 2 ++ src/Options/Tooltips.php | 2 ++ 5 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 src/Delegate/NumberUtils.php diff --git a/composer.json b/composer.json index 303ed6c..42ed5cc 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "php": ">=5.6.0 || ^7.0", "zendframework/zend-json": "3.0.0", "zf1/zend-reflection": "1.12.11", - "halfpastfouram/collection": "1.0.0" + "halfpastfouram/collection": "1.0.0", + "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "5.7.*", diff --git a/src/Delegate/NumberUtils.php b/src/Delegate/NumberUtils.php new file mode 100644 index 0000000..b6025b2 --- /dev/null +++ b/src/Delegate/NumberUtils.php @@ -0,0 +1,40 @@ + Date: Thu, 8 Aug 2019 10:29:26 +0200 Subject: [PATCH 08/23] Add maintainAspectRatio option. --- src/Options.php | 38 +++++++++++++++++++++++++++++++++++--- test/unit/OptionsTest.php | 17 +++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/Options.php b/src/Options.php index 090c760..e83a796 100644 --- a/src/Options.php +++ b/src/Options.php @@ -15,6 +15,7 @@ /** * Class Options + * * @package Halfpastfour\PHPChartJS */ class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonSerializable @@ -62,13 +63,18 @@ class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonS */ protected $tooltips; + /** + * @var bool + */ + protected $maintainAspectRatio; + /** * @return Layout */ public function getLayout() { if (is_null($this->layout)) { - $this->layout = new Layout(); + $this->layout = new Layout(); } return $this->layout; @@ -80,7 +86,7 @@ public function getLayout() public function getElements() { if (is_null($this->elements)) { - $this->elements = new Elements(); + $this->elements = new Elements(); } return $this->elements; @@ -158,11 +164,37 @@ public function getTooltips() return $this->tooltips; } + /** + * @return bool + */ + public function isMaintainAspectRatio() + { + if (is_null($this->maintainAspectRatio)) { + $this->maintainAspectRatio = true; + } + + return $this->maintainAspectRatio; + } + + /** + * @param bool $flag + * + * @return $this + */ + public function setMaintainAspectRatio($flag) + { + $this->maintainAspectRatio = boolval($flag); + + return $this; + } + /** * @return string + * @throws \ReflectionException + * @throws \Zend_Reflection_Exception */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return Json::encode($this->getArrayCopy(), false, ['enableJsonExprFinder' => true]); } } diff --git a/test/unit/OptionsTest.php b/test/unit/OptionsTest.php index 7e3d740..58215c4 100644 --- a/test/unit/OptionsTest.php +++ b/test/unit/OptionsTest.php @@ -108,6 +108,23 @@ public function testTooltips() self::assertInstanceOf(Tooltips::class, $tooltips); } + /** + * + */ + public function testAspectRatio() + { + // Test default value. Should be true. + self::assertTrue($this->options->isMaintainAspectRatio()); + + // Set to false. + self::assertSame($this->options, $this->options->setMaintainAspectRatio(false)); + self::assertFalse($this->options->isMaintainAspectRatio()); + + // Set to true again. + self::assertSame($this->options, $this->options->setMaintainAspectRatio(true)); + self::assertTrue($this->options->isMaintainAspectRatio()); + } + /** * */ From b1caca8c38b699a0a16fd8407e53f0cf65e058d7 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 16:00:56 +0100 Subject: [PATCH 09/23] Fix unit test. --- src/Options/Scales/GridLines.php | 4 ++-- test/unit/Options/Scales/GridLinesTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index 5e41dd8..039086f 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -28,7 +28,7 @@ class GridLines implements ArraySerializableInterface, \JsonSerializable private $color; /** - * @var float[] + * @var string[] */ private $borderDash; @@ -122,7 +122,7 @@ public function setColor($color) } /** - * @return \float[] + * @return \string[] */ public function getBorderDash() { diff --git a/test/unit/Options/Scales/GridLinesTest.php b/test/unit/Options/Scales/GridLinesTest.php index 7d541c7..4cd1649 100644 --- a/test/unit/Options/Scales/GridLinesTest.php +++ b/test/unit/Options/Scales/GridLinesTest.php @@ -40,7 +40,7 @@ class GridLinesTest extends \PHPUnit_Framework_TestCase private $input_data_single_value = [ 'display' => true, 'color' => 'color', - 'borderDash' => [2.0], + 'borderDash' => ['2'], 'borderDashOffset' => 3.0, 'lineWidth' => 4, 'drawBorder' => true, @@ -55,9 +55,9 @@ class GridLinesTest extends \PHPUnit_Framework_TestCase private $input_data_nested_arrays = [ 'display' => true, 'color' => ['color1', 'color2', ['color3', 'color4']], - 'borderDash' => [2.0, 3.0, [4.0, 5.0]], + 'borderDash' => ['2.0', '3.0', ['4.0', '5.0']], 'borderDashOffset' => 3.0, - 'lineWidth' => [4, 5, [6, 7], 8], + 'lineWidth' => ['4', '5', ['6', '7'], '8'], 'drawBorder' => true, 'drawOnChartArea' => true, 'drawTicks' => true, From f39bf399cfd7131ca4d1d9d5a47dbac6d2f9b667 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 18:00:09 +0100 Subject: [PATCH 10/23] Fix CS --- src/Options/Elements/Line.php | 2 +- src/Options/Elements/Point.php | 2 +- src/Options/Elements/Rectangle.php | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Options/Elements/Line.php b/src/Options/Elements/Line.php index 0ae3c71..a447cc1 100644 --- a/src/Options/Elements/Line.php +++ b/src/Options/Elements/Line.php @@ -322,4 +322,4 @@ public function jsonSerialize() { return Json::encode($this->getArrayCopy()); } -} \ No newline at end of file +} diff --git a/src/Options/Elements/Point.php b/src/Options/Elements/Point.php index 5a18198..4347883 100644 --- a/src/Options/Elements/Point.php +++ b/src/Options/Elements/Point.php @@ -259,4 +259,4 @@ public function jsonSerialize() { return Json::encode($this->getArrayCopy()); } -} \ No newline at end of file +} diff --git a/src/Options/Elements/Rectangle.php b/src/Options/Elements/Rectangle.php index f99c192..17a4812 100644 --- a/src/Options/Elements/Rectangle.php +++ b/src/Options/Elements/Rectangle.php @@ -130,5 +130,4 @@ public function jsonSerialize() { return Json::encode($this->getArrayCopy()); } - -} \ No newline at end of file +} From 9784495d6a4befd54a568e315fbd270cb7e76261 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Thu, 9 Jan 2020 18:39:10 +0100 Subject: [PATCH 11/23] Apply suggestions from code review Co-Authored-By: Bob --- composer.json | 2 +- src/Options/Legend.php | 6 +++--- src/Options/Legend/Labels.php | 2 +- src/Options/Scale.php | 4 ++-- src/Options/Scales/GridLines.php | 10 +++++----- src/Options/Scales/ScaleLabel.php | 2 +- src/Options/Scales/Ticks.php | 10 +++++----- src/Options/Title.php | 4 ++-- src/Options/Tooltips.php | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 42ed5cc..6b26671 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "homepage": "http://github.com/halfpastfouram/PHPChartJS", "type": "package", "version": "dev-master", - "license": "AGPL 3.0", + "license": "AGPL-3.0-or-later", "authors": [ { "name": "Bob Kruithof" diff --git a/src/Options/Legend.php b/src/Options/Legend.php index 8747f6c..ca3e1fa 100644 --- a/src/Options/Legend.php +++ b/src/Options/Legend.php @@ -62,7 +62,7 @@ public function isDisplay() /** * @return bool */ - public function getDisplay() + public function isDisplay() { return $this->display; } @@ -110,7 +110,7 @@ public function isFullWidth() /** * @return bool */ - public function getFullWidth() + public function isFullWidth() { return $this->fullWidth; } @@ -190,7 +190,7 @@ public function isReverse() /** * @return bool */ - public function getReverse() + public function isReverse() { return $this->reverse; } diff --git a/src/Options/Legend/Labels.php b/src/Options/Legend/Labels.php index 122f036..1513b71 100644 --- a/src/Options/Legend/Labels.php +++ b/src/Options/Legend/Labels.php @@ -206,7 +206,7 @@ public function isUsePointStyle() /** * @return bool */ - public function getUsePointStyle() + public function isUsePointStyle() { return $this->usePointStyle; } diff --git a/src/Options/Scale.php b/src/Options/Scale.php index 6feeac1..13cf836 100644 --- a/src/Options/Scale.php +++ b/src/Options/Scale.php @@ -163,7 +163,7 @@ public function isDisplay() /** * @return bool */ - public function getDisplay() + public function isDisplay() { return $this->display; } @@ -211,7 +211,7 @@ public function isStacked() /** * @return bool */ - public function getStacked() + public function isStacked() { return $this->stacked; } diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index 1a3a7dc..afd4b57 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -90,7 +90,7 @@ public function isDisplay() /** * @return bool */ - public function getDisplay() + public function isDisplay() { return $this->display; } @@ -208,7 +208,7 @@ public function isDrawBorder() /** * @return bool */ - public function getDrawBorder() + public function isDrawBorder() { return $this->drawBorder; } @@ -236,7 +236,7 @@ public function isDrawOnChartArea() /** * @return bool */ - public function getDrawOnChartArea() + public function isDrawOnChartArea() { return $this->drawOnChartArea; } @@ -256,7 +256,7 @@ public function setDrawOnChartArea($drawOnChartArea) /** * @return bool */ - public function getDrawTicks() + public function isDrawTicks() { return $this->drawTicks; } @@ -352,7 +352,7 @@ public function isOffsetGridLines() /** * @return bool */ - public function getOffsetGridLines() + public function isOffsetGridLines() { return $this->offsetGridLines; } diff --git a/src/Options/Scales/ScaleLabel.php b/src/Options/Scales/ScaleLabel.php index 2328d33..053b26f 100644 --- a/src/Options/Scales/ScaleLabel.php +++ b/src/Options/Scales/ScaleLabel.php @@ -55,7 +55,7 @@ public function isDisplay() /** * @return bool */ - public function getDisplay() + public function isDisplay() { return $this->display; } diff --git a/src/Options/Scales/Ticks.php b/src/Options/Scales/Ticks.php index 3093860..8c0512b 100644 --- a/src/Options/Scales/Ticks.php +++ b/src/Options/Scales/Ticks.php @@ -137,7 +137,7 @@ public function isBeginAtZero() /** * @return bool */ - public function getBeginAtZero() + public function isBeginAtZero() { return $this->beginAtZero; } @@ -185,7 +185,7 @@ public function isAutoSkip() /** * @return bool */ - public function getAutoSkip() + public function isAutoSkip() { return $this->autoSkip; } @@ -253,7 +253,7 @@ public function isDisplay() /** * @return bool */ - public function getDisplay() + public function isDisplay() { return $this->display; } @@ -421,7 +421,7 @@ public function isMirror() /** * @return bool */ - public function getMirror() + public function isMirror() { return $this->mirror; } @@ -469,7 +469,7 @@ public function isReverse() /** * @return bool */ - public function getReverse() + public function isReverse() { return $this->reverse; } diff --git a/src/Options/Title.php b/src/Options/Title.php index 3edc97a..9291442 100644 --- a/src/Options/Title.php +++ b/src/Options/Title.php @@ -70,7 +70,7 @@ public function isDisplay() /** * @return bool */ - public function getDisplay() + public function isDisplay() { return $this->display; } @@ -118,7 +118,7 @@ public function isFullWidth() /** * @return bool */ - public function getFullWidth() + public function isFullWidth() { return $this->fullWidth; } diff --git a/src/Options/Tooltips.php b/src/Options/Tooltips.php index 6880761..84e12cc 100644 --- a/src/Options/Tooltips.php +++ b/src/Options/Tooltips.php @@ -187,7 +187,7 @@ public function isEnabled() /** * @return bool */ - public function getEnabled() + public function isEnabled() { return $this->enabled; } @@ -255,7 +255,7 @@ public function isIntersect() /** * @return bool */ - public function getIntersect() + public function isIntersect() { return $this->intersect; } @@ -803,7 +803,7 @@ public function isDisplayColors() /** * @return bool */ - public function getDisplayColors() + public function isDisplayColors() { return $this->displayColors; } From 31e825dd793a7880ff11f9d5fa349f484c7ee3c8 Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 9 Jan 2020 18:50:23 +0100 Subject: [PATCH 12/23] Bumped up version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6b26671..d44d208 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ ], "homepage": "http://github.com/halfpastfouram/PHPChartJS", "type": "package", - "version": "dev-master", + "version": "v1.2.0-dev", "license": "AGPL-3.0-or-later", "authors": [ { From a9694fb63fb9a8d09973cf953f950983241b5922 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 22:37:23 +0100 Subject: [PATCH 13/23] ArraySerializable objects now return arrays according in compliance with the ArraySerializable interface. --- composer.json | 4 +- composer.lock | 495 ++++++++++++++----------- src/Chart.php | 2 +- src/Collection/Data.php | 9 +- src/DataSet.php | 8 +- src/DataSetCollection.php | 11 +- src/Delegate/ArraySerializable.php | 58 +-- src/LabelsCollection.php | 9 +- src/Options.php | 12 +- src/Options/Animation.php | 9 +- src/Options/Elements.php | 12 +- src/Options/Elements/Arc.php | 22 +- src/Options/Elements/Line.php | 14 +- src/Options/Elements/Point.php | 56 ++- src/Options/Elements/Rectangle.php | 31 +- src/Options/Hover.php | 11 +- src/Options/Layout.php | 10 +- src/Options/Layout/Padding.php | 8 +- src/Options/Legend.php | 41 +- src/Options/Legend/Labels.php | 19 +- src/Options/Scale.php | 27 +- src/Options/Scales.php | 8 +- src/Options/Scales/GridLines.php | 50 +-- src/Options/Scales/ScaleLabel.php | 19 +- src/Options/Scales/Ticks.php | 58 +-- src/Options/Scales/XAxis.php | 6 +- src/Options/Scales/XAxisCollection.php | 10 +- src/Options/Scales/YAxisCollection.php | 10 +- src/Options/Title.php | 31 +- src/Options/Tooltips.php | 41 +- src/Options/Tooltips/Callbacks.php | 9 +- src/Renderer/Html.php | 5 +- src/Renderer/Json.php | 13 +- src/Renderer/Renderer.php | 2 +- 34 files changed, 519 insertions(+), 611 deletions(-) diff --git a/composer.json b/composer.json index d44d208..df48e16 100644 --- a/composer.json +++ b/composer.json @@ -17,10 +17,12 @@ ], "require": { "php": ">=5.6.0 || ^7.0", + "ext-dom": "*", + "ext-json": "*", "zendframework/zend-json": "3.0.0", "zf1/zend-reflection": "1.12.11", "halfpastfouram/collection": "1.0.0", - "ext-json": "*" + "symfony/var-dumper": "^3.4" }, "require-dev": { "phpunit/phpunit": "5.7.*", diff --git a/composer.lock b/composer.lock index 4f5842f..84aac6f 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ec0fc9f809a88232ebfbe8ea9a829f26", + "content-hash": "1055ab8393adc5a0332a58b38f335a5c", "packages": [ { "name": "halfpastfouram/collection", @@ -51,6 +51,134 @@ ], "time": "2016-12-18T13:04:48+00:00" }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.13.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.13-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2019-11-27T14:18:11+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v3.4.36", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "569e261461600810845a8305ca3f64abd3e712c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/569e261461600810845a8305ca3f64abd3e712c0", + "reference": "569e261461600810845a8305ca3f64abd3e712c0", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" + }, + "require-dev": { + "ext-iconv": "*", + "twig/twig": "~1.34|~2.4" + }, + "suggest": { + "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", + "ext-intl": "To show region name in time zone dump", + "ext-symfony_debug": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony mechanism for exploring and dumping PHP variables", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "time": "2019-10-10T11:03:19+00:00" + }, { "name": "zendframework/zend-json", "version": "3.0.0", @@ -99,6 +227,7 @@ "json", "zf2" ], + "abandoned": "laminas/laminas-json", "time": "2016-04-01T02:34:00+00:00" }, { @@ -242,27 +371,27 @@ }, { "name": "composer/ca-bundle", - "version": "1.1.2", + "version": "1.2.5", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "46afded9720f40b9dc63542af4e3e43a1177acb0" + "reference": "62e8fc2dc550e5d6d8c9360c7721662670f58149" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/46afded9720f40b9dc63542af4e3e43a1177acb0", - "reference": "46afded9720f40b9dc63542af4e3e43a1177acb0", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/62e8fc2dc550e5d6d8c9360c7721662670f58149", + "reference": "62e8fc2dc550e5d6d8c9360c7721662670f58149", "shasum": "" }, "require": { "ext-openssl": "*", "ext-pcre": "*", - "php": "^5.3.2 || ^7.0" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5", + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8", "psr/log": "^1.0", - "symfony/process": "^2.5 || ^3.0 || ^4.0" + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" }, "type": "library", "extra": { @@ -294,20 +423,20 @@ "ssl", "tls" ], - "time": "2018-08-08T08:57:40+00:00" + "time": "2019-12-11T14:44:42+00:00" }, { "name": "composer/semver", - "version": "1.4.2", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573" + "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573", - "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573", + "url": "https://api.github.com/repos/composer/semver/zipball/46d9139568ccb8d9e7cdd4539cab7347568a5e2e", + "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e", "shasum": "" }, "require": { @@ -356,7 +485,7 @@ "validation", "versioning" ], - "time": "2016-08-30T16:08:34+00:00" + "time": "2019-03-19T17:25:45+00:00" }, { "name": "doctrine/annotations", @@ -482,21 +611,24 @@ }, { "name": "doctrine/lexer", - "version": "v1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8", "shasum": "" }, "require": { "php": ">=5.3.2" }, + "require-dev": { + "phpunit/phpunit": "^4.5" + }, "type": "library", "extra": { "branch-alias": { @@ -504,8 +636,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" } }, "notification-url": "https://packagist.org/downloads/", @@ -526,13 +658,16 @@ "email": "schmittjoh@gmail.com" } ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", "keywords": [ + "annotations", + "docblock", "lexer", - "parser" + "parser", + "php" ], - "time": "2014-09-09T13:34:57+00:00" + "time": "2019-06-08T11:03:04+00:00" }, { "name": "friendsofphp/php-cs-fixer", @@ -889,16 +1024,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.17", + "version": "v2.0.18", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d" + "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d", - "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", + "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", "shasum": "" }, "require": { @@ -930,11 +1065,11 @@ "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", "keywords": [ "csprng", - "polyfill", + "polyfill", "pseudorandom", "random" ], - "time": "2018-07-04T16:31:37+00:00" + "time": "2019-01-03T20:59:08+00:00" }, { "name": "php-cs-fixer/diff", @@ -1135,38 +1270,38 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.0", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/cbe1df668b3fe136bcc909126a0f529a78d4cbbc", + "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpspec/phpspec": "^2.5 || ^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -1194,7 +1329,7 @@ "spy", "stub" ], - "time": "2018-08-05T17:53:17+00:00" + "time": "2019-12-22T21:05:45+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1584,20 +1719,21 @@ "mock", "xunit" ], + "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, { "name": "psr/log", - "version": "1.0.2", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", "shasum": "" }, "require": { @@ -1606,7 +1742,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -1631,7 +1767,7 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2019-11-01T11:05:21+00:00" }, { "name": "satooshi/php-coveralls", @@ -1692,6 +1828,7 @@ "github", "test" ], + "abandoned": "php-coveralls/php-coveralls", "time": "2017-12-06T23:17:56+00:00" }, { @@ -2260,22 +2397,22 @@ }, { "name": "symfony/config", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "7b08223b7f6abd859651c56bcabf900d1627d085" + "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/7b08223b7f6abd859651c56bcabf900d1627d085", - "reference": "7b08223b7f6abd859651c56bcabf900d1627d085", + "url": "https://api.github.com/repos/symfony/config/zipball/a599a867d0e4a07c342b5f1e656b3915a540ddbe", + "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0|~4.0", - "symfony/polyfill-ctype": "~1.8" + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/dependency-injection": "<3.3", @@ -2320,20 +2457,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2019-12-01T10:45:41+00:00" }, { "name": "symfony/console", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "6b217594552b9323bcdcfc14f8a0ce126e84cd73" + "reference": "1ee23b3b659b06c622f2bd2492a229e416eb4586" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/6b217594552b9323bcdcfc14f8a0ce126e84cd73", - "reference": "6b217594552b9323bcdcfc14f8a0ce126e84cd73", + "url": "https://api.github.com/repos/symfony/console/zipball/1ee23b3b659b06c622f2bd2492a229e416eb4586", + "reference": "1ee23b3b659b06c622f2bd2492a229e416eb4586", "shasum": "" }, "require": { @@ -2345,6 +2482,9 @@ "symfony/dependency-injection": "<3.4", "symfony/process": "<3.3" }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.3|~4.0", @@ -2354,7 +2494,7 @@ "symfony/process": "~3.3|~4.0" }, "suggest": { - "psr/log-implementation": "For using the console logger", + "psr/log": "For using the console logger", "symfony/event-dispatcher": "", "symfony/lock": "", "symfony/process": "" @@ -2389,20 +2529,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2019-12-01T10:04:45+00:00" }, { "name": "symfony/debug", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "c4625e75341e4fb309ce0c049cbf7fb84b8897cd" + "reference": "f72e33fdb1170b326e72c3157f0cd456351dd086" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/c4625e75341e4fb309ce0c049cbf7fb84b8897cd", - "reference": "c4625e75341e4fb309ce0c049cbf7fb84b8897cd", + "url": "https://api.github.com/repos/symfony/debug/zipball/f72e33fdb1170b326e72c3157f0cd456351dd086", + "reference": "f72e33fdb1170b326e72c3157f0cd456351dd086", "shasum": "" }, "require": { @@ -2445,20 +2585,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-08-03T10:42:44+00:00" + "time": "2019-10-24T15:33:53+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb" + "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb", - "reference": "b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f9031c22ec127d4a2450760f81a8677fe8a10177", + "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177", "shasum": "" }, "require": { @@ -2508,25 +2648,25 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2018-07-26T09:06:28+00:00" + "time": "2019-10-24T15:33:53+00:00" }, { "name": "symfony/filesystem", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "285ce5005cb01a0aeaa5b0cf590bd0cc40bb631c" + "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/285ce5005cb01a0aeaa5b0cf590bd0cc40bb631c", - "reference": "285ce5005cb01a0aeaa5b0cf590bd0cc40bb631c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/00cdad0936d06fab136944bc2342b762b1c3a4a2", + "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { @@ -2558,20 +2698,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2018-08-10T07:29:05+00:00" + "time": "2019-11-25T16:36:22+00:00" }, { "name": "symfony/finder", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "8a84fcb207451df0013b2c74cbbf1b62d47b999a" + "reference": "290ae21279b37bfd287cdcce640d51204e84afdf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/8a84fcb207451df0013b2c74cbbf1b62d47b999a", - "reference": "8a84fcb207451df0013b2c74cbbf1b62d47b999a", + "url": "https://api.github.com/repos/symfony/finder/zipball/290ae21279b37bfd287cdcce640d51204e84afdf", + "reference": "290ae21279b37bfd287cdcce640d51204e84afdf", "shasum": "" }, "require": { @@ -2607,20 +2747,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2019-11-17T21:55:15+00:00" }, { "name": "symfony/options-resolver", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "6debc476953a45969ab39afe8dee0b825f356dc7" + "reference": "b224d20be60e6f7b55cd66914379a13a0b28651a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/6debc476953a45969ab39afe8dee0b825f356dc7", - "reference": "6debc476953a45969ab39afe8dee0b825f356dc7", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/b224d20be60e6f7b55cd66914379a13a0b28651a", + "reference": "b224d20be60e6f7b55cd66914379a13a0b28651a", "shasum": "" }, "require": { @@ -2661,95 +2801,37 @@ "configuration", "options" ], - "time": "2018-07-26T08:45:46+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.9.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-10-26T11:02:01+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.9.0", + "name": "symfony/polyfill-ctype", + "version": "v1.13.1", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", "shasum": "" }, "require": { "php": ">=5.3.3" }, "suggest": { - "ext-mbstring": "For best performance" + "ext-ctype": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.13-dev" } }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" + "Symfony\\Polyfill\\Ctype\\": "" }, "files": [ "bootstrap.php" @@ -2761,47 +2843,46 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for the Mbstring extension", + "description": "Symfony polyfill for ctype functions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "mbstring", + "ctype", "polyfill", - "portable", - "shim" + "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.9.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "1e24b0c4a56d55aaf368763a06c6d1c7d3194934" + "reference": "af23c7bb26a73b850840823662dda371484926c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/1e24b0c4a56d55aaf368763a06c6d1c7d3194934", - "reference": "1e24b0c4a56d55aaf368763a06c6d1c7d3194934", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/af23c7bb26a73b850840823662dda371484926c4", + "reference": "af23c7bb26a73b850840823662dda371484926c4", "shasum": "" }, "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", + "paragonie/random_compat": "~1.0|~2.0|~9.99", "php": ">=5.3.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -2837,20 +2918,20 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.9.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "95c50420b0baed23852452a7f0c7b527303ed5ae" + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/95c50420b0baed23852452a7f0c7b527303ed5ae", - "reference": "95c50420b0baed23852452a7f0c7b527303ed5ae", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", + "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", "shasum": "" }, "require": { @@ -2859,7 +2940,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -2892,20 +2973,20 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-11-27T13:56:44+00:00" }, { "name": "symfony/process", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "4d6b125d5293cbceedc2aa10f2c71617e76262e7" + "reference": "9a4545c01e1e4f473492bd52b71e574dcc401ca2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/4d6b125d5293cbceedc2aa10f2c71617e76262e7", - "reference": "4d6b125d5293cbceedc2aa10f2c71617e76262e7", + "url": "https://api.github.com/repos/symfony/process/zipball/9a4545c01e1e4f473492bd52b71e574dcc401ca2", + "reference": "9a4545c01e1e4f473492bd52b71e574dcc401ca2", "shasum": "" }, "require": { @@ -2941,20 +3022,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-08-03T10:42:44+00:00" + "time": "2019-11-28T10:05:51+00:00" }, { "name": "symfony/stopwatch", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "deda2765e8dab2fc38492e926ea690f2a681f59d" + "reference": "efe0af281ad336bc3b10375c88b117499f1d8494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/deda2765e8dab2fc38492e926ea690f2a681f59d", - "reference": "deda2765e8dab2fc38492e926ea690f2a681f59d", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/efe0af281ad336bc3b10375c88b117499f1d8494", + "reference": "efe0af281ad336bc3b10375c88b117499f1d8494", "shasum": "" }, "require": { @@ -2990,25 +3071,25 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2018-07-26T10:03:52+00:00" + "time": "2019-11-03T17:17:59+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.15", + "version": "v3.4.36", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c2f4812ead9f847cb69e90917ca7502e6892d6b8" + "reference": "dab657db15207879217fc81df4f875947bf68804" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c2f4812ead9f847cb69e90917ca7502e6892d6b8", - "reference": "c2f4812ead9f847cb69e90917ca7502e6892d6b8", + "url": "https://api.github.com/repos/symfony/yaml/zipball/dab657db15207879217fc81df4f875947bf68804", + "reference": "dab657db15207879217fc81df4f875947bf68804", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/console": "<3.4" @@ -3049,35 +3130,33 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-08-10T07:34:36+00:00" + "time": "2019-10-24T15:33:53+00:00" }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "vimeo/psalm": "<3.6.0" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -3099,7 +3178,7 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "time": "2019-11-24T13:36:37+00:00" } ], "aliases": [], @@ -3110,7 +3189,9 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.6.0 || ^7.0" + "php": ">=5.6.0 || ^7.0", + "ext-dom": "*", + "ext-json": "*" }, "platform-dev": [] } diff --git a/src/Chart.php b/src/Chart.php index 47af78d..caa4b3e 100644 --- a/src/Chart.php +++ b/src/Chart.php @@ -220,7 +220,7 @@ public function render($pretty = false) { $renderer = new Html($this); - return $renderer->render(! ! $pretty ? $renderer::RENDER_PRETTY : null); + return $renderer->render($pretty ? $renderer::RENDER_PRETTY : null); } /** diff --git a/src/Collection/Data.php b/src/Collection/Data.php index 7482ee2..cf35017 100644 --- a/src/Collection/Data.php +++ b/src/Collection/Data.php @@ -3,19 +3,20 @@ namespace Halfpastfour\PHPChartJS\Collection; use Halfpastfour\Collection\Collection\ArrayAccess; -use Zend\Json\Json; +use JsonSerializable; /** * Class Data + * * @package Halfpastfour\PHPChartJS\Collection */ -class Data extends ArrayAccess implements \JsonSerializable +class Data extends ArrayAccess implements JsonSerializable { /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->data); + return $this->data; } } diff --git a/src/DataSet.php b/src/DataSet.php index 1f2d2af..e6669da 100644 --- a/src/DataSet.php +++ b/src/DataSet.php @@ -4,14 +4,14 @@ use Halfpastfour\PHPChartJS\Collection\Data; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class DataSet * * @package Halfpastfour\PHPChartJS */ -class DataSet implements ChartOwnedInterface, ArraySerializableInterface, \JsonSerializable +class DataSet implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializable { use ChartOwned; use ArraySerializable; @@ -351,10 +351,10 @@ public function setHoverBorderWidth($hoverBorderWidth) } /** - * + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/DataSetCollection.php b/src/DataSetCollection.php index 2694222..c84432b 100644 --- a/src/DataSetCollection.php +++ b/src/DataSetCollection.php @@ -3,20 +3,21 @@ namespace Halfpastfour\PHPChartJS; use Halfpastfour\Collection\Collection\ArrayAccess; -use Zend\Json\Json; +use JsonSerializable; /** * Class DataSetCollection + * * @package Halfpastfour\PHPChartJS */ -class DataSetCollection extends ArrayAccess implements \JsonSerializable +class DataSetCollection extends ArrayAccess implements JsonSerializable { /** * @return array */ public function getArrayCopy() { - $rows = []; + $rows = []; foreach ($this->data as $row) { /** @var DataSet $row */ $rows[] = $row->getArrayCopy(); @@ -26,10 +27,10 @@ public function getArrayCopy() } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Delegate/ArraySerializable.php b/src/Delegate/ArraySerializable.php index c68f198..cb13182 100644 --- a/src/Delegate/ArraySerializable.php +++ b/src/Delegate/ArraySerializable.php @@ -2,65 +2,35 @@ namespace Halfpastfour\PHPChartJS\Delegate; -use Zend\Json\Expr; +use Halfpastfour\PHPChartJS\ArraySerializableInterface; /** * Class ArraySerializable + * * @package Halfpastfour\PHPChartJS\Model */ trait ArraySerializable { /** - * Will loop through class properties and try and assign their values to an array of data that will be returned. + * Returns an array copy of the properties and their current values in this class * * @return array - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception */ public function getArrayCopy() { - $data = []; - $properties = get_object_vars($this); - $reflectionClass = new \Zend_Reflection_Class($this); - foreach ($properties as $property => $value) { - // Skip property if it is not accessible - if (! $reflectionClass->hasProperty($property)) { - continue; - } - - // Only process properties that aren't null - if (! is_null($value)) { - // Gather phpdoc from property - $phpDoc = $reflectionClass->getProperty($property)->getDocComment(); - $type = $phpDoc->getTag('var')->getDescription(); - $object = false; - - // Prepend 'get' to the getter method. - $getter = 'get' . ucfirst($property); - if (is_object($value) && ! $this->$property instanceof Expr) { - $object = true; - } - - // Determine whether the getter method is equal to the property name or is prepended by 'is' or 'get' - if (strcmp($type, 'bool') === 0 || strcmp($type, 'boolean') === 0) { - // Prepend 'is' to the getter method - $getter = 'is' . ucfirst($property); - } elseif (method_exists($this, $property) && is_object($value)) { - // The getter method is equal to the property name and the value is an actual object - $getter = $property; - $object = true; + $currentValues = array_map(function ($value) { + if (is_object($value)) { + if ($value instanceof ArraySerializableInterface) { + return $value->getArrayCopy(); } - - // Abort if the method does not exist - if (! method_exists($this, $getter)) { - continue; - } - - // Assign the contents of the property to the data array - $data[ $property ] = $object ? $this->$getter()->getArrayCopy() : $this->$getter(); } - } - return $data; + return $value; + }, get_object_vars($this)); + + // Filter out null values and return the remaining. + return array_filter($currentValues, function ($value) { + return ! is_null($value); + }); } } diff --git a/src/LabelsCollection.php b/src/LabelsCollection.php index 8858a50..19a0eaa 100644 --- a/src/LabelsCollection.php +++ b/src/LabelsCollection.php @@ -3,19 +3,20 @@ namespace Halfpastfour\PHPChartJS; use Halfpastfour\Collection\Collection\ArrayAccess; -use Zend\Json\Json; +use JsonSerializable; /** * Class LabelsCollection + * * @package Halfpastfour\PHPChartJS */ -class LabelsCollection extends ArrayAccess implements \JsonSerializable +class LabelsCollection extends ArrayAccess implements JsonSerializable { /** - * return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->data); + return $this->data; } } diff --git a/src/Options.php b/src/Options.php index bcf48dc..a2ce177 100644 --- a/src/Options.php +++ b/src/Options.php @@ -11,15 +11,15 @@ use Halfpastfour\PHPChartJS\Options\Scales; use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Tooltips; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Options * * @package Halfpastfour\PHPChartJS */ -class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonSerializable +class Options implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializable { use ChartOwned; use ArraySerializable; @@ -131,7 +131,7 @@ public function getOnClick() } /** - * @param Expr $onClick + * @param string $onClick * * @return $this */ @@ -215,12 +215,10 @@ public function setMaintainAspectRatio($flag) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, ['enableJsonExprFinder' => true]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Animation.php b/src/Options/Animation.php index ca7fd01..eb765a2 100644 --- a/src/Options/Animation.php +++ b/src/Options/Animation.php @@ -4,14 +4,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Animation + * * @package Halfpastfour\PHPChartJS\Options */ -class Animation implements ArraySerializableInterface, \JsonSerializable +class Animation implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -116,10 +117,10 @@ public function setOnComplete($onComplete) } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Elements.php b/src/Options/Elements.php index f306676..ad3b519 100644 --- a/src/Options/Elements.php +++ b/src/Options/Elements.php @@ -8,14 +8,14 @@ use Halfpastfour\PHPChartJS\Options\Elements\Line; use Halfpastfour\PHPChartJS\Options\Elements\Point; use Halfpastfour\PHPChartJS\Options\Elements\Rectangle; -use Zend\Json\Expr; -use Zend\Json\Json; +use JsonSerializable; /** * Class Elements + * * @package Halfpastfour\PHPChartJS\Options */ -class Elements implements ArraySerializableInterface, \JsonSerializable +class Elements implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -120,12 +120,10 @@ public function arc() } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Elements/Arc.php b/src/Options/Elements/Arc.php index 49139ea..fe04713 100644 --- a/src/Options/Elements/Arc.php +++ b/src/Options/Elements/Arc.php @@ -4,18 +4,20 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class Arc + * * @package Halfpastfour\PHPChartJS\Options\Elements */ -class Arc implements ArraySerializableInterface, \JsonSerializable +class Arc implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; /** * Arc fill color. + * * @default 'rgba(0,0,0,0.1)' * @var string */ @@ -23,6 +25,7 @@ class Arc implements ArraySerializableInterface, \JsonSerializable /** * Arc stroke color. + * * @default '#fff' * @var string */ @@ -30,6 +33,7 @@ class Arc implements ArraySerializableInterface, \JsonSerializable /** * Arc stroke width. + * * @default 2 * @var int */ @@ -45,11 +49,13 @@ public function getBackgroundColor() /** * @param string $backgroundColor + * * @return Arc */ public function setBackgroundColor($backgroundColor) { $this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor); + return $this; } @@ -63,11 +69,13 @@ public function getBorderColor() /** * @param string $borderColor + * * @return Arc */ public function setBorderColor($borderColor) { $this->borderColor = is_null($borderColor) ? null : strval($borderColor); + return $this; } @@ -81,21 +89,21 @@ public function getBorderWidth() /** * @param int $borderWidth + * * @return Arc */ public function setBorderWidth($borderWidth) { $this->borderWidth = intval($borderWidth); + return $this; } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } -} \ No newline at end of file +} diff --git a/src/Options/Elements/Line.php b/src/Options/Elements/Line.php index a447cc1..2483d87 100644 --- a/src/Options/Elements/Line.php +++ b/src/Options/Elements/Line.php @@ -4,19 +4,19 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class Line * @package Halfpastfour\PHPChartJS\Options\Elements */ -class Line implements ArraySerializableInterface, \JsonSerializable +class Line implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; /** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap */ - const CAP_STYLE_BUTT = 'butt'; - const CAP_STYLE_ROUND = 'round'; + const CAP_STYLE_BUTT = 'butt'; + const CAP_STYLE_ROUND = 'round'; const CAP_STYLE_SQUARE = 'square'; /** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin */ @@ -314,12 +314,10 @@ public function setStepped($stepped) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Elements/Point.php b/src/Options/Elements/Point.php index 4347883..06059d4 100644 --- a/src/Options/Elements/Point.php +++ b/src/Options/Elements/Point.php @@ -4,29 +4,31 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class Point + * * @package Halfpastfour\PHPChartJS\Options\Elements */ -class Point implements ArraySerializableInterface, \JsonSerializable +class Point implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; - const STYLE_CIRCLE = 'circle'; - const STYLE_CROSS = 'cross'; - const STYLE_CROSS_ROT = 'crossRot'; - const STYLE_DASH = 'dash'; - const STYLE_LINE = 'line'; - const STYLE_RECT = 'rect'; + const STYLE_CIRCLE = 'circle'; + const STYLE_CROSS = 'cross'; + const STYLE_CROSS_ROT = 'crossRot'; + const STYLE_DASH = 'dash'; + const STYLE_LINE = 'line'; + const STYLE_RECT = 'rect'; const STYLE_RECT_ROUNDED = 'rectRounded'; - const STYLE_RECT_ROT = 'rectRot'; - const STYLE_RECT_STAR = 'star'; - const STYLE_TRIANGLE = 'triangle'; + const STYLE_RECT_ROT = 'rectRot'; + const STYLE_RECT_STAR = 'star'; + const STYLE_TRIANGLE = 'triangle'; /** * Point radius. + * * @default 3 * @var int */ @@ -34,6 +36,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Point style. + * * @default self::STYLE_CIRCLE * @var string */ @@ -41,6 +44,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Point rotation (in degrees). + * * @default 0 * @var int */ @@ -48,6 +52,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Point fill color. + * * @default 'rgba(0,0,0,0.1)' * @var string */ @@ -55,6 +60,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Point stroke width. + * * @default 1 * @var int */ @@ -62,6 +68,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Point stroke color. + * * @default 'rgba(0,0,0,0.1)' * @var string */ @@ -69,6 +76,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Extra radius added to point radius for hit detection. + * * @default 1 * @var int */ @@ -76,6 +84,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Point radius when hovered. + * * @default 4 * @var int */ @@ -83,6 +92,7 @@ class Point implements ArraySerializableInterface, \JsonSerializable /** * Stroke width when hovered. + * * @default 1 * @var int */ @@ -98,11 +108,13 @@ public function getRadius() /** * @param int $radius + * * @return Point */ public function setRadius($radius) { $this->radius = intval($radius); + return $this; } @@ -116,11 +128,13 @@ public function getPointStyle() /** * @param string $pointStyle + * * @return Point */ public function setPointStyle($pointStyle) { $this->pointStyle = is_null($pointStyle) ? null : strval($pointStyle); + return $this; } @@ -134,11 +148,13 @@ public function getRotation() /** * @param int $rotation + * * @return Point */ public function setRotation($rotation) { $this->rotation = intval($rotation); + return $this; } @@ -152,11 +168,13 @@ public function getBackgroundColor() /** * @param string $backgroundColor + * * @return Point */ public function setBackgroundColor($backgroundColor) { $this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor); + return $this; } @@ -170,11 +188,13 @@ public function getBorderWidth() /** * @param int $borderWidth + * * @return Point */ public function setBorderWidth($borderWidth) { $this->borderWidth = intval($borderWidth); + return $this; } @@ -188,11 +208,13 @@ public function getBorderColor() /** * @param string $borderColor + * * @return Point */ public function setBorderColor($borderColor) { $this->borderColor = is_null($borderColor) ? null : strval($borderColor); + return $this; } @@ -206,11 +228,13 @@ public function getHitRadius() /** * @param int $hitRadius + * * @return Point */ public function setHitRadius($hitRadius) { $this->hitRadius = intval($hitRadius); + return $this; } @@ -224,11 +248,13 @@ public function getHoverRadius() /** * @param int $hoverRadius + * * @return Point */ public function setHoverRadius($hoverRadius) { $this->hoverRadius = intval($hoverRadius); + return $this; } @@ -242,21 +268,21 @@ public function getHoverBorderWidth() /** * @param int $hoverBorderWidth + * * @return Point */ public function setHoverBorderWidth($hoverBorderWidth) { $this->hoverBorderWidth = intval($hoverBorderWidth); + return $this; } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Elements/Rectangle.php b/src/Options/Elements/Rectangle.php index 17a4812..e30adc9 100644 --- a/src/Options/Elements/Rectangle.php +++ b/src/Options/Elements/Rectangle.php @@ -4,23 +4,25 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class Rectangle + * * @package Halfpastfour\PHPChartJS\Options\Elements */ -class Rectangle implements ArraySerializableInterface, \JsonSerializable +class Rectangle implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; const BORDER_SKIPPED_BOTTOM = 'bottom'; - const BORDER_SKIPPED_LEFT = 'left'; - const BORDER_SKIPPED_TOP = 'top'; - const BORDER_SKIPPED_RIGHT = 'right'; + const BORDER_SKIPPED_LEFT = 'left'; + const BORDER_SKIPPED_TOP = 'top'; + const BORDER_SKIPPED_RIGHT = 'right'; /** * Bar fill color. + * * @default 'rgba(0,0,0,0.1)' * @var string */ @@ -28,6 +30,7 @@ class Rectangle implements ArraySerializableInterface, \JsonSerializable /** * Bar stroke width. + * * @default 0 * @var int */ @@ -35,6 +38,7 @@ class Rectangle implements ArraySerializableInterface, \JsonSerializable /** * Bar stroke color. + * * @default 'rgba(0,0,0,0.1)' * @var string */ @@ -42,6 +46,7 @@ class Rectangle implements ArraySerializableInterface, \JsonSerializable /** * Skipped (excluded) border: 'bottom', 'left', 'top' or 'right'. + * * @default self::BORDER_SKIPPED_BOTTOM * @var string */ @@ -57,11 +62,13 @@ public function getBackgroundColor() /** * @param string $backgroundColor + * * @return Rectangle */ public function setBackgroundColor($backgroundColor) { $this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor); + return $this; } @@ -75,11 +82,13 @@ public function getBorderWidth() /** * @param int $borderWidth + * * @return Rectangle */ public function setBorderWidth($borderWidth) { $this->borderWidth = intval($borderWidth); + return $this; } @@ -93,11 +102,13 @@ public function getBorderColor() /** * @param string $borderColor + * * @return Rectangle */ public function setBorderColor($borderColor) { $this->borderColor = is_null($borderColor) ? null : strval($borderColor); + return $this; } @@ -111,23 +122,21 @@ public function getBorderSkipped() /** * @param string $borderSkipped + * * @return Rectangle */ public function setBorderSkipped($borderSkipped) { $this->borderSkipped = is_null($borderSkipped) ? null : strval($borderSkipped); + return $this; } - - /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Hover.php b/src/Options/Hover.php index 48a6095..5156a2b 100644 --- a/src/Options/Hover.php +++ b/src/Options/Hover.php @@ -4,14 +4,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Hover + * * @package Halfpastfour\PHPChartJS\Options */ -class Hover implements ArraySerializableInterface, \JsonSerializable +class Hover implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -124,12 +125,10 @@ public function setOnHover($onHover) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Layout.php b/src/Options/Layout.php index 6f7f7ff..f48889f 100644 --- a/src/Options/Layout.php +++ b/src/Options/Layout.php @@ -5,14 +5,14 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\Options\Layout\Padding; -use Zend\Json\Json; +use JsonSerializable; /** * Class Layout * * @package Halfpastfour\PHPChartJS\Options */ -class Layout implements ArraySerializableInterface, \JsonSerializable +class Layout implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -50,12 +50,10 @@ public function padding() } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Layout/Padding.php b/src/Options/Layout/Padding.php index 67d2539..c775b29 100644 --- a/src/Options/Layout/Padding.php +++ b/src/Options/Layout/Padding.php @@ -4,13 +4,13 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class Padding * @package Halfpastfour\PHPChartJS\Options\Layout */ -class Padding implements ArraySerializableInterface, \JsonSerializable +class Padding implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -115,10 +115,10 @@ public function setTop($top) } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Legend.php b/src/Options/Legend.php index ca3e1fa..5324721 100644 --- a/src/Options/Legend.php +++ b/src/Options/Legend.php @@ -5,14 +5,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\LabelsCollection; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Legend + * * @package Halfpastfour\PHPChartJS\Options */ -class Legend implements ArraySerializableInterface, \JsonSerializable +class Legend implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -59,14 +60,6 @@ public function isDisplay() return $this->display; } - /** - * @return bool - */ - public function isDisplay() - { - return $this->display; - } - /** * @param bool $display * @@ -74,7 +67,7 @@ public function isDisplay() */ public function setDisplay($display) { - $this->display = ! ! $display; + $this->display = boolval($display); return $this; } @@ -107,14 +100,6 @@ public function isFullWidth() return $this->fullWidth; } - /** - * @return bool - */ - public function isFullWidth() - { - return $this->fullWidth; - } - /** * @param bool $fullWidth * @@ -122,7 +107,7 @@ public function isFullWidth() */ public function setFullWidth($fullWidth) { - $this->fullWidth = ! ! $fullWidth; + $this->fullWidth = boolval($fullWidth); return $this; } @@ -187,14 +172,6 @@ public function isReverse() return $this->reverse; } - /** - * @return bool - */ - public function isReverse() - { - return $this->reverse; - } - /** * @param bool $reverse * @@ -202,18 +179,16 @@ public function isReverse() */ public function setReverse($reverse) { - $this->reverse = ! ! $reverse; + $this->reverse = boolval($reverse); return $this; } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Legend/Labels.php b/src/Options/Legend/Labels.php index 1513b71..7b7fcc3 100644 --- a/src/Options/Legend/Labels.php +++ b/src/Options/Legend/Labels.php @@ -4,14 +4,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class PieLegend + * * @package Halfpastfour\PHPChartJS\Options\Legend */ -class Labels implements ArraySerializableInterface, \JsonSerializable +class Labels implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -203,14 +204,6 @@ public function isUsePointStyle() return $this->usePointStyle; } - /** - * @return bool - */ - public function isUsePointStyle() - { - return $this->usePointStyle; - } - /** * @param bool $usePointStyle * @@ -224,12 +217,10 @@ public function setUsePointStyle($usePointStyle) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scale.php b/src/Options/Scale.php index 13cf836..66f6c2d 100644 --- a/src/Options/Scale.php +++ b/src/Options/Scale.php @@ -7,13 +7,14 @@ use Halfpastfour\PHPChartJS\Options\Scales\GridLines; use Halfpastfour\PHPChartJS\Options\Scales\ScaleLabel; use Halfpastfour\PHPChartJS\Options\Scales\Ticks; -use Zend\Json\Json; +use JsonSerializable; /** * Class Scale + * * @package Halfpastfour\PHPChartJS\Options */ -abstract class Scale implements ArraySerializableInterface, \JsonSerializable +abstract class Scale implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -160,14 +161,6 @@ public function isDisplay() return $this->display; } - /** - * @return bool - */ - public function isDisplay() - { - return $this->display; - } - /** * @param bool $display * @@ -208,14 +201,6 @@ public function isStacked() return $this->stacked; } - /** - * @return bool - */ - public function isStacked() - { - return $this->stacked; - } - /** * @param bool $stacked * @@ -609,12 +594,10 @@ public function ticks() } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales.php b/src/Options/Scales.php index 8f4c926..573e71a 100644 --- a/src/Options/Scales.php +++ b/src/Options/Scales.php @@ -8,13 +8,13 @@ use Halfpastfour\PHPChartJS\Options\Scales\XAxisCollection; use Halfpastfour\PHPChartJS\Options\Scales\YAxis; use Halfpastfour\PHPChartJS\Options\Scales\YAxisCollection; -use Zend\Json\Json; +use JsonSerializable; /** * Class Scales * @package Halfpastfour\PHPChartJS\Options */ -class Scales implements ArraySerializableInterface, \JsonSerializable +class Scales implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -69,10 +69,10 @@ public function getYAxes() } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index 47f6d05..e626a45 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -6,14 +6,14 @@ use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\Delegate\NumberUtils; use Halfpastfour\PHPChartJS\Delegate\StringUtils; -use Zend\Json\Json; +use JsonSerializable; /** * Class GridLines * * @package Halfpastfour\PHPChartJS\Options\Scales */ -class GridLines implements ArraySerializableInterface, \JsonSerializable +class GridLines implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; use StringUtils; @@ -87,14 +87,6 @@ public function isDisplay() return $this->display; } - /** - * @return bool - */ - public function isDisplay() - { - return $this->display; - } - /** * @param bool $display * @@ -205,14 +197,6 @@ public function isDrawBorder() return $this->drawBorder; } - /** - * @return bool - */ - public function isDrawBorder() - { - return $this->drawBorder; - } - /** * @param bool $drawBorder * @@ -233,14 +217,6 @@ public function isDrawOnChartArea() return $this->drawOnChartArea; } - /** - * @return bool - */ - public function isDrawOnChartArea() - { - return $this->drawOnChartArea; - } - /** * @param bool $drawOnChartArea * @@ -261,14 +237,6 @@ public function isDrawTicks() return $this->drawTicks; } - /** - * @return bool - */ - public function isDrawTicks() - { - return $this->drawTicks; - } - /** * @param bool $drawTicks * @@ -349,14 +317,6 @@ public function isOffsetGridLines() return $this->offsetGridLines; } - /** - * @return bool - */ - public function isOffsetGridLines() - { - return $this->offsetGridLines; - } - /** * @param bool $offsetGridLines * @@ -370,12 +330,10 @@ public function setOffsetGridLines($offsetGridLines) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales/ScaleLabel.php b/src/Options/Scales/ScaleLabel.php index 053b26f..78a1447 100644 --- a/src/Options/Scales/ScaleLabel.php +++ b/src/Options/Scales/ScaleLabel.php @@ -4,13 +4,14 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class ScaleLabel + * * @package Halfpastfour\PHPChartJS\Options\Scales */ -class ScaleLabel implements ArraySerializableInterface, \JsonSerializable +class ScaleLabel implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -52,14 +53,6 @@ public function isDisplay() return $this->display; } - /** - * @return bool - */ - public function isDisplay() - { - return $this->display; - } - /** * @param bool $display * @@ -173,12 +166,10 @@ public function setFontStyle($fontStyle) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales/Ticks.php b/src/Options/Scales/Ticks.php index 8c0512b..4737233 100644 --- a/src/Options/Scales/Ticks.php +++ b/src/Options/Scales/Ticks.php @@ -4,15 +4,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Ticks * * @package Halfpastfour\PHPChartJS\Options\Scales */ -class Ticks implements ArraySerializableInterface, \JsonSerializable +class Ticks implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -134,14 +134,6 @@ public function isBeginAtZero() return $this->beginAtZero; } - /** - * @return bool - */ - public function isBeginAtZero() - { - return $this->beginAtZero; - } - /** * @param bool $beginAtZero * @@ -182,14 +174,6 @@ public function isAutoSkip() return $this->autoSkip; } - /** - * @return bool - */ - public function isAutoSkip() - { - return $this->autoSkip; - } - /** * @param bool $autoSkip * @@ -197,7 +181,7 @@ public function isAutoSkip() */ public function setAutoSkip($autoSkip) { - $this->autoSkip = ! ! $autoSkip; + $this->autoSkip = boolval($autoSkip); return $this; } @@ -250,14 +234,6 @@ public function isDisplay() return $this->display; } - /** - * @return bool - */ - public function isDisplay() - { - return $this->display; - } - /** * @param bool $display * @@ -265,7 +241,7 @@ public function isDisplay() */ public function setDisplay($display) { - $this->display = ! ! $display; + $this->display = boolval($display); return $this; } @@ -418,14 +394,6 @@ public function isMirror() return $this->mirror; } - /** - * @return bool - */ - public function isMirror() - { - return $this->mirror; - } - /** * @param bool $mirror * @@ -433,7 +401,7 @@ public function isMirror() */ public function setMirror($mirror) { - $this->mirror = ! ! $mirror; + $this->mirror = boolval($mirror); return $this; } @@ -466,14 +434,6 @@ public function isReverse() return $this->reverse; } - /** - * @return bool - */ - public function isReverse() - { - return $this->reverse; - } - /** * @param bool $reverse * @@ -481,7 +441,7 @@ public function isReverse() */ public function setReverse($reverse) { - $this->reverse = ! ! $reverse; + $this->reverse = boolval($reverse); return $this; } @@ -507,12 +467,10 @@ public function setMax($max) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, ['enableJsonExprFinder' => true]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales/XAxis.php b/src/Options/Scales/XAxis.php index 436a5e8..6e3793b 100644 --- a/src/Options/Scales/XAxis.php +++ b/src/Options/Scales/XAxis.php @@ -3,10 +3,10 @@ namespace Halfpastfour\PHPChartJS\Options\Scales; use Halfpastfour\PHPChartJS\Options\Scale; -use Zend\Json\Json; /** * Class XAxis + * * @package Halfpastfour\PHPChartJS\Options\Scales */ class XAxis extends Scale @@ -62,10 +62,10 @@ public function setBarPercentage($barPercentage) } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales/XAxisCollection.php b/src/Options/Scales/XAxisCollection.php index a0ada70..bc9a9a7 100644 --- a/src/Options/Scales/XAxisCollection.php +++ b/src/Options/Scales/XAxisCollection.php @@ -3,13 +3,15 @@ namespace Halfpastfour\PHPChartJS\Options\Scales; use Halfpastfour\Collection\Collection\ArrayAccess; -use Zend\Json\Json; +use Halfpastfour\PHPChartJS\ArraySerializableInterface; +use JsonSerializable; /** * Class XAxisCollection + * * @package Halfpastfour\PHPChartJS\Collection */ -class XAxisCollection extends ArrayAccess implements \JsonSerializable +class XAxisCollection extends ArrayAccess implements ArraySerializableInterface, JsonSerializable { /** * @return array @@ -26,10 +28,10 @@ public function getArrayCopy() } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Scales/YAxisCollection.php b/src/Options/Scales/YAxisCollection.php index 7af794e..03f4d6c 100644 --- a/src/Options/Scales/YAxisCollection.php +++ b/src/Options/Scales/YAxisCollection.php @@ -3,13 +3,15 @@ namespace Halfpastfour\PHPChartJS\Options\Scales; use Halfpastfour\Collection\Collection\ArrayAccess; -use Zend\Json\Json; +use Halfpastfour\PHPChartJS\ArraySerializableInterface; +use JsonSerializable; /** * Class YAxisCollection + * * @package Halfpastfour\PHPChartJS\Collection */ -class YAxisCollection extends ArrayAccess implements \JsonSerializable +class YAxisCollection extends ArrayAccess implements ArraySerializableInterface, JsonSerializable { /** * @return array @@ -26,10 +28,10 @@ public function getArrayCopy() } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Title.php b/src/Options/Title.php index 9291442..1e31716 100644 --- a/src/Options/Title.php +++ b/src/Options/Title.php @@ -4,13 +4,14 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use Zend\Json\Json; +use JsonSerializable; /** * Class LineOptions + * * @package Halfpastfour\PHPChartJS\Options */ -class Title implements ArraySerializableInterface, \JsonSerializable +class Title implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -67,14 +68,6 @@ public function isDisplay() return $this->display; } - /** - * @return bool - */ - public function isDisplay() - { - return $this->display; - } - /** * @param bool $display * @@ -82,7 +75,7 @@ public function isDisplay() */ public function setDisplay($display) { - $this->display = ! ! $display; + $this->display = boolval($display); return $this; } @@ -115,14 +108,6 @@ public function isFullWidth() return $this->fullWidth; } - /** - * @return bool - */ - public function isFullWidth() - { - return $this->fullWidth; - } - /** * @param bool $fullWidth * @@ -130,7 +115,7 @@ public function isFullWidth() */ public function setFullWidth($fullWidth) { - $this->fullWidth = ! ! $fullWidth; + $this->fullWidth = boolval($fullWidth); return $this; } @@ -256,12 +241,10 @@ public function setText($text) } /** - * @return string - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy()); + return $this->getArrayCopy(); } } diff --git a/src/Options/Tooltips.php b/src/Options/Tooltips.php index 84e12cc..6a26380 100644 --- a/src/Options/Tooltips.php +++ b/src/Options/Tooltips.php @@ -5,14 +5,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\Options\Tooltips\Callbacks; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Tooltips + * * @package Halfpastfour\PHPChartJS\Options */ -class Tooltips implements ArraySerializableInterface, \JsonSerializable +class Tooltips implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -184,14 +185,6 @@ public function isEnabled() return $this->enabled; } - /** - * @return bool - */ - public function isEnabled() - { - return $this->enabled; - } - /** * @param bool $enabled * @@ -199,7 +192,7 @@ public function isEnabled() */ public function setEnabled($enabled) { - $this->enabled = ! ! $enabled; + $this->enabled = boolval($enabled); return $this; } @@ -252,14 +245,6 @@ public function isIntersect() return $this->intersect; } - /** - * @return bool - */ - public function isIntersect() - { - return $this->intersect; - } - /** * @param bool $intersect * @@ -267,7 +252,7 @@ public function isIntersect() */ public function setIntersect($intersect) { - $this->intersect = ! ! $intersect; + $this->intersect = boolval($intersect); return $this; } @@ -800,14 +785,6 @@ public function isDisplayColors() return $this->displayColors; } - /** - * @return bool - */ - public function isDisplayColors() - { - return $this->displayColors; - } - /** * @param bool $displayColors * @@ -815,7 +792,7 @@ public function isDisplayColors() */ public function setDisplayColors($displayColors) { - $this->displayColors = ! ! $displayColors; + $this->displayColors = boolval($displayColors); return $this; } @@ -833,12 +810,10 @@ public function callbacks() } /** - * @return mixed - * @throws \ReflectionException - * @throws \Zend_Reflection_Exception + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Options/Tooltips/Callbacks.php b/src/Options/Tooltips/Callbacks.php index 62c0778..8b72e8e 100644 --- a/src/Options/Tooltips/Callbacks.php +++ b/src/Options/Tooltips/Callbacks.php @@ -4,14 +4,15 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; +use JsonSerializable; use Zend\Json\Expr; -use Zend\Json\Json; /** * Class Callbacks + * * @package Halfpastfour\PHPChartJS\Tooltips */ -class Callbacks implements ArraySerializableInterface, \JsonSerializable +class Callbacks implements ArraySerializableInterface, JsonSerializable { use ArraySerializable; @@ -316,10 +317,10 @@ public function setDataPoints($dataPoints) } /** - * @return string + * @return array */ public function jsonSerialize() { - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); + return $this->getArrayCopy(); } } diff --git a/src/Renderer/Html.php b/src/Renderer/Html.php index 5d5fd71..f67dc90 100644 --- a/src/Renderer/Html.php +++ b/src/Renderer/Html.php @@ -2,8 +2,11 @@ namespace Halfpastfour\PHPChartJS\Renderer; +use DOMDocument; + /** * Class Renderer + * * @package Halfpastfour\PHPChartJS */ class Html extends Renderer @@ -17,7 +20,7 @@ class Html extends Renderer */ public function render($flags = null) { - $dom = new \DOMDocument(); + $dom = new DOMDocument(); // Render canvas HTML element $canvas = $dom->createElement('canvas'); diff --git a/src/Renderer/Json.php b/src/Renderer/Json.php index fff4b6e..7cc311f 100644 --- a/src/Renderer/Json.php +++ b/src/Renderer/Json.php @@ -2,10 +2,9 @@ namespace Halfpastfour\PHPChartJS\Renderer; -use Zend\Json\Json as JsonHelper; - /** * Class Json + * * @package Halfpastfour\PHPChartJS\Renderer */ class Json extends Renderer @@ -16,8 +15,9 @@ class Json extends Renderer * @param int|null $flags * * @return string + * @throws \ReflectionException */ - public function render($flags = null) + public function render($flags = JSON_PRETTY_PRINT) { $config = [ 'type' => constant(get_class($this->chart) . "::TYPE"), @@ -39,11 +39,6 @@ public function render($flags = null) $config['options'] = $options; } - $output = JsonHelper::encode($config, false, [ 'enableJsonExprFinder' => true ]); - if ($flags & Renderer::RENDER_PRETTY) { - $output = JsonHelper::prettyPrint($output); - } - - return $output; + return json_encode($config, $flags); } } diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 318e8e6..5d67d92 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -13,7 +13,7 @@ abstract class Renderer implements RendererInterface /** * Flag used for rendering JSON in pretty mode. */ - const RENDER_PRETTY = 1; + const RENDER_PRETTY = JSON_PRETTY_PRINT; /** * @var Chart The chart that needs to be rendered. From b73938ef9fe15a314f67ba91d89d3baaf0cfc7b3 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 22:39:11 +0100 Subject: [PATCH 14/23] Update unit tests to expect the arrays being returned by the jsonSerialize method. --- test/unit/Collection/DataTest.php | 6 +- test/unit/DataSetCollectionTest.php | 32 +++++++-- test/unit/DataSetTest.php | 35 ++++----- test/unit/LabelsCollectionTest.php | 10 +-- test/unit/Options/ClickTest.php | 10 +-- test/unit/Options/Elements/ArcTest.php | 6 +- test/unit/Options/Elements/LineTest.php | 72 ++++++++++--------- test/unit/Options/Elements/PointTest.php | 60 ++++++++-------- test/unit/Options/Elements/RectangleTest.php | 6 +- test/unit/Options/ElementsTest.php | 12 ++-- test/unit/Options/HoverTest.php | 6 +- test/unit/Options/Layout/PaddingTest.php | 7 +- test/unit/Options/LayoutTest.php | 9 +-- test/unit/Options/Legend/LabelsTest.php | 5 +- test/unit/Options/LegendTest.php | 6 +- test/unit/Options/ScaleTest.php | 7 +- test/unit/Options/Scales/GridLinesTest.php | 12 ++-- test/unit/Options/Scales/ScaleLabelTest.php | 6 +- test/unit/Options/Scales/TicksTest.php | 8 ++- .../Options/Scales/XAxisCollectionTest.php | 12 ++-- test/unit/Options/ScalesTest.php | 12 ++-- test/unit/Options/TitleTest.php | 5 +- test/unit/Options/Tooltips/CallbacksTest.php | 17 ++--- test/unit/Options/TooltipsTest.php | 6 +- test/unit/OptionsTest.php | 14 ++-- test/unit/RendererTest.php | 40 ++++++----- 26 files changed, 246 insertions(+), 175 deletions(-) diff --git a/test/unit/Collection/DataTest.php b/test/unit/Collection/DataTest.php index 24395a3..07e5867 100644 --- a/test/unit/Collection/DataTest.php +++ b/test/unit/Collection/DataTest.php @@ -3,12 +3,14 @@ namespace Collection; use Halfpastfour\PHPChartJS\Collection\Data; +use PHPUnit_Framework_TestCase; /** * Class DataTest + * * @package Collection */ -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends PHPUnit_Framework_TestCase { /** * @var Data @@ -28,7 +30,7 @@ public function setUp() */ public function testJsonSerializeEmpty() { - $expected = "[]"; + $expected = []; $result = $this->data->jsonSerialize(); self::assertSame($expected, $result); } diff --git a/test/unit/DataSetCollectionTest.php b/test/unit/DataSetCollectionTest.php index dd6773b..2565e16 100644 --- a/test/unit/DataSetCollectionTest.php +++ b/test/unit/DataSetCollectionTest.php @@ -2,23 +2,39 @@ namespace Halfpastfour\PHPChartJS; -class DataSetCollectionTest extends \PHPUnit_Framework_TestCase +use PHPUnit_Framework_TestCase; + +/** + * Class DataSetCollectionTest + * + * @package Halfpastfour\PHPChartJS + */ +class DataSetCollectionTest extends PHPUnit_Framework_TestCase { /** @var DataSetCollection */ private $dataSetCollection; + /** + * + */ public function setUp() { $this->dataSetCollection = new DataSetCollection(); } + /** + * + */ public function testGetArrayCopyEmpty() { $expected = []; - $result = $this->dataSetCollection->getArrayCopy(); + $result = $this->dataSetCollection->getArrayCopy(); self::assertSame($expected, $result); } + /** + * + */ public function testGetArrayCopyNonEmpty() { $expected = [[]]; @@ -27,16 +43,22 @@ public function testGetArrayCopyNonEmpty() self::assertSame($expected, $result); } + /** + * + */ public function testJsonSerializeEmpty() { - $expected = '[]'; - $result = $this->dataSetCollection->jsonSerialize(); + $expected = []; + $result = $this->dataSetCollection->jsonSerialize(); self::assertSame($expected, $result); } + /** + * + */ public function testJsonSerializeNonEmpty() { - $expected = '[[]]'; + $expected = [[]]; $this->dataSetCollection->append(new DataSet()); $result = $this->dataSetCollection->jsonSerialize(); self::assertSame($expected, $result); diff --git a/test/unit/DataSetTest.php b/test/unit/DataSetTest.php index da63d8f..c8daea5 100644 --- a/test/unit/DataSetTest.php +++ b/test/unit/DataSetTest.php @@ -9,12 +9,15 @@ use Halfpastfour\PHPChartJS\ChartOwnedInterface; use Halfpastfour\PHPChartJS\Collection\Data; use Halfpastfour\PHPChartJS\DataSet; +use JsonSerializable; +use PHPUnit_Framework_TestCase; /** * Class DataSetTest + * * @package Test */ -class DataSetTest extends \PHPUnit_Framework_TestCase +class DataSetTest extends PHPUnit_Framework_TestCase { /** * @@ -28,7 +31,7 @@ public function testImplementation() $dataSet, 'Class implements ArraySerializableInterface' ); - $this->assertInstanceOf(\JsonSerializable::class, $dataSet, 'Class implements JsonSerializable'); + $this->assertInstanceOf(JsonSerializable::class, $dataSet, 'Class implements JsonSerializable'); } /** @@ -75,7 +78,7 @@ public function testData() $this->assertInstanceOf(Data::class, $dataCollection, 'The data collection is the right class'); $this->assertInstanceOf(ArrayAccess::class, $dataCollection, 'The data collection extends Collection'); $this->assertInstanceOf( - \JsonSerializable::class, + JsonSerializable::class, $dataCollection, 'The data collection implements JsonSerializable' ); @@ -106,7 +109,7 @@ public function testBackgroundColor() $dataSet->setBackgroundColor('#fff'); $this->assertEquals('#fff', $dataSet->getBackgroundColor()); - $backgroundColorArray = [ '#fff', 'rgb( 255, 255, 255 )', 'rgba( 255, 255, 255, .5 )', 'white' ]; + $backgroundColorArray = ['#fff', 'rgb( 255, 255, 255 )', 'rgba( 255, 255, 255, .5 )', 'white']; $dataSet->setBackgroundColor($backgroundColorArray); $this->assertEquals( $backgroundColorArray, @@ -127,7 +130,7 @@ public function testBorderColor() $dataSet->setBorderColor('#fff'); $this->assertEquals('#fff', $dataSet->getBorderColor(), 'The border color is set and returned correctly'); - $borderColorArray = [ '#fff', 'rgb( 255, 255, 255 )', 'rgba( 255, 255, 255, .5 )', 'white' ]; + $borderColorArray = ['#fff', 'rgb( 255, 255, 255 )', 'rgba( 255, 255, 255, .5 )', 'white']; $dataSet->setBorderColor($borderColorArray); $this->assertEquals( $borderColorArray, @@ -168,9 +171,9 @@ public function testBorderWidth() $this->assertTrue(is_int($dataSet->getBorderWidth()), 'Return type should be int'); $this->assertEquals(0, $dataSet->getBorderWidth(), 'The border width should equal int 0'); - $dataSet->setBorderWidth([ 10, '20', '30abc', 40.00, 'abc50' ]); + $dataSet->setBorderWidth([10, '20', '30abc', 40.00, 'abc50']); $this->assertTrue(is_array($dataSet->getBorderWidth()), 'Return type should be array'); - $this->assertEquals([ 10, 20, 30, 40, 0 ], $dataSet->getBorderWidth(), 'Return value should be array of int'); + $this->assertEquals([10, 20, 30, 40, 0], $dataSet->getBorderWidth(), 'Return value should be array of int'); } /** @@ -201,10 +204,10 @@ public function testAxes() $this->assertInstanceOf(DataSet::class, $dataSet->setXAxisID('myXAxis')); $this->assertEquals('myXAxis', $dataSet->getXAxisID(), 'The correct value is returned'); - $this->assertArraySubset([ 'xAxisID' => 'myXAxis' ], $dataSet->getArrayCopy()); + $this->assertArraySubset(['xAxisID' => 'myXAxis'], $dataSet->getArrayCopy()); $this->assertArraySubset( - [ 'xAxisID' => 'myXAxis' ], - json_decode($dataSet->jsonSerialize(), true), + ['xAxisID' => 'myXAxis'], + $dataSet->jsonSerialize(), 'Serialized data is not correct' ); @@ -217,7 +220,7 @@ public function testAxes() 'xAxisID' => 'myXAxis', 'yAxisID' => 'myYAxis', ], - json_decode($dataSet->jsonSerialize(), true), + $dataSet->jsonSerialize(), 'The serialized data is not correct' ); } @@ -234,7 +237,7 @@ public function testHoverBackgroundColor() $this->assertInstanceOf(DataSet::class, $dataSet->setHoverBackgroundColor('#fff')); $this->assertEquals('#fff', $dataSet->getHoverBackgroundColor(), 'The correct value is returned'); - $newColors = [ 'silver', '#fff', 'rgb( 0, 0, 0 )', 'rgba( 255, 255, 255, .5 )' ]; + $newColors = ['silver', '#fff', 'rgb( 0, 0, 0 )', 'rgba( 255, 255, 255, .5 )']; $dataSet->setHoverBackgroundColor($newColors); $this->assertEquals($newColors, $dataSet->getHoverBackgroundColor(), 'The correct value is returned'); } @@ -251,9 +254,9 @@ public function testHoverBorderColor() $this->assertInstanceOf(DataSet::class, $dataSet->setHoverBorderColor('#fff')); $this->assertEquals('#fff', $dataSet->getHoverBorderColor(), 'The correct value is returned'); - $dataSet->setHoverBorderColor([ 'silver', '#fff', 'rgb( 0, 0, 0 )', 'rgba( 255, 255, 255, .5 )', 0 ]); + $dataSet->setHoverBorderColor(['silver', '#fff', 'rgb( 0, 0, 0 )', 'rgba( 255, 255, 255, .5 )', 0]); $this->assertEquals( - [ 'silver', '#fff', 'rgb( 0, 0, 0 )', 'rgba( 255, 255, 255, .5 )', '0' ], + ['silver', '#fff', 'rgb( 0, 0, 0 )', 'rgba( 255, 255, 255, .5 )', '0'], $dataSet->getHoverBorderColor(), 'The correct value is returned' ); @@ -271,7 +274,7 @@ public function testHoverBorderWidth() $this->assertInstanceOf(DataSet::class, $dataSet->setHoverBorderWidth(1)); $this->assertEquals(1, $dataSet->getHoverBorderWidth(), 'The correct value is returned'); - $dataSet->setHoverBorderWidth([ 1, 10, '5a', 0 ]); - $this->assertEquals([ 1, 10, 5, 0 ], $dataSet->getHoverBorderWidth(), 'The correct value is returned'); + $dataSet->setHoverBorderWidth([1, 10, '5a', 0]); + $this->assertEquals([1, 10, 5, 0], $dataSet->getHoverBorderWidth(), 'The correct value is returned'); } } diff --git a/test/unit/LabelsCollectionTest.php b/test/unit/LabelsCollectionTest.php index b2926a0..8e98bce 100644 --- a/test/unit/LabelsCollectionTest.php +++ b/test/unit/LabelsCollectionTest.php @@ -3,12 +3,14 @@ namespace Test; use Halfpastfour\PHPChartJS\LabelsCollection; +use PHPUnit_Framework_TestCase; /** * Class LabelsCollectionTest + * * @package Test */ -class LabelsCollectionTest extends \PHPUnit_Framework_TestCase +class LabelsCollectionTest extends PHPUnit_Framework_TestCase { /** * @var LabelsCollection @@ -23,7 +25,7 @@ class LabelsCollectionTest extends \PHPUnit_Framework_TestCase /** * @var array */ - private $labelsArray = [ 'startingLabel', 'label1', 'label2', 'endLabel' ]; + private $labelsArray = ['startingLabel', 'label1', 'label2', 'endLabel']; /** * @@ -39,7 +41,7 @@ public function setUp() */ public function testJsonSerializeEmpty() { - $expected = '[]'; + $expected = []; $result = $this->labelsCollectionEmpty->jsonSerialize(); self::assertSame($expected, $result); } @@ -49,7 +51,7 @@ public function testJsonSerializeEmpty() */ public function testJsonSerialize() { - $expected = "[\"" . implode("\",\"", $this->labelsArray) . "\"]"; + $expected = $this->labelsArray; $result = $this->labelsCollection->jsonSerialize(); self::assertSame($expected, $result); } diff --git a/test/unit/Options/ClickTest.php b/test/unit/Options/ClickTest.php index 6e2cdc5..007b864 100644 --- a/test/unit/Options/ClickTest.php +++ b/test/unit/Options/ClickTest.php @@ -3,14 +3,16 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options; +use PHPUnit_Framework_TestCase; use Test\TestUtils; use Zend\Json\Expr; /** * Class ClickTest + * * @package Test\Options */ -class ClickTest extends \PHPUnit_Framework_TestCase +class ClickTest extends PHPUnit_Framework_TestCase { /** * @var Options @@ -21,7 +23,7 @@ class ClickTest extends \PHPUnit_Framework_TestCase 'onClick' => null, ]; - private $input_data_no_expressions = ['onClick' => null]; + private $input_data_no_expressions = ['onClick' => null]; private $input_data_with_expressions = null; /** @@ -29,7 +31,7 @@ class ClickTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->options = new Options(); + $this->options = new Options(); $this->input_data_with_expressions = ['onClick' => new Expr('function(event, array) { echo "onClick"; }')]; } @@ -62,7 +64,7 @@ public function testJsonSerializeWithoutExpressions() { $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); TestUtils::setAttributes($this->options, $this->input_data_no_expressions); - $result = json_decode($this->options->jsonSerialize(), true); + $result = $this->options->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Elements/ArcTest.php b/test/unit/Options/Elements/ArcTest.php index d303732..36bab6b 100644 --- a/test/unit/Options/Elements/ArcTest.php +++ b/test/unit/Options/Elements/ArcTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Elements; use Halfpastfour\PHPChartJS\Options\Elements\Arc; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class ArcTest + * * @package Test\Options\Elements */ -class ArcTest extends \PHPUnit_Framework_TestCase +class ArcTest extends PHPUnit_Framework_TestCase { /** * @var Arc @@ -79,7 +81,7 @@ public function testJsonSerialize() { $expected = TestUtils::removeNullsFromArray($this->input_data); TestUtils::setAttributes($this->arc, $this->input_data); - $result = json_decode($this->arc->jsonSerialize(), true); + $result = $this->arc->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Elements/LineTest.php b/test/unit/Options/Elements/LineTest.php index 0d9a298..34e1ea6 100644 --- a/test/unit/Options/Elements/LineTest.php +++ b/test/unit/Options/Elements/LineTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Elements; use Halfpastfour\PHPChartJS\Options\Elements\Line; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class LineTest + * * @package Test\Options\Elements */ -class LineTest extends \PHPUnit_Framework_TestCase +class LineTest extends PHPUnit_Framework_TestCase { /** * @var Line @@ -20,51 +22,51 @@ class LineTest extends \PHPUnit_Framework_TestCase * @var array */ private $data_types = [ - 'tension' => 1.0, /* float */ - 'backgroundColor' => '', /* string */ - 'borderWidth' => 1, /* int */ - 'borderColor' => '', /* string */ - 'borderCapStyle' => '', /* string */ - 'borderDash' => [1, 2], /* int[] */ - 'borderDashOffset' => 1.0, /* float */ - 'borderJoinStyle' => '', /* string */ - 'capBezierPoints' => false, /* bool */ - 'fill' => '', /* string */ - 'stepped' => false, /* bool */ + 'tension' => 1.0, /* float */ + 'backgroundColor' => '', /* string */ + 'borderWidth' => 1, /* int */ + 'borderColor' => '', /* string */ + 'borderCapStyle' => '', /* string */ + 'borderDash' => [1, 2], /* int[] */ + 'borderDashOffset' => 1.0, /* float */ + 'borderJoinStyle' => '', /* string */ + 'capBezierPoints' => false, /* bool */ + 'fill' => '', /* string */ + 'stepped' => false, /* bool */ ]; /** * @var array */ private $empty_data = [ - 'tension' => null, /* float */ - 'backgroundColor' => null, /* string */ - 'borderWidth' => null, /* int */ - 'borderColor' => null, /* string */ - 'borderCapStyle' => null, /* string */ - 'borderDash' => null, /* int[] */ - 'borderDashOffset' => null, /* float */ - 'borderJoinStyle' => null, /* string */ - 'capBezierPoints' => null, /* bool */ - 'fill' => null, /* bool */ - 'stepped' => null, /* bool */ + 'tension' => null, /* float */ + 'backgroundColor' => null, /* string */ + 'borderWidth' => null, /* int */ + 'borderColor' => null, /* string */ + 'borderCapStyle' => null, /* string */ + 'borderDash' => null, /* int[] */ + 'borderDashOffset' => null, /* float */ + 'borderJoinStyle' => null, /* string */ + 'capBezierPoints' => null, /* bool */ + 'fill' => null, /* bool */ + 'stepped' => null, /* bool */ ]; /** * @var array */ private $input_data = [ - 'tension' => 0.2, /* float */ - 'backgroundColor' => 'backgroundColor', /* string */ - 'borderWidth' => 2, /* int */ - 'borderColor' => 'borderColor', /* string */ - 'borderCapStyle' => 'borderCapStyle', /* string */ - 'borderDash' => [5, 6], /* int[] */ - 'borderDashOffset' => 0.1, /* float */ - 'borderJoinStyle' => 'borderJoinStyle', /* string */ - 'capBezierPoints' => true, /* bool */ - 'fill' => true, /* bool */ - 'stepped' => true, /* bool */ + 'tension' => 0.2, /* float */ + 'backgroundColor' => 'backgroundColor', /* string */ + 'borderWidth' => 2, /* int */ + 'borderColor' => 'borderColor', /* string */ + 'borderCapStyle' => 'borderCapStyle', /* string */ + 'borderDash' => [5, 6], /* int[] */ + 'borderDashOffset' => 0.1, /* float */ + 'borderJoinStyle' => 'borderJoinStyle', /* string */ + 'capBezierPoints' => true, /* bool */ + 'fill' => true, /* bool */ + 'stepped' => true, /* bool */ ]; /** @@ -103,7 +105,7 @@ public function testJsonSerialize() { $expected = TestUtils::removeNullsFromArray($this->input_data); TestUtils::setAttributes($this->line, $this->input_data); - $result = json_decode($this->line->jsonSerialize(), true); + $result = $this->line->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Elements/PointTest.php b/test/unit/Options/Elements/PointTest.php index 47aaa0a..6b40e36 100644 --- a/test/unit/Options/Elements/PointTest.php +++ b/test/unit/Options/Elements/PointTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Elements; use Halfpastfour\PHPChartJS\Options\Elements\Point; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class PointTest + * * @package Test\Options\Elements */ -class PointTest extends \PHPUnit_Framework_TestCase +class PointTest extends PHPUnit_Framework_TestCase { /** * @var Point @@ -20,45 +22,45 @@ class PointTest extends \PHPUnit_Framework_TestCase * @var array */ private $data_types = [ - 'radius' => 1, /* int */ - 'pointStyle' => '', /* string */ - 'rotation' => 1, /* int */ - 'backgroundColor' => '', /* string */ - 'borderWidth' => 1, /* int */ - 'borderColor' => '', /* string */ - 'hitRadius' => 1, /* int */ - 'hoverRadius' => 1, /* int */ - 'hoverBorderWidth' => 1, /* int */ + 'radius' => 1, /* int */ + 'pointStyle' => '', /* string */ + 'rotation' => 1, /* int */ + 'backgroundColor' => '', /* string */ + 'borderWidth' => 1, /* int */ + 'borderColor' => '', /* string */ + 'hitRadius' => 1, /* int */ + 'hoverRadius' => 1, /* int */ + 'hoverBorderWidth' => 1, /* int */ ]; /** * @var array */ private $empty_data = [ - 'radius' => null, /* int */ - 'pointStyle' => null, /* string */ - 'rotation' => null, /* int */ - 'backgroundColor' => null, /* string */ - 'borderWidth' => null, /* int */ - 'borderColor' => null, /* string */ - 'hitRadius' => null, /* int */ - 'hoverRadius' => null, /* int */ - 'hoverBorderWidth' => null, /* int */ + 'radius' => null, /* int */ + 'pointStyle' => null, /* string */ + 'rotation' => null, /* int */ + 'backgroundColor' => null, /* string */ + 'borderWidth' => null, /* int */ + 'borderColor' => null, /* string */ + 'hitRadius' => null, /* int */ + 'hoverRadius' => null, /* int */ + 'hoverBorderWidth' => null, /* int */ ]; /** * @var array */ private $input_data = [ - 'radius' => 2, /* int */ - 'pointStyle' => 'pointStyle', /* string */ - 'rotation' => 2, /* int */ - 'backgroundColor' => 'backgroundColor', /* string */ - 'borderWidth' => 2, /* int */ - 'borderColor' => 'borderColor', /* string */ - 'hitRadius' => 2, /* int */ - 'hoverRadius' => 2, /* int */ - 'hoverBorderWidth' => 2, /* int */ + 'radius' => 2, /* int */ + 'pointStyle' => 'pointStyle', /* string */ + 'rotation' => 2, /* int */ + 'backgroundColor' => 'backgroundColor', /* string */ + 'borderWidth' => 2, /* int */ + 'borderColor' => 'borderColor', /* string */ + 'hitRadius' => 2, /* int */ + 'hoverRadius' => 2, /* int */ + 'hoverBorderWidth' => 2, /* int */ ]; /** @@ -97,7 +99,7 @@ public function testJsonSerialize() { $expected = TestUtils::removeNullsFromArray($this->input_data); TestUtils::setAttributes($this->point, $this->input_data); - $result = json_decode($this->point->jsonSerialize(), true); + $result = $this->point->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Elements/RectangleTest.php b/test/unit/Options/Elements/RectangleTest.php index 4e72967..fa0689b 100644 --- a/test/unit/Options/Elements/RectangleTest.php +++ b/test/unit/Options/Elements/RectangleTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Elements; use Halfpastfour\PHPChartJS\Options\Elements\Rectangle; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class RectangleTest + * * @package Test\Options\Elements */ -class RectangleTest extends \PHPUnit_Framework_TestCase +class RectangleTest extends PHPUnit_Framework_TestCase { /** * @var Rectangle @@ -82,7 +84,7 @@ public function testJsonSerialize() { $expected = TestUtils::removeNullsFromArray($this->input_data); TestUtils::setAttributes($this->rectangle, $this->input_data); - $result = json_decode($this->rectangle->jsonSerialize(), true); + $result = $this->rectangle->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/ElementsTest.php b/test/unit/Options/ElementsTest.php index b061d29..dd7866e 100644 --- a/test/unit/Options/ElementsTest.php +++ b/test/unit/Options/ElementsTest.php @@ -3,17 +3,19 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options\Elements; -use Halfpastfour\PHPChartJS\Options\Elements\Rectangle; -use Halfpastfour\PHPChartJS\Options\Elements\Point; -use Halfpastfour\PHPChartJS\Options\Elements\Line; use Halfpastfour\PHPChartJS\Options\Elements\Arc; +use Halfpastfour\PHPChartJS\Options\Elements\Line; +use Halfpastfour\PHPChartJS\Options\Elements\Point; +use Halfpastfour\PHPChartJS\Options\Elements\Rectangle; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class ElementsTest + * * @package Test\Options */ -class ElementsTest extends \PHPUnit_Framework_TestCase +class ElementsTest extends PHPUnit_Framework_TestCase { /** * @var Elements @@ -115,7 +117,7 @@ public function testJsonSerialize() { $expected = TestUtils::removeNullsFromArray($this->input_data); TestUtils::setAttributes($this->elements, $this->input_data); - $result = json_decode($this->elements->jsonSerialize(), true); + $result = $this->elements->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/HoverTest.php b/test/unit/Options/HoverTest.php index 8972d7f..da6eba8 100644 --- a/test/unit/Options/HoverTest.php +++ b/test/unit/Options/HoverTest.php @@ -3,13 +3,15 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options\Hover; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class HoverTest + * * @package Test\Options */ -class HoverTest extends \PHPUnit_Framework_TestCase +class HoverTest extends PHPUnit_Framework_TestCase { /** * @var Hover @@ -92,7 +94,7 @@ public function testJsonSerializeWithoutExpressions() { $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); TestUtils::setAttributes($this->hover, $this->input_data_no_expressions); - $result = json_decode($this->hover->jsonSerialize(), true); + $result = $this->hover->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Layout/PaddingTest.php b/test/unit/Options/Layout/PaddingTest.php index b773d9a..c43aa30 100644 --- a/test/unit/Options/Layout/PaddingTest.php +++ b/test/unit/Options/Layout/PaddingTest.php @@ -3,12 +3,13 @@ namespace Test\Options\Layout; use Halfpastfour\PHPChartJS\Options\Layout\Padding; +use PHPUnit_Framework_TestCase; /** * Class PaddingTest * @package Test\Options\Layout */ -class PaddingTest extends \PHPUnit_Framework_TestCase +class PaddingTest extends PHPUnit_Framework_TestCase { /** * @var Padding @@ -69,7 +70,7 @@ public function testTop() public function testJsonSerialize() { $this->padding->setTop(20); - $result = json_decode($this->padding->jsonSerialize(), true); - self::assertArraySubset([ 'top' => 20 ], $result); + $result = $this->padding->jsonSerialize(); + self::assertArraySubset(['top' => 20], $result); } } diff --git a/test/unit/Options/LayoutTest.php b/test/unit/Options/LayoutTest.php index beb4faf..e125589 100644 --- a/test/unit/Options/LayoutTest.php +++ b/test/unit/Options/LayoutTest.php @@ -3,13 +3,15 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options\Layout; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class LayoutTest + * * @package Test\Options */ -class LayoutTest extends \PHPUnit_Framework_TestCase +class LayoutTest extends PHPUnit_Framework_TestCase { /** * @var Layout @@ -84,8 +86,7 @@ public function testJsonSerializeAllInt() { $expected = $this->input_data; TestUtils::setAttributes($this->layout, $this->input_data); - $result = json_decode($this->layout->jsonSerialize(), true); - self::assertEquals($expected, $result); + self::assertEquals($expected, $this->layout->jsonSerialize()); } /** @@ -102,7 +103,7 @@ public function testJsonSerializePaddingObj() ]; $this->layout->padding()->setRight(5); - $result = json_decode($this->layout->jsonSerialize(), true); + $result = $this->layout->jsonSerialize(); self::assertEquals(5, $result['padding']['right']); } } diff --git a/test/unit/Options/Legend/LabelsTest.php b/test/unit/Options/Legend/LabelsTest.php index 556ffd0..5f11933 100644 --- a/test/unit/Options/Legend/LabelsTest.php +++ b/test/unit/Options/Legend/LabelsTest.php @@ -3,13 +3,14 @@ namespace Test\Options\Legend; use Halfpastfour\PHPChartJS\Options\Legend\Labels; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class LabelsTest * @package Test\Options\Legend */ -class LabelsTest extends \PHPUnit_Framework_TestCase +class LabelsTest extends PHPUnit_Framework_TestCase { /** * @var Labels $labels @@ -125,7 +126,7 @@ public function testJsonSerializeWithoutExpr() { $expected = TestUtils::removeNullsFromArray($this->input_data_1); TestUtils::setAttributes($this->labels, $expected); - $result = json_decode($this->labels->jsonSerialize(), true); + $result = $this->labels->jsonSerialize(); self::assertEquals($expected, $result); } } diff --git a/test/unit/Options/LegendTest.php b/test/unit/Options/LegendTest.php index 51893cc..ceddaeb 100644 --- a/test/unit/Options/LegendTest.php +++ b/test/unit/Options/LegendTest.php @@ -4,14 +4,16 @@ use Halfpastfour\PHPChartJS\LabelsCollection; use Halfpastfour\PHPChartJS\Options\Legend; +use PHPUnit_Framework_TestCase; use Test\TestUtils; use Zend\Json\Expr; /** * Class LegendTest + * * @package Test\Options */ -class LegendTest extends \PHPUnit_Framework_TestCase +class LegendTest extends PHPUnit_Framework_TestCase { /** * @var Legend @@ -117,7 +119,7 @@ public function testJsonSerializeWithoutExpressions() { $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); TestUtils::setAttributes($this->legend, $this->input_data_no_expressions); - $result = json_decode($this->legend->jsonSerialize(), true); + $result = $this->legend->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/ScaleTest.php b/test/unit/Options/ScaleTest.php index fdea551..29c3334 100644 --- a/test/unit/Options/ScaleTest.php +++ b/test/unit/Options/ScaleTest.php @@ -6,10 +6,12 @@ use Halfpastfour\PHPChartJS\Options\Scales\GridLines; use Halfpastfour\PHPChartJS\Options\Scales\ScaleLabel; use Halfpastfour\PHPChartJS\Options\Scales\Ticks; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class AScale + * * @package Test\Options */ class AScale extends Scale @@ -18,9 +20,10 @@ class AScale extends Scale /** * Class ScaleTest + * * @package Test\Options */ -class ScaleTest extends \PHPUnit_Framework_TestCase +class ScaleTest extends PHPUnit_Framework_TestCase { /** * @var Scale @@ -177,7 +180,7 @@ public function testJsonSerializeNoObjects() { $expected = TestUtils::removeNullsFromArray($this->input_data); TestUtils::setAttributes($this->scale, $this->input_data); - $result = json_decode($this->scale->jsonSerialize(), true); + $result = $this->scale->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Scales/GridLinesTest.php b/test/unit/Options/Scales/GridLinesTest.php index 4cd1649..98c0db4 100644 --- a/test/unit/Options/Scales/GridLinesTest.php +++ b/test/unit/Options/Scales/GridLinesTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Scales; use Halfpastfour\PHPChartJS\Options\Scales\GridLines; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class GridLinesTest + * * @package Test\Options\Scales */ -class GridLinesTest extends \PHPUnit_Framework_TestCase +class GridLinesTest extends PHPUnit_Framework_TestCase { /** * @var GridLines @@ -40,7 +42,7 @@ class GridLinesTest extends \PHPUnit_Framework_TestCase private $input_data_single_value = [ 'display' => true, 'color' => 'color', - 'borderDash' => ['2'], + 'borderDash' => [2.0], 'borderDashOffset' => 3.0, 'lineWidth' => 4, 'drawBorder' => true, @@ -55,9 +57,9 @@ class GridLinesTest extends \PHPUnit_Framework_TestCase private $input_data_nested_arrays = [ 'display' => true, 'color' => ['color1', 'color2', ['color3', 'color4']], - 'borderDash' => ['2.0', '3.0', ['4.0', '5.0']], + 'borderDash' => [2.0, 3.0, [4.0, 5.0]], 'borderDashOffset' => 3.0, - 'lineWidth' => ['4', '5', ['6', '7'], '8'], + 'lineWidth' => [4, 5, [6, 7], 8], 'drawBorder' => true, 'drawOnChartArea' => true, 'drawTicks' => true, @@ -133,7 +135,7 @@ public function testJsonSerialize() { $expected = $this->input_data_single_value; TestUtils::setAttributes($this->gridLines, $this->input_data_single_value); - $result = json_decode($this->gridLines->jsonSerialize(), true); + $result = $this->gridLines->jsonSerialize(); self::assertEquals($expected, $result); } } diff --git a/test/unit/Options/Scales/ScaleLabelTest.php b/test/unit/Options/Scales/ScaleLabelTest.php index 1edf148..84dfc7d 100644 --- a/test/unit/Options/Scales/ScaleLabelTest.php +++ b/test/unit/Options/Scales/ScaleLabelTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Scales; use Halfpastfour\PHPChartJS\Options\Scales\ScaleLabel; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class ScaleLabelTest + * * @package Test\Options\Scales */ -class ScaleLabelTest extends \PHPUnit_Framework_TestCase +class ScaleLabelTest extends PHPUnit_Framework_TestCase { /** * @var ScaleLabel @@ -92,7 +94,7 @@ public function testJsonSerialize() { $expected = $this->input_data; TestUtils::setAttributes($this->scaleLabel, $this->input_data); - $result = json_decode($this->scaleLabel->jsonSerialize(), true); + $result = $this->scaleLabel->jsonSerialize(); self::assertEquals($expected, $result); } } diff --git a/test/unit/Options/Scales/TicksTest.php b/test/unit/Options/Scales/TicksTest.php index 7d02193..63fd460 100644 --- a/test/unit/Options/Scales/TicksTest.php +++ b/test/unit/Options/Scales/TicksTest.php @@ -3,13 +3,15 @@ namespace Test\Options\Scales; use Halfpastfour\PHPChartJS\Options\Scales\Ticks; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class TicksTest + * * @package Test\Options\Scales */ -class TicksTest extends \PHPUnit_Framework_TestCase +class TicksTest extends PHPUnit_Framework_TestCase { /** * @var Ticks @@ -143,7 +145,7 @@ public function testGetAndSetWithoutExpr() public function testExpr() { TestUtils::setAttributes($this->ticks, $this->input_data_2); - $result = $this->ticks->getCallback()->__toString(); + $result = $this->ticks->getCallback()->__toString(); $expected = $this->input_data_2['callback']; self::assertSame($expected, $result); } @@ -159,7 +161,7 @@ public function testJsonSerializeWithoutExpr() { $expected = TestUtils::removeNullsFromArray($this->input_data_1); TestUtils::setAttributes($this->ticks, $expected); - $result = json_decode($this->ticks->jsonSerialize(), true); + $result = $this->ticks->jsonSerialize(); self::assertEquals($expected, $result); } } diff --git a/test/unit/Options/Scales/XAxisCollectionTest.php b/test/unit/Options/Scales/XAxisCollectionTest.php index 23dce4f..20f74f4 100644 --- a/test/unit/Options/Scales/XAxisCollectionTest.php +++ b/test/unit/Options/Scales/XAxisCollectionTest.php @@ -4,12 +4,14 @@ use Halfpastfour\PHPChartJS\Options\Scales\XAxis; use Halfpastfour\PHPChartJS\Options\Scales\XAxisCollection; +use PHPUnit_Framework_TestCase; /** * Class XAxisCollectionTest + * * @package Test\Options\Scales */ -class XAxisCollectionTest extends \PHPUnit_Framework_TestCase +class XAxisCollectionTest extends PHPUnit_Framework_TestCase { /** * @var XAxisCollection @@ -38,9 +40,9 @@ public function setUp() */ public function testGetArrayCopyEmpty() { - $expected = []; + $expected = []; $xAxisCollection = new XAxisCollection(); - $result = $xAxisCollection->getArrayCopy(); + $result = $xAxisCollection->getArrayCopy(); self::assertSame($expected, $result); } @@ -63,7 +65,7 @@ public function testGetArrayCopyNonEmpty() public function testJsonSerializeEmpty() { $expected = []; - $result = json_decode($this->xAxisCollection->jsonSerialize(), true); + $result = $this->xAxisCollection->jsonSerialize(); self::assertSame($expected, $result); } @@ -76,7 +78,7 @@ public function testJsonSerializeNonEmpty() $x = new XAxis(); $expected[] = $x->getArrayCopy(); $this->xAxisCollection[] = $x; - $result = json_decode($this->xAxisCollection->jsonSerialize(), true); + $result = $this->xAxisCollection->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/ScalesTest.php b/test/unit/Options/ScalesTest.php index 02faed9..97fc127 100644 --- a/test/unit/Options/ScalesTest.php +++ b/test/unit/Options/ScalesTest.php @@ -3,12 +3,14 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options\Scales; +use PHPUnit_Framework_TestCase; /** * Class ScalesTest + * * @package Test\Options */ -class ScalesTest extends \PHPUnit_Framework_TestCase +class ScalesTest extends PHPUnit_Framework_TestCase { /** * @var Scales @@ -70,18 +72,18 @@ public function testJsonSerialize() $x1 = new Scales\XAxis(); $x1->setBarThickness(2); $xc[] = $x1; - $expected['xAxes'] = json_decode($xc->jsonSerialize(), true); + $expected['xAxes'] = $xc->jsonSerialize(); $yc = new Scales\YAxisCollection(); $y1 = new Scales\YAxis(); $y1->setBarThickness(3); $yc[] = $y1; - $expected['xAxes'] = json_decode($xc->jsonSerialize(), true); - $expected['yAxes'] = json_decode($yc->jsonSerialize(), true); + $expected['xAxes'] = $xc->jsonSerialize(); + $expected['yAxes'] = $yc->jsonSerialize(); $this->scales->getXAxes()[] = $x1; $this->scales->getYAxes()[] = $y1; - $result = json_decode($this->scales->jsonSerialize(), true); + $result = $this->scales->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/TitleTest.php b/test/unit/Options/TitleTest.php index 1c9e1fa..35be498 100644 --- a/test/unit/Options/TitleTest.php +++ b/test/unit/Options/TitleTest.php @@ -3,13 +3,14 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options\Title; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class TitleTest * @package Test\Options */ -class TitleTest extends \PHPUnit_Framework_TestCase +class TitleTest extends PHPUnit_Framework_TestCase { /** * @var Title @@ -97,7 +98,7 @@ public function testJsonSerialize() { $expected = $this->input_data; TestUtils::setAttributes($this->title, $this->input_data); - $result = json_decode($this->title->jsonSerialize(), true); + $result = $this->title->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/Tooltips/CallbacksTest.php b/test/unit/Options/Tooltips/CallbacksTest.php index aa1cda3..70e551f 100644 --- a/test/unit/Options/Tooltips/CallbacksTest.php +++ b/test/unit/Options/Tooltips/CallbacksTest.php @@ -2,16 +2,17 @@ namespace Test\Options\Tooltips; -use Zend\Json\Expr; - use Halfpastfour\PHPChartJS\Options\Tooltips\Callbacks; +use PHPUnit_Framework_TestCase; use Test\TestUtils; +use Zend\Json\Expr; /** * Class CallbacksTest + * * @package Test\Options\Tooltips */ -class CallbacksTest extends \PHPUnit_Framework_TestCase +class CallbacksTest extends PHPUnit_Framework_TestCase { /** * @var Callbacks @@ -23,7 +24,7 @@ class CallbacksTest extends \PHPUnit_Framework_TestCase */ private $data_types = [ 'beforeTitle' => '', - 'title' => '', + 'title' => '', 'afterTitle' => '', 'beforeLabel' => '', 'label' => '', @@ -57,7 +58,7 @@ class CallbacksTest extends \PHPUnit_Framework_TestCase /** * @var array */ - private $empty_data = [ + private $empty_data = [ 'beforeTitle' => null, 'title' => null, 'afterTitle' => null, @@ -84,7 +85,7 @@ public function setUp() // Re-initialize Expr properties $keys = array_keys($this->empty_data); foreach ($keys as $key) { - $this->initial_data[ $key ] = new Expr(''); + $this->initial_data[$key] = new Expr(''); } } @@ -117,8 +118,8 @@ function (&$value) { public function testJsonSerializeEmpty() { - $expected = "[]"; - $result = $this->callbacks->jsonSerialize(); + $expected = []; + $result = $this->callbacks->jsonSerialize(); self::assertSame($expected, $result); } } diff --git a/test/unit/Options/TooltipsTest.php b/test/unit/Options/TooltipsTest.php index 5449bea..6175139 100644 --- a/test/unit/Options/TooltipsTest.php +++ b/test/unit/Options/TooltipsTest.php @@ -3,13 +3,15 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options\Tooltips; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class TooltipsTest + * * @package Test\Options */ -class TooltipsTest extends \PHPUnit_Framework_TestCase +class TooltipsTest extends PHPUnit_Framework_TestCase { /** * @var Tooltips @@ -209,7 +211,7 @@ public function testJsonSerializeNoExpressions() { $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); TestUtils::setAttributes($this->tooltips, $expected); - $result = json_decode($this->tooltips->jsonSerialize(), true); + $result = $this->tooltips->jsonSerialize(); self::assertSame($expected, $result); } diff --git a/test/unit/OptionsTest.php b/test/unit/OptionsTest.php index 58215c4..6665f22 100644 --- a/test/unit/OptionsTest.php +++ b/test/unit/OptionsTest.php @@ -3,20 +3,22 @@ namespace Test; use Halfpastfour\PHPChartJS\Options; -use Halfpastfour\PHPChartJS\Options\Layout; -use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Animation; +use Halfpastfour\PHPChartJS\Options\Elements; use Halfpastfour\PHPChartJS\Options\Hover; +use Halfpastfour\PHPChartJS\Options\Layout; +use Halfpastfour\PHPChartJS\Options\Legend; use Halfpastfour\PHPChartJS\Options\Scales; +use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Tooltips; -use Halfpastfour\PHPChartJS\Options\Legend; -use Halfpastfour\PHPChartJS\Options\Elements; +use PHPUnit_Framework_TestCase; /** * Class OptionsTest + * * @package Test */ -class OptionsTest extends \PHPUnit_Framework_TestCase +class OptionsTest extends PHPUnit_Framework_TestCase { /** * @var Options $options @@ -131,7 +133,7 @@ public function testAspectRatio() public function testJsonSerialize() { $expected = $this->empty_options; - $result = json_decode($this->options->jsonSerialize(), true); + $result = $this->options->jsonSerialize(); self::assertEquals($expected, $result); } } diff --git a/test/unit/RendererTest.php b/test/unit/RendererTest.php index cc7d985..b78ad52 100644 --- a/test/unit/RendererTest.php +++ b/test/unit/RendererTest.php @@ -2,17 +2,19 @@ namespace Test; -use Halfpastfour\PHPChartJS\Chart\Bar; use Halfpastfour\PHPChartJS\Chart; +use Halfpastfour\PHPChartJS\Chart\Bar; use Halfpastfour\PHPChartJS\DataSet; use Halfpastfour\PHPChartJS\Renderer\Html; use Halfpastfour\PHPChartJS\Renderer\Json; +use PHPUnit_Framework_TestCase; /** * Class RendererTest + * * @package Test */ -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends PHPUnit_Framework_TestCase { /** * @var Chart @@ -26,10 +28,10 @@ public function setUp() { $chart = new Bar(); $chart->setId('myChart') - ->addLabel('Label 1')->addLabel('Label 2') - ->setTitle('My beautiful chart') - ->setHeight(320) - ->setWidth(480); + ->addLabel('Label 1')->addLabel('Label 2') + ->setTitle('My beautiful chart') + ->setHeight(320) + ->setWidth(480); /** @var DataSet $dataSet */ $chart->addDataSet($dataSet = $chart->createDataSet()); @@ -49,18 +51,20 @@ public function testJson() { $renderer = new Json($this->chart); $json = $renderer->render(); - $result = preg_match('/ - (?(DEFINE) - (? -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? ) - (? true | false | null ) - (? " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* " ) - (? \[ (?: (?&json) (?: , (?&json) )* )? \s* \] ) - (? \s* (?&string) \s* : (?&json) ) - (? \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} ) - (? \s* (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) \s* ) - ) - \A (?&json) \Z - /six', $json, $matches); + $regex = << -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? ) + (? true | false | null ) + (? " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* " ) + (? \[ (?: (?&json) (?: , (?&json) )* )? \s* \] ) + (? \s* (?&string) \s* : (?&json) ) + (? \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} ) + (? \s* (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) \s* ) +) +\A (?&json) \Z/six +REGEX; + + $result = preg_match($regex, $json, $matches); $this->assertEquals(1, $result, 'Validate JSON output'); } From f638c53e36646405662c7ea0ba8ce1c218587918 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 22:40:02 +0100 Subject: [PATCH 15/23] Update unit tests to expect the arrays being returned by the jsonSerialize method. --- test/unit/Options/AnimationTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/unit/Options/AnimationTest.php b/test/unit/Options/AnimationTest.php index 52f92ed..1258190 100644 --- a/test/unit/Options/AnimationTest.php +++ b/test/unit/Options/AnimationTest.php @@ -3,13 +3,15 @@ namespace Options; use Halfpastfour\PHPChartJS\Options\Animation; +use PHPUnit_Framework_TestCase; use Test\TestUtils; /** * Class AnimationTest + * * @package Test\Options */ -class AnimationTest extends \PHPUnit_Framework_TestCase +class AnimationTest extends PHPUnit_Framework_TestCase { /** * @var Animation @@ -92,7 +94,7 @@ public function testJsonSerializeNoExpressions() { $expected = TestUtils::removeNullsFromArray($this->input_data_no_expressions); TestUtils::setAttributes($this->animation, $this->input_data_no_expressions); - $result = json_decode($this->animation->jsonSerialize(), true); + $result = $this->animation->jsonSerialize(); self::assertSame($expected, $result); } } From 37a88761a30ad0b4f82eb6c8d5db76980e52e160 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 22:42:46 +0100 Subject: [PATCH 16/23] Update examples --- test/example/bar.php | 7 +- test/example/barAndLine.php | 7 +- ...bar-no-scales.php => barWithoutScales.php} | 7 +- test/example/bubble.php | 11 +-- test/example/doughnut.php | 7 +- .../{half-doughnut.php => halfDoughnut.php} | 7 +- test/example/horizontalBar.php | 7 +- test/example/index.html | 82 +++++++++++++++++++ test/example/line.php | 7 +- test/example/lineScatter.php | 9 +- test/example/pie.php | 7 +- test/example/polarArea.php | 7 +- test/example/radar.php | 7 +- test/example/scatter.php | 13 +-- 14 files changed, 140 insertions(+), 45 deletions(-) rename test/example/{bar-no-scales.php => barWithoutScales.php} (93%) rename test/example/{half-doughnut.php => halfDoughnut.php} (94%) create mode 100644 test/example/index.html diff --git a/test/example/bar.php b/test/example/bar.php index 4757561..88e47e8 100644 --- a/test/example/bar.php +++ b/test/example/bar.php @@ -25,9 +25,10 @@ $bar->addDataSet($oranges); ?> - - + + + Bar @@ -36,4 +37,4 @@ echo $bar->render(); ?> - \ No newline at end of file + diff --git a/test/example/barAndLine.php b/test/example/barAndLine.php index 250e282..4798bd7 100644 --- a/test/example/barAndLine.php +++ b/test/example/barAndLine.php @@ -57,9 +57,10 @@ $bar->addDataSet($oranges); ?> - - + + + Bar & line @@ -68,4 +69,4 @@ echo $bar->render(); ?> - \ No newline at end of file + diff --git a/test/example/bar-no-scales.php b/test/example/barWithoutScales.php similarity index 93% rename from test/example/bar-no-scales.php rename to test/example/barWithoutScales.php index a83c2dd..2570ced 100644 --- a/test/example/bar-no-scales.php +++ b/test/example/barWithoutScales.php @@ -37,9 +37,10 @@ $options->getScales()->getYAxes()->append($yAxis); ?> - - + + + Bar without scales @@ -48,4 +49,4 @@ echo $bar->render(); ?> - \ No newline at end of file + diff --git a/test/example/bubble.php b/test/example/bubble.php index fb08b43..beadf11 100644 --- a/test/example/bubble.php +++ b/test/example/bubble.php @@ -22,7 +22,7 @@ ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], - ]); + ]); $bubble->addDataSet($apples); $oranges = $bubble->createDataSet(); @@ -35,13 +35,14 @@ ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], - ]); + ]); $bubble->addDataSet($oranges); ?> - - + + + Bubble @@ -50,4 +51,4 @@ echo $bubble->render(); ?> - \ No newline at end of file + diff --git a/test/example/doughnut.php b/test/example/doughnut.php index f499c65..310b804 100644 --- a/test/example/doughnut.php +++ b/test/example/doughnut.php @@ -42,9 +42,10 @@ $doughnut->addDataSet($oranges); ?> - - + + + Doughnut @@ -53,4 +54,4 @@ echo $doughnut->render(); ?> - \ No newline at end of file + diff --git a/test/example/half-doughnut.php b/test/example/halfDoughnut.php similarity index 94% rename from test/example/half-doughnut.php rename to test/example/halfDoughnut.php index 5fe3b7d..2106f62 100644 --- a/test/example/half-doughnut.php +++ b/test/example/halfDoughnut.php @@ -48,9 +48,10 @@ $doughnut->addDataSet($oranges); ?> - - + + + Half doughnut @@ -59,4 +60,4 @@ echo $doughnut->render(); ?> - \ No newline at end of file + diff --git a/test/example/horizontalBar.php b/test/example/horizontalBar.php index 753832a..599fabf 100644 --- a/test/example/horizontalBar.php +++ b/test/example/horizontalBar.php @@ -29,9 +29,10 @@ $scales->getYAxes()->append($scales->createYAxis()->setStacked(true)); ?> - - + + + Horizontal bar @@ -40,4 +41,4 @@ echo $bar->render(); ?> - \ No newline at end of file + diff --git a/test/example/index.html b/test/example/index.html new file mode 100644 index 0000000..e0e82dc --- /dev/null +++ b/test/example/index.html @@ -0,0 +1,82 @@ + + + + + + + + + + + halfpastfouram/phpchartjs - examples + + +
+
+
+

halfpastfouram/phpchartjs - examples

+

These examples demonstrate the usage of this library. For more information please visit https://halfpastfouram.github.io/PHPChartJS/. +

+
+
+ + + + +
+ + + + + + + + diff --git a/test/example/line.php b/test/example/line.php index d457401..0e94d84 100644 --- a/test/example/line.php +++ b/test/example/line.php @@ -56,9 +56,10 @@ $line->addDataSet($oranges); ?> - - + + + Line @@ -67,4 +68,4 @@ echo $line->render(); ?> - \ No newline at end of file + diff --git a/test/example/lineScatter.php b/test/example/lineScatter.php index 83a7b99..a83072e 100644 --- a/test/example/lineScatter.php +++ b/test/example/lineScatter.php @@ -15,7 +15,7 @@ ['x' => -10, 'y' => 0], ['x' => 0, 'y' => 10], ['x' => 10, 'y' => 5], - ]); + ]); $line->addDataSet($dataSet); $scales = $line->options()->getScales(); @@ -26,9 +26,10 @@ $scales->getXAxes()->append($xAxis); ?> - - + + + Line & scatter @@ -37,4 +38,4 @@ echo $line->render(); ?> - \ No newline at end of file + diff --git a/test/example/pie.php b/test/example/pie.php index 6be86f1..5990ca8 100644 --- a/test/example/pie.php +++ b/test/example/pie.php @@ -37,9 +37,10 @@ $pie->addDataSet($apples); ?> - - + + + Pie @@ -48,4 +49,4 @@ echo $pie->render(); ?> - \ No newline at end of file + diff --git a/test/example/polarArea.php b/test/example/polarArea.php index 027b12b..9b34f16 100644 --- a/test/example/polarArea.php +++ b/test/example/polarArea.php @@ -20,9 +20,10 @@ $polarArea->addDataSet($dataSet); ?> - - + + + Polar area @@ -31,4 +32,4 @@ echo $polarArea->render(); ?> - \ No newline at end of file + diff --git a/test/example/radar.php b/test/example/radar.php index 63b9b61..086b02a 100644 --- a/test/example/radar.php +++ b/test/example/radar.php @@ -43,9 +43,10 @@ $radar->addDataSet($dataSet2); ?> - - + + + Radar @@ -54,4 +55,4 @@ echo $radar->render(); ?> - \ No newline at end of file + diff --git a/test/example/scatter.php b/test/example/scatter.php index e8b0bfe..cdabb7d 100644 --- a/test/example/scatter.php +++ b/test/example/scatter.php @@ -14,7 +14,7 @@ $options = $scatter->options(); $xAxis = $options->getScales()->createXAxis(); $xAxis->ticks()->setStepSize(1); -$yAxis = $options->getScales()->createYAxis(); +$yAxis = $options->getScales()->createYAxis(); $options->getScales()->getXAxes()->append($xAxis); $options->getScales()->getYAxes()->append($yAxis); @@ -36,7 +36,7 @@ ['x' => 0, 'y' => 4], ['x' => 0, 'y' => 5], ['x' => 0, 'y' => 6], - ]); + ]); $scatter->addDataSet($apples); $oranges = $scatter->createDataSet(); @@ -50,13 +50,14 @@ ['x' => 1, 'y' => 4], ['x' => 1, 'y' => 5], ['x' => 1, 'y' => 6], - ]); + ]); $scatter->addDataSet($oranges); ?> - - + + + Scatter @@ -65,4 +66,4 @@ echo $scatter->render(); ?> - \ No newline at end of file + From fa9747a0839d94dac5a9c28d12bf19640f71049c Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 22:44:08 +0100 Subject: [PATCH 17/23] Fix CS --- test/example/lineScatter.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/example/lineScatter.php b/test/example/lineScatter.php index a83072e..8bd65aa 100644 --- a/test/example/lineScatter.php +++ b/test/example/lineScatter.php @@ -10,12 +10,11 @@ // Add Datasets $dataSet = $line->createDataSet(); -$dataSet->setLabel('Scatter Dataset') - ->data()->exchangeArray([ - ['x' => -10, 'y' => 0], - ['x' => 0, 'y' => 10], - ['x' => 10, 'y' => 5], - ]); +$dataSet->setLabel('Scatter Dataset')->data()->exchangeArray([ + ['x' => -10, 'y' => 0], + ['x' => 0, 'y' => 10], + ['x' => 10, 'y' => 5], +]); $line->addDataSet($dataSet); $scales = $line->options()->getScales(); From 821baec6a54fb7dd6593eff3d2419d51fd4fd3ae Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 22:46:50 +0100 Subject: [PATCH 18/23] Update examples --- test/example/index.html | 3 +-- test/example/lineScatter.php | 2 +- test/example/scatter.php | 40 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/test/example/index.html b/test/example/index.html index e0e82dc..698e350 100644 --- a/test/example/index.html +++ b/test/example/index.html @@ -38,8 +38,7 @@

Bar graphs

Line graphs

diff --git a/test/example/lineScatter.php b/test/example/lineScatter.php index 8bd65aa..7a421d1 100644 --- a/test/example/lineScatter.php +++ b/test/example/lineScatter.php @@ -28,7 +28,7 @@ - Line & scatter + Line scatter diff --git a/test/example/scatter.php b/test/example/scatter.php index cdabb7d..028602f 100644 --- a/test/example/scatter.php +++ b/test/example/scatter.php @@ -27,30 +27,30 @@ $apples->setLabel('My first dataset') ->setBackgroundColor('rgba( 0, 150, 0, .5 )') ->setPointStyle('rect') - ->setPointRadius(10) - ->data()->exchangeArray([ - ['x' => 0, 'y' => 0], - ['x' => 0, 'y' => 1], - ['x' => 0, 'y' => 2], - ['x' => 0, 'y' => 3], - ['x' => 0, 'y' => 4], - ['x' => 0, 'y' => 5], - ['x' => 0, 'y' => 6], - ]); + ->setPointRadius(10); +$apples->data()->exchangeArray([ + ['x' => 0, 'y' => 0], + ['x' => 0, 'y' => 1], + ['x' => 0, 'y' => 2], + ['x' => 0, 'y' => 3], + ['x' => 0, 'y' => 4], + ['x' => 0, 'y' => 5], + ['x' => 0, 'y' => 6], +]); $scatter->addDataSet($apples); $oranges = $scatter->createDataSet(); $oranges->setLabel('My second dataset') - ->setBackgroundColor('rgba( 255, 153, 0, .5 )') - ->data()->exchangeArray([ - ['x' => 1, 'y' => 0], - ['x' => 1, 'y' => 1], - ['x' => 1, 'y' => 2], - ['x' => 1, 'y' => 3], - ['x' => 1, 'y' => 4], - ['x' => 1, 'y' => 5], - ['x' => 1, 'y' => 6], - ]); + ->setBackgroundColor('rgba( 255, 153, 0, .5 )'); +$oranges->data()->exchangeArray([ + ['x' => 1, 'y' => 0], + ['x' => 1, 'y' => 1], + ['x' => 1, 'y' => 2], + ['x' => 1, 'y' => 3], + ['x' => 1, 'y' => 4], + ['x' => 1, 'y' => 5], + ['x' => 1, 'y' => 6], +]); $scatter->addDataSet($oranges); ?> From c6faf63d27c49896cb31565089d8045b67e38291 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 23:13:22 +0100 Subject: [PATCH 19/23] Fix PHPDoc type indication --- src/Options/Scales/GridLines.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Options/Scales/GridLines.php b/src/Options/Scales/GridLines.php index e626a45..2636743 100644 --- a/src/Options/Scales/GridLines.php +++ b/src/Options/Scales/GridLines.php @@ -30,7 +30,7 @@ class GridLines implements ArraySerializableInterface, JsonSerializable private $color; /** - * @var string[] + * @var float[]|null */ private $borderDash; @@ -124,7 +124,7 @@ public function setColor($color) } /** - * @return \string[] + * @return float[]|null */ public function getBorderDash() { @@ -132,7 +132,7 @@ public function getBorderDash() } /** - * @param \float[] $borderDash + * @param float[] $borderDash * * @return $this */ From fb14957634827eeb9b4810ded0f8d980e9fad13d Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Thu, 9 Jan 2020 23:16:02 +0100 Subject: [PATCH 20/23] Improve non-empty check on array. --- src/Renderer/Json.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Renderer/Json.php b/src/Renderer/Json.php index 7cc311f..d20ab17 100644 --- a/src/Renderer/Json.php +++ b/src/Renderer/Json.php @@ -15,7 +15,6 @@ class Json extends Renderer * @param int|null $flags * * @return string - * @throws \ReflectionException */ public function render($flags = JSON_PRETTY_PRINT) { @@ -35,7 +34,7 @@ public function render($flags = JSON_PRETTY_PRINT) } $options = $this->chart->options()->getArrayCopy(); - if ($options) { + if (! empty($options)) { $config['options'] = $options; } From b8cfabe81077466e1e74b65b820fbb9e5ff9e8f3 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Fri, 10 Jan 2020 00:30:36 +0100 Subject: [PATCH 21/23] Fix onClick method, add examples. --- src/Collection/Data.php | 13 ++----- src/DataSet.php | 17 +++------ src/DataSetCollection.php | 8 +++- src/Delegate/ArraySerializable.php | 6 +-- src/Delegate/JsonSerializable.php | 30 +++++++++++++++ src/Renderer/JavaScript.php | 22 +++++++++-- src/Renderer/Json.php | 19 +++++++--- src/Renderer/Renderer.php | 2 +- test/example/disableAspectRatio.php | 57 +++++++++++++++++++++++++++++ test/example/index.html | 5 ++- test/example/onClick.php | 49 +++++++++++++++++++++++++ 11 files changed, 191 insertions(+), 37 deletions(-) create mode 100644 src/Delegate/JsonSerializable.php create mode 100644 test/example/disableAspectRatio.php create mode 100644 test/example/onClick.php diff --git a/src/Collection/Data.php b/src/Collection/Data.php index cf35017..ba51780 100644 --- a/src/Collection/Data.php +++ b/src/Collection/Data.php @@ -3,20 +3,15 @@ namespace Halfpastfour\PHPChartJS\Collection; use Halfpastfour\Collection\Collection\ArrayAccess; -use JsonSerializable; +use Halfpastfour\PHPChartJS\Delegate; +use JsonSerializable as JsonSerializableInterface; /** * Class Data * * @package Halfpastfour\PHPChartJS\Collection */ -class Data extends ArrayAccess implements JsonSerializable +class Data extends ArrayAccess implements JsonSerializableInterface { - /** - * @return array - */ - public function jsonSerialize() - { - return $this->data; - } + use Delegate\JsonSerializable; } diff --git a/src/DataSet.php b/src/DataSet.php index e6669da..88ac32f 100644 --- a/src/DataSet.php +++ b/src/DataSet.php @@ -3,18 +3,19 @@ namespace Halfpastfour\PHPChartJS; use Halfpastfour\PHPChartJS\Collection\Data; -use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; -use JsonSerializable; +use Halfpastfour\PHPChartJS\Delegate; +use JsonSerializable as JsonSerializableInterface; /** * Class DataSet * * @package Halfpastfour\PHPChartJS */ -class DataSet implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializable +class DataSet implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializableInterface { use ChartOwned; - use ArraySerializable; + use Delegate\ArraySerializable; + use Delegate\JsonSerializable; /** * @var string @@ -349,12 +350,4 @@ public function setHoverBorderWidth($hoverBorderWidth) return $this; } - - /** - * @return array - */ - public function jsonSerialize() - { - return $this->getArrayCopy(); - } } diff --git a/src/DataSetCollection.php b/src/DataSetCollection.php index c84432b..b48f3b5 100644 --- a/src/DataSetCollection.php +++ b/src/DataSetCollection.php @@ -31,6 +31,12 @@ public function getArrayCopy() */ public function jsonSerialize() { - return $this->getArrayCopy(); + $rows = []; + foreach ($this->data as $row) { + /** @var DataSet $row */ + $rows[] = $row->jsonSerialize(); + } + + return $rows; } } diff --git a/src/Delegate/ArraySerializable.php b/src/Delegate/ArraySerializable.php index cb13182..307e8dd 100644 --- a/src/Delegate/ArraySerializable.php +++ b/src/Delegate/ArraySerializable.php @@ -29,8 +29,8 @@ public function getArrayCopy() }, get_object_vars($this)); // Filter out null values and return the remaining. - return array_filter($currentValues, function ($value) { - return ! is_null($value); - }); + return array_filter($currentValues, function ($value, $key) { + return ! is_null($value) && $key !== 'owner'; + }, ARRAY_FILTER_USE_BOTH); } } diff --git a/src/Delegate/JsonSerializable.php b/src/Delegate/JsonSerializable.php new file mode 100644 index 0000000..486ed77 --- /dev/null +++ b/src/Delegate/JsonSerializable.php @@ -0,0 +1,30 @@ +jsonSerialize(); + } elseif ($value instanceof ArraySerializableInterface) { + return $value->getArrayCopy(); + } + + return $value; + }, $this->getArrayCopy()); + } +} diff --git a/src/Renderer/JavaScript.php b/src/Renderer/JavaScript.php index b37a704..609d060 100644 --- a/src/Renderer/JavaScript.php +++ b/src/Renderer/JavaScript.php @@ -4,6 +4,7 @@ /** * Class JavaScript + * * @package Halfpastfour\PHPChartJS\Renderer */ class JavaScript extends Renderer @@ -26,11 +27,24 @@ public function render($flags = null) $jsonRenderer = new Json($this->chart); $json = $jsonRenderer->render($flags); $script[] = "var chart = new Chart( ctx, {$json} );"; + $scriptString = implode("\n", $script); // Return the script - return "\nwindow.onload=(function(oldLoad){return function(){\n" - . "if( oldLoad ) oldLoad();\n" - . implode("\n", $script) . "\n" - . "}})(window.onload);\n"; + return <<chart->getId()}'] = chart; +}})(window.onload); +JS + ; } } diff --git a/src/Renderer/Json.php b/src/Renderer/Json.php index d20ab17..bde7ad5 100644 --- a/src/Renderer/Json.php +++ b/src/Renderer/Json.php @@ -2,6 +2,8 @@ namespace Halfpastfour\PHPChartJS\Renderer; +use Zend\Json\Json as JsonHelper; + /** * Class Json * @@ -12,32 +14,37 @@ class Json extends Renderer /** * Render the necessary JSON for the chart to function in the frontend. * - * @param int|null $flags + * @param int|false $flags * * @return string */ - public function render($flags = JSON_PRETTY_PRINT) + public function render($flags = null) { $config = [ 'type' => constant(get_class($this->chart) . "::TYPE"), 'data' => [], ]; - $labels = $this->chart->labels()->getArrayCopy(); + $labels = $this->chart->labels()->jsonSerialize(); if ($labels) { $config['data']['labels'] = $labels; } - $dataSets = $this->chart->dataSets()->getArrayCopy(); + $dataSets = $this->chart->dataSets()->jsonSerialize(); if ($dataSets) { $config['data']['datasets'] = $dataSets; } - $options = $this->chart->options()->getArrayCopy(); + $options = $this->chart->options()->jsonSerialize(); if (! empty($options)) { $config['options'] = $options; } - return json_encode($config, $flags); + $output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]); + if ($flags & Renderer::RENDER_PRETTY) { + $output = JsonHelper::prettyPrint($output); + } + + return $output; } } diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 5d67d92..318e8e6 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -13,7 +13,7 @@ abstract class Renderer implements RendererInterface /** * Flag used for rendering JSON in pretty mode. */ - const RENDER_PRETTY = JSON_PRETTY_PRINT; + const RENDER_PRETTY = 1; /** * @var Chart The chart that needs to be rendered. diff --git a/test/example/disableAspectRatio.php b/test/example/disableAspectRatio.php new file mode 100644 index 0000000..82eb51f --- /dev/null +++ b/test/example/disableAspectRatio.php @@ -0,0 +1,57 @@ +create($factory::BUBBLE); + +// Set labels +$bubble->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]); + +// Add Datasets +$apples = $bubble->createDataSet(); +$apples->setLabel('My first dataset') + ->setBackgroundColor('rgba( 0, 150, 0, .5 )') + ->data()->exchangeArray([ + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ]); +$bubble->addDataSet($apples); + +$oranges = $bubble->createDataSet(); +$oranges->setLabel('My second dataset') + ->setBackgroundColor('rgba( 255, 153, 0, .5 )') + ->data()->exchangeArray([ + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)], + ]); +$bubble->addDataSet($oranges); + +$bubble->options()->setMaintainAspectRatio(false); +$bubble->setHeight(250); + +?> + + + + Disable aspect ratio + + + +render(); +?> + + diff --git a/test/example/index.html b/test/example/index.html index 698e350..bf1001d 100644 --- a/test/example/index.html +++ b/test/example/index.html @@ -58,9 +58,12 @@

Pie graphs

Other graphs

Bubble graph Disable maintaining + aspect ratio Polar area graph Radar graph Scatter graph + href="scatter.php" class="list-group-item list-group-item-action">Scatter graph onClick
diff --git a/test/example/onClick.php b/test/example/onClick.php new file mode 100644 index 0000000..e40ef38 --- /dev/null +++ b/test/example/onClick.php @@ -0,0 +1,49 @@ +setId('myChart'); + +// Set labels +$bar->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]); + +// Add Datasets +$apples = $bar->createDataSet(); + +$apples->setLabel("apples") + ->setBackgroundColor("rgba( 0, 150, 0, .5 )") + ->data()->exchangeArray([12, 19, 3, 17, 28, 24, 7]); +$bar->addDataSet($apples); + +$oranges = $bar->createDataSet(); +$oranges->setLabel("oranges") + ->setBackgroundColor('rgba( 255, 153, 0, .5 )') + ->data()->exchangeArray([30, 29, 5, 5, 20, 3, 10]); +$bar->addDataSet($oranges); +$bar->options()->setOnClick('myClickEvent'); +?> + + + + onClick + + + +render(); +?> + + + From 461c6d8b05f2db0047d2755c04bd1042528367fc Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Fri, 10 Jan 2020 00:42:36 +0100 Subject: [PATCH 22/23] Update travis configuration --- .travis.yml | 8 +++++--- composer.json | 1 + composer.lock | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 538cb1e..12109b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ php: - '7.0' - '7.1' - '7.2' + - '7.3' + - '7.4' - nightly before_script: @@ -12,7 +14,7 @@ before_script: - mkdir build/logs -p script: - - phpunit + - composer test - composer cs-check after_success: @@ -27,5 +29,5 @@ matrix: branches: only: - - master - - dev + - master + - dev diff --git a/composer.json b/composer.json index df48e16..c97edde 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ } }, "scripts": { + "test": "./vendor/bin/phpunit", "cs-check": "./vendor/bin/phpcs", "cs-fix": "./vendor/bin/phpcbf" } diff --git a/composer.lock b/composer.lock index 84aac6f..b300200 100644 --- a/composer.lock +++ b/composer.lock @@ -1,7 +1,7 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "content-hash": "1055ab8393adc5a0332a58b38f335a5c", From efef0d56c57c45ee044dcf04bdb9701fe69512da Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Fri, 10 Jan 2020 01:04:51 +0100 Subject: [PATCH 23/23] Update dependencies, add composer security scan. --- .travis.yml | 4 +- composer.json | 9 +- composer.lock | 793 ++++++------------- src/Options.php | 6 +- src/Options/Animation.php | 2 +- src/Options/Hover.php | 4 +- src/Options/Legend.php | 2 +- src/Options/Legend/Labels.php | 2 +- src/Options/Scales/Ticks.php | 2 +- src/Options/Tooltips.php | 6 +- src/Options/Tooltips/Callbacks.php | 2 +- src/Renderer/Json.php | 2 +- test/TestUtils.php | 11 +- test/unit/Options/ClickTest.php | 2 +- test/unit/Options/LegendTest.php | 2 +- test/unit/Options/Tooltips/CallbacksTest.php | 2 +- 16 files changed, 255 insertions(+), 596 deletions(-) diff --git a/.travis.yml b/.travis.yml index 12109b5..d8bbb86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,7 @@ before_script: script: - composer test - composer cs-check - -after_success: - - vendor/bin/test-reporter + - php vendor/bin/security-checker security:check after_script: - rm -rf build/logs diff --git a/composer.json b/composer.json index c97edde..8fd8dec 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,15 @@ "php": ">=5.6.0 || ^7.0", "ext-dom": "*", "ext-json": "*", - "zendframework/zend-json": "3.0.0", - "zf1/zend-reflection": "1.12.11", + "laminas/laminas-json": "3.1.2", "halfpastfouram/collection": "1.0.0", "symfony/var-dumper": "^3.4" }, "require-dev": { "phpunit/phpunit": "5.7.*", - "codeclimate/php-test-reporter": "dev-master", - "squizlabs/php_codesniffer": "3.0.0", - "friendsofphp/php-cs-fixer": "2.11.1" + "squizlabs/php_codesniffer": "3.5.3", + "friendsofphp/php-cs-fixer": "*", + "sensiolabs/security-checker": "^5.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index b300200..99389aa 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1055ab8393adc5a0332a58b38f335a5c", + "content-hash": "7d97e5802f8b5709b3c6b88840495753", "packages": [ { "name": "halfpastfouram/collection", @@ -51,6 +51,112 @@ ], "time": "2016-12-18T13:04:48+00:00" }, + { + "name": "laminas/laminas-json", + "version": "3.1.2", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-json.git", + "reference": "00dc0da7b5e5018904c5c4a8e80a5faa16c2c1c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-json/zipball/00dc0da7b5e5018904c5c4a8e80a5faa16c2c1c6", + "reference": "00dc0da7b5e5018904c5c4a8e80a5faa16c2c1c6", + "shasum": "" + }, + "require": { + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^5.6 || ^7.0" + }, + "replace": { + "zendframework/zend-json": "self.version" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-stdlib": "^2.7.7 || ^3.1", + "phpunit/phpunit": "^5.7.23 || ^6.4.3" + }, + "suggest": { + "laminas/laminas-json-server": "For implementing JSON-RPC servers", + "laminas/laminas-xml2json": "For converting XML documents to JSON" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev", + "dev-develop": "3.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Laminas\\Json\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", + "homepage": "https://laminas.dev", + "keywords": [ + "json", + "laminas" + ], + "time": "2019-12-31T17:15:04+00:00" + }, + { + "name": "laminas/laminas-zendframework-bridge", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-zendframework-bridge.git", + "reference": "0fb9675b84a1666ab45182b6c5b29956921e818d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/0fb9675b84a1666ab45182b6c5b29956921e818d", + "reference": "0fb9675b84a1666ab45182b6c5b29956921e818d", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev", + "dev-develop": "1.1.x-dev" + }, + "laminas": { + "module": "Laminas\\ZendFrameworkBridge" + } + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\ZendFrameworkBridge\\": "src//" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Alias legacy ZF class names to Laminas Project equivalents.", + "keywords": [ + "ZendFramework", + "autoloading", + "laminas", + "zf" + ], + "time": "2020-01-07T22:58:31+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.13.1", @@ -178,197 +284,9 @@ "dump" ], "time": "2019-10-10T11:03:19+00:00" - }, - { - "name": "zendframework/zend-json", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-json.git", - "reference": "f42a1588e75c2a3e338cd94c37906231e616daab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-json/zipball/f42a1588e75c2a3e338cd94c37906231e616daab", - "reference": "f42a1588e75c2a3e338cd94c37906231e616daab", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "^2.3", - "zendframework/zend-stdlib": "^2.7 || ^3.0" - }, - "suggest": { - "zendframework/zend-json-server": "For implementing JSON-RPC servers", - "zendframework/zend-xml2json": "For converting XML documents to JSON" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev", - "dev-develop": "3.1-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Json\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", - "homepage": "https://github.com/zendframework/zend-json", - "keywords": [ - "json", - "zf2" - ], - "abandoned": "laminas/laminas-json", - "time": "2016-04-01T02:34:00+00:00" - }, - { - "name": "zf1/zend-exception", - "version": "1.12.11", - "source": { - "type": "git", - "url": "https://github.com/zf1/zend-exception.git", - "reference": "ca30959d3e2f522f481a3d1459386acf1aa4ca74" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zf1/zend-exception/zipball/ca30959d3e2f522f481a3d1459386acf1aa4ca74", - "reference": "ca30959d3e2f522f481a3d1459386acf1aa4ca74", - "shasum": "" - }, - "require": { - "php": ">=5.2.11" - }, - "type": "library", - "autoload": { - "psr-0": { - "Zend_Exception": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Zend Framework 1 Exception package", - "homepage": "http://framework.zend.com/", - "keywords": [ - "ZF1", - "exception", - "framework", - "zend" - ], - "time": "2015-04-30T11:10:20+00:00" - }, - { - "name": "zf1/zend-reflection", - "version": "1.12.11", - "source": { - "type": "git", - "url": "https://github.com/zf1/zend-reflection.git", - "reference": "cb052c09e53bb94b8499bace2952b6263fbf05d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zf1/zend-reflection/zipball/cb052c09e53bb94b8499bace2952b6263fbf05d3", - "reference": "cb052c09e53bb94b8499bace2952b6263fbf05d3", - "shasum": "" - }, - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version" - }, - "suggest": { - "zf1/zend-loader": "Used in special situations or with special adapters" - }, - "type": "library", - "autoload": { - "psr-0": { - "Zend_Reflection": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Zend Framework 1 Reflection package", - "homepage": "http://framework.zend.com/", - "keywords": [ - "ZF1", - "framework", - "reflection", - "zend" - ], - "time": "2015-04-30T11:14:41+00:00" } ], "packages-dev": [ - { - "name": "codeclimate/php-test-reporter", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/codeclimate/php-test-reporter.git", - "reference": "f35752238d994c8894a3c079bdbe2c535e0265af" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/f35752238d994c8894a3c079bdbe2c535e0265af", - "reference": "f35752238d994c8894a3c079bdbe2c535e0265af", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "padraic/phar-updater": "^1.0", - "php": "^5.3 || ^7.0", - "psr/log": "^1.0", - "satooshi/php-coveralls": "^1.0", - "symfony/console": "^2.0 || ^3.0 || ^4.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0.0", - "phpunit/phpunit": "^4.8.35 || ^5.7.0 || ^6.0.0" - }, - "bin": [ - "composer/bin/test-reporter" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3.x-dev" - } - }, - "autoload": { - "psr-4": { - "CodeClimate\\PhpTestReporter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Code Climate", - "email": "hello@codeclimate.com", - "homepage": "https://codeclimate.com" - } - ], - "description": "PHP client for reporting test coverage to Code Climate", - "homepage": "https://github.com/codeclimate/php-test-reporter", - "keywords": [ - "codeclimate", - "coverage" - ], - "time": "2018-04-11T15:45:47+00:00" - }, { "name": "composer/ca-bundle", "version": "1.2.5", @@ -487,6 +405,50 @@ ], "time": "2019-03-19T17:25:45+00:00" }, + { + "name": "composer/xdebug-handler", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "cbe23383749496fe0f373345208b79568e4bc248" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/cbe23383749496fe0f373345208b79568e4bc248", + "reference": "cbe23383749496fe0f373345208b79568e4bc248", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2019-11-06T16:40:04+00:00" + }, { "name": "doctrine/annotations", "version": "v1.4.0", @@ -671,62 +633,60 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.11.1", + "version": "v2.16.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "ad94441c17b8ef096e517acccdbf3238af8a2da8" + "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/ad94441c17b8ef096e517acccdbf3238af8a2da8", - "reference": "ad94441c17b8ef096e517acccdbf3238af8a2da8", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02", + "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02", "shasum": "" }, "require": { "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", "doctrine/annotations": "^1.2", "ext-json": "*", "ext-tokenizer": "*", - "php": "^5.6 || >=7.0 <7.3", + "php": "^5.6 || ^7.0", "php-cs-fixer/diff": "^1.3", - "symfony/console": "^3.2 || ^4.0", - "symfony/event-dispatcher": "^3.0 || ^4.0", - "symfony/filesystem": "^3.0 || ^4.0", - "symfony/finder": "^3.0 || ^4.0", - "symfony/options-resolver": "^3.0 || ^4.0", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", "symfony/polyfill-php70": "^1.0", "symfony/polyfill-php72": "^1.4", - "symfony/process": "^3.0 || ^4.0", - "symfony/stopwatch": "^3.0 || ^4.0" - }, - "conflict": { - "hhvm": "*" + "symfony/process": "^3.0 || ^4.0 || ^5.0", + "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" }, "require-dev": { "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", "justinrainbow/json-schema": "^5.0", - "keradus/cli-executor": "^1.0", + "keradus/cli-executor": "^1.2", "mikey179/vfsstream": "^1.6", - "php-coveralls/php-coveralls": "^2.0", + "php-coveralls/php-coveralls": "^2.1", "php-cs-fixer/accessible-object": "^1.0", - "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", - "phpunitgoodpractices/traits": "^1.3.1", - "symfony/phpunit-bridge": "^3.2.2 || ^4.0" + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/traits": "^1.8", + "symfony/phpunit-bridge": "^4.3 || ^5.0", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0" }, "suggest": { "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." }, "bin": [ "php-cs-fixer" ], "type": "application", - "extra": { - "branch-alias": { - "dev-master": "2.11-dev" - } - }, "autoload": { "psr-4": { "PhpCsFixer\\": "src/" @@ -736,9 +696,6 @@ "tests/Test/AbstractIntegrationCaseFactory.php", "tests/Test/AbstractIntegrationTestCase.php", "tests/Test/Assert/AssertTokensTrait.php", - "tests/Test/Constraint/SameStringsConstraint.php", - "tests/Test/Constraint/SameStringsConstraintForV5.php", - "tests/Test/Constraint/SameStringsConstraintForV7.php", "tests/Test/IntegrationCase.php", "tests/Test/IntegrationCaseFactory.php", "tests/Test/IntegrationCaseFactoryInterface.php", @@ -751,110 +708,17 @@ "MIT" ], "authors": [ - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" - } - ], - "description": "A tool to automatically fix PHP code style", - "time": "2018-03-21T17:41:26+00:00" - }, - { - "name": "guzzle/guzzle", - "version": "v3.8.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/4de0618a01b34aa1c8c33a3f13f396dcd3882eba", - "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.3", - "symfony/event-dispatcher": ">=2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "*", - "monolog/monolog": "1.*", - "phpunit/phpunit": "3.7.*", - "psr/log": "1.0.*", - "symfony/class-loader": "*", - "zendframework/zend-cache": "<2.3", - "zendframework/zend-log": "<2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.8-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle": "src/", - "Guzzle\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" }, { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" } ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "abandoned": "guzzlehttp/guzzle", - "time": "2014-01-28T22:29:15+00:00" + "description": "A tool to automatically fix PHP code style", + "time": "2019-11-25T22:10:32+00:00" }, { "name": "myclabs/deep-copy", @@ -901,127 +765,6 @@ ], "time": "2017-10-19T19:58:43+00:00" }, - { - "name": "padraic/humbug_get_contents", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/humbug/file_get_contents.git", - "reference": "dcb086060c9dd6b2f51d8f7a895500307110b7a7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/humbug/file_get_contents/zipball/dcb086060c9dd6b2f51d8f7a895500307110b7a7", - "reference": "dcb086060c9dd6b2f51d8f7a895500307110b7a7", - "shasum": "" - }, - "require": { - "composer/ca-bundle": "^1.0", - "ext-openssl": "*", - "php": "^5.3 || ^7.0 || ^7.1 || ^7.2" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.1", - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": false - }, - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Humbug\\": "src/" - }, - "files": [ - "src/function.php", - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Padraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Théo Fidry", - "email": "theo.fidry@gmail.com" - } - ], - "description": "Secure wrapper for accessing HTTPS resources with file_get_contents for PHP 5.3+", - "homepage": "https://github.com/padraic/file_get_contents", - "keywords": [ - "download", - "file_get_contents", - "http", - "https", - "ssl", - "tls" - ], - "time": "2018-02-12T18:47:17+00:00" - }, - { - "name": "padraic/phar-updater", - "version": "v1.0.6", - "source": { - "type": "git", - "url": "https://github.com/humbug/phar-updater.git", - "reference": "d01d3b8f26e541ac9b9eeba1e18d005d852f7ff1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/humbug/phar-updater/zipball/d01d3b8f26e541ac9b9eeba1e18d005d852f7ff1", - "reference": "d01d3b8f26e541ac9b9eeba1e18d005d852f7ff1", - "shasum": "" - }, - "require": { - "padraic/humbug_get_contents": "^1.0", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Humbug\\SelfUpdate\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Padraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - } - ], - "description": "A thing to make PHAR self-updating easy and secure.", - "keywords": [ - "humbug", - "phar", - "self-update", - "update" - ], - "time": "2018-03-30T12:52:15+00:00" - }, { "name": "paragonie/random_compat", "version": "v2.0.18", @@ -1769,68 +1512,6 @@ ], "time": "2019-11-01T11:05:21+00:00" }, - { - "name": "satooshi/php-coveralls", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-coveralls/php-coveralls.git", - "reference": "37f8f83fe22224eb9d9c6d593cdeb33eedd2a9ad" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/37f8f83fe22224eb9d9c6d593cdeb33eedd2a9ad", - "reference": "37f8f83fe22224eb9d9c6d593cdeb33eedd2a9ad", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-simplexml": "*", - "guzzle/guzzle": "^2.8 || ^3.0", - "php": "^5.3.3 || ^7.0", - "psr/log": "^1.0", - "symfony/config": "^2.1 || ^3.0 || ^4.0", - "symfony/console": "^2.1 || ^3.0 || ^4.0", - "symfony/stopwatch": "^2.0 || ^3.0 || ^4.0", - "symfony/yaml": "^2.0 || ^3.0 || ^4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0" - }, - "suggest": { - "symfony/http-kernel": "Allows Symfony integration" - }, - "bin": [ - "bin/coveralls" - ], - "type": "library", - "autoload": { - "psr-4": { - "Satooshi\\": "src/Satooshi/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kitamura Satoshi", - "email": "with.no.parachute@gmail.com", - "homepage": "https://www.facebook.com/satooshi.jp" - } - ], - "description": "PHP client library for Coveralls API", - "homepage": "https://github.com/php-coveralls/php-coveralls", - "keywords": [ - "ci", - "coverage", - "github", - "test" - ], - "abandoned": "php-coveralls/php-coveralls", - "time": "2017-12-06T23:17:56+00:00" - }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -2345,119 +2026,101 @@ "time": "2016-10-03T07:35:21+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.0.0", + "name": "sensiolabs/security-checker", + "version": "v5.0.3", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "b95ff2c3b122a3ee4b57d149a57d2afce65522c3" + "url": "https://github.com/sensiolabs/security-checker.git", + "reference": "46be3f58adac13084497961e10eed9a7fb4d44d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b95ff2c3b122a3ee4b57d149a57d2afce65522c3", - "reference": "b95ff2c3b122a3ee4b57d149a57d2afce65522c3", + "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/46be3f58adac13084497961e10eed9a7fb4d44d1", + "reference": "46be3f58adac13084497961e10eed9a7fb4d44d1", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" + "composer/ca-bundle": "^1.0", + "php": ">=5.5.9", + "symfony/console": "~2.7|~3.0|~4.0" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "security-checker" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "SensioLabs\\Security\\": "SensioLabs/Security" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Greg Sherwood", - "role": "lead" + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2017-05-04T00:33:04+00:00" + "description": "A security checker for your composer.lock", + "time": "2018-12-19T17:14:59+00:00" }, { - "name": "symfony/config", - "version": "v3.4.36", + "name": "squizlabs/php_codesniffer", + "version": "3.5.3", "source": { "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe" + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "557a1fc7ac702c66b0bbfe16ab3d55839ef724cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a599a867d0e4a07c342b5f1e656b3915a540ddbe", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/557a1fc7ac702c66b0bbfe16ab3d55839ef724cb", + "reference": "557a1fc7ac702c66b0bbfe16ab3d55839ef724cb", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0|~4.0", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3", - "symfony/finder": "<3.3" + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" }, "require-dev": { - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/event-dispatcher": "~3.3|~4.0", - "symfony/finder": "~3.3|~4.0", - "symfony/yaml": "~3.0|~4.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "3.x-dev" } }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Greg Sherwood", + "role": "lead" } ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T10:45:41+00:00" + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2019-12-04T04:46:47+00:00" }, { "name": "symfony/console", @@ -3183,9 +2846,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "codeclimate/php-test-reporter": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Options.php b/src/Options.php index a2ce177..cccb2d4 100644 --- a/src/Options.php +++ b/src/Options.php @@ -12,7 +12,7 @@ use Halfpastfour\PHPChartJS\Options\Title; use Halfpastfour\PHPChartJS\Options\Tooltips; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Options @@ -45,7 +45,7 @@ class Options implements ChartOwnedInterface, ArraySerializableInterface, JsonSe protected $hover; /** - * @var \Zend\Json\Expr + * @var \Laminas\Json\Expr */ protected $onClick; @@ -123,7 +123,7 @@ public function getHover() } /** - * @return \Zend\Json\Expr + * @return \Laminas\Json\Expr */ public function getOnClick() { diff --git a/src/Options/Animation.php b/src/Options/Animation.php index eb765a2..2e553c8 100644 --- a/src/Options/Animation.php +++ b/src/Options/Animation.php @@ -5,7 +5,7 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Animation diff --git a/src/Options/Hover.php b/src/Options/Hover.php index 5156a2b..2617dcb 100644 --- a/src/Options/Hover.php +++ b/src/Options/Hover.php @@ -5,7 +5,7 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Hover @@ -105,7 +105,7 @@ public function setAnimationDuration($animationDuration) } /** - * @return \Zend\Json\Expr + * @return \Laminas\Json\Expr */ public function getOnHover() { diff --git a/src/Options/Legend.php b/src/Options/Legend.php index 5324721..2e3c3a4 100644 --- a/src/Options/Legend.php +++ b/src/Options/Legend.php @@ -6,7 +6,7 @@ use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\LabelsCollection; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Legend diff --git a/src/Options/Legend/Labels.php b/src/Options/Legend/Labels.php index 7b7fcc3..898fdf9 100644 --- a/src/Options/Legend/Labels.php +++ b/src/Options/Legend/Labels.php @@ -5,7 +5,7 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class PieLegend diff --git a/src/Options/Scales/Ticks.php b/src/Options/Scales/Ticks.php index 4737233..9e0edf8 100644 --- a/src/Options/Scales/Ticks.php +++ b/src/Options/Scales/Ticks.php @@ -5,7 +5,7 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Ticks diff --git a/src/Options/Tooltips.php b/src/Options/Tooltips.php index 6a26380..fa65625 100644 --- a/src/Options/Tooltips.php +++ b/src/Options/Tooltips.php @@ -6,7 +6,7 @@ use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use Halfpastfour\PHPChartJS\Options\Tooltips\Callbacks; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Tooltips @@ -198,7 +198,7 @@ public function setEnabled($enabled) } /** - * @return \Zend\Json\Expr + * @return \Laminas\Json\Expr */ public function getCustom() { @@ -206,7 +206,7 @@ public function getCustom() } /** - * @param \Zend\Json\Expr $custom + * @param \Laminas\Json\Expr $custom * * @return $this */ diff --git a/src/Options/Tooltips/Callbacks.php b/src/Options/Tooltips/Callbacks.php index 8b72e8e..7864510 100644 --- a/src/Options/Tooltips/Callbacks.php +++ b/src/Options/Tooltips/Callbacks.php @@ -5,7 +5,7 @@ use Halfpastfour\PHPChartJS\ArraySerializableInterface; use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; use JsonSerializable; -use Zend\Json\Expr; +use Laminas\Json\Expr; /** * Class Callbacks diff --git a/src/Renderer/Json.php b/src/Renderer/Json.php index bde7ad5..29f9b17 100644 --- a/src/Renderer/Json.php +++ b/src/Renderer/Json.php @@ -2,7 +2,7 @@ namespace Halfpastfour\PHPChartJS\Renderer; -use Zend\Json\Json as JsonHelper; +use Laminas\Json\Json as JsonHelper; /** * Class Json diff --git a/test/TestUtils.php b/test/TestUtils.php index 117d3bc..787bef8 100644 --- a/test/TestUtils.php +++ b/test/TestUtils.php @@ -2,7 +2,8 @@ namespace Test; -use Zend\Json\Expr; +use Laminas\Json\Expr; +use RuntimeException; /** * Class TestUtils @@ -21,13 +22,13 @@ public static function setAttributes($obj, array $data) { if (! is_object($obj)) { - throw new \RuntimeException("First param should be an object. "); + throw new RuntimeException("First param should be an object. "); } foreach ($data as $key => $value) { $function = 'set' . ucfirst($key); if (! is_null($value) && method_exists($obj, $function)) { - $obj->$function( $value ); + $obj->$function($value); } } } @@ -46,14 +47,14 @@ public static function getAttributes($obj, array $dataTypes) { if (! is_object($obj)) { - throw new \RuntimeException("First param should be an object. "); + throw new RuntimeException("First param should be an object. "); } $array = []; foreach ($dataTypes as $key => $value) { $function = ( gettype($value) == "boolean" ? 'is' : 'get' ) . ucfirst($key); if (method_exists($obj, $function)) { - $getResult = $obj->$function( $value ); + $getResult = $obj->$function($value); $getResult = $getResult instanceof Expr ? $getResult->__toString() : $getResult; $array[ $key ] = $getResult; } diff --git a/test/unit/Options/ClickTest.php b/test/unit/Options/ClickTest.php index 007b864..62affda 100644 --- a/test/unit/Options/ClickTest.php +++ b/test/unit/Options/ClickTest.php @@ -3,9 +3,9 @@ namespace Test\Options; use Halfpastfour\PHPChartJS\Options; +use Laminas\Json\Expr; use PHPUnit_Framework_TestCase; use Test\TestUtils; -use Zend\Json\Expr; /** * Class ClickTest diff --git a/test/unit/Options/LegendTest.php b/test/unit/Options/LegendTest.php index ceddaeb..4ef7668 100644 --- a/test/unit/Options/LegendTest.php +++ b/test/unit/Options/LegendTest.php @@ -4,9 +4,9 @@ use Halfpastfour\PHPChartJS\LabelsCollection; use Halfpastfour\PHPChartJS\Options\Legend; +use Laminas\Json\Expr; use PHPUnit_Framework_TestCase; use Test\TestUtils; -use Zend\Json\Expr; /** * Class LegendTest diff --git a/test/unit/Options/Tooltips/CallbacksTest.php b/test/unit/Options/Tooltips/CallbacksTest.php index 70e551f..1d4f3c7 100644 --- a/test/unit/Options/Tooltips/CallbacksTest.php +++ b/test/unit/Options/Tooltips/CallbacksTest.php @@ -3,9 +3,9 @@ namespace Test\Options\Tooltips; use Halfpastfour\PHPChartJS\Options\Tooltips\Callbacks; +use Laminas\Json\Expr; use PHPUnit_Framework_TestCase; use Test\TestUtils; -use Zend\Json\Expr; /** * Class CallbacksTest