From a8eb2a7abd2b0600965901f30b7534b0dd2379d4 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 17 Sep 2024 18:11:35 +0530 Subject: [PATCH] Fix stan errors --- phpstan-baseline.neon | 22 +--------------------- psalm-baseline.xml | 6 ------ src/View/Cell/TablesListCell.php | 2 +- src/View/Widget/DateTimeWidget.php | 6 ++---- 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 933a621..e45215c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11,7 +11,7 @@ parameters: path: src/Listener/ViewListener.php - - message: "#^Parameter \\#1 \\$field of method CrudView\\\\Listener\\\\ViewListener\\:\\:_deriveFieldFromContext\\(\\) expects string, array\\\\|string\\|null given\\.$#" + message: "#^Parameter \\#1 \\$field of method CrudView\\\\Listener\\\\ViewListener\\:\\:_deriveFieldFromContext\\(\\) expects string, array\\\\|string\\|null given\\.$#" count: 1 path: src/Listener/ViewListener.php @@ -24,23 +24,3 @@ parameters: message: "#^Call to an undefined method Cake\\\\ORM\\\\Table\\:\\:searchManager\\(\\)\\.$#" count: 1 path: src/Listener/ViewSearchListener.php - - - - message: "#^Binary operation \"\\+\" between string and non\\-empty\\-array results in an error\\.$#" - count: 1 - path: src/View/Widget/DateTimeWidget.php - - - - message: "#^Offset 'name' does not exist on array\\\\|string\\|null\\.$#" - count: 1 - path: src/View/Widget/DateTimeWidget.php - - - - message: "#^Offset 'templateVars' does not exist on array\\\\|string\\|null\\.$#" - count: 2 - path: src/View/Widget/DateTimeWidget.php - - - - message: "#^Parameter \\#1 \\$options of method Cake\\\\View\\\\StringTemplate\\:\\:formatAttributes\\(\\) expects array\\\\|null, array\\\\|string\\|null given\\.$#" - count: 1 - path: src/View/Widget/DateTimeWidget.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7213f69..8bdfa5f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,9 +1,3 @@ - - - - - - diff --git a/src/View/Cell/TablesListCell.php b/src/View/Cell/TablesListCell.php index 9f5b82a..46269aa 100644 --- a/src/View/Cell/TablesListCell.php +++ b/src/View/Cell/TablesListCell.php @@ -23,7 +23,7 @@ public function display(?array $tables = null, ?array $blacklist = null): void $connection = ConnectionManager::get('default'); $schema = $connection->getSchemaCollection(); $tables = $schema->listTables(); - ksort($tables); + sort($tables); /** @psalm-suppress RiskyTruthyFalsyComparison */ if (!empty($blacklist)) { diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index fb6143e..4846061 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -123,6 +123,7 @@ public function render(array $data, ContextInterface $context): string $this->_templates->add(['datetimePicker' => $this->defaultTemplate]); } + /** @var array $data */ $data = $this->_templates->addClass($data, 'form-control'); $wrap = $datetimePicker['data-wrap'] === 'true'; if ($wrap) { @@ -136,13 +137,10 @@ public function render(array $data, ContextInterface $context): string } } else { $data += $datetimePicker; + /** @var array $data */ $data = $this->_templates->addClass($data, 'flatpickr'); } - /** - * @psalm-suppress PossiblyInvalidArrayOffset - * @psalm-suppress PossiblyInvalidArgument - */ $input = $this->_templates->format('input', [ 'name' => $data['name'], 'type' => 'text',