diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb7c780..ea14560 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,10 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' extensions: mbstring, intl coverage: none - tools: vimeo/psalm:5, phpstan:1.10, cs2pr + tools: vimeo/psalm:5, phpstan:1.11, cs2pr - name: Composer Install run: composer require --dev cakephp/cakephp-codesniffer:^5.0 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5b56306..933a621 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -31,12 +31,12 @@ parameters: path: src/View/Widget/DateTimeWidget.php - - message: "#^Offset 'name' does not exist on array\\\\|string\\.$#" + 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\\.$#" + message: "#^Offset 'templateVars' does not exist on array\\\\|string\\|null\\.$#" count: 2 path: src/View/Widget/DateTimeWidget.php diff --git a/phpstan.neon b/phpstan.neon index ec34e63..20cb9a8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,10 +2,11 @@ includes: - phpstan-baseline.neon parameters: - level: 7 - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + level: 8 paths: - src universalObjectCratesClasses: - Crud\Event\Subject + ignoreErrors: + - identifier: missingType.iterableValue + - identifier: missingType.generics diff --git a/src/Listener/Traits/IndexTypeTrait.php b/src/Listener/Traits/IndexTypeTrait.php index d2d4f6f..5ff4f06 100644 --- a/src/Listener/Traits/IndexTypeTrait.php +++ b/src/Listener/Traits/IndexTypeTrait.php @@ -4,6 +4,7 @@ namespace CrudView\Listener\Traits; use Cake\Controller\Controller; +use Cake\Datasource\RepositoryInterface; use Crud\Action\BaseAction; use Crud\Action\IndexAction; @@ -154,5 +155,5 @@ abstract protected function _action(?string $name = null): BaseAction; /** * @inheritDoc */ - abstract protected function _model(); + abstract protected function _model(): RepositoryInterface; } diff --git a/src/Listener/ViewListener.php b/src/Listener/ViewListener.php index 42261fe..33aa22b 100644 --- a/src/Listener/ViewListener.php +++ b/src/Listener/ViewListener.php @@ -33,9 +33,9 @@ class ViewListener extends BaseListener /** * Default associations config * - * @var array|null + * @var array */ - protected ?array $associations = null; + protected array $associations; /** * [beforeFind description] @@ -96,7 +96,8 @@ public function beforeRender(EventInterface $event): void $this->_entity = $event->getSubject()->entity; } - if ($this->associations === null) { + /** @psalm-suppress RedundantPropertyInitializationCheck */ + if (!isset($this->associations)) { $this->associations = $this->_associations(array_keys($this->_getRelatedModels())); }