Skip to content

Fix result of immutable methods in BaseListView #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
11 changes: 4 additions & 7 deletions src/BaseListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@

final public function ignoreMissingPage(bool $enabled): static
{
$new = clone $this;

Check warning on line 173 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": @@ @@ } final public function ignoreMissingPage(bool $enabled): static { - $new = clone $this; + $new = $this; $new->ignoreMissingPage = $enabled; return $new; }
$new->ignoreMissingPage = $enabled;
return $new;
}
Expand Down Expand Up @@ -218,12 +218,12 @@

final public function urlParameterProvider(?UrlParameterProviderInterface $provider): static
{
$new = clone $this;

Check warning on line 221 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": @@ @@ } final public function urlParameterProvider(?UrlParameterProviderInterface $provider): static { - $new = clone $this; + $new = $this; $new->urlParameterProvider = $provider; return $new; }
$new->urlParameterProvider = $provider;
return $new;
}

final public function enableMultiSort(bool $enable = true): self
final public function enableMultiSort(bool $enable = true): static
{
$new = clone $this;
$new->enableMultiSort = $enable;
Expand Down Expand Up @@ -317,7 +317,7 @@
*
* @psalm-return list{FilterInterface[]|null,ValidationResult}
*/
protected function makeFilters(): array

Check warning on line 320 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": @@ @@ * * @psalm-return list{FilterInterface[]|null,ValidationResult} */ - protected function makeFilters(): array + private function makeFilters(): array { return [[], new ValidationResult()]; }
{
return [[], new ValidationResult()];
}
Expand Down Expand Up @@ -428,7 +428,7 @@
}
}

if (!empty($sort) && $dataReader->isSortable()) {

Check warning on line 431 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation": @@ @@ $dataReader = $dataReader->withToken(PageToken::previous($previousPage)); } } - if (!empty($sort) && $dataReader->isSortable()) { + if (!empty($sort) && !$dataReader->isSortable()) { $sortObject = $dataReader->getSort(); if ($sortObject !== null) { $order = OrderHelper::stringToArray($sort);
$sortObject = $dataReader->getSort();
if ($sortObject !== null) {
$order = OrderHelper::stringToArray($sort);
Expand All @@ -443,7 +443,7 @@
}
}

if (!empty($filters) && $dataReader->isFilterable()) {

Check warning on line 446 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAnd": @@ @@ $dataReader = $dataReader->withSort($sortObject->withOrder($this->prepareOrder($order))); } } - if (!empty($filters) && $dataReader->isFilterable()) { + if (!empty($filters) || $dataReader->isFilterable()) { $dataReader = $dataReader->withFilter(new All(...$filters)); } return $dataReader;

Check warning on line 446 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAndNegation": @@ @@ $dataReader = $dataReader->withSort($sortObject->withOrder($this->prepareOrder($order))); } } - if (!empty($filters) && $dataReader->isFilterable()) { + if (!(!empty($filters) && $dataReader->isFilterable())) { $dataReader = $dataReader->withFilter(new All(...$filters)); } return $dataReader;

Check warning on line 446 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation": @@ @@ $dataReader = $dataReader->withSort($sortObject->withOrder($this->prepareOrder($order))); } } - if (!empty($filters) && $dataReader->isFilterable()) { + if (!empty($filters) && !$dataReader->isFilterable()) { $dataReader = $dataReader->withFilter(new All(...$filters)); } return $dataReader;
$dataReader = $dataReader->withFilter(new All(...$filters));
}

Expand All @@ -466,11 +466,10 @@
*
* {@see headerAttributes}
*/
public function header(string $content): self
public function header(string $content): static
{
$new = clone $this;
$new->header = $content;

return $new;
}

Expand All @@ -479,11 +478,10 @@
*
* @param array $attributes Attribute values indexed by attribute names.
*/
public function headerAttributes(array $attributes): self
public function headerAttributes(array $attributes): static
{
$new = clone $this;
$new->headerAttributes = $attributes;

return $new;
}

Expand Down Expand Up @@ -580,7 +578,7 @@
*/
public function offsetPaginationConfig(array $config): static
{
$new = clone $this;

Check warning on line 581 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": @@ @@ */ public function offsetPaginationConfig(array $config): static { - $new = clone $this; + $new = $this; $new->offsetPaginationConfig = $config; return $new; }
$new->offsetPaginationConfig = $config;
return $new;
}
Expand All @@ -593,7 +591,7 @@
*/
public function keysetPaginationConfig(array $config): static
{
$new = clone $this;

Check warning on line 594 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": @@ @@ */ public function keysetPaginationConfig(array $config): static { - $new = clone $this; + $new = $this; $new->keysetPaginationConfig = $config; return $new; }
$new->keysetPaginationConfig = $config;
return $new;
}
Expand Down Expand Up @@ -662,11 +660,10 @@
*
* @psalm-param array $toolbar
*/
public function toolbar(string $content): self
public function toolbar(string $content): static
{
$new = clone $this;
$new->toolbar = $content;

return $new;
}

Expand Down Expand Up @@ -930,7 +927,7 @@
$currentPage = $dataReader->getCurrentPage();

// The starting row number (1-based) currently being displayed
$begin = ($currentPage - 1) * $dataReader->getPageSize() + 1;

Check warning on line 930 in src/BaseListView.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ // The page number (1-based) current being displayed $currentPage = $dataReader->getCurrentPage(); // The starting row number (1-based) currently being displayed - $begin = ($currentPage - 1) * $dataReader->getPageSize() + 1; + $begin = ($currentPage - 0) * $dataReader->getPageSize() + 1; // The number of rows currently being displayed $count = $dataReader->getCurrentPageSize(); // The ending row number (1-based) currently being displayed

// The number of rows currently being displayed
$count = $dataReader->getCurrentPageSize();
Expand Down