Skip to content

Commit

Permalink
Housekeep: Fix cs & phpstan issues (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
radimvaculik authored Aug 22, 2023
1 parent 87acbdd commit 2e6986d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 36 deletions.
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/AggregationFunction/FunctionSum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 14 additions & 14 deletions src/DataSource/FilterableDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*
Expand Down Expand Up @@ -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;

}
20 changes: 10 additions & 10 deletions src/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 5 additions & 5 deletions tests/Cases/Utils/TestingDDatagridEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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;
Expand Down

0 comments on commit 2e6986d

Please sign in to comment.