Skip to content

Commit

Permalink
Bump up CakePHP to 4.5 and fix deprecations and static analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Mar 18, 2024
1 parent 7371316 commit 0e10e0a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"irc": "irc://irc.freenode.org/muffin"
},
"require": {
"cakephp/orm": "^4.2"
"cakephp/orm": "^4.5"
},
"require-dev": {
"cakephp/cakephp": "^4.2",
"cakephp/cakephp-codesniffer": "^4.0",
"phpunit/phpunit": "^8.5 || ^9.3"
"cakephp/cakephp": "^4.5",
"cakephp/cakephp-codesniffer": "^4.2",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 3 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@
</testsuite>
</testsuites>

<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<extensions>
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
</extensions>

<filter>
<whitelist>
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
8 changes: 4 additions & 4 deletions src/Datasource/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function clause(string $name)
*/
public function setEndpoint(Endpoint $endpoint)
{
$this->repository($endpoint);
$this->setRepository($endpoint);

return $this;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ public function firstOrFail()
*
* @param string $field The field to alias.
* @param string|null $alias Not being used
* @return array The field prefixed with the endpoint alias.
* @return array<string, string> The field prefixed with the endpoint alias.
*/
public function aliasField(string $field, ?string $alias = null): array
{
Expand Down Expand Up @@ -396,9 +396,9 @@ public function set($fields = null)
/**
* @inheritDoc
*/
public function offset($num)
public function offset($offset)
{
$this->_parts['offset'] = $num;
$this->_parts['offset'] = $offset;

return $this;
}
Expand Down
14 changes: 10 additions & 4 deletions src/Datasource/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
use Cake\Collection\CollectionTrait;
use Cake\Datasource\ResultSetInterface;

/**
* @template T of \Cake\Datasource\EntityInterface|array
* @implements \Cake\Datasource\ResultSetInterface<T>
*/
class ResultSet implements ResultSetInterface
{
use CollectionTrait;
Expand All @@ -20,7 +24,8 @@ class ResultSet implements ResultSetInterface
/**
* Last record fetched from the statement
*
* @var array
* @var \Cake\Datasource\EntityInterface|array
* @psalm-var T
*/
protected $_current;

Expand Down Expand Up @@ -55,8 +60,10 @@ public function __construct(array $resources, ?int $total = null)
*
* Part of Iterator interface.
*
* @return array|object
* @return \Cake\Datasource\EntityInterface|array
* @psalm-return T
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->_current;
Expand All @@ -67,7 +74,6 @@ public function current()
*
* Part of Iterator interface.
*
* @throws \Cake\Database\Exception
* @return void
*/
public function rewind()
Expand Down Expand Up @@ -116,7 +122,7 @@ public function valid()
*
* @return int
*/
public function key()
public function key(): int
{
return $this->_index;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Datasource/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function columns(): array
* Get column data in the endpoint.
*
* @param string $name The column name.
* @return array|null Column data or null.
* @return array<string, mixed>|null Column data or null.
*/
public function getColumn(string $name): ?array
{
Expand Down Expand Up @@ -289,7 +289,7 @@ public function baseColumnType(string $column): ?string
* Returns an array where the keys are the column names in the schema
* and the values the schema type they have.
*
* @return array
* @return array<string, string>
*/
public function typeMap(): array
{
Expand All @@ -316,7 +316,7 @@ public function isNullable(string $name): bool
/**
* Get a hash of columns and their default values.
*
* @return array
* @return array<string, mixed>
*/
public function defaultValues(): array
{
Expand Down Expand Up @@ -357,7 +357,7 @@ public function getPrimaryKey(): array
/**
* Set the schema options for an endpoint
*
* @param array $options Array of options to set
* @param array<string, mixed> $options Array of options to set
* @return $this
*/
public function setOptions(array $options)
Expand All @@ -370,7 +370,7 @@ public function setOptions(array $options)
/**
* Get the schema options
*
* @return array
* @return array<string, mixed>
*/
public function getOptions(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ public function patchEntity(EntityInterface $entity, array $data, array $options
* $article = $this->Articles->patchEntities($articles, $this->request->data());
* ```
*
* @param array|\Traversable $entities the entities that will get the
* @param iterable<\Cake\Datasource\EntityInterface> $entities the entities that will get the
* data merged in
* @param array $data list of arrays to be merged into the entities
* @param array $options A list of options for the objects hydration.
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public function patchEntities(iterable $entities, array $data, array $options =
* - Model.beforeRules => beforeRules
* - Model.afterRules => afterRules
*
* @return array
* @return array<string, mixed>
*/
public function implementedEvents(): array
{
Expand Down

0 comments on commit 0e10e0a

Please sign in to comment.