From cd8846db198faf00cac3f70ba99e29567ca2cd20 Mon Sep 17 00:00:00 2001 From: mwansinck Date: Wed, 23 Feb 2022 10:44:04 +0100 Subject: [PATCH] deps: Updated php-cs-fixer to ^3.6 --- .php_cs.dist => .php-cs-fixer.dist.php | 8 ++--- Datatable/AbstractDatatable.php | 4 +-- Datatable/Action/Action.php | 10 +++--- Datatable/Column/AbstractColumn.php | 12 ++++---- Datatable/Column/BooleanColumn.php | 4 +-- Datatable/Column/ColumnInterface.php | 2 +- Datatable/Column/NumberColumn.php | 2 +- Datatable/DatatableFactory.php | 4 +-- Datatable/DatatableInterface.php | 2 +- Datatable/Extension/Responsive.php | 4 +-- Datatable/Extension/RowGroup.php | 36 ++++++---------------- Datatable/OptionsTrait.php | 8 ++--- Datatable/Style.php | 42 +++++++++++++------------- Generator/DatatableGenerator.php | 8 +---- Response/DatatableQueryBuilder.php | 10 +++--- Tests/DatatableTest.php | 2 +- composer.json | 2 +- 17 files changed, 62 insertions(+), 98 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (88%) diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 88% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index 29296c27..cc6903b5 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -15,10 +15,9 @@ ->append([__DIR__.'/php-cs-fixer']) ; -$config = PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setRules([ - '@PHP56Migration' => true, '@PhpCsFixer' => true, '@PhpCsFixer:risky' => true, '@PHPUnit60Migration:risky' => true, @@ -31,7 +30,4 @@ 'no_useless_return' => true, 'not_operator_with_successor_space' => true, ]) - ->setFinder($finder) -; - -return $config; + ->setFinder($finder); diff --git a/Datatable/AbstractDatatable.php b/Datatable/AbstractDatatable.php index d05c03eb..805d13cf 100755 --- a/Datatable/AbstractDatatable.php +++ b/Datatable/AbstractDatatable.php @@ -168,8 +168,8 @@ public function __construct( $this->authorizationChecker = $authorizationChecker; $this->securityToken = $securityToken; - if (!($translator instanceof LegacyTranslatorInterface) && !($translator instanceof TranslatorInterface)) { - throw new \InvalidArgumentException(sprintf('The $translator argument of %s must be an instance of %s or %s, a %s was given.', static::class, LegacyTranslatorInterface::class, TranslatorInterface::class, get_class($translator))); + if (! ($translator instanceof LegacyTranslatorInterface) && ! ($translator instanceof TranslatorInterface)) { + throw new \InvalidArgumentException(sprintf('The $translator argument of %s must be an instance of %s or %s, a %s was given.', static::class, LegacyTranslatorInterface::class, TranslatorInterface::class, \get_class($translator))); } $this->translator = $translator; $this->router = $router; diff --git a/Datatable/Action/Action.php b/Datatable/Action/Action.php index e19743d6..2f5770aa 100644 --- a/Datatable/Action/Action.php +++ b/Datatable/Action/Action.php @@ -20,17 +20,17 @@ class Action { - use OptionsTrait; - - // Render an Action only if conditions are TRUE. - use RenderIfTrait; - /* * An Action has a 'start_html' and a 'end_html' option. * action */ use HtmlContainerTrait; + use OptionsTrait; + + // Render an Action only if conditions are TRUE. + use RenderIfTrait; + /** * The name of the Action route. * Default: null. diff --git a/Datatable/Column/AbstractColumn.php b/Datatable/Column/AbstractColumn.php index af5609aa..e5c5f2cb 100755 --- a/Datatable/Column/AbstractColumn.php +++ b/Datatable/Column/AbstractColumn.php @@ -23,11 +23,11 @@ abstract class AbstractColumn implements ColumnInterface { - use OptionsTrait; - // Use an 'add_if' option to check in ColumnBuilder if the Column can be added. use AddIfTrait; + use OptionsTrait; + //------------------------------------------------- // Column Types //------------------------------------------------- @@ -35,22 +35,22 @@ abstract class AbstractColumn implements ColumnInterface /** * Identifies a Data Column. */ - const DATA_COLUMN = 'data'; + public const DATA_COLUMN = 'data'; /** * Identifies an Action Column. */ - const ACTION_COLUMN = 'action'; + public const ACTION_COLUMN = 'action'; /** * Identifies a Multiselect Column. */ - const MULTISELECT_COLUMN = 'multiselect'; + public const MULTISELECT_COLUMN = 'multiselect'; /** * Identifies a Virtual Column. */ - const VIRTUAL_COLUMN = 'virtual'; + public const VIRTUAL_COLUMN = 'virtual'; //-------------------------------------------------------------------------------------------------- // DataTables - Columns Options diff --git a/Datatable/Column/BooleanColumn.php b/Datatable/Column/BooleanColumn.php index 1e5423d6..811e769f 100644 --- a/Datatable/Column/BooleanColumn.php +++ b/Datatable/Column/BooleanColumn.php @@ -26,12 +26,12 @@ class BooleanColumn extends AbstractColumn /** * @internal */ - const RENDER_TRUE_VALUE = 'true'; + public const RENDER_TRUE_VALUE = 'true'; /** * @internal */ - const RENDER_FALSE_VALUE = 'false'; + public const RENDER_FALSE_VALUE = 'false'; /** * The icon for a value that is true. diff --git a/Datatable/Column/ColumnInterface.php b/Datatable/Column/ColumnInterface.php index 05a86c58..2667d583 100644 --- a/Datatable/Column/ColumnInterface.php +++ b/Datatable/Column/ColumnInterface.php @@ -19,7 +19,7 @@ interface ColumnInterface /** * @var int */ - const LAST_POSITION = -1; + public const LAST_POSITION = -1; /** * Validates $dql. Normally a non-empty string is expected. diff --git a/Datatable/Column/NumberColumn.php b/Datatable/Column/NumberColumn.php index f03396f5..f363b4f3 100644 --- a/Datatable/Column/NumberColumn.php +++ b/Datatable/Column/NumberColumn.php @@ -149,7 +149,7 @@ public function getFormatter() /** * @return $this */ - public function setFormatter(\NumberFormatter $formatter) + public function setFormatter(\NumberFormatter $formatter) { $this->formatter = $formatter; diff --git a/Datatable/DatatableFactory.php b/Datatable/DatatableFactory.php index 8fd7bab0..a86a91e3 100755 --- a/Datatable/DatatableFactory.php +++ b/Datatable/DatatableFactory.php @@ -75,8 +75,8 @@ public function __construct( $this->authorizationChecker = $authorizationChecker; $this->securityToken = $securityToken; - if (!($translator instanceof LegacyTranslatorInterface) && !($translator instanceof TranslatorInterface)) { - throw new \InvalidArgumentException(sprintf('The $translator argument of %s must be an instance of %s or %s, a %s was given.', static::class, LegacyTranslatorInterface::class, TranslatorInterface::class, get_class($translator))); + if (! ($translator instanceof LegacyTranslatorInterface) && ! ($translator instanceof TranslatorInterface)) { + throw new \InvalidArgumentException(sprintf('The $translator argument of %s must be an instance of %s or %s, a %s was given.', static::class, LegacyTranslatorInterface::class, TranslatorInterface::class, \get_class($translator))); } $this->translator = $translator; $this->router = $router; diff --git a/Datatable/DatatableInterface.php b/Datatable/DatatableInterface.php index d5192f7f..9b6f91ca 100644 --- a/Datatable/DatatableInterface.php +++ b/Datatable/DatatableInterface.php @@ -19,7 +19,7 @@ */ interface DatatableInterface { - const NAME_REGEX = '/^[a-zA-Z0-9\-\_]+$/'; + public const NAME_REGEX = '/^[a-zA-Z0-9\-\_]+$/'; /** * Builds the datatable. diff --git a/Datatable/Extension/Responsive.php b/Datatable/Extension/Responsive.php index 45ca34f3..d28ed938 100644 --- a/Datatable/Extension/Responsive.php +++ b/Datatable/Extension/Responsive.php @@ -76,9 +76,7 @@ public function setDetails($details) if (\is_array($details)) { foreach ($details as $key => $value) { if (false === \in_array($key, ['type', 'target', 'renderer', 'display'], true)) { - throw new Exception( - "Responsive::setDetails(): {$key} is not an valid option." - ); + throw new Exception("Responsive::setDetails(): {$key} is not an valid option."); } } diff --git a/Datatable/Extension/RowGroup.php b/Datatable/Extension/RowGroup.php index 410b23a9..85a294c4 100644 --- a/Datatable/Extension/RowGroup.php +++ b/Datatable/Extension/RowGroup.php @@ -148,9 +148,7 @@ public function getDataSrc() public function setDataSrc($dataSrc) { if (\is_string($dataSrc) && empty($dataSrc)) { - throw new \Exception( - 'RowGroup::setDataSrc(): the column name is empty.' - ); + throw new \Exception('RowGroup::setDataSrc(): the column name is empty.'); } $this->dataSrc = $dataSrc; @@ -174,16 +172,12 @@ public function getStartRender() public function setStartRender($startRender) { if (false === \array_key_exists('template', $startRender)) { - throw new Exception( - 'RowGroup::setStartRender(): The "template" option is required.' - ); + throw new Exception('RowGroup::setStartRender(): The "template" option is required.'); } foreach ($startRender as $key => $value) { if (false === \in_array($key, ['template', 'vars'], true)) { - throw new Exception( - "RowGroup::setStartRender(): {$key} is not a valid option." - ); + throw new Exception("RowGroup::setStartRender(): {$key} is not a valid option."); } } @@ -208,16 +202,12 @@ public function getEndRender() public function setEndRender($endRender) { if (false === \array_key_exists('template', $endRender)) { - throw new Exception( - 'RowGroup::setEndRender(): The "template" option is required.' - ); + throw new Exception('RowGroup::setEndRender(): The "template" option is required.'); } foreach ($endRender as $key => $value) { if (false === \in_array($key, ['template', 'vars'], true)) { - throw new Exception( - "RowGroup::setEndRender(): {$key} is not a valid option." - ); + throw new Exception("RowGroup::setEndRender(): {$key} is not a valid option."); } } @@ -242,9 +232,7 @@ public function getClassName() public function setClassName($className) { if (\is_string($className) && empty($className)) { - throw new \Exception( - 'RowGroup::setClassName(): the class name is empty.' - ); + throw new \Exception('RowGroup::setClassName(): the class name is empty.'); } $this->className = $className; @@ -268,9 +256,7 @@ public function getEmptyDataGroup() public function setEmptyDataGroup($emptyDataGroup) { if (\is_string($emptyDataGroup) && empty($emptyDataGroup)) { - throw new \Exception( - 'RowGroup::setEmptyDataGroup(): the empty data group text is empty.' - ); + throw new \Exception('RowGroup::setEmptyDataGroup(): the empty data group text is empty.'); } $this->emptyDataGroup = $emptyDataGroup; @@ -314,9 +300,7 @@ public function getEndClassName() public function setEndClassName($endClassName) { if (\is_string($endClassName) && empty($endClassName)) { - throw new \Exception( - 'RowGroup::setEndClassName(): the end class name is empty.' - ); + throw new \Exception('RowGroup::setEndClassName(): the end class name is empty.'); } $this->endClassName = $endClassName; @@ -340,9 +324,7 @@ public function getStartClassName() public function setStartClassName($startClassName) { if (\is_string($startClassName) && empty($startClassName)) { - throw new \Exception( - 'RowGroup::setStartClassName(): the start class name is empty.' - ); + throw new \Exception('RowGroup::setStartClassName(): the start class name is empty.'); } $this->startClassName = $startClassName; diff --git a/Datatable/OptionsTrait.php b/Datatable/OptionsTrait.php index 2fd3a958..e7bcbef9 100644 --- a/Datatable/OptionsTrait.php +++ b/Datatable/OptionsTrait.php @@ -98,16 +98,12 @@ protected function optionToJson($value) protected function validateArrayForTemplateAndOther(array $array, array $other = ['template', 'vars']) { if (false === \array_key_exists('template', $array)) { - throw new Exception( - 'OptionsTrait::validateArrayForTemplateAndOther(): The "template" option is required.' - ); + throw new Exception('OptionsTrait::validateArrayForTemplateAndOther(): The "template" option is required.'); } foreach ($array as $key => $value) { if (false === \in_array($key, $other, true)) { - throw new Exception( - "OptionsTrait::validateArrayForTemplateAndOther(): {$key} is not an valid option." - ); + throw new Exception("OptionsTrait::validateArrayForTemplateAndOther(): {$key} is not an valid option."); } } diff --git a/Datatable/Style.php b/Datatable/Style.php index d5edeece..616b4d7f 100644 --- a/Datatable/Style.php +++ b/Datatable/Style.php @@ -22,105 +22,105 @@ class Style * * @var string */ - const BASE_STYLE = 'display'; + public const BASE_STYLE = 'display'; /** * Default style with none of the additional feature style classes. * * @var string */ - const BASE_STYLE_NO_CLASSES = ''; + public const BASE_STYLE_NO_CLASSES = ''; /** * Default style with cell border. * * @var string */ - const BASE_STYLE_CELL_BORDERS = 'cell-border'; + public const BASE_STYLE_CELL_BORDERS = 'cell-border'; /** * Reduce the amount of white-spaces. * * @var string */ - const BASE_STYLE_COMPACT = 'display compact'; + public const BASE_STYLE_COMPACT = 'display compact'; /** * Default style with hover class. * * @var string */ - const BASE_STYLE_HOVER = 'hover'; + public const BASE_STYLE_HOVER = 'hover'; /** * Default style with order-column class. * * @var string */ - const BASE_STYLE_ORDER_COLUMN = 'order-column'; + public const BASE_STYLE_ORDER_COLUMN = 'order-column'; /** * Default style with row border. * * @var string */ - const BASE_STYLE_ROW_BORDERS = 'row-border'; + public const BASE_STYLE_ROW_BORDERS = 'row-border'; /** * Default style with stripe class. * * @var string */ - const BASE_STYLE_STRIPE = 'stripe'; + public const BASE_STYLE_STRIPE = 'stripe'; /** * Bootstrap3 table styling options. * * @var string */ - const BOOTSTRAP_3_STYLE = 'table table-striped table-bordered'; + public const BOOTSTRAP_3_STYLE = 'table table-striped table-bordered'; /** * Foundations's table styling options. * * @var string */ - const FOUNDATION_STYLE = 'display'; + public const FOUNDATION_STYLE = 'display'; /** * Semantic UI styling options. * * @var string */ - const SEMANTIC_UI_STYLE = 'ui celled table'; + public const SEMANTIC_UI_STYLE = 'ui celled table'; /** * jQuery UI's ThemeRoller styles. * * @var string */ - const JQUERY_UI_STYLE = 'display'; + public const JQUERY_UI_STYLE = 'display'; /** * Bootstrap4 table styling options. * * @var string */ - const BOOTSTRAP_4_STYLE = 'table table-striped table-bordered'; + public const BOOTSTRAP_4_STYLE = 'table table-striped table-bordered'; /** * Material Design style. * * @var string */ - const MATERIAL_DESIGN = 'mdl-data-table'; + public const MATERIAL_DESIGN = 'mdl-data-table'; /** * Uikit styling options. * * @var string */ - const UI_KIT = 'uk-table uk-table-hover uk-table-striped'; + public const UI_KIT = 'uk-table uk-table-hover uk-table-striped'; //------------------------------------------------- // Built-in paging button arrangements @@ -131,40 +131,40 @@ class Style * * @var string */ - const NUMBERS_PAGINATION = 'numbers'; + public const NUMBERS_PAGINATION = 'numbers'; /** * "Previous" and "Next" buttons only. * * @var string */ - const SIMPLE_PAGINATION = 'simple'; + public const SIMPLE_PAGINATION = 'simple'; /** * "Previous" and "Next" buttons, plus page numbers. * * @var string */ - const SIMPLE_NUMBERS_PAGINATION = 'simple_numbers'; + public const SIMPLE_NUMBERS_PAGINATION = 'simple_numbers'; /** * "First", "Previous", "Next" and "Last" buttons. * * @var string */ - const FULL_PAGINATION = 'full'; + public const FULL_PAGINATION = 'full'; /** * "First", "Previous", "Next" and "Last" buttons, plus page numbers. * * @var string */ - const FULL_NUMBERS_PAGINATION = 'full_numbers'; + public const FULL_NUMBERS_PAGINATION = 'full_numbers'; /** * "First" and "Last" buttons, plus page numbers. * * @var string */ - const FIRST_LAST_NUMBERS_PAGINATION = 'first_last_numbers'; + public const FIRST_LAST_NUMBERS_PAGINATION = 'first_last_numbers'; } diff --git a/Generator/DatatableGenerator.php b/Generator/DatatableGenerator.php index 9e718609..c93df5d9 100644 --- a/Generator/DatatableGenerator.php +++ b/Generator/DatatableGenerator.php @@ -60,13 +60,7 @@ public function generate(BundleInterface $bundle, $entity, array $fields, $id, $ if (! $overwrite) { if (file_exists($this->classPath)) { - throw new Exception( - sprintf( - 'Unable to generate the %s as it already exists under the %s.', - $this->className, - $this->classPath - ) - ); + throw new Exception(sprintf('Unable to generate the %s as it already exists under the %s.', $this->className, $this->classPath)); } } diff --git a/Response/DatatableQueryBuilder.php b/Response/DatatableQueryBuilder.php index f7aa60be..8d8a340d 100644 --- a/Response/DatatableQueryBuilder.php +++ b/Response/DatatableQueryBuilder.php @@ -36,12 +36,12 @@ class DatatableQueryBuilder /** * @internal */ - const DISABLE_PAGINATION = -1; + public const DISABLE_PAGINATION = -1; /** * @internal */ - const INIT_PARAMETER_COUNTER = 100; + public const INIT_PARAMETER_COUNTER = 100; /** * $_GET or $_POST parameters. @@ -80,8 +80,6 @@ class DatatableQueryBuilder /** * The root ID of the entity. - * - * @var mixed */ private $rootEntityIdentifier; @@ -429,7 +427,7 @@ private function initColumnArrays() foreach ($orderColumns as $orderColumn) { $orderParts = explode('.', $orderColumn); if (\count($orderParts) < 2) { - if (!isset($this->columnNames[$orderColumn]) || null == $this->accessor->getValue($this->columns[$this->columnNames[$orderColumn]], 'customDql')) { + if (! isset($this->columnNames[$orderColumn]) || null === $this->accessor->getValue($this->columns[$this->columnNames[$orderColumn]], 'customDql')) { $orderColumn = $this->entityShortName.'.'.$orderColumn; } } @@ -445,7 +443,7 @@ private function initColumnArrays() foreach ($searchColumns as $searchColumn) { $searchParts = explode('.', $searchColumn); if (\count($searchParts) < 2) { - $searchColumn = $this->entityShortName . '.' . $searchColumn; + $searchColumn = $this->entityShortName.'.'.$searchColumn; } $this->searchColumns[$key][] = $searchColumn; } diff --git a/Tests/DatatableTest.php b/Tests/DatatableTest.php index 4b934465..0ada1619 100755 --- a/Tests/DatatableTest.php +++ b/Tests/DatatableTest.php @@ -60,7 +60,7 @@ public function testCreate() /** @var \Sg\DatatablesBundle\Tests\Datatables\PostDatatable $table */ $table = new $tableClass($authorizationChecker, $securityToken, $translator, $router, $em, $twig); - /** @noinspection PhpUndefinedMethodInspection */ + /* @noinspection PhpUndefinedMethodInspection */ static::assertSame('post_datatable', $table->getName()); $table->buildDatatable(); diff --git a/composer.json b/composer.json index d43dba8e..83ab9052 100755 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ }, "require-dev": { "phpunit/phpunit": "^7.5|^8.5", - "friendsofphp/php-cs-fixer": "^2.15" + "friendsofphp/php-cs-fixer": "^3.6" }, "autoload": { "psr-4": { "Sg\\DatatablesBundle\\": "" }