Skip to content
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

Fix psalm #97

Merged
merged 2 commits into from
Feb 8, 2024
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
12 changes: 11 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'phpunit.xml.dist'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -28,4 +30,12 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1']
['8.1', '8.2', '8.3']
psalm80:
uses: yiisoft/actions/.github/workflows/psalm.yml@master
with:
psalm-config: psalm80.xml
os: >-
['ubuntu-latest']
php: >-
['8.0']
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"rector/rector": "^1.0.0",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
"vimeo/psalm": "^4.30|^5.21",
"yiisoft/di": "^1.2",
"yiisoft/psr-dummy-provider": "^1.0",
"yiisoft/test-support": "^3.0",
Expand Down
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 19 additions & 0 deletions psalm80.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
1 change: 0 additions & 1 deletion src/ViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
private ?string $layout = null,
private array $injections = []
) {
$this->viewPath = rtrim($viewPath, '/');

Check warning on line 66 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapRtrim": --- Original +++ New @@ @@ */ public function __construct(private DataResponseFactoryInterface $responseFactory, private Aliases $aliases, private WebView $view, string $viewPath, private ?string $layout = null, private array $injections = []) { - $this->viewPath = rtrim($viewPath, '/'); + $this->viewPath = $viewPath; } /** * Returns a path to a base directory of view templates that is prefixed to the relative view name.

Check warning on line 66 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapRtrim": --- Original +++ New @@ @@ */ public function __construct(private DataResponseFactoryInterface $responseFactory, private Aliases $aliases, private WebView $view, string $viewPath, private ?string $layout = null, private array $injections = []) { - $this->viewPath = rtrim($viewPath, '/'); + $this->viewPath = $viewPath; } /** * Returns a path to a base directory of view templates that is prefixed to the relative view name.
}

/**
Expand Down Expand Up @@ -243,7 +243,7 @@
public function withAddedInjections(object ...$injections): self
{
$new = clone $this;
$new->injections = array_merge($this->injections, $injections);

Check warning on line 246 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": --- Original +++ New @@ @@ public function withAddedInjections(object ...$injections) : self { $new = clone $this; - $new->injections = array_merge($this->injections, $injections); + $new->injections = $this->injections; return $new; } /**

Check warning on line 246 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": --- Original +++ New @@ @@ public function withAddedInjections(object ...$injections) : self { $new = clone $this; - $new->injections = array_merge($this->injections, $injections); + $new->injections = $injections; return $new; } /**

Check warning on line 246 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": --- Original +++ New @@ @@ public function withAddedInjections(object ...$injections) : self { $new = clone $this; - $new->injections = array_merge($this->injections, $injections); + $new->injections = $this->injections; return $new; } /**

Check warning on line 246 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": --- Original +++ New @@ @@ public function withAddedInjections(object ...$injections) : self { $new = clone $this; - $new->injections = array_merge($this->injections, $injections); + $new->injections = $injections; return $new; } /**
return $new;
}

Expand All @@ -266,7 +266,7 @@
*/
public function withLocale(string $locale): self
{
$new = clone $this;

Check warning on line 269 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": --- Original +++ New @@ @@ */ public function withLocale(string $locale) : self { - $new = clone $this; + $new = $this; $new->locale = $locale; return $new; }

Check warning on line 269 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": --- Original +++ New @@ @@ */ public function withLocale(string $locale) : self { - $new = clone $this; + $new = $this; $new->locale = $locale; return $new; }
$new->locale = $locale;
return $new;
}
Expand Down Expand Up @@ -345,10 +345,10 @@
$parameters = [];
foreach ($this->injections as $injection) {
if ($injection instanceof CommonParametersInjectionInterface) {
$parameters = array_merge($parameters, $injection->getCommonParameters());

Check warning on line 348 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": --- Original +++ New @@ @@ $parameters = []; foreach ($this->injections as $injection) { if ($injection instanceof CommonParametersInjectionInterface) { - $parameters = array_merge($parameters, $injection->getCommonParameters()); + $parameters = $injection->getCommonParameters(); } } return $parameters;

Check warning on line 348 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": --- Original +++ New @@ @@ $parameters = []; foreach ($this->injections as $injection) { if ($injection instanceof CommonParametersInjectionInterface) { - $parameters = array_merge($parameters, $injection->getCommonParameters()); + $parameters = $injection->getCommonParameters(); } } return $parameters;
}
}
return $parameters;

Check warning on line 351 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "ArrayOneItem": --- Original +++ New @@ @@ $parameters = array_merge($parameters, $injection->getCommonParameters()); } } - return $parameters; + return count($parameters) > 1 ? array_slice($parameters, 0, 1, true) : $parameters; } /** * Gets the merged injection layout parameters.

Check warning on line 351 in src/ViewRenderer.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "ArrayOneItem": --- Original +++ New @@ @@ $parameters = array_merge($parameters, $injection->getCommonParameters()); } } - return $parameters; + return count($parameters) > 1 ? array_slice($parameters, 0, 1, true) : $parameters; } /** * Gets the merged injection layout parameters.
}

/**
Expand Down Expand Up @@ -445,7 +445,6 @@
{
foreach ($tags as $key => $tag) {
if (is_array($tag)) {
/** @var mixed */
$position = $tag['__position'] ?? WebView::POSITION_HEAD;
if (!is_int($position)) {
throw new InvalidLinkTagException(
Expand Down
Loading