Skip to content

Commit e24f2d4

Browse files
committed
Bump up CakePHP to 4.5 and fix deprecations and static analysis errors
1 parent 7371316 commit e24f2d4

File tree

9 files changed

+32
-30
lines changed

9 files changed

+32
-30
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"irc": "irc://irc.freenode.org/muffin"
4040
},
4141
"require": {
42-
"cakephp/orm": "^4.2"
42+
"cakephp/orm": "^4.5"
4343
},
4444
"require-dev": {
45-
"cakephp/cakephp": "^4.2",
46-
"cakephp/cakephp-codesniffer": "^4.0",
47-
"phpunit/phpunit": "^8.5 || ^9.3"
45+
"cakephp/cakephp": "^4.5",
46+
"cakephp/cakephp-codesniffer": "^4.2",
47+
"phpunit/phpunit": "^9.3"
4848
},
4949
"autoload": {
5050
"psr-4": {

phpunit.xml.dist

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@
1111
</testsuite>
1212
</testsuites>
1313

14-
<!-- Setup a listener for fixtures -->
15-
<listeners>
16-
<listener
17-
class="\Cake\TestSuite\Fixture\FixtureInjector"
18-
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
19-
<arguments>
20-
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
21-
</arguments>
22-
</listener>
23-
</listeners>
14+
<extensions>
15+
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
16+
</extensions>
2417

2518
<filter>
2619
<whitelist>

psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="false"
43
resolveFromConfigFile="true"
54
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
65
xmlns="https://getpsalm.org/schema/config"

src/Datasource/Marshaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public function merge(EntityInterface $entity, array $data, array $options = [])
260260
* the accessible fields list in the entity will be used.
261261
* - accessibleFields: A list of fields to allow or deny in entity accessible fields.
262262
*
263-
* @param array|\Traversable $entities the entities that will get the
263+
* @param iterable<\Cake\Datasource\EntityInterface> $entities the entities that will get the
264264
* data merged in
265265
* @param array $data list of arrays to be merged into the entities
266266
* @param array $options List of options.

src/Datasource/Query.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function clause(string $name)
176176
*/
177177
public function setEndpoint(Endpoint $endpoint)
178178
{
179-
$this->repository($endpoint);
179+
$this->setRepository($endpoint);
180180

181181
return $this;
182182
}
@@ -262,7 +262,7 @@ public function firstOrFail()
262262
*
263263
* @param string $field The field to alias.
264264
* @param string|null $alias Not being used
265-
* @return array The field prefixed with the endpoint alias.
265+
* @return array<string, string> The field prefixed with the endpoint alias.
266266
*/
267267
public function aliasField(string $field, ?string $alias = null): array
268268
{
@@ -396,9 +396,9 @@ public function set($fields = null)
396396
/**
397397
* @inheritDoc
398398
*/
399-
public function offset($num)
399+
public function offset($offset)
400400
{
401-
$this->_parts['offset'] = $num;
401+
$this->_parts['offset'] = $offset;
402402

403403
return $this;
404404
}

src/Datasource/ResultSet.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
use Cake\Collection\CollectionTrait;
77
use Cake\Datasource\ResultSetInterface;
88

9+
/**
10+
* @template T of \Cake\Datasource\EntityInterface|array
11+
* @implements \Cake\Datasource\ResultSetInterface<T>
12+
*/
913
class ResultSet implements ResultSetInterface
1014
{
1115
use CollectionTrait;
@@ -20,7 +24,8 @@ class ResultSet implements ResultSetInterface
2024
/**
2125
* Last record fetched from the statement
2226
*
23-
* @var array
27+
* @var \Cake\Datasource\EntityInterface|array
28+
* @psalm-var T
2429
*/
2530
protected $_current;
2631

@@ -55,8 +60,10 @@ public function __construct(array $resources, ?int $total = null)
5560
*
5661
* Part of Iterator interface.
5762
*
58-
* @return array|object
63+
* @return \Cake\Datasource\EntityInterface|array
64+
* @psalm-return T
5965
*/
66+
#[\ReturnTypeWillChange]
6067
public function current()
6168
{
6269
return $this->_current;
@@ -67,7 +74,6 @@ public function current()
6774
*
6875
* Part of Iterator interface.
6976
*
70-
* @throws \Cake\Database\Exception
7177
* @return void
7278
*/
7379
public function rewind()

src/Datasource/Schema.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function columns(): array
189189
* Get column data in the endpoint.
190190
*
191191
* @param string $name The column name.
192-
* @return array|null Column data or null.
192+
* @return array<string, mixed>|null Column data or null.
193193
*/
194194
public function getColumn(string $name): ?array
195195
{
@@ -289,7 +289,7 @@ public function baseColumnType(string $column): ?string
289289
* Returns an array where the keys are the column names in the schema
290290
* and the values the schema type they have.
291291
*
292-
* @return array
292+
* @return array<string, string>
293293
*/
294294
public function typeMap(): array
295295
{
@@ -316,7 +316,7 @@ public function isNullable(string $name): bool
316316
/**
317317
* Get a hash of columns and their default values.
318318
*
319-
* @return array
319+
* @return array<string, mixed>
320320
*/
321321
public function defaultValues(): array
322322
{
@@ -357,7 +357,7 @@ public function getPrimaryKey(): array
357357
/**
358358
* Set the schema options for an endpoint
359359
*
360-
* @param array $options Array of options to set
360+
* @param array<string, mixed> $options Array of options to set
361361
* @return $this
362362
*/
363363
public function setOptions(array $options)
@@ -370,7 +370,7 @@ public function setOptions(array $options)
370370
/**
371371
* Get the schema options
372372
*
373-
* @return array
373+
* @return array<string, mixed>
374374
*/
375375
public function getOptions(): array
376376
{

src/Model/Endpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ public function patchEntity(EntityInterface $entity, array $data, array $options
11821182
* $article = $this->Articles->patchEntities($articles, $this->request->data());
11831183
* ```
11841184
*
1185-
* @param array|\Traversable $entities the entities that will get the
1185+
* @param iterable<\Cake\Datasource\EntityInterface> $entities the entities that will get the
11861186
* data merged in
11871187
* @param array $data list of arrays to be merged into the entities
11881188
* @param array $options A list of options for the objects hydration.
@@ -1218,7 +1218,7 @@ public function patchEntities(iterable $entities, array $data, array $options =
12181218
* - Model.beforeRules => beforeRules
12191219
* - Model.afterRules => afterRules
12201220
*
1221-
* @return array
1221+
* @return array<string, mixed>
12221222
*/
12231223
public function implementedEvents(): array
12241224
{

tests/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@
103103
'file' => 'error',
104104
],
105105
]);
106+
107+
Configure::write('Error.ignoredDeprecationPaths', [
108+
'ests/TestCase/BootstrapTest.php',
109+
]);

0 commit comments

Comments
 (0)