Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
skie committed Sep 11, 2024
1 parent 3b5cbd9 commit 55aa86c
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 26 deletions.
7 changes: 5 additions & 2 deletions src/Filter/FilterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
*
* This class represents a collection of filters and provides methods to manage and interact with them.
*
* @implements \IteratorAggregate<string, \CakeDC\SearchFilter\Filter\FilterInterface>
* @psalm-suppress TooManyTemplateParams
*/
class FilterCollection implements IteratorAggregate, Countable
{
/**
* Filter list
*
* @var array<\CakeDC\SearchFilter\Filter\FilterInterface>
* @var array<string, \CakeDC\SearchFilter\Filter\FilterInterface>
*/
protected array $filters = [];

Expand Down Expand Up @@ -92,7 +94,8 @@ public function remove(string $name)
/**
* Implementation of IteratorAggregate.
*
* @return \Traversable
* @return \Traversable<string, \CakeDC\SearchFilter\Filter\FilterInterface>
* @psalm-suppress TooManyTemplateParams
*/
public function getIterator(): Traversable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function __construct(ServerRequest $request, ?array $filters = null)
}

$this->loadFilters();
$this->_criteriaBuilder = new CriteriaBuilder();
$this->_criteriaBuilder = new CriteriaBuilder();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Model/Filter/CriteriaFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public function __construct(FilterRegistry $registry, array $config = [])
*
* @param \Cake\ORM\Query\SelectQuery<\Cake\Datasource\EntityInterface> $query Query.
* @param string $field Field name.
* @param mixed $value Field value.
* @param string|array $value Field value.
* @param array<string, mixed> $data Filters values.
* @return \Cake\ORM\Query\SelectQuery<\Cake\Datasource\EntityInterface>
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @phpstan-param array<string, array{condition: string, value: mixed}>|string $value
*/
protected function _buildQuery(SelectQuery $query, string $field, $value, array $data = []): SelectQuery
{
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Filter/Criterion/BaseCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace CakeDC\SearchFilter\Model\Filter\Criterion;

use Cake\Database\ExpressionInterface;
use Cake\Database\Expression\ComparisonExpression;
use Cake\Database\Expression\QueryExpression;
use Cake\Database\ExpressionInterface;
use Cake\I18n\Date;
use Cake\I18n\DateTime;
use Cake\Utility\Hash;
Expand All @@ -21,7 +21,7 @@ abstract class BaseCriterion implements CriterionInterface
/**
* Field name used for searching
*
* @var string|ExpressionInterface
* @var string|\Cake\Database\ExpressionInterface
*/
protected string|ExpressionInterface $field;

Expand Down
6 changes: 3 additions & 3 deletions src/Model/Filter/Criterion/DateCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use Cake\Database\ExpressionInterface;
use Cake\Database\FunctionsBuilder;
use Cake\I18n\Date;
use Cake\I18n\DateTime;
use Cake\ORM\Query\SelectQuery;
use CakeDC\SearchFilter\Filter\AbstractFilter;
use DateInterface;

class DateCriterion extends BaseCriterion
{
Expand Down Expand Up @@ -181,9 +181,9 @@ protected function buildYearWeekExpression(string|ExpressionInterface $value): F
* Create a date/time object from a string
*
* @param string $dateStr
* @return Date
* @return \Cake\I18n\Date|\Cake\I18n\DateTime
*/
protected function prepareTime(string $dateStr)
protected function prepareTime(string $dateStr): DateTime|Date
{
return Date::createFromFormat($this->format, $dateStr);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Model/Filter/Criterion/DateTimeCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace CakeDC\SearchFilter\Model\Filter\Criterion;

use Cake\Database\ExpressionInterface;
use Cake\I18n\Date;
use Cake\I18n\DateTime;
use DateTimeInterface;

class DateTimeCriterion extends DateCriterion
{
Expand All @@ -31,9 +31,9 @@ public function __construct(string|ExpressionInterface $field, string $format =
* Create a date/time object from a string
*
* @param string $dateStr
* @return \DateTimeInterface
* @return \Cake\I18n\Date|\Cake\I18n\DateTime
*/
protected function prepareTime(string $dateStr): DateTimeInterface
protected function prepareTime(string $dateStr): DateTime|Date
{
return DateTime::createFromFormat($this->format, $dateStr);
}
Expand Down
1 change: 0 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace CakeDC\SearchFilter;

use Cake\Core\BasePlugin;
use Cake\Core\PluginApplicationInterface;

/**
* Plugin for SearchFilter
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/BooleanFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BooleanFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->booleanFilter = new BooleanFilter('test_field');
$this->booleanFilter = new BooleanFilter();
}

public function tearDown(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/DateFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DateFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->dateFilter = new DateFilter('test_date');
$this->dateFilter = new DateFilter();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/DateTimeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DateTimeFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->dateTimeFilter = new DateTimeFilter('test_field');
$this->dateTimeFilter = new DateTimeFilter();
}

public function tearDown(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Filter/FilterCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function testGetCriteria(): void
$stringFilter = new StringFilter();
$numericFilter = new NumericFilter();

$stringCriterion = new StringCriterion('test', 'like', 'value');
$numericCriterion = new NumericCriterion('test2', '>', 10);
$stringCriterion = new StringCriterion('test');
$numericCriterion = new NumericCriterion('test2');

$stringFilter->setCriterion($stringCriterion);
$numericFilter->setCriterion($numericCriterion);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/LookupFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function setUp(): void
$routes->connect('/authors/autocomplete', ['controller' => 'Authors', 'action' => 'autocomplete']);
});

$this->lookupFilter = new LookupFilter('test_lookup');
$this->lookupFilter = new LookupFilter();
$this->lookupFilter->setAutocompleteRoute([
'controller' => 'Authors',
'action' => 'autocomplete',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/MultipleFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MultipleFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->multipleFilter = new MultipleFilter('test_field');
$this->multipleFilter = new MultipleFilter();
}

public function tearDown(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/NumericFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NumericFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->numericFilter = new NumericFilter('test_field');
$this->numericFilter = new NumericFilter();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/SelectFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SelectFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->selectFilter = new SelectFilter('test_field');
$this->selectFilter = new SelectFilter();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Filter/StringFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StringFilterTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->stringFilter = new StringFilter('test_field');
$this->stringFilter = new StringFilter();
}

/**
Expand Down
4 changes: 1 addition & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Error\ErrorTrap;
use Cake\TestSuite\Fixture\SchemaLoader;

Configure::write('App', ['namespace' => 'CakeDC\SearchFilter\Test\App']);
// Cake\Core\Configure::write('Error', ['errorLevel' => E_ALL ^ E_USER_DEPRECATED]);
Configure::write('debug', true);

@mkdir(TMP . 'cache/models', 0777);
Expand Down Expand Up @@ -89,8 +89,6 @@
]);

// Create test database schema
use Cake\TestSuite\Fixture\SchemaLoader;

if (env('FIXTURE_SCHEMA_METADATA')) {
$loader = new SchemaLoader();
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'));
Expand Down

0 comments on commit 55aa86c

Please sign in to comment.