Skip to content

Commit

Permalink
Fix cs & phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
radimvaculik committed Mar 11, 2024
1 parent 976291a commit a135d53
Show file tree
Hide file tree
Showing 24 changed files with 12 additions and 57 deletions.
3 changes: 0 additions & 3 deletions src/Column/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ class Action extends Column

protected ?IConfirmation $confirmation = null;

/** @var array */
protected array $dataAttributes = [];

/** @var array */
protected array $attributes = [];

/** @var array */
protected array $parameters = [];

/** @var string|callable|null */
Expand Down
2 changes: 0 additions & 2 deletions src/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ abstract class Column extends FilterableColumn

protected ?string $align = null;

/** @var array */
protected array $templateVariables = [];

/** @var callable|null */
Expand All @@ -42,7 +41,6 @@ abstract class Column extends FilterableColumn
/** @var callable|null */
protected $editableConditionCallback = null;

/** @var array */
protected array $editableElement = ['textarea', ['class' => 'form-control']];

protected bool $defaultHide = false;
Expand Down
2 changes: 0 additions & 2 deletions src/Column/ColumnLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ class ColumnLink extends Column

protected ?string $icon = null;

/** @var array */
protected array $dataAttributes = [];

protected bool $openInNewTab = false;

/** @var array */
protected array $parameters = [];

public function __construct(
Expand Down
1 change: 0 additions & 1 deletion src/Column/ColumnNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ColumnNumber extends Column

protected ?string $align = 'end';

/** @var array */
protected array $numberFormat = [
0, // Decimals
'.', // Decimal point
Expand Down
1 change: 0 additions & 1 deletion src/Column/ColumnStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class ColumnStatus extends Column

protected string $key;

/** @var array */
protected array $options = [];

public function __construct(
Expand Down
1 change: 0 additions & 1 deletion src/Column/MultiAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class MultiAction extends Column

protected string $name;

/** @var array */
protected array $actions = [];

/** @var array|callable[] */
Expand Down
1 change: 0 additions & 1 deletion src/ColumnsSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ColumnsSummary
/** @var array|int[] */
protected array $summary;

/** @var array */
protected array $format = [];

/** @var callable|null */
Expand Down
2 changes: 0 additions & 2 deletions src/DataSource/ApiDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class ApiDataSource implements IDataSource
{

/** @var array */
protected array $data = [];

protected ?string $sortColumn = null;
Expand All @@ -21,7 +20,6 @@ class ApiDataSource implements IDataSource

protected int $filterOne = 0;

/** @var array */
protected array $filter = [];

public function __construct(protected string $url, protected array $queryParams = [])
Expand Down
1 change: 0 additions & 1 deletion src/DataSource/ArrayDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
class ArrayDataSource implements IDataSource
{

/** @var array */
protected array $data = [];

protected int $count = 0;
Expand Down
1 change: 0 additions & 1 deletion src/DataSource/DibiFluentDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
class DibiFluentDataSource extends FilterableDataSource implements IDataSource, IAggregatable
{

/** @var array */
protected array $data = [];

public function __construct(protected Fluent $dataSource, protected string $primaryKey)
Expand Down
1 change: 0 additions & 1 deletion src/DataSource/DibiFluentMssqlDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class DibiFluentMssqlDataSource extends DibiFluentDataSource
{

/** @var array */
protected array $data = [];

public function __construct(Fluent $dataSource, string $primaryKey)
Expand Down
1 change: 0 additions & 1 deletion src/DataSource/NetteDatabaseTableDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class NetteDatabaseTableDataSource extends FilterableDataSource implements IDataSource
{

/** @var array */
protected array $data = [];

public function __construct(protected Selection $dataSource, protected string $primaryKey)
Expand Down
1 change: 0 additions & 1 deletion src/DataSource/NextrasDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
class NextrasDataSource extends FilterableDataSource implements IDataSource, IAggregatable
{

/** @var array */
protected array $data = [];

public function __construct(protected ICollection $dataSource, protected string $primaryKey)
Expand Down
21 changes: 4 additions & 17 deletions src/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,18 @@ class Datagrid extends Control
/** @persistent */
public string|int|null $perPage = null;

/**
* @var array
* @persistent
*/
/** @persistent */
public array $sort = [];

/** @var array */
public array $defaultSort = [];

/** @var array */
public array $defaultFilter = [];

public bool $defaultFilterUseOnReset = true;

public bool $defaultSortUseOnReset = true;

/**
* @var array
* @persistent
*/
/** @persistent */
public array $filter = [];

/** @var callable|null */
Expand All @@ -166,7 +158,6 @@ class Datagrid extends Control
/** @var callable */
protected $rowCallback;

/** @var array */
protected array $itemsPerPageList = [10, 20, 50, 'all'];

protected ?int $defaultPerPage = null;
Expand Down Expand Up @@ -208,7 +199,6 @@ class Datagrid extends Control

protected ?string $originalTemplate = null;

/** @var array */
protected array $redrawItem = [];

protected ?Translator $translator = null;
Expand Down Expand Up @@ -242,18 +232,15 @@ class Datagrid extends Control

protected ?ItemDetail $itemsDetail = null;

/** @var array */
protected array $rowConditions = [
'group_action' => false,
'action' => [],
];

/** @var array */
protected array $columnCallbacks = [];

protected bool $canHideColumns = false;

/** @var array */
protected array $columnsVisibility = [];

protected ?InlineEdit $inlineEdit = null;
Expand Down Expand Up @@ -1311,8 +1298,8 @@ public function filterSucceeded(NetteForm $form): void
}

if ($edit['submit']->isSubmittedBy() || $edit['cancel']->isSubmittedBy()) {
$id = $form->getHttpData(Form::DATA_LINE, 'inline_edit[_id]');
$primaryWhereColumn = $form->getHttpData(Form::DATA_LINE, 'inline_edit[_primary_where_column]');
$id = $form->getHttpData(Form::DataLine, 'inline_edit[_id]');
$primaryWhereColumn = $form->getHttpData(Form::DataLine, 'inline_edit[_primary_where_column]');

if ($edit['submit']->isSubmittedBy() && $edit->getErrors() === []) {
$this->inlineEdit->onSubmit($id, $values['inline_edit']);
Expand Down
1 change: 0 additions & 1 deletion src/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Export

protected ?Link $link = null;

/** @var array */
protected array $columns = [];

protected ?string $confirmDialog = null;
Expand Down
1 change: 0 additions & 1 deletion src/Filter/FilterDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class FilterDate extends OneColumnFilter implements IFilterDate

protected ?string $template = 'datagrid_filter_date.latte';

/** @var array */
protected array $format = ['j. n. Y', 'd. m. yyyy'];

protected ?string $type = 'date';
Expand Down
1 change: 0 additions & 1 deletion src/Filter/FilterDateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class FilterDateRange extends FilterRange implements IFilterDate

protected ?string $template = 'datagrid_filter_daterange.latte';

/** @var array */
protected array $format = ['j. n. Y', 'd. m. yyyy'];

protected ?string $type = 'date-range';
Expand Down
1 change: 0 additions & 1 deletion src/Filter/FilterRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class FilterRange extends OneColumnFilter
{

/** @var array */
protected array $placeholders = [];

protected ?string $template = 'datagrid_filter_range.latte';
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/SubmitButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Contributte\Datagrid\Traits\TButtonTryAddIcon;
use Nette\Forms\Controls\Button;
use Nette\Utils\Html;
use Stringable;

class SubmitButton extends Button
{
Expand All @@ -31,8 +32,7 @@ public function __construct(protected Datagrid $grid)
$this->control = Html::el('button', ['type' => 'submit', 'name' => 'submit']);
}

/** @inheritdoc */
public function getControl($caption = null): Html
public function getControl(Stringable|string|null $caption = null): Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html

Check failure on line 35 in src/Filter/SubmitButton.php

View workflow job for this annotation

GitHub Actions / Nette Tester / Nette Tester 8.0 / MySQL

Declaration of Contributte\Datagrid\Filter\SubmitButton::getControl(Stringable|string|null $caption = null): Nette\Utils\Html must be compatible with Nette\Forms\Controls\Button::getControl($caption = null): Nette\Utils\Html
{
$el = parent::getControl($caption);

Expand Down
10 changes: 5 additions & 5 deletions src/GroupAction/GroupActionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public function addToFormContainer(Container $container): void
$control = $container->addText((string) $id, '');

$control->setHtmlAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
->addConditionOn($groupActionSelect, Form::EQUAL, $id)
->addConditionOn($groupActionSelect, Form::Equal, $id)
->setRequired('contributte_datagrid.choose_input_required')
->endCondition();

} elseif ($action instanceof GroupTextareaAction) {
$control = $container->addTextArea((string) $id, '');

$control->setHtmlAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
->addConditionOn($groupActionSelect, Form::EQUAL, $id)
->addConditionOn($groupActionSelect, Form::Equal, $id)
->setRequired('contributte_datagrid.choose_input_required');
}

Expand All @@ -120,11 +120,11 @@ public function addToFormContainer(Container $container): void

if ($main_options !== []) {
foreach (array_keys($this->groupActions) as $id) {
$groupActionSelect->addCondition(Form::EQUAL, $id)
$groupActionSelect->addCondition(Form::Equal, $id)
->toggle($lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
}

$groupActionSelect->addCondition(Form::FILLED)
$groupActionSelect->addCondition(Form::Filled)
->toggle(
strtolower($this->datagrid->getFullName()) . 'group_action_submit'
);
Expand Down Expand Up @@ -165,7 +165,7 @@ public function submitted(NetteForm $form): void
}

$httpIds = $form->getHttpData(
Form::DATA_LINE | Form::DATA_KEYS,
Form::DataLine | Form::DataKeys,
strtolower($this->datagrid->getFullName()) . '_group_action_item[]'
);

Expand Down
1 change: 0 additions & 1 deletion src/Toolbar/ToolbarButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ToolbarButton
use TButtonTitle;
use TLink;

/** @var array */
protected array $attributes = [];

protected ?string $confirmDialog = null;
Expand Down
1 change: 0 additions & 1 deletion src/Traits/TButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ trait TButtonRenderer

protected ?Renderer $renderer = null;

/** @var array */
protected array $replacements = [];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/TLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function createLink(
if (
str_starts_with($link, '#error') ||
(strrpos($href, '!') !== false && str_starts_with($link, '#')) ||
(in_array($presenter->invalidLinkMode, [Presenter::INVALID_LINK_WARNING, Presenter::INVALID_LINK_SILENT], true) && str_starts_with($link, '#'))
(in_array($presenter->invalidLinkMode, [Presenter::InvalidLinkWarning, Presenter::InvalidLinkSilent], true) && str_starts_with($link, '#'))
) {
continue; // Did not find signal handler
}
Expand Down
8 changes: 0 additions & 8 deletions src/Utils/ItemDetailForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ private function getHttpData(): mixed
$lookupPath = $this->lookupPath(Form::class);
$form = $this->getForm();

if ($lookupPath === null || $form === null) {
throw new UnexpectedValueException();
}

$path = explode(self::NameSeparator, $lookupPath);

$this->httpPost = Arrays::get($form->getHttpData(), $path, null);
Expand All @@ -79,10 +75,6 @@ private function loadHttpData(): void
{
$form = $this->getForm();

if ($form === null) {
throw new UnexpectedValueException();
}

if ($form->isSubmitted() === false) {
return;
}
Expand Down

0 comments on commit a135d53

Please sign in to comment.