Skip to content

Commit

Permalink
Fix errors reported by phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed May 27, 2020
1 parent 6a614d9 commit ecfcf50
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ docs export-ignore
.github export-ignore
.coveralls.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
phpstan-baseline.neon export-ignore
psalm.xml export-ignore
72 changes: 72 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
parameters:
ignoreErrors:
-
message: "#^Access to an undefined property object\\:\\:\\$query\\.$#"
count: 4
path: src/Listener/ViewListener.php

-
message: "#^Access to an undefined property object\\:\\:\\$params\\.$#"
count: 1
path: src/Listener/ViewListener.php

-
message: "#^Access to an undefined property object\\:\\:\\$element\\.$#"
count: 1
path: src/Listener/ViewListener.php

-
message: "#^Access to an undefined property object\\:\\:\\$type\\.$#"
count: 1
path: src/Listener/ViewListener.php

-
message: "#^Parameter \\#2 \\$arr2 of function array_diff_key expects array, array\\|false given\\.$#"
count: 1
path: src/Listener/ViewListener.php

-
message: "#^Result of \\|\\| is always false\\.$#"
count: 1
path: src/Listener/ViewListener.php

-
message: "#^Cannot unset offset mixed on array\\(\\)\\.$#"
count: 2
path: src/Listener/ViewListener.php

-
message: "#^Parameter \\#1 \\$field of method CrudView\\\\Listener\\\\ViewListener\\:\\:_deriveFieldFromContext\\(\\) expects string, array\\<string\\>\\|string\\|null given\\.$#"
count: 1
path: src/Listener/ViewListener.php

-
message: "#^Call to an undefined method Cake\\\\ORM\\\\Table\\:\\:searchManager\\(\\)\\.$#"
count: 1
path: src/Listener/ViewSearchListener.php

-
message: "#^Offset 'data\\-wrap' does not exist on array\\(\\?'data\\-enable\\-seconds' \\=\\> 'true', 'data\\-date\\-format' \\=\\> string, \\?'data\\-enable\\-time' \\=\\> 'true', \\?'data\\-alt\\-format' \\=\\> mixed, \\?'data\\-alt\\-input' \\=\\> 'true', \\?'data\\-no\\-calendar' \\=\\> 'true'\\)\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Binary operation \"\\+\\=\" between array\\<string\\>\\|string and array\\('data\\-date\\-format' \\=\\> string, \\?'data\\-alt\\-format' \\=\\> mixed, \\?'data\\-alt\\-input' \\=\\> 'true', \\?'data\\-no\\-calendar' \\=\\> 'true', \\?'data\\-enable\\-seconds' \\=\\> 'true', \\?'data\\-enable\\-time' \\=\\> 'true', 'data\\-wrap' \\=\\> mixed\\) results in an error\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Offset 'name' does not exist on array\\<string\\>\\|string\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Offset 'templateVars' does not exist on array\\<string\\>\\|string\\.$#"
count: 2
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Parameter \\#1 \\$options of method Cake\\\\View\\\\StringTemplate\\:\\:formatAttributes\\(\\) expects array\\|null, array\\<string\\>\\|string given\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

14 changes: 3 additions & 11 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
includes:
- phpstan-baseline.neon

parameters:
level: 7
checkMissingIterableValueType: false
universalObjectCratesClasses:
- Crud\Event\Subject
ignoreErrors:
- '#Parameter \#1 $dateString of method Cake\\View\\Helper\\TimeHelper::nice() expects DateTime|int|string|null, DateTime|DateTimeImmutable|int|string given#'
-
message: '#Result of || is always false#'
path: 'src/Listener/ViewListener.php'
-
message: '#Call to an undefined method Cake\\ORM\\Table::searchManager\(\)#'
path: 'src/Listener/ViewSearchListener.php'
-
message: '#Method CrudView\\Action\\DashboardAction::_get\(\) should return Cake\\Http\\Response|void but return statement is missing#'
path: 'src/Action/DashboardAction.php'
5 changes: 2 additions & 3 deletions src/View/Widget/DateTimeWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ public function render(array $data, ContextInterface $context): string

$iconClass = 'fa fa-calendar-alt';
if (isset($datetimePicker['iconClass'])) {
$iconClass = $data['iconClass'];
$iconClass = $datetimePicker['iconClass'];
unset($datetimePicker['iconClass']);
} elseif ($data['type'] === 'time') {
$iconClass = 'fa fa-clock';
}

unset($datetimePicker['iconClass']);

if ($this->_templates->get('datetimePicker') === null) {
// phpcs:disable
$this->_templates->add([
Expand Down

0 comments on commit ecfcf50

Please sign in to comment.