Skip to content

Commit

Permalink
Merge pull request #36 from cmen/sf5
Browse files Browse the repository at this point in the history
Compatibility with Symfony 5
  • Loading branch information
cmen authored Nov 26, 2019
2 parents b07b234 + da86da3 commit 350b39d
Show file tree
Hide file tree
Showing 27 changed files with 41 additions and 56 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/CMENGoogleChartsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace CMEN\GoogleChartsBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class CMENGoogleChartsExtension extends Extension
{
Expand Down
2 changes: 0 additions & 2 deletions GoogleCharts/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class Events

/**
* Events constructor.
*
* @param Chart $chart
*/
public function __construct(Chart $chart)
{
Expand Down
4 changes: 2 additions & 2 deletions GoogleCharts/Options/BarChart/BarChartOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace CMEN\GoogleChartsBundle\GoogleCharts\Options\BarChart;

use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedAnimation;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedAnnotations;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedChartOptions;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedLegend;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedTooltip;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Bar;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\DataOpacityTrait;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Explorer;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedLegend;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\FocusTargetTrait;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\HAxis;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\IsStackedTrait;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\MediumHAxis;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AdvancedAnnotations;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\OrientationTrait;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\ReverseCategoriesTrait;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Trendlines;
Expand Down
4 changes: 1 addition & 3 deletions Output/AbstractChartOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public function setLanguage($language)
protected function checkElementsId(array $charts, array $elementsID)
{
if (count($charts) != count($elementsID)) {
throw new GoogleChartsException(
'Array charts and array HTML elements ID do not have the same number of element.'
);
throw new GoogleChartsException('Array charts and array HTML elements ID do not have the same number of element.');
}

foreach ($elementsID as $elementId) {
Expand Down
4 changes: 0 additions & 4 deletions Output/ChartOutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ interface ChartOutputInterface
/**
* Returns a string to draw the beginning of the chart (Declaration, data and options).
*
* @param Chart $chart
*
* @return string
*
* @throws GoogleChartsException
Expand All @@ -24,8 +22,6 @@ public function startChart(Chart $chart);
/**
* Returns a string to draw the end of the chart (Events and drawing).
*
* @param Chart $chart
*
* @return string
*/
public function endChart(Chart $chart);
Expand Down
1 change: 0 additions & 1 deletion Output/DataOutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface DataOutputInterface
/**
* Returns a string to draw data.
*
* @param Data $data
* @param string $dataName Variable name who will contain the data
*
* @return string
Expand Down
2 changes: 0 additions & 2 deletions Output/DateOutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ interface DateOutputInterface
/**
* Returns a string to draw a DateTimeInterface object.
*
* @param \DateTimeInterface $date
*
* @return string
*/
public function draw(\DateTimeInterface $date);
Expand Down
1 change: 0 additions & 1 deletion Output/EventsOutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface EventsOutputInterface
/**
* Returns a string to draw events of a chart.
*
* @param Events $events
* @param string $chartName
*
* @return string
Expand Down
7 changes: 2 additions & 5 deletions Output/Javascript/ChartOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ class ChartOutput extends AbstractChartOutput
/**
* ChartOutput constructor.
*
* @param string $version
* @param string $language
* @param OptionsOutputInterface $optionsOutput
* @param DataOutputInterface $dataOutput
* @param EventsOutputInterface $eventsOutput
* @param string $version
* @param string $language
*/
public function __construct(
$version,
Expand Down
6 changes: 1 addition & 5 deletions Output/Javascript/DataOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class DataOutput implements DataOutputInterface

/**
* DataOutput constructor.
*
* @param DateOutputInterface $dateOutput
*/
public function __construct(DateOutputInterface $dateOutput)
{
Expand All @@ -33,9 +31,7 @@ public function draw(Data $data, $dataName)
$arrayToDataTable = $data->getArrayToDataTable();

if (!$arrayToDataTable) {
throw new GoogleChartsException(
'There is no data for chart. Use method setArrayToDataTable() to provide data.'
);
throw new GoogleChartsException('There is no data for chart. Use method setArrayToDataTable() to provide data.');
}

$js = "var $dataName = new google.visualization.arrayToDataTable([";
Expand Down
2 changes: 0 additions & 2 deletions Output/Javascript/OptionsOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class OptionsOutput extends AbstractOptionsOutput

/**
* OptionsOutput constructor.
*
* @param DateOutputInterface $dateOutput
*/
public function __construct(DateOutputInterface $dateOutput)
{
Expand Down
3 changes: 1 addition & 2 deletions Output/OptionsOutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public function renameRecursivelyKeys($options);
* a string or an array. If an option have a null value, an empty array or an empty class, it is not returned :
* the default value will be applied.
*
* @param ChartOptionsInterface $options
* @param string $optionsName Variable name who will contain the options
* @param string $optionsName Variable name who will contain the options
*
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion Tests/GoogleCharts/Charts/AnnotationChartTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Charts;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Charts;

use CMEN\GoogleChartsBundle\GoogleCharts\Charts\AnnotationChart;
use CMEN\GoogleChartsBundle\Output\ChartOutputInterface;
Expand Down
2 changes: 1 addition & 1 deletion Tests/GoogleCharts/Charts/ColumnChartTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Charts;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Charts;

use CMEN\GoogleChartsBundle\GoogleCharts\Charts\ColumnChart;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Trendlines;
Expand Down
2 changes: 1 addition & 1 deletion Tests/GoogleCharts/Charts/GanttChartTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Charts;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Charts;

use CMEN\GoogleChartsBundle\GoogleCharts\Charts\GanttChart;
use CMEN\GoogleChartsBundle\Output\ChartOutputInterface;
Expand Down
2 changes: 1 addition & 1 deletion Tests/GoogleCharts/Charts/LineChartTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Charts;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Charts;

use CMEN\GoogleChartsBundle\GoogleCharts\Charts\LineChart;
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Trendlines;
Expand Down
2 changes: 1 addition & 1 deletion Tests/GoogleCharts/EventsTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts;

use CMEN\GoogleChartsBundle\GoogleCharts\Charts\ComboChart;
use CMEN\GoogleChartsBundle\GoogleCharts\Charts\Map;
Expand Down
2 changes: 1 addition & 1 deletion Tests/GoogleCharts/ListenerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts;

use CMEN\GoogleChartsBundle\GoogleCharts\EventType;
use CMEN\GoogleChartsBundle\GoogleCharts\Listener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Options\AnnotationChart;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Options\AnnotationChart;

use CMEN\GoogleChartsBundle\GoogleCharts\Options\AnnotationChart\AnnotationChartOptions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Options\ColumnChart;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Options\ColumnChart;

use CMEN\GoogleChartsBundle\GoogleCharts\Options\ColumnChart\ColumnChartOptions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Options\GanttChart;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Options\GanttChart;

use CMEN\GoogleChartsBundle\GoogleCharts\Options\GanttChart\GanttChartOptions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\GoogleCharts\Options\LineChart;
namespace CMEN\GoogleChartsBundle\Tests\GoogleCharts\Options\LineChart;

use CMEN\GoogleChartsBundle\GoogleCharts\Options\LineChart\LineChartOptions;

Expand Down
2 changes: 1 addition & 1 deletion Tests/Output/Javascript/ChartOutputTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\Output\Javascript;
namespace CMEN\GoogleChartsBundle\Tests\Output\Javascript;

use CMEN\GoogleChartsBundle\GoogleCharts\Charts\ColumnChart;
use CMEN\GoogleChartsBundle\Output\ChartOutputInterface;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Output/Javascript/DataOutputTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\Output\Javascript;
namespace CMEN\GoogleChartsBundle\Tests\Output\Javascript;

use CMEN\GoogleChartsBundle\GoogleCharts\Data;
use CMEN\GoogleChartsBundle\Output\Javascript\DataOutput;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Output/Javascript/DateOutputTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\CMEN\GoogleChartsBundle\Output\Javascript;
namespace CMEN\GoogleChartsBundle\Tests\Output\Javascript;

use CMEN\GoogleChartsBundle\Output\Javascript\DateOutput;

Expand Down
16 changes: 8 additions & 8 deletions Twig/GoogleChartsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
use CMEN\GoogleChartsBundle\Exception\GoogleChartsException;
use CMEN\GoogleChartsBundle\GoogleCharts\Chart;
use CMEN\GoogleChartsBundle\Output\ChartOutputInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* @author Christophe Meneses
*/
class GoogleChartsExtension extends \Twig_Extension
class GoogleChartsExtension extends AbstractExtension
{
/** @var ChartOutputInterface */
private $chartOutput;

/**
* GoogleChartsExtension constructor.
*
* @param ChartOutputInterface $chartOutput
*/
public function __construct(ChartOutputInterface $chartOutput)
{
Expand All @@ -30,11 +30,11 @@ public function __construct(ChartOutputInterface $chartOutput)
public function getFunctions()
{
return [
new \Twig_SimpleFunction('gc_draw', [$this, 'gcDraw'], ['is_safe' => ['html']]),
new \Twig_SimpleFunction('gc_start', [$this, 'gcStart'], ['is_safe' => ['html']]),
new \Twig_SimpleFunction('gc_end', [$this, 'gcEnd'], ['is_safe' => ['html']]),
new \Twig_SimpleFunction('gc_event', [$this, 'gcEvent'], ['is_safe' => ['html']]),
new \Twig_SimpleFunction('gc_language', [$this, 'gcLanguage']),
new TwigFunction('gc_draw', [$this, 'gcDraw'], ['is_safe' => ['html']]),
new TwigFunction('gc_start', [$this, 'gcStart'], ['is_safe' => ['html']]),
new TwigFunction('gc_end', [$this, 'gcEnd'], ['is_safe' => ['html']]),
new TwigFunction('gc_event', [$this, 'gcEvent'], ['is_safe' => ['html']]),
new TwigFunction('gc_language', [$this, 'gcLanguage']),
];
}

Expand Down
15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@
],
"require": {
"php": "^5.6 || ^7.0",
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0"
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0 || ^5.0",
"twig/twig": "^1.42 || ^2.12 || ^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"friendsofphp/php-cs-fixer": "^2.16"
},
"autoload": {
"psr-4": { "CMEN\\GoogleChartsBundle\\": "" }
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"friendsofphp/php-cs-fixer": "^2.9"
"autoload-dev": {
"psr-4": { "CMEN\\GoogleChartsBundle\\Tests\\": "Tests/" }
},
"config": {
"sort-packages": true
}
}

0 comments on commit 350b39d

Please sign in to comment.