Skip to content

Commit 402bd90

Browse files
committed
Fix / suppress psalm issues
1 parent be1891f commit 402bd90

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

examples/generate-yes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$r = \fwrite($stdout, $data);
2525

2626
// nothing could be written despite being writable => closed
27-
if ($r === 0) {
27+
if ($r === 0 || $r === false) {
2828
EventLoop::cancel($watcher);
2929
\stream_set_blocking($stdout, true);
3030
\fclose($stdout);

psalm.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
<directory name="src"/>
6666
</errorLevel>
6767
</UnsupportedPropertyReferenceUsage>
68+
69+
<PossiblyInvalidArgument>
70+
<errorLevel type="suppress">
71+
<directory name="examples" />
72+
</errorLevel>
73+
</PossiblyInvalidArgument>
6874
</issueHandlers>
6975

7076
<stubs>

src/EventLoop/Driver/StreamSelectDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private function selectStreams(array $read, array $write, float $timeout): void
277277
}
278278

279279
/** @var array<int, resource>|null $except */
280-
if ($except) {
280+
if ($except !== null) {
281281
foreach ($except as $key => $socket) {
282282
$write[$key] = $socket;
283283
}

src/EventLoop/DriverFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function create(): Driver
4242
return new StreamSelectDriver();
4343
})();
4444

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

60+
/** @psalm-suppress RiskyTruthyFalsyComparison */
5961
if (!$driver) {
6062
return null;
6163
}

src/EventLoop/Internal/AbstractDriver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function __construct()
6868
{
6969
if (\PHP_VERSION_ID < 80117 || \PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80204) {
7070
// PHP GC is broken on early 8.1 and 8.2 versions, see https://github.com/php/php-src/issues/10496
71+
/** @psalm-suppress RiskyTruthyFalsyComparison */
7172
if (!\getenv('REVOLT_DRIVER_SUPPRESS_ISSUE_10496')) {
7273
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');
7374
}

src/EventLoop/Internal/ClosureHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function getDescription(\Closure $closure): string
1818
$description = $scopeClass->name . '::' . $description;
1919
}
2020

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

0 commit comments

Comments
 (0)