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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Orderly

[![Build Status](https://img.shields.io/github/actions/workflow/status/UseMuffin/Orderly/ci.yml?style=flat-square&branch=master)](https://github.com/UseMuffin/Orderly/actions/workflows/ci.yml?query=branch%3Amaster)
[![Build Status](https://img.shields.io/github/actions/workflow/status/UseMuffin/Orderly/ci.yml?branch=master&style=flat-square)](https://github.com/UseMuffin/Orderly/actions/workflows/ci.yml?query=branch%3Amaster)
[![Coverage](https://img.shields.io/codecov/c/github/UseMuffin/Orderly/master?style=flat-square
)](https://app.codecov.io/gh/UseMuffin/Orderly)
[![Total Downloads](https://img.shields.io/packagist/dt/muffin/orderly.svg?style=flat-square)](https://packagist.org/packages/muffin/orderly)
Expand All @@ -12,13 +12,13 @@ Allows setting default order for your tables.

Using [Composer][composer]:

```
```sh
composer require muffin/orderly
```

Then load the plugin using the console command:

```
```sh
bin/cake plugin load Muffin/Orderly
```

Expand All @@ -38,7 +38,7 @@ $this->addBehavior('Muffin/Orderly.Orderly');
$this->addBehavior('Muffin/Orderly.Orderly', ['order' => $this->aliasField('field_name')]);
```

Value for `order` key can any valid value that `\Cake\ORM\Query::orderBy()` takes.
Value for `order` key can any valid value that `\Cake\ORM\Query\SelectQuery::orderBy()` takes.
The default order clause will only be applied to the primary query and when no
custom order clause has already been set for the query.

Expand All @@ -48,7 +48,7 @@ condition using `callback` option. The order will be applied if callback returns
```php
$this->addBehavior('Muffin/Orderly.Orderly', [
'order' => ['Alias.field_name' => 'DESC'],
'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
'callback' => function (SelectQuery $query, ArrayObject $options, bool $primary) {
//return a boolean
}
]);
Expand All @@ -61,13 +61,13 @@ on return value of their respective callbacks:
$this->addBehavior('Muffin/Orderly.Orderly', [
[
'order' => ['Alias.field_name' => 'DESC'],
'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
'callback' => function (SelectQuery $query, ArrayObject $options, bool $primary) {
//return a boolean
}
],
[
'order' => ['Alias.another_field'],
'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
'callback' => function (SelectQuery $query, ArrayObject $options, bool $primary) {
//return a boolean
}
],
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"require-dev": {
"cakephp/cakephp": "^5.0",
"phpunit/phpunit": "^10.1 || ^11.1"
"phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 7 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<ruleset name="Orderly">
<rule ref="CakePHP"/>

<file>src/</file>
<file>tests/</file>
</ruleset>
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
parameters:
level: 7
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- tests/bootstrap.php
paths:
- src
ignoreErrors:
- identifier: missingType.generics
9 changes: 2 additions & 7 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
</projectFiles>

<issueHandlers>
<MissingClosureReturnType errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
<MissingOverrideAttribute errorLevel="info" />
<ClassMustBeFinal errorLevel="info" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Model/Behavior/OrderlyBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function _normalizeConfig(array $orders): void
$default = [
'order' => array_map(
$this->_table->aliasField(...),
(array)$this->_table->getDisplayField()
(array)$this->_table->getDisplayField(),
),
'callback' => null,
];
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Model/Behavior/OrderlyBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testInitialize()
];
$this->assertEquals(
$expected,
$this->Table->behaviors()->Orderly->getConfig()['orders']
$this->Table->behaviors()->Orderly->getConfig()['orders'],
);

$this->Table->removeBehavior('Orderly');
Expand All @@ -58,7 +58,7 @@ public function testInitialize()
];
$this->assertEquals(
$expected,
$this->Table->behaviors()->Orderly->getConfig()['orders']
$this->Table->behaviors()->Orderly->getConfig()['orders'],
);

$callback = function () {
Expand All @@ -75,7 +75,7 @@ public function testInitialize()
];
$this->assertEquals(
$expected,
$this->Table->behaviors()->Orderly->getConfig()['orders']
$this->Table->behaviors()->Orderly->getConfig()['orders'],
);

$this->Table->removeBehavior('Orderly');
Expand All @@ -96,7 +96,7 @@ public function testInitialize()
];
$this->assertEquals(
$expected,
$this->Table->behaviors()->Orderly->getConfig()['orders']
$this->Table->behaviors()->Orderly->getConfig()['orders'],
);
}

Expand Down