Skip to content

Commit

Permalink
Cake 5 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 9, 2023
1 parent a6d7c06 commit 92f5f3e
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 132 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Expand Up @@ -15,4 +15,7 @@ end_of_line = crlf

[*.yml]
indent_style = space
indent_size = 2
indent_size = 2

[*.neon]
indent_style = tab
4 changes: 2 additions & 2 deletions .gitattributes
Expand Up @@ -2,9 +2,9 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.semver export-ignore
.github export-ignore
phpunit.xml.dist export-ignore
.travis.yml export-ignore
tests export-ignore
psalm.xml export-ignore
psalm-baseline.xml export-ignore
phpstan.neon export-ignore
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,22 @@
name: CI

on:
push:
branches:
- master
- cake-5
pull_request:
branches:
- '*'

permissions:
contents: read

jobs:
testsuite:
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@master
secrets: inherit

cs-stan:
uses: ADmad/.github/.github/workflows/cs-stan.yml@master
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
/composer.lock
/plugins
/vendor
.phpunit.cache
.phpunit.result.cache
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

16 changes: 12 additions & 4 deletions composer.json
Expand Up @@ -30,11 +30,11 @@
"source": "https://github.com/usemuffin/orderly"
},
"require": {
"cakephp/orm": "^4.0"
"cakephp/orm": "5.x-dev"
},
"require-dev": {
"cakephp/cakephp": "^4.0",
"phpunit/phpunit": "~8.5.0"
"cakephp/cakephp": "5.x-dev",
"phpunit/phpunit": "^10.1"
},
"autoload": {
"psr-4": {
Expand All @@ -46,5 +46,13 @@
"Muffin\\Orderly\\Test\\": "tests",
"Cake\\Test\\Fixture\\": "vendor/cakephp/cakephp/tests/Fixture"
}
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
9 changes: 9 additions & 0 deletions phpstan.neon
@@ -0,0 +1,9 @@
parameters:
level: 7
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- tests/bootstrap.php
paths:
- src
33 changes: 11 additions & 22 deletions phpunit.xml.dist
@@ -1,30 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="./tests/bootstrap.php"
colors="true"
stopOnFailure="false"
>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Orderly Test Cases">
<directory>./tests/</directory>
</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>

<filter>
<whitelist>
<extensions>
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>
<php>
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
</php>
<source>
<include>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
8 changes: 0 additions & 8 deletions psalm-baseline.xml

This file was deleted.

3 changes: 2 additions & 1 deletion psalm.xml
Expand Up @@ -4,7 +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"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
Expand Down
19 changes: 11 additions & 8 deletions src/Model/Behavior/OrderlyBehavior.php
Expand Up @@ -6,14 +6,14 @@
use ArrayObject;
use Cake\Event\EventInterface;
use Cake\ORM\Behavior;
use Cake\ORM\Query;
use Cake\ORM\Query\SelectQuery;

class OrderlyBehavior extends Behavior
{
/**
* Initialize behavior
*
* @param array $config Config
* @param array<string, mixed> $config Config
* @return void
*/
public function initialize(array $config): void
Expand All @@ -24,15 +24,15 @@ public function initialize(array $config): void
}

/**
* Add default order clause to query as necessary.
* Add the default order clause to the query as necessary.
*
* @param \Cake\Event\EventInterface $event Event
* @param \Cake\ORM\Query $query Query
* @param \Cake\ORM\Query\SelectQuery $query Query
* @param \ArrayObject $options Options
* @param bool $primary Boolean indicating whether it's primary query.
* @return void
*/
public function beforeFind(EventInterface $event, Query $query, ArrayObject $options, bool $primary)
public function beforeFind(EventInterface $event, SelectQuery $query, ArrayObject $options, bool $primary): void
{
if ($query->clause('order')) {
return;
Expand All @@ -44,15 +44,15 @@ public function beforeFind(EventInterface $event, Query $query, ArrayObject $opt
empty($config['callback'])
|| call_user_func($config['callback'], $query, $options, $primary)
) {
$query->order($config['order']);
$query->orderBy($config['order']);
}
}
}

/**
* Normalize configuration.
*
* @param array $orders Orders config
* @param array<string, mixed> $orders Orders config
* @return void
*/
protected function _normalizeConfig(array $orders): void
Expand All @@ -64,7 +64,10 @@ protected function _normalizeConfig(array $orders): void
}

$default = [
'order' => $this->_table->aliasField($this->_table->getDisplayField()),
'order' => array_map(
$this->_table->aliasField(...),
(array)$this->_table->getDisplayField()
),
'callback' => null,
];

Expand Down
12 changes: 6 additions & 6 deletions src/Plugin.php → src/OrderlyPlugin.php
Expand Up @@ -5,33 +5,33 @@

use Cake\Core\BasePlugin;

class Plugin extends BasePlugin
class OrderlyPlugin extends BasePlugin
{
/**
* The name of this plugin
*
* @var string
* @var string|null
*/
protected $name = 'Orderly';
protected ?string $name = 'Orderly';

/**
* Do bootstrapping or not
*
* @var bool
*/
protected $bootstrapEnabled = false;
protected bool $bootstrapEnabled = false;

/**
* Load routes or not
*
* @var bool
*/
protected $routesEnabled = false;
protected bool $routesEnabled = false;

/**
* Console middleware
*
* @var bool
*/
protected $consoleEnabled = false;
protected bool $consoleEnabled = false;
}

0 comments on commit 92f5f3e

Please sign in to comment.