diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 356a5ff..8886457 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,8 @@ permissions: jobs: testsuite: uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@master - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} cs-stan: uses: ADmad/.github/.github/workflows/cs-stan.yml@master diff --git a/composer.json b/composer.json index 217860d..65c6000 100755 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "require-dev": { "cakephp/cakephp-codesniffer": "^5.0", - "phpunit/phpunit": "^10.1" + "phpunit/phpunit": "^11.5.3 || ^12.4 || ^13.0" }, "scripts": { "cs-check": "phpcs --colors --parallel=16 -p src/ tests/", diff --git a/phpcs.xml b/phpcs.xml index 584f45c..f7dc2a1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,8 +1,7 @@ - - + + - - - + src/ + tests/ diff --git a/phpstan.neon b/phpstan.neon index e531f71..a9e3fc4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,5 @@ parameters: level: 8 - checkGenericClassInNonGenericObjectType: false - checkMissingIterableValueType: false treatPhpDocTypesAsCertain: false paths: - src/ diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..46cbdcc --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index 6f36d46..bee935b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,6 +7,7 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedCode="false" findUnusedBaselineEntry="true" + errorBaseline="psalm-baseline.xml" > @@ -20,5 +21,7 @@ + + diff --git a/src/Event/FootprintListener.php b/src/Event/FootprintListener.php index 5f961ac..f4bb605 100644 --- a/src/Event/FootprintListener.php +++ b/src/Event/FootprintListener.php @@ -86,15 +86,15 @@ public function getUser(): ?EntityInterface /** * Universal callback. * - * @param \Cake\Event\EventInterface $event Event. - * @param \Cake\Datasource\EntityInterface|\Cake\ORM\Query\SelectQuery $ormObject Query or Entity. - * @param \ArrayObject $options Options. + * @param \Cake\Event\EventInterface<\Cake\ORM\Table> $event Event. + * @param \Cake\Datasource\EntityInterface|\Cake\ORM\Query\SelectQuery<\Cake\Datasource\EntityInterface|array> $ormObject Query or Entity. + * @param \ArrayObject $options Options. * @return void */ public function handleEvent( EventInterface $event, EntityInterface|SelectQuery $ormObject, - ArrayObject $options + ArrayObject $options, ): void { $key = $this->getConfig('optionKey'); if ($this->_currentUser && empty($options[$key])) { diff --git a/src/FootprintPlugin.php b/src/FootprintPlugin.php index c876586..bbb68fa 100644 --- a/src/FootprintPlugin.php +++ b/src/FootprintPlugin.php @@ -25,7 +25,7 @@ class FootprintPlugin extends BasePlugin /** * Bootstrap hook * - * @param \Cake\Core\PluginApplicationInterface $app Application instance. + * @param \Cake\Core\PluginApplicationInterface $app Application instance. * @return void */ public function bootstrap(PluginApplicationInterface $app): void @@ -35,7 +35,7 @@ public function bootstrap(PluginApplicationInterface $app): void /** @param \Cake\Event\EventInterface<\Cake\ORM\Table> $event */ function (EventInterface $event): void { $event->getSubject()->getEventManager()->on(static::getListener()); - } + }, ); } diff --git a/src/Model/Behavior/FootprintBehavior.php b/src/Model/Behavior/FootprintBehavior.php index 1ddd253..0c0b92a 100644 --- a/src/Model/Behavior/FootprintBehavior.php +++ b/src/Model/Behavior/FootprintBehavior.php @@ -83,7 +83,7 @@ public function implementedEvents(): array /** @phpstan-ignore-next-line */ return array_fill_keys( array_keys($this->_config['events']), - 'dispatch' + 'dispatch', ); } @@ -92,9 +92,9 @@ public function implementedEvents(): array * * Called by the event manager as per list provided by implementedEvents(). * - * @param \Cake\Event\EventInterface $event Event. - * @param \Cake\Datasource\EntityInterface|\Cake\ORM\Query\SelectQuery $data Query or Entity. - * @param \ArrayObject $options Options. + * @param \Cake\Event\EventInterface<\Cake\ORM\Table> $event Event. + * @param \Cake\Datasource\EntityInterface|\Cake\ORM\Query\SelectQuery<\Cake\Datasource\EntityInterface|array> $data Query or Entity. + * @param \ArrayObject $options Options. * @return void */ public function dispatch(EventInterface $event, EntityInterface|SelectQuery $data, ArrayObject $options): void @@ -118,9 +118,9 @@ public function dispatch(EventInterface $event, EntityInterface|SelectQuery $dat /** * Injects configured fields into finder conditions. * - * @param \Cake\ORM\Query\SelectQuery $query Query. - * @param \ArrayObject $options Options. - * @param array $fields Field configuration. + * @param \Cake\ORM\Query\SelectQuery<\Cake\Datasource\EntityInterface|array> $query Query. + * @param \ArrayObject $options Options. + * @param array $fields Field configuration. * @return void */ protected function _injectConditions(SelectQuery $query, ArrayObject $options, array $fields): void @@ -140,7 +140,7 @@ protected function _injectConditions(SelectQuery $query, ArrayObject $options, a '/^' . $alias . '/', // TODO: Add test to show that cloning is necessary here to avoid issue mentioned in // https://github.com/UseMuffin/Footprint/issues/74 - $expression->sql(clone $query->getValueBinder()) + $expression->sql(clone $query->getValueBinder()), ); }); @@ -155,8 +155,8 @@ protected function _injectConditions(SelectQuery $query, ArrayObject $options, a * Injects configured field values into entity if those fields are not dirty. * * @param \Cake\Datasource\EntityInterface $entity Entity. - * @param \ArrayObject $options Options. - * @param array $fields Field configuration. + * @param \ArrayObject $options Options. + * @param array $fields Field configuration. * @return void */ protected function _injectEntity(EntityInterface $entity, ArrayObject $options, array $fields): void @@ -169,7 +169,7 @@ protected function _injectEntity(EntityInterface $entity, ArrayObject $options, 'When should be one of "always", "new" or "existing", ' . 'or a closure that takes an EntityInterface and returns a bool. ' . 'The passed value "%s" is invalid.', - $when + $when, )); } @@ -187,8 +187,8 @@ protected function _injectEntity(EntityInterface $entity, ArrayObject $options, $field, Hash::get( $options, - $this->getConfig('propertiesMap.' . $field) - ) + $this->getConfig('propertiesMap.' . $field), + ), ); } } diff --git a/tests/TestCase/Event/FootprintListenerTest.php b/tests/TestCase/Event/FootprintListenerTest.php index 31fb236..13c19f8 100644 --- a/tests/TestCase/Event/FootprintListenerTest.php +++ b/tests/TestCase/Event/FootprintListenerTest.php @@ -39,7 +39,7 @@ public function testHandleEvent() $this->listener->handleEvent( new Event('Model.save'), new Entity(['title' => 'article']), - $options + $options, ); $this->assertSame($entity, $options['_footprint']); diff --git a/tests/TestCase/Model/Behavior/FootprintBehaviorTest.php b/tests/TestCase/Model/Behavior/FootprintBehaviorTest.php index 833ac54..5b82460 100644 --- a/tests/TestCase/Model/Behavior/FootprintBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/FootprintBehaviorTest.php @@ -75,7 +75,7 @@ public function testSave() $this->assertSame( $expected, - $entity->extract(['id', 'title', 'created_by', 'modified_by', 'company_id', 'manager_id']) + $entity->extract(['id', 'title', 'created_by', 'modified_by', 'company_id', 'manager_id']), ); // Closure fields won't set if disallowed @@ -206,7 +206,7 @@ public function testInjectEntityException() 'Model.beforeSave' => [ 'created_by' => 'invalid', ], - ] + ], ); $entity = new Entity(['title' => 'new article']); $entity = $this->Table->save($entity, ['_footprint' => $footprint]); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index cbe16ce..6b74eef 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,8 +1,6 @@