Skip to content

Commit 191277d

Browse files
authored
Merge pull request #50 from ADmad/issue-49
Fix deprecation warning on CakePHP 5.3
2 parents ef063c8 + aadca89 commit 191277d

File tree

4 files changed

+13
-34
lines changed

4 files changed

+13
-34
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"require-dev": {
1111
"cakephp/cakephp": "^5.0",
12-
"phpunit/phpunit": "^10.1"
12+
"phpunit/phpunit": "^11.5.3 || ^12.1.3"
1313
},
1414
"autoload": {
1515
"psr-4": {

psalm.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Model/Behavior/SequenceBehavior.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
149149
$this->_sync(
150150
[$orderField => $this->_getUpdateExpression('+')],
151151
[$orderField . ' >=' => $newOrder],
152-
$newScope
152+
$newScope,
153153
);
154154
}
155155

@@ -176,15 +176,15 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
176176
$this->_sync(
177177
[$orderField => $this->_getUpdateExpression('-')],
178178
[$orderField . ' >' => $oldOrder],
179-
$oldScope
179+
$oldScope,
180180
);
181181

182182
// Order not specified
183183
if ($newOrder === null) {
184184
// Insert at end of new scope
185185
$entity->set(
186186
$orderField,
187-
$this->_getHighestOrder($newScope) + 1
187+
$this->_getHighestOrder($newScope) + 1,
188188
);
189189

190190
// Order specified
@@ -193,7 +193,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
193193
$this->_sync(
194194
[$orderField => $this->_getUpdateExpression('+')],
195195
[$orderField . ' >=' => $newOrder],
196-
$newScope
196+
$newScope,
197197
);
198198
}
199199
// Same scope
@@ -207,7 +207,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
207207
$orderField . ' >=' => $newOrder,
208208
$orderField . ' <' => $oldOrder,
209209
],
210-
$newScope
210+
$newScope,
211211
);
212212

213213
// Moving down
@@ -219,7 +219,7 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
219219
$orderField . ' >' => $oldOrder,
220220
$orderField . ' <=' => $newOrder,
221221
],
222-
$newScope
222+
$newScope,
223223
);
224224
}
225225
}
@@ -262,7 +262,7 @@ public function afterDelete(EventInterface $event, EntityInterface $entity): voi
262262
$this->_sync(
263263
[$orderField => $this->_getUpdateExpression('-')],
264264
[$orderField . ' >' => $order],
265-
$scope
265+
$scope,
266266
);
267267

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

354354
return $table->save($entity, ['atomic' => false, 'checkRules' => false]);
355-
}
355+
},
356356
);
357357

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

407407
$r = $table->save(
408408
$record,
409-
['atomic' => false, 'checkRules' => false]
409+
['atomic' => false, 'checkRules' => false],
410410
);
411411
if ($r === false) {
412412
return false;
413413
}
414414
}
415415

416416
return true;
417-
}
417+
},
418418
);
419419

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

557-
return $this->_table->selectQuery()->newExpr()
557+
return $this->_table->selectQuery()->expr()
558558
->add(new IdentifierExpression($field))
559559
->add('1')
560560
->setConjunction($direction);

tests/TestCase/Model/Behavior/SequenceBehaviorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function testSetOrder()
267267
['id' => 1],
268268
['id' => 5],
269269
],
270-
['accessibleFields' => ['id' => true]]
270+
['accessibleFields' => ['id' => true]],
271271
);
272272
foreach ($entities as &$entity) {
273273
$entity->setNew(false);

0 commit comments

Comments
 (0)