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

Increase psalm level to 4 and corresponding changes #242

Merged
merged 3 commits into from
Jan 7, 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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"rector/rector": "^0.15.18",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.7",
"vimeo/psalm": "^5.18",
"yiisoft/error-handler": "^3.0",
"yiisoft/event-dispatcher": "^1.0",
"yiisoft/log": "^2.0",
Expand Down
5 changes: 4 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="5"
errorLevel="4"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -13,4 +13,7 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 8 additions & 11 deletions src/Collector/Console/CommandCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,14 @@ public function collect(ConsoleEvent|ConsoleErrorEvent|ConsoleTerminateEvent $ev
return;
}

/** @noinspection PhpConditionAlreadyCheckedInspection */
if ($event instanceof ConsoleEvent) {
$this->commands[$event::class] = [
'name' => $command->getName(),
'command' => $command,
'input' => $this->castInputToString($event->getInput()),
'output' => $this->fetchOutput($event->getOutput()),
'arguments' => $command->getDefinition()->getArguments(),
'options' => $command->getDefinition()->getOptions(),
];
}
$this->commands[$event::class] = [
'name' => $command->getName(),
'command' => $command,
'input' => $this->castInputToString($event->getInput()),
'output' => $this->fetchOutput($event->getOutput()),
'arguments' => $command->getDefinition()->getArguments(),
'options' => $command->getDefinition()->getOptions(),
];
}

public function getSummary(): array
Expand Down
4 changes: 2 additions & 2 deletions src/Collector/Stream/FilesystemStreamProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

use const SEEK_SET;

class FilesystemStreamProxy implements StreamWrapperInterface
final class FilesystemStreamProxy implements StreamWrapperInterface
{
public static bool $registered = false;
/**
* @var resource|null
*/
public $context;
public StreamWrapperInterface $decorated;
public StreamWrapper $decorated;
public bool $ignored = false;

public static ?FilesystemStreamCollector $collector = null;
Expand Down
4 changes: 2 additions & 2 deletions src/Collector/Stream/HttpStreamProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use const SEEK_SET;

class HttpStreamProxy implements StreamWrapperInterface
final class HttpStreamProxy implements StreamWrapperInterface
{
public static bool $registered = false;
public static array $ignoredPathPatterns = [];
Expand All @@ -23,7 +23,7 @@ class HttpStreamProxy implements StreamWrapperInterface
* @var resource|null
*/
public $context;
public StreamWrapperInterface $decorated;
public StreamWrapper $decorated;
public bool $ignored = false;

public static ?HttpStreamCollector $collector = null;
Expand Down
4 changes: 1 addition & 3 deletions src/Collector/Web/RequestCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use Yiisoft\Yii\Http\Event\AfterRequest;
use Yiisoft\Yii\Http\Event\BeforeRequest;

use function is_object;

final class RequestCollector implements SummaryCollectorInterface
{
use CollectorTrait;
Expand Down Expand Up @@ -68,7 +66,7 @@ public function getCollected(): array

public function collect(object $event): void
{
if (!is_object($event) || !$this->isActive()) {
if (!$this->isActive()) {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion src/Helper/StreamWrapper/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ final class StreamWrapper implements StreamWrapperInterface
public function dir_closedir(): bool
{
closedir($this->stream);

/**
* @psalm-suppress RedundantCondition
*/
return is_resource($this->stream);
}

Expand All @@ -54,7 +58,11 @@ public function dir_rewinddir(): bool
}

rewinddir($this->stream);
/** @noinspection PhpConditionAlreadyCheckedInspection */

/**
* @noinspection PhpConditionAlreadyCheckedInspection
* @psalm-suppress RedundantCondition
*/
return is_resource($this->stream);
}

Expand Down
Loading