Skip to content

Commit

Permalink
Fix / suppress psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Mar 19, 2024
1 parent be1891f commit 402bd90
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/generate-yes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$r = \fwrite($stdout, $data);

// nothing could be written despite being writable => closed
if ($r === 0) {
if ($r === 0 || $r === false) {
EventLoop::cancel($watcher);
\stream_set_blocking($stdout, true);
\fclose($stdout);
Expand Down
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<directory name="src"/>
</errorLevel>
</UnsupportedPropertyReferenceUsage>

<PossiblyInvalidArgument>
<errorLevel type="suppress">
<directory name="examples" />
</errorLevel>
</PossiblyInvalidArgument>
</issueHandlers>

<stubs>
Expand Down
2 changes: 1 addition & 1 deletion src/EventLoop/Driver/StreamSelectDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private function selectStreams(array $read, array $write, float $timeout): void
}

/** @var array<int, resource>|null $except */
if ($except) {
if ($except !== null) {
foreach ($except as $key => $socket) {
$write[$key] = $socket;
}
Expand Down
2 changes: 2 additions & 0 deletions src/EventLoop/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function create(): Driver
return new StreamSelectDriver();
})();

/** @psalm-suppress RiskyTruthyFalsyComparison */
if (\getenv("REVOLT_DRIVER_DEBUG_TRACE")) {
return new TracingDriver($driver);
}
Expand All @@ -56,6 +57,7 @@ private function createDriverFromEnv(): ?Driver
{
$driver = \getenv("REVOLT_DRIVER");

/** @psalm-suppress RiskyTruthyFalsyComparison */
if (!$driver) {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/EventLoop/Internal/AbstractDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function __construct()
{
if (\PHP_VERSION_ID < 80117 || \PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80204) {
// PHP GC is broken on early 8.1 and 8.2 versions, see https://github.com/php/php-src/issues/10496
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (!\getenv('REVOLT_DRIVER_SUPPRESS_ISSUE_10496')) {
throw new \Error('Your version of PHP is affected by serious garbage collector bugs related to fibers. Please upgrade to a newer version of PHP, i.e. >= 8.1.17 or => 8.2.4');
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventLoop/Internal/ClosureHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function getDescription(\Closure $closure): string
$description = $scopeClass->name . '::' . $description;
}

if ($reflection->getFileName() && $reflection->getStartLine()) {
if ($reflection->getFileName() !== false && $reflection->getStartLine()) {
$description .= " defined in " . $reflection->getFileName() . ':' . $reflection->getStartLine();
}

Expand Down

0 comments on commit 402bd90

Please sign in to comment.