Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
9 changes: 4 additions & 5 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0"?>
<ruleset name="CakePHP Core">
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />
<ruleset name="Footprint">
<rule ref="CakePHP"/>

<rule ref="CakePHP" />

<arg value="s"/>
<file>src/</file>
<file>tests/</file>
</ruleset>
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
parameters:
level: 8
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false
paths:
- src/
Expand Down
14 changes: 14 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac">
<file src="src/FootprintPlugin.php">
<MoreSpecificImplementedParamType>
<code><![CDATA[$app]]></code>
<code><![CDATA[$app]]></code>
</MoreSpecificImplementedParamType>
</file>
<file src="src/Model/Behavior/FootprintBehavior.php">
<InvalidArgument>
<code><![CDATA[$options]]></code>
</InvalidArgument>
</file>
</files>
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedCode="false"
findUnusedBaselineEntry="true"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
Expand All @@ -20,5 +21,7 @@
<MissingClosureParamType errorLevel="suppress"/>
<MissingClosureReturnType errorLevel="suppress"/>
<PropertyNotSetInConstructor errorLevel="suppress"/>
<ClassMustBeFinal errorLevel="suppress"/>
<MissingOverrideAttribute errorLevel="suppress"/>
</issueHandlers>
</psalm>
8 changes: 4 additions & 4 deletions src/Event/FootprintListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>> $ormObject Query or Entity.
* @param \ArrayObject<string, mixed> $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])) {
Expand Down
4 changes: 2 additions & 2 deletions src/FootprintPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FootprintPlugin extends BasePlugin
/**
* Bootstrap hook
*
* @param \Cake\Core\PluginApplicationInterface $app Application instance.
* @param \Cake\Core\PluginApplicationInterface<self> $app Application instance.
* @return void
*/
public function bootstrap(PluginApplicationInterface $app): void
Expand All @@ -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());
}
},
);
}

Expand Down
26 changes: 13 additions & 13 deletions src/Model/Behavior/FootprintBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function implementedEvents(): array
/** @phpstan-ignore-next-line */
return array_fill_keys(
array_keys($this->_config['events']),
'dispatch'
'dispatch',
);
}

Expand All @@ -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<string, mixed>> $data Query or Entity.
* @param \ArrayObject<string, mixed> $options Options.
* @return void
*/
public function dispatch(EventInterface $event, EntityInterface|SelectQuery $data, ArrayObject $options): void
Expand All @@ -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<string, mixed>> $query Query.
* @param \ArrayObject<string, mixed> $options Options.
* @param array<string, mixed> $fields Field configuration.
* @return void
*/
protected function _injectConditions(SelectQuery $query, ArrayObject $options, array $fields): void
Expand All @@ -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()),
);
});

Expand All @@ -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<string, mixed> $options Options.
* @param array<string, string|\Closure> $fields Field configuration.
* @return void
*/
protected function _injectEntity(EntityInterface $entity, ArrayObject $options, array $fields): void
Expand All @@ -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,
));
}

Expand All @@ -187,8 +187,8 @@ protected function _injectEntity(EntityInterface $entity, ArrayObject $options,
$field,
Hash::get(
$options,
$this->getConfig('propertiesMap.' . $field)
)
$this->getConfig('propertiesMap.' . $field),
),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Event/FootprintListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Model/Behavior/FootprintBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down
6 changes: 0 additions & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
declare(strict_types=1);

use Cake\Core\Configure;

/**
* Test suite bootstrap.
*
Expand Down Expand Up @@ -32,7 +30,3 @@
}

require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';

Configure::write('Error.ignoredDeprecationPaths', [
'src/TestSuite/Fixture/FixtureInjector.php',
]);
Loading