From d22e65f0641f12d7830e96933218304b44b6b649 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 22 Apr 2026 11:26:28 +0530 Subject: [PATCH 1/6] Cleanup tests/bootstrap.php --- tests/bootstrap.php | 6 ------ 1 file changed, 6 deletions(-) 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 @@ Date: Wed, 22 Apr 2026 11:32:23 +0530 Subject: [PATCH 2/6] Update CI config --- .github/workflows/ci.yml | 3 ++- phpstan.neon | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) 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/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/ From fb28fc773b7ae13867fe2874bc2e510837d7515a Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 22 Apr 2026 11:49:30 +0530 Subject: [PATCH 3/6] Fix stan issues --- psalm-baseline.xml | 14 ++++++++++++++ psalm.xml | 3 +++ src/Event/FootprintListener.php | 6 +++--- src/FootprintPlugin.php | 2 +- src/Model/Behavior/FootprintBehavior.php | 16 ++++++++-------- 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 psalm-baseline.xml 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..d9ee868 100644 --- a/src/Event/FootprintListener.php +++ b/src/Event/FootprintListener.php @@ -86,9 +86,9 @@ 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( diff --git a/src/FootprintPlugin.php b/src/FootprintPlugin.php index c876586..54708d5 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 diff --git a/src/Model/Behavior/FootprintBehavior.php b/src/Model/Behavior/FootprintBehavior.php index 1ddd253..d52f3b1 100644 --- a/src/Model/Behavior/FootprintBehavior.php +++ b/src/Model/Behavior/FootprintBehavior.php @@ -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 @@ -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 From 54ac4d8a0b30e428b01493319461152572306f34 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 22 Apr 2026 11:49:47 +0530 Subject: [PATCH 4/6] Fix phpcs config --- phpcs.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 584f45c..d04eb09 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,7 +1,5 @@ - - From dc9d3e172f367e8711e2990050f10659381cb5be Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 22 Apr 2026 11:53:10 +0530 Subject: [PATCH 5/6] Fix CS errors --- phpcs.xml | 7 ++++--- src/Event/FootprintListener.php | 2 +- src/FootprintPlugin.php | 2 +- src/Model/Behavior/FootprintBehavior.php | 10 +++++----- tests/TestCase/Event/FootprintListenerTest.php | 2 +- .../TestCase/Model/Behavior/FootprintBehaviorTest.php | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index d04eb09..f7dc2a1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,7 @@ - - + + - + src/ + tests/ diff --git a/src/Event/FootprintListener.php b/src/Event/FootprintListener.php index d9ee868..f4bb605 100644 --- a/src/Event/FootprintListener.php +++ b/src/Event/FootprintListener.php @@ -94,7 +94,7 @@ public function getUser(): ?EntityInterface 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 54708d5..bbb68fa 100644 --- a/src/FootprintPlugin.php +++ b/src/FootprintPlugin.php @@ -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 d52f3b1..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', ); } @@ -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()), ); }); @@ -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]); From c9a07264210bbc6469a575b7a21cd797661a811c Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 22 Apr 2026 11:54:24 +0530 Subject: [PATCH 6/6] Update phpunit constraints --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/",