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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"require-dev": {
"cakephp/cakephp": "^5.0",
"phpunit/phpunit": "^10.1"
"phpunit/phpunit": "^11.5.3 || ^12.1.3"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 0 additions & 21 deletions psalm.xml

This file was deleted.

22 changes: 11 additions & 11 deletions src/Model/Behavior/SequenceBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
$this->_sync(
[$orderField => $this->_getUpdateExpression('+')],
[$orderField . ' >=' => $newOrder],
$newScope
$newScope,
);
}

Expand All @@ -176,15 +176,15 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
$this->_sync(
[$orderField => $this->_getUpdateExpression('-')],
[$orderField . ' >' => $oldOrder],
$oldScope
$oldScope,
);

// Order not specified
if ($newOrder === null) {
// Insert at end of new scope
$entity->set(
$orderField,
$this->_getHighestOrder($newScope) + 1
$this->_getHighestOrder($newScope) + 1,
);

// Order specified
Expand All @@ -193,7 +193,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
$this->_sync(
[$orderField => $this->_getUpdateExpression('+')],
[$orderField . ' >=' => $newOrder],
$newScope
$newScope,
);
}
// Same scope
Expand All @@ -207,7 +207,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
$orderField . ' >=' => $newOrder,
$orderField . ' <' => $oldOrder,
],
$newScope
$newScope,
);

// Moving down
Expand All @@ -219,7 +219,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
$orderField . ' >' => $oldOrder,
$orderField . ' <=' => $newOrder,
],
$newScope
$newScope,
);
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ public function afterDelete(EventInterface $event, EntityInterface $entity): voi
$this->_sync(
[$orderField => $this->_getUpdateExpression('-')],
[$orderField . ' >' => $order],
$scope
$scope,
);

$this->_oldValues = null;
Expand Down Expand Up @@ -352,7 +352,7 @@ function ($connection) use ($table, $entity, $config, $scope, $direction) {
$entity->set($orderField, $newOrder);

return $table->save($entity, ['atomic' => false, 'checkRules' => false]);
}
},
);

$table->addBehavior('ADmad/Sequence.Sequence', $config);
Expand Down Expand Up @@ -406,15 +406,15 @@ function ($connection) use ($table, $records) {

$r = $table->save(
$record,
['atomic' => false, 'checkRules' => false]
['atomic' => false, 'checkRules' => false],
);
if ($r === false) {
return false;
}
}

return true;
}
},
);

$table->addBehavior('ADmad/Sequence.Sequence', $config);
Expand Down Expand Up @@ -554,7 +554,7 @@ protected function _getUpdateExpression(string $direction = '+'): QueryExpressio
{
$field = $this->_config['sequenceField'];

return $this->_table->selectQuery()->newExpr()
return $this->_table->selectQuery()->expr()
->add(new IdentifierExpression($field))
->add('1')
->setConjunction($direction);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Model/Behavior/SequenceBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function testSetOrder()
['id' => 1],
['id' => 5],
],
['accessibleFields' => ['id' => true]]
['accessibleFields' => ['id' => true]],
);
foreach ($entities as &$entity) {
$entity->setNew(false);
Expand Down