Skip to content

Commit

Permalink
Added phpstan/phpstan-strict-rules (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonrietdijk authored Aug 23, 2024
1 parent aafe260 commit 2beaac8
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"livewire/livewire": "^3.0"
},
"require-dev": {
"laravel/pint": "^1.16",
"larastan/larastan": "^2.9",
"laravel/pint": "^1.16",
"orchestra/testbench": "^9.2",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^11.2"
},
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
includes:
- ./vendor/phpstan/phpstan-strict-rules/rules.neon
- ./vendor/larastan/larastan/extension.neon

parameters:
paths:
- src
- tests
level: 9
ignoreErrors:
- identifier: staticMethod.dynamicCall
- identifier: property.dynamicName
- identifier: method.dynamicName
6 changes: 3 additions & 3 deletions src/Concerns/HasColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function reorderColumn(string $from, string $to, bool $above): void
return;
}

$currentOrder = (int) array_search($from, $this->columnOrder);
$currentOrder = (int) array_search($from, $this->columnOrder, true);

$toOrder = (int) array_search($to, $this->columnOrder);
$toOrder = (int) array_search($to, $this->columnOrder, true);

$up = $toOrder > $currentOrder;

Expand Down Expand Up @@ -95,7 +95,7 @@ protected function columns(): array
protected function resolveColumns(): Enumerable
{
return collect($this->columns())->sortBy(function (BaseColumn $column): int {
return (int) array_search($column->code(), $this->columnOrder);
return (int) array_search($column->code(), $this->columnOrder, true);
})->values();
}
}
2 changes: 1 addition & 1 deletion src/Concerns/HasPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function perPage(): int
{
$options = $this->perPageOptions();

if (! in_array($this->perPage, $options)) {
if (! in_array($this->perPage, $options, true)) {
return $options[0];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Concerns/HasRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ protected function applyRelations(Builder $builder): static

$fullRelation = $previous->push($segment)->implode('.');

if (! in_array($fullRelation, $with)) {
if (! in_array($fullRelation, $with, true)) {
$with[] = $fullRelation;
}

if (! in_array($fullRelation, $join) && $shouldJoin) {
if (! in_array($fullRelation, $join, true) && $shouldJoin) {
$join[] = $fullRelation;

$lookup[$fullRelation] = $this->joinEloquentRelation($builder, $relation, $model, $segment, $alias);
Expand Down
4 changes: 2 additions & 2 deletions src/Concerns/HasSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function applyGlobalSearch(Builder $builder): static
}

$columns = $this->resolveColumns()->filter(function (BaseColumn $column): bool {
return $column->isSearchable() && in_array($column->code(), $this->columns);
return $column->isSearchable() && in_array($column->code(), $this->columns, true);
});

$builder->where(function (Builder $builder) use ($columns): void {
Expand All @@ -89,7 +89,7 @@ protected function applyColumnSearch(Builder $builder): static
}

$columns = $this->resolveColumns()->filter(function (BaseColumn $column): bool {
return $column->isSearchable() && in_array($column->code(), $this->columns);
return $column->isSearchable() && in_array($column->code(), $this->columns, true);
});

$builder->where(function (Builder $builder) use ($columns): void {
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/HasSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function updatedHasSession(string $property): void

$property = Str::of($property)->before('.')->toString();

if (! in_array($property, $this->sessionProperties)) {
if (! in_array($property, $this->sessionProperties, true)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Filters/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class DateFilter extends BaseFilter
{
protected string $view = 'livewire-table::filters.date';

/** @param array<string, string> $value */
public function filter(Builder $builder, mixed $value): void
{
/** @var array<string, string> $value */
$from = $value['from'] ?? null;
$to = $value['to'] ?? null;

Expand Down
2 changes: 1 addition & 1 deletion src/Livewire/LivewireTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LivewireTable extends Component

protected string $model = Model::class;

/** @var array <int|string, string> */
/** @var mixed */
protected $listeners = [
'refreshLivewireTable' => '$refresh',
];
Expand Down

0 comments on commit 2beaac8

Please sign in to comment.