diff --git a/psalm.xml b/psalm.xml index a09944e..b192091 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,6 +4,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + findUnusedBaselineEntry="true" + findUnusedCode="false" > diff --git a/src/Model/Behavior/TrashBehavior.php b/src/Model/Behavior/TrashBehavior.php index ce878b1..94402c3 100644 --- a/src/Model/Behavior/TrashBehavior.php +++ b/src/Model/Behavior/TrashBehavior.php @@ -295,12 +295,13 @@ public function cascadingRestoreTrash( foreach ($this->_table->associations() as $association) { if ($this->_isRecursable($association, $this->_table)) { if ($entity === null) { - if ($result) { + if ($result > 1) { $result += $association->getTarget()->cascadingRestoreTrash(null, $options); } } else { - /** @var array $foreignKey */ + /** @var list $foreignKey */ $foreignKey = (array)$association->getForeignKey(); + /** @var list $bindingKey */ $bindingKey = (array)$association->getBindingKey(); $conditions = array_combine($foreignKey, $entity->extract($bindingKey)); diff --git a/tests/Fixture/ArticlesFixture.php b/tests/Fixture/ArticlesFixture.php index 674e9a4..7e47dc4 100644 --- a/tests/Fixture/ArticlesFixture.php +++ b/tests/Fixture/ArticlesFixture.php @@ -1,7 +1,7 @@ records, function (&$record) use ($created, $modified) { $record += compact('created', 'modified'); }); diff --git a/tests/TestCase/Model/Behavior/TrashBehaviorTest.php b/tests/TestCase/Model/Behavior/TrashBehaviorTest.php index ed4c28b..cd02d98 100644 --- a/tests/TestCase/Model/Behavior/TrashBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/TrashBehaviorTest.php @@ -12,19 +12,11 @@ use Cake\I18n\DateTime; use Cake\ORM\Association\HasMany; use Cake\ORM\Entity; +use Cake\ORM\Table; use Cake\TestSuite\TestCase; use InvalidArgumentException; use Muffin\Trash\Model\Behavior\TrashBehavior; -/** - * @property \Cake\ORM\Table Users - * @property \Cake\ORM\Table CompositeArticlesUsers - * @property \Cake\ORM\Table Comments - * @property \Cake\ORM\Table Articles - * @property \Muffin\Trash\Model\Behavior\TrashBehavior Behavior - * - * @property \Cake\ORM\Table @mixin \Muffin\Trash\Model\Behavior\TrashBehavior - */ class TrashBehaviorTest extends TestCase { /** @@ -32,7 +24,7 @@ class TrashBehaviorTest extends TestCase * * @var array */ - public array $fixtures = [ + protected array $fixtures = [ 'plugin.Muffin/Trash.Articles', 'plugin.Muffin/Trash.Comments', 'plugin.Muffin/Trash.Users', @@ -40,6 +32,12 @@ class TrashBehaviorTest extends TestCase 'plugin.Muffin/Trash.CompositeArticlesUsers', ]; + protected Table $Users; + protected Table $CompositeArticlesUsers; + protected Table $Comments; + protected Table $Articles; + protected TrashBehavior $Behavior; + /** * Runs before each test. * diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5b073d5..eae831c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,8 +1,6 @@