diff --git a/phpstan.neon b/phpstan.neon index 60935294..0d42c566 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -46,10 +46,6 @@ parameters: message: '#string\\|Stringable#' count: 1 path: src/Column/Action.php - - # In PHP 8+, the Stringable typehint should be used, and this can be removed. - message: '#string\\|Stringable#' - count: 1 - path: src/DataGrid.php - # In PHP 8+, the Stringable typehint should be used, and this can be removed. message: '#string\\|Stringable#' count: 3 diff --git a/src/AggregationFunction/FunctionSum.php b/src/AggregationFunction/FunctionSum.php index 1ad9fb31..7fb74c42 100644 --- a/src/AggregationFunction/FunctionSum.php +++ b/src/AggregationFunction/FunctionSum.php @@ -41,7 +41,7 @@ public function processDataSource(Fluent|QueryBuilder|Collection|Selection|IColl ? $this->column : current($dataSource->getRootAliases()) . '.' . $this->column; - $this->result = $dataSource + $this->result = (int) $dataSource ->select(sprintf('SUM(%s)', $column)) ->setMaxResults(1) ->setFirstResult(0) diff --git a/src/DataSource/FilterableDataSource.php b/src/DataSource/FilterableDataSource.php index ccdbd48a..2cb2e8cd 100644 --- a/src/DataSource/FilterableDataSource.php +++ b/src/DataSource/FilterableDataSource.php @@ -14,20 +14,6 @@ abstract class FilterableDataSource { - abstract protected function getDataSource(): mixed; - - abstract protected function applyFilterDate(FilterDate $filter): void; - - abstract protected function applyFilterDateRange(FilterDateRange $filter): void; - - abstract protected function applyFilterRange(FilterRange $filter): void; - - abstract protected function applyFilterText(FilterText $filter): void; - - abstract protected function applyFilterMultiSelect(FilterMultiSelect $filter): void; - - abstract protected function applyFilterSelect(FilterSelect $filter): void; - /** * {@inheritDoc} * @@ -64,4 +50,18 @@ public function filter(array $filters): void } } + abstract protected function getDataSource(): mixed; + + abstract protected function applyFilterDate(FilterDate $filter): void; + + abstract protected function applyFilterDateRange(FilterDateRange $filter): void; + + abstract protected function applyFilterRange(FilterRange $filter): void; + + abstract protected function applyFilterText(FilterText $filter): void; + + abstract protected function applyFilterMultiSelect(FilterMultiSelect $filter): void; + + abstract protected function applyFilterSelect(FilterSelect $filter): void; + } diff --git a/src/Datagrid.php b/src/Datagrid.php index 5f2e5275..ad0f48ca 100644 --- a/src/Datagrid.php +++ b/src/Datagrid.php @@ -82,6 +82,15 @@ class Datagrid extends Control '_grid_hidden_columns_manipulated', ]; + public static string $iconPrefix = 'fa fa-'; + + public static string $btnSecondaryClass = 'btn-default btn-secondary'; + + /** + * Default form method + */ + public static string $formMethod = 'post'; + /** @var array|callable[] */ public array $onRedraw = []; @@ -149,15 +158,6 @@ class Datagrid extends Control */ public array $filter = []; - public static string $iconPrefix = 'fa fa-'; - - public static string $btnSecondaryClass = 'btn-default btn-secondary'; - - /** - * Default form method - */ - public static string $formMethod = 'post'; - /** @var callable|null */ protected $sortCallback = null; @@ -2201,7 +2201,7 @@ public function getPerPage(): int|string } /** - * @return array|array|int[]|array|string[] + * @return array|array|int[]|array|string[]|\Stringable[] */ public function getItemsPerPageList(): array { diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php index 69c3152d..6ba00ab5 100644 --- a/src/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -29,12 +29,12 @@ abstract class Filter private ?string $placeholder = null; - abstract public function getCondition(): array; - public function __construct(protected Datagrid $grid, protected string $key, protected string $name) { } + abstract public function getCondition(): array; + /** * Get filter key */ diff --git a/tests/Cases/Utils/TestingDDatagridEntity.php b/tests/Cases/Utils/TestingDDatagridEntity.php index 6033c88d..2144e95e 100644 --- a/tests/Cases/Utils/TestingDDatagridEntity.php +++ b/tests/Cases/Utils/TestingDDatagridEntity.php @@ -30,11 +30,6 @@ class TestingDDatagridEntity private ?TestingDDatagridEntity $partner = null; - final public function getId(): int - { - return $this->id; - } - public function __construct(array $args) { $this->id = $args['id']; @@ -43,6 +38,11 @@ public function __construct(array $args) $this->gender = $args['gender'] ?? null; } + final public function getId(): int + { + return $this->id; + } + public function getName(): string { return $this->name;