From 8ba39f9c30842a852584f46fd7e68771c4c7f3c7 Mon Sep 17 00:00:00 2001 From: Stephan Grootveld Date: Mon, 7 Sep 2026 13:23:51 +0200 Subject: [PATCH 1/5] Replace PHP-CS-Fixer for Pint --- .circleci/config.yml | 8 ++-- .php-cs-fixer.php | 34 ----------------- composer.json | 4 +- database/factories/TicketFactory.php | 2 +- database/factories/UserFactory.php | 2 +- pint.json | 11 ++++++ src/Aspects/SearchAspect.php | 34 +---------------- src/Aspects/SearchExact.php | 32 ++++------------ src/Aspects/SearchJson.php | 32 ++++------------ src/Aspects/SearchPartial.php | 32 ++++------------ src/Aspects/SearchPrefix.php | 51 ++++---------------------- src/Concerns/ExtractsQuotedPhrases.php | 6 --- src/Contracts/Search.php | 8 +--- src/Requests/SearchRequest.php | 13 +------ src/Searchable.php | 24 +----------- src/Weights.php | 17 +-------- tests/CustomSearchTest.php | 25 +++++++------ tests/ExactSearchTest.php | 12 +++--- tests/Models/Ticket.php | 6 +-- tests/Models/User.php | 4 +- tests/PartialSearchTest.php | 12 +++--- tests/PrefixSearchTest.php | 10 ++--- tests/SearchQueryTest.php | 10 ++--- tests/TestCase.php | 8 ++-- tests/WeightedSearchTest.php | 10 ++--- 25 files changed, 106 insertions(+), 301 deletions(-) delete mode 100644 .php-cs-fixer.php create mode 100644 pint.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 7d21584..3d73fc9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,10 +33,10 @@ jobs: - attach_workspace: at: . - run: - name: PHP CS Fixer - command: | - mkdir -p ./logs/phpcsfixer - vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run --format=junit > logs/phpcsfixer/junit.xml + name: Pint + command: | + mkdir -p ./logs/pint + vendor/bin/pint --test --format=junit > logs/pint/junit.xml - run: name: PHPCS command: | diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php deleted file mode 100644 index 3311557..0000000 --- a/.php-cs-fixer.php +++ /dev/null @@ -1,34 +0,0 @@ -exclude('vendor') - ->in(__DIR__); - -return (new PhpCsFixer\Config()) - ->setRiskyAllowed(true) - ->setUsingCache(true) - ->setRules([ - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'blank_line_before_statement' => true, - 'cast_spaces' => true, - 'concat_space' => ['spacing' => 'one'], - 'no_empty_statement' => true, - 'no_extra_blank_lines' => true, - 'no_leading_import_slash' => true, - 'no_multiline_whitespace_around_double_arrow' => true, - 'multiline_whitespace_before_semicolons' => false, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unused_imports' => true, - 'no_whitespace_in_blank_line' => true, - 'object_operator_without_whitespace' => true, - 'ordered_imports' => ['sort_algorithm' => 'length'], - 'phpdoc_order' => true, - 'phpdoc_separation' => false, - 'phpdoc_summary' => true, - 'space_after_semicolon' => true, - 'standardize_not_equals' => true, - 'ternary_to_null_coalescing' => true, - 'trailing_comma_in_multiline' => true, - ]) - ->setFinder($finder); diff --git a/composer.json b/composer.json index c8cc49b..d96f060 100644 --- a/composer.json +++ b/composer.json @@ -38,9 +38,9 @@ }, "require-dev": { "phpunit/phpunit": "^11.0", - "friendsofphp/php-cs-fixer": "^3.7", "squizlabs/php_codesniffer": "^3.6", - "orchestra/testbench": "^9.0|^10.0" + "orchestra/testbench": "^9.0|^10.0", + "laravel/pint": "^1.30" }, "autoload": { "psr-4": { diff --git a/database/factories/TicketFactory.php b/database/factories/TicketFactory.php index 303a02c..d66de92 100644 --- a/database/factories/TicketFactory.php +++ b/database/factories/TicketFactory.php @@ -2,8 +2,8 @@ namespace TestMonitor\Searchable\Database\Factories; -use TestMonitor\Searchable\Test\Models\Ticket; use Illuminate\Database\Eloquent\Factories\Factory; +use TestMonitor\Searchable\Test\Models\Ticket; class TicketFactory extends Factory { diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 61d9548..fce15dc 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,8 +2,8 @@ namespace TestMonitor\Searchable\Database\Factories; -use TestMonitor\Searchable\Test\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; +use TestMonitor\Searchable\Test\Models\User; class UserFactory extends Factory { diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..9999c7c --- /dev/null +++ b/pint.json @@ -0,0 +1,11 @@ +{ + "preset": "laravel", + "rules": { + "concat_space": { + "spacing": "one" + }, + "phpdoc_align": { + "align": "left" + } + } +} diff --git a/src/Aspects/SearchAspect.php b/src/Aspects/SearchAspect.php index 48cd7a1..d35324d 100644 --- a/src/Aspects/SearchAspect.php +++ b/src/Aspects/SearchAspect.php @@ -2,34 +2,20 @@ namespace TestMonitor\Searchable\Aspects; -use TestMonitor\Searchable\Weights; use Illuminate\Database\Eloquent\Builder; use TestMonitor\Searchable\Contracts\Search; +use TestMonitor\Searchable\Weights; class SearchAspect { - /** - * @param string $name - * @param \TestMonitor\Searchable\Contracts\Search $searchClass - * @param int $weight - */ - public function __construct(protected string $name, protected Search $searchClass, protected int $weight = 1) - { - } + public function __construct(protected string $name, protected Search $searchClass, protected int $weight = 1) {} - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $term - */ public function search(Builder $query, Weights $weights, string $term): void { ($this->searchClass)($query, $weights, $this->name, $term, $this->weight); } /** - * @param string $name - * @param int $weight * @return \App\Models\Search\SearchAspect */ public static function exact(string $name, int $weight = 1): self @@ -38,8 +24,6 @@ public static function exact(string $name, int $weight = 1): self } /** - * @param string $name - * @param int $weight * @return \App\Models\Search\SearchAspect */ public static function partial(string $name, int $weight = 1): self @@ -48,10 +32,6 @@ public static function partial(string $name, int $weight = 1): self } /** - * @param string $name - * @param string $prefix - * @param bool $exact - * @param int $weight * @return \App\Models\Search\SearchAspect */ public static function prefix(string $name, string $prefix, bool $exact = false, int $weight = 1): self @@ -60,8 +40,6 @@ public static function prefix(string $name, string $prefix, bool $exact = false, } /** - * @param string $name - * @param int $weight * @return \App\Models\Search\SearchAspect */ public static function json(string $name, int $weight = 1): self @@ -70,8 +48,6 @@ public static function json(string $name, int $weight = 1): self } /** - * @param string $name - * @param \TestMonitor\Searchable\Contracts\Search $searchClass * @return \App\Models\Search\SearchAspect */ public static function custom(string $name, Search $searchClass): self @@ -79,17 +55,11 @@ public static function custom(string $name, Search $searchClass): self return new self($name, $searchClass); } - /** - * @return string - */ public function getName(): string { return $this->name; } - /** - * @return int - */ public function getWeight(): int { return $this->weight; diff --git a/src/Aspects/SearchExact.php b/src/Aspects/SearchExact.php index 1716ef1..c08cc6a 100644 --- a/src/Aspects/SearchExact.php +++ b/src/Aspects/SearchExact.php @@ -2,13 +2,14 @@ namespace TestMonitor\Searchable\Aspects; -use Illuminate\Support\Str; -use Illuminate\Support\Collection; -use TestMonitor\Searchable\Weights; use Illuminate\Database\Eloquent\Builder; -use TestMonitor\Searchable\Contracts\Search; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Support\Collection; +use Illuminate\Support\Str; use TestMonitor\Searchable\Concerns\ExtractsQuotedPhrases; +use TestMonitor\Searchable\Contracts\Search; +use TestMonitor\Searchable\Weights; /** * @template TModelClass of \Illuminate\Database\Eloquent\Model @@ -19,21 +20,13 @@ class SearchExact implements Search { use ExtractsQuotedPhrases; - /** - * @var array - */ protected array $relationConstraints = []; /** - * @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight + * @param Builder $query + * @return mixed * * @throws \InvalidArgumentException - * - * @return mixed */ public function __invoke(Builder $query, Weights $weights, string $property, string $term, int $weight = 1): void { @@ -48,11 +41,6 @@ public function __invoke(Builder $query, Weights $weights, string $property, str $weights->registerIf(empty($this->relationConstraints), $query, $weight); } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $property - * @return bool - */ protected function isRelationProperty(Builder $query, string $property): bool { if (! Str::contains($property, '.')) { @@ -69,12 +57,6 @@ protected function isRelationProperty(Builder $query, string $property): bool } /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight - * * @throws \RuntimeException */ protected function withRelationConstraint( diff --git a/src/Aspects/SearchJson.php b/src/Aspects/SearchJson.php index e959d50..a8bd671 100644 --- a/src/Aspects/SearchJson.php +++ b/src/Aspects/SearchJson.php @@ -2,12 +2,13 @@ namespace TestMonitor\Searchable\Aspects; -use Illuminate\Support\Str; -use Illuminate\Support\Collection; -use TestMonitor\Searchable\Weights; use Illuminate\Database\Eloquent\Builder; -use TestMonitor\Searchable\Contracts\Search; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Support\Collection; +use Illuminate\Support\Str; +use TestMonitor\Searchable\Contracts\Search; +use TestMonitor\Searchable\Weights; /** * @template TModelClass of \Illuminate\Database\Eloquent\Model @@ -16,21 +17,13 @@ */ class SearchJson implements Search { - /** - * @var array - */ protected array $relationConstraints = []; /** - * @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight + * @param Builder $query + * @return mixed * * @throws \InvalidArgumentException - * - * @return mixed */ public function __invoke(Builder $query, Weights $weights, string $property, string $term, int $weight = 1): void { @@ -47,11 +40,6 @@ public function __invoke(Builder $query, Weights $weights, string $property, str $weights->registerIf(empty($this->relationConstraints), $query, $weight); } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $property - * @return bool - */ protected function isRelationProperty(Builder $query, string $property): bool { if (! Str::contains($property, '.')) { @@ -68,12 +56,6 @@ protected function isRelationProperty(Builder $query, string $property): bool } /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight - * * @throws \RuntimeException */ protected function withRelationConstraint( diff --git a/src/Aspects/SearchPartial.php b/src/Aspects/SearchPartial.php index 4ebd6ec..af510a3 100644 --- a/src/Aspects/SearchPartial.php +++ b/src/Aspects/SearchPartial.php @@ -2,13 +2,14 @@ namespace TestMonitor\Searchable\Aspects; -use Illuminate\Support\Str; -use Illuminate\Support\Collection; -use TestMonitor\Searchable\Weights; use Illuminate\Database\Eloquent\Builder; -use TestMonitor\Searchable\Contracts\Search; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Support\Collection; +use Illuminate\Support\Str; use TestMonitor\Searchable\Concerns\ExtractsQuotedPhrases; +use TestMonitor\Searchable\Contracts\Search; +use TestMonitor\Searchable\Weights; /** * @template TModelClass of \Illuminate\Database\Eloquent\Model @@ -19,21 +20,13 @@ class SearchPartial implements Search { use ExtractsQuotedPhrases; - /** - * @var array - */ protected array $relationConstraints = []; /** - * @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight + * @param Builder $query + * @return mixed * * @throws \InvalidArgumentException - * - * @return mixed */ public function __invoke(Builder $query, Weights $weights, string $property, string $term, int $weight = 1): void { @@ -50,11 +43,6 @@ public function __invoke(Builder $query, Weights $weights, string $property, str $weights->registerIf(empty($this->relationConstraints), $query, $weight); } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $property - * @return bool - */ protected function isRelationProperty(Builder $query, string $property): bool { if (! Str::contains($property, '.')) { @@ -71,12 +59,6 @@ protected function isRelationProperty(Builder $query, string $property): bool } /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight - * * @throws \RuntimeException */ protected function withRelationConstraint( diff --git a/src/Aspects/SearchPrefix.php b/src/Aspects/SearchPrefix.php index 849f168..e253cc3 100644 --- a/src/Aspects/SearchPrefix.php +++ b/src/Aspects/SearchPrefix.php @@ -2,13 +2,14 @@ namespace TestMonitor\Searchable\Aspects; -use Illuminate\Support\Str; -use Illuminate\Support\Collection; -use TestMonitor\Searchable\Weights; use Illuminate\Database\Eloquent\Builder; -use TestMonitor\Searchable\Contracts\Search; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Support\Collection; +use Illuminate\Support\Str; use TestMonitor\Searchable\Concerns\ExtractsQuotedPhrases; +use TestMonitor\Searchable\Contracts\Search; +use TestMonitor\Searchable\Weights; /** * @template TModelClass of \Illuminate\Database\Eloquent\Model @@ -19,29 +20,15 @@ class SearchPrefix implements Search { use ExtractsQuotedPhrases; - /** - * @var array - */ protected array $relationConstraints = []; - /** - * @param string $prefix - * @param bool $exact - */ - public function __construct(protected string $prefix, protected bool $exact = false) - { - } + public function __construct(protected string $prefix, protected bool $exact = false) {} /** - * @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight + * @param Builder $query + * @return mixed * * @throws \InvalidArgumentException - * - * @return mixed */ public function __invoke(Builder $query, Weights $weights, string $property, string $term, int $weight = 1): void { @@ -62,10 +49,6 @@ public function __invoke(Builder $query, Weights $weights, string $property, str /** * Search for an exact match. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $property - * @param string $term */ protected function searchForExactMatch(Builder $query, string $property, string $term): void { @@ -80,10 +63,6 @@ protected function searchForExactMatch(Builder $query, string $property, string /** * Search for a partial match. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $property - * @param string $term */ protected function searchForPartialMatch(Builder $query, string $property, string $term): void { @@ -94,20 +73,12 @@ protected function searchForPartialMatch(Builder $query, string $property, strin /** * Strip defined prefix from a search term. - * - * @param string $term - * @return string */ protected function stripPrefix(string $term): string { return preg_replace('/^' . preg_quote($this->prefix, '/') . '/i', '', $term); } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $property - * @return bool - */ protected function isRelationProperty(Builder $query, string $property): bool { if (! Str::contains($property, '.')) { @@ -124,12 +95,6 @@ protected function isRelationProperty(Builder $query, string $property): bool } /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight - * * @throws \RuntimeException */ protected function withRelationConstraint( diff --git a/src/Concerns/ExtractsQuotedPhrases.php b/src/Concerns/ExtractsQuotedPhrases.php index 6ca7213..8e361e0 100644 --- a/src/Concerns/ExtractsQuotedPhrases.php +++ b/src/Concerns/ExtractsQuotedPhrases.php @@ -6,9 +6,6 @@ trait ExtractsQuotedPhrases { /** * Parses a search term string into individual terms, preserving quoted phrases. - * - * @param string $term - * @return array */ public function extractQuotedPhrases(string $term): array { @@ -17,9 +14,6 @@ public function extractQuotedPhrases(string $term): array /** * Removes quotes from search terms. - * - * @param string $term - * @return string */ public function stripQuotedPhrases(string $term): string { diff --git a/src/Contracts/Search.php b/src/Contracts/Search.php index b308055..e2c1be2 100644 --- a/src/Contracts/Search.php +++ b/src/Contracts/Search.php @@ -2,8 +2,8 @@ namespace TestMonitor\Searchable\Contracts; -use TestMonitor\Searchable\Weights; use Illuminate\Database\Eloquent\Builder; +use TestMonitor\Searchable\Weights; /** * @template TModelClass of \Illuminate\Database\Eloquent\Model @@ -11,11 +11,7 @@ interface Search { /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \TestMonitor\Searchable\Weights $weights - * @param string $property - * @param string $term - * @param int $weight + * @param Builder $query * @return mixed */ public function __invoke(Builder $query, Weights $weights, string $property, string $term, int $weight = 1): void; diff --git a/src/Requests/SearchRequest.php b/src/Requests/SearchRequest.php index ef2d198..8b99c4f 100644 --- a/src/Requests/SearchRequest.php +++ b/src/Requests/SearchRequest.php @@ -3,33 +3,24 @@ namespace TestMonitor\Searchable\Requests; use Illuminate\Http\Request; +use Symfony\Component\HttpFoundation\Exception\BadRequestException; class SearchRequest extends Request { /** - * @param \Illuminate\Http\Request $request - * - * @throws \Symfony\Component\HttpFoundation\Exception\BadRequestException + * @throws BadRequestException * @throws \RuntimeException - * - * @return \TestMonitor\Searchable\Requests\SearchRequest */ public static function fromRequest(Request $request): self { return static::createFrom($request, new self); } - /** - * @return bool - */ public function hasTerm(): bool { return strlen($this->term()) >= config('searchable.minimal_length'); } - /** - * @return string - */ public function term(): string { return $this->input(config('searchable.parameter')) ?? ''; diff --git a/src/Searchable.php b/src/Searchable.php index f6251ca..3adaa87 100644 --- a/src/Searchable.php +++ b/src/Searchable.php @@ -2,36 +2,22 @@ namespace TestMonitor\Searchable; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; use Illuminate\Support\Collection; -use Illuminate\Database\Eloquent\Builder; use TestMonitor\Searchable\Aspects\SearchAspect; use TestMonitor\Searchable\Requests\SearchRequest; trait Searchable { - /** - * @var \Illuminate\Support\Collection - */ protected Collection $searchAspects; - /** - * @var \TestMonitor\Searchable\Requests\SearchRequest - */ public SearchRequest $searchRequest; - /** - * @var \TestMonitor\Searchable\Weights - */ protected Weights $searchWeights; /** * Provide a model search query scope. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string|array $aspects - * @param \Illuminate\Http\Request|null $request - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeSearchUsing(Builder $query, string|array $aspects, ?Request $request = null): Builder { @@ -53,7 +39,7 @@ public function scopeSearchUsing(Builder $query, string|array $aspects, ?Request return SearchAspect::exact($aspect); }); - $this->searchWeights = new Weights(); + $this->searchWeights = new Weights; $query->where(fn (Builder $query) => $this->addSearchAspectsToQuery($query)) ->tap(fn (Builder $query) => $this->addOrderByWeightToQuery($query)); @@ -61,9 +47,6 @@ public function scopeSearchUsing(Builder $query, string|array $aspects, ?Request return $query; } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - */ protected function addSearchAspectsToQuery(Builder $query): void { $this->searchAspects->each(function (SearchAspect $aspect) use ($query) { @@ -73,9 +56,6 @@ protected function addSearchAspectsToQuery(Builder $query): void }); } - /** - * @param \Illuminate\Database\Eloquent\Builder $query - */ protected function addOrderByWeightToQuery(Builder $query): void { $this->searchWeights->applyOrderQuery($query); diff --git a/src/Weights.php b/src/Weights.php index d6a14de..b881d95 100644 --- a/src/Weights.php +++ b/src/Weights.php @@ -2,8 +2,8 @@ namespace TestMonitor\Searchable; -use Illuminate\Support\Facades\DB; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\DB; class Weights { @@ -12,10 +12,6 @@ class Weights */ protected array $weights = []; - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param int $weight - */ public function register(Builder $query, int $weight = 1): void { $sql = $this->compileWheresIntoSQL($query); @@ -25,11 +21,6 @@ public function register(Builder $query, int $weight = 1): void $this->weights[$condition] = $weight; } - /** - * @param bool $condition - * @param \Illuminate\Database\Eloquent\Builder $query - * @param int $weight - */ public function registerIf(bool $condition, Builder $query, int $weight = 1): void { if ($condition) { @@ -39,9 +30,6 @@ public function registerIf(bool $condition, Builder $query, int $weight = 1): vo /** * Compile all where conditions to SQL. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @return string */ protected function compileWheresIntoSQL(Builder $query): string { @@ -53,9 +41,6 @@ protected function compileWheresIntoSQL(Builder $query): string ); } - /** - * @return \Illuminate\Database\Eloquent\Builder - */ public function applyOrderQuery(Builder $query): Builder { if (empty($this->weights)) { diff --git a/tests/CustomSearchTest.php b/tests/CustomSearchTest.php index db59be4..6cbfc4e 100644 --- a/tests/CustomSearchTest.php +++ b/tests/CustomSearchTest.php @@ -2,30 +2,30 @@ namespace TestMonitor\Searchable\Test; -use Illuminate\Http\Request; -use TestMonitor\Searchable\Weights; -use PHPUnit\Framework\Attributes\Test; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; -use TestMonitor\Searchable\Contracts\Search; -use TestMonitor\Searchable\Test\Models\User; +use Illuminate\Database\Eloquent\Factories\Sequence; +use Illuminate\Http\Request; +use PHPUnit\Framework\Attributes\Test; use TestMonitor\Searchable\Aspects\SearchAspect; +use TestMonitor\Searchable\Contracts\Search; use TestMonitor\Searchable\Requests\SearchRequest; -use Illuminate\Database\Eloquent\Factories\Sequence; +use TestMonitor\Searchable\Test\Models\User; +use TestMonitor\Searchable\Weights; class CustomSearchTest extends TestCase { /** - * @var \Illuminate\Database\Eloquent\Collection + * @var Collection */ protected $users; /** - * @var \TestMonitor\Searchable\Contracts\Search + * @var Search */ protected $domainSearcher; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -38,7 +38,8 @@ public function setUp(): void )) ->create(); - $this->domainSearcher = new class() implements Search { + $this->domainSearcher = new class implements Search + { public function __invoke(Builder $query, Weights $weights, string $property, string $term, int $weight = 1): void { $query->where($query->qualifyColumn($property), 'LIKE', "%@{$term}"); @@ -58,7 +59,7 @@ public function it_will_find_records_using_an_exact_match() // When $results = User::query() - ->searchUsing([SearchAspect::custom('email', new $this->domainSearcher())]) + ->searchUsing([SearchAspect::custom('email', new $this->domainSearcher)]) ->get(); // Then @@ -77,7 +78,7 @@ public function it_doesnt_return_records_when_an_exact_match_does_not_exists() // When $results = User::query() - ->searchUsing([SearchAspect::custom('email', new $this->domainSearcher())]) + ->searchUsing([SearchAspect::custom('email', new $this->domainSearcher)]) ->get(); // Then diff --git a/tests/ExactSearchTest.php b/tests/ExactSearchTest.php index 3452d17..764ed00 100644 --- a/tests/ExactSearchTest.php +++ b/tests/ExactSearchTest.php @@ -2,23 +2,23 @@ namespace TestMonitor\Searchable\Test; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Factories\Sequence; use Illuminate\Http\Request; use PHPUnit\Framework\Attributes\Test; -use Illuminate\Database\Eloquent\Collection; -use TestMonitor\Searchable\Test\Models\User; -use TestMonitor\Searchable\Test\Models\Ticket; use TestMonitor\Searchable\Aspects\SearchAspect; use TestMonitor\Searchable\Requests\SearchRequest; -use Illuminate\Database\Eloquent\Factories\Sequence; +use TestMonitor\Searchable\Test\Models\Ticket; +use TestMonitor\Searchable\Test\Models\User; class ExactSearchTest extends TestCase { /** - * @var \Illuminate\Database\Eloquent\Collection + * @var Collection */ protected $users; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Models/Ticket.php b/tests/Models/Ticket.php index 3781ebf..ebf4f7f 100644 --- a/tests/Models/Ticket.php +++ b/tests/Models/Ticket.php @@ -2,11 +2,11 @@ namespace TestMonitor\Searchable\Test\Models; -use TestMonitor\Searchable\Searchable; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use TestMonitor\Searchable\Searchable; class Ticket extends Model { diff --git a/tests/Models/User.php b/tests/Models/User.php index 1665220..0c9cb09 100644 --- a/tests/Models/User.php +++ b/tests/Models/User.php @@ -2,10 +2,10 @@ namespace TestMonitor\Searchable\Test\Models; -use TestMonitor\Searchable\Searchable; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use TestMonitor\Searchable\Searchable; class User extends Model { diff --git a/tests/PartialSearchTest.php b/tests/PartialSearchTest.php index b7c8684..7088516 100644 --- a/tests/PartialSearchTest.php +++ b/tests/PartialSearchTest.php @@ -2,23 +2,23 @@ namespace TestMonitor\Searchable\Test; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Factories\Sequence; use Illuminate\Http\Request; use PHPUnit\Framework\Attributes\Test; -use Illuminate\Database\Eloquent\Collection; -use TestMonitor\Searchable\Test\Models\User; -use TestMonitor\Searchable\Test\Models\Ticket; use TestMonitor\Searchable\Aspects\SearchAspect; use TestMonitor\Searchable\Requests\SearchRequest; -use Illuminate\Database\Eloquent\Factories\Sequence; +use TestMonitor\Searchable\Test\Models\Ticket; +use TestMonitor\Searchable\Test\Models\User; class PartialSearchTest extends TestCase { /** - * @var \Illuminate\Database\Eloquent\Collection + * @var Collection */ protected $users; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/PrefixSearchTest.php b/tests/PrefixSearchTest.php index e736195..a361afd 100644 --- a/tests/PrefixSearchTest.php +++ b/tests/PrefixSearchTest.php @@ -2,22 +2,22 @@ namespace TestMonitor\Searchable\Test; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Http\Request; use PHPUnit\Framework\Attributes\Test; -use Illuminate\Database\Eloquent\Collection; -use TestMonitor\Searchable\Test\Models\User; -use TestMonitor\Searchable\Test\Models\Ticket; use TestMonitor\Searchable\Aspects\SearchAspect; use TestMonitor\Searchable\Requests\SearchRequest; +use TestMonitor\Searchable\Test\Models\Ticket; +use TestMonitor\Searchable\Test\Models\User; class PrefixSearchTest extends TestCase { /** - * @var \Illuminate\Database\Eloquent\Collection + * @var Collection */ protected $users; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/SearchQueryTest.php b/tests/SearchQueryTest.php index 7b73777..ac8a0e9 100644 --- a/tests/SearchQueryTest.php +++ b/tests/SearchQueryTest.php @@ -2,22 +2,22 @@ namespace TestMonitor\Searchable\Test; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Factories\Sequence; use Illuminate\Http\Request; use PHPUnit\Framework\Attributes\Test; -use Illuminate\Database\Eloquent\Collection; -use TestMonitor\Searchable\Test\Models\User; use TestMonitor\Searchable\Aspects\SearchAspect; use TestMonitor\Searchable\Requests\SearchRequest; -use Illuminate\Database\Eloquent\Factories\Sequence; +use TestMonitor\Searchable\Test\Models\User; class SearchQueryTest extends TestCase { /** - * @var \Illuminate\Database\Eloquent\Collection + * @var Collection */ protected $users; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/TestCase.php b/tests/TestCase.php index c96d1a5..09b121d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,11 +2,11 @@ namespace TestMonitor\Searchable\Test; -use Illuminate\Foundation\Application; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Eloquent\Factories\Factory; -use TestMonitor\Searchable\SearchableServiceProvider; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Foundation\Application; use Orchestra\Testbench\TestCase as OrchestraTestCase; +use TestMonitor\Searchable\SearchableServiceProvider; abstract class TestCase extends OrchestraTestCase { @@ -18,7 +18,7 @@ protected function getPackageProviders($app) } /** - * @param \Illuminate\Foundation\Application $app + * @param Application $app */ protected function getEnvironmentSetUp($app) { diff --git a/tests/WeightedSearchTest.php b/tests/WeightedSearchTest.php index e8f4a41..a3e5eb9 100644 --- a/tests/WeightedSearchTest.php +++ b/tests/WeightedSearchTest.php @@ -2,22 +2,22 @@ namespace TestMonitor\Searchable\Test; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Factories\Sequence; use Illuminate\Http\Request; use PHPUnit\Framework\Attributes\Test; -use Illuminate\Database\Eloquent\Collection; -use TestMonitor\Searchable\Test\Models\User; use TestMonitor\Searchable\Aspects\SearchAspect; use TestMonitor\Searchable\Requests\SearchRequest; -use Illuminate\Database\Eloquent\Factories\Sequence; +use TestMonitor\Searchable\Test\Models\User; class WeightedSearchTest extends TestCase { /** - * @var \Illuminate\Database\Eloquent\Collection + * @var Collection */ protected $users; - public function setUp(): void + protected function setUp(): void { parent::setUp(); From 3f12f020e09c667ed0776319a2a8d822eba81e3e Mon Sep 17 00:00:00 2001 From: Stephan Grootveld Date: Mon, 7 Sep 2026 13:25:06 +0200 Subject: [PATCH 2/5] Replace PHP-CS-Fixer for Pint --- .styleci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index 13291e1..701612d 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,11 +1,10 @@ preset: laravel enabled: - - length_ordered_imports - concat_with_spaces disabled: - - alpha_ordered_imports + - class_definition - concat_without_spaces - laravel_braces - laravel_phpdoc_alignment From 4dd74d6099c61bc447cccfd19ece791510893edc Mon Sep 17 00:00:00 2001 From: Stephan Grootveld Date: Mon, 7 Sep 2026 13:35:32 +0200 Subject: [PATCH 3/5] Replace PHP-CS-Fixer for Pint --- phpcs.xml | 99 ++++++++----------------------------------------------- 1 file changed, 14 insertions(+), 85 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 9decaee..f98a898 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,89 +1,18 @@ - - The coding standard for PHP_CodeSniffer itself. - - - - */Standards/*/Tests/*.(inc|css|js) + + src/ - - - - - - - error + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + From 732abd344f1cd974d7f423b75bf6ae26bd6771d3 Mon Sep 17 00:00:00 2001 From: Stephan Grootveld Date: Mon, 7 Sep 2026 13:49:01 +0200 Subject: [PATCH 4/5] Replace PHP-CS-Fixer for Pint --- src/Aspects/SearchPrefix.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Aspects/SearchPrefix.php b/src/Aspects/SearchPrefix.php index e253cc3..a2aa4a8 100644 --- a/src/Aspects/SearchPrefix.php +++ b/src/Aspects/SearchPrefix.php @@ -22,7 +22,10 @@ class SearchPrefix implements Search protected array $relationConstraints = []; - public function __construct(protected string $prefix, protected bool $exact = false) {} + public function __construct(protected string $prefix, protected bool $exact = false) + { + // + } /** * @param Builder $query From f35daec72a2f67baf09932f3214156df2366899a Mon Sep 17 00:00:00 2001 From: Stephan Grootveld Date: Mon, 7 Sep 2026 13:50:04 +0200 Subject: [PATCH 5/5] Replace PHP-CS-Fixer for Pint --- src/Aspects/SearchAspect.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Aspects/SearchAspect.php b/src/Aspects/SearchAspect.php index d35324d..95d99d2 100644 --- a/src/Aspects/SearchAspect.php +++ b/src/Aspects/SearchAspect.php @@ -8,7 +8,10 @@ class SearchAspect { - public function __construct(protected string $name, protected Search $searchClass, protected int $weight = 1) {} + public function __construct(protected string $name, protected Search $searchClass, protected int $weight = 1) + { + // + } public function search(Builder $query, Weights $weights, string $term): void {