Skip to content

Commit

Permalink
Fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Nov 19, 2023
1 parent af2c79a commit 5b7b0fa
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<directory name="src/Test"/>
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 1 addition & 1 deletion src/Handler/Http/Handler/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function handle(StreamClient $streamClient, ServerRequestInterface $reque
}

/**
* Todo: extract to a separate Websocket service
* Todo: extract to a separated Websocket service
*
* @return iterable<array-key, Frame>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Pipeline
/**
* @param iterable<TMiddleware> $middlewares
* @param non-empty-string $method
* @param Closure(): TReturn $last
* @param Closure(mixed...): TReturn $last
* @param class-string<TReturn>|string $returnType
*/
private function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Proto/Frame/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function fromString(string $payload, DateTimeImmutable $time): sta
$request = new ServerRequest(
$payload['method'] ?? 'GET',
$payload['uri'] ?? '/',
(array)$payload['headers'] ?? [],
(array)($payload['headers'] ?? []),
$payload['body'] ?? '',
$payload['protocolVersion'] ?? '1.1',
$payload['serverParams'] ?? [],
Expand Down
2 changes: 1 addition & 1 deletion src/Proto/Frame/Sentry/SentryStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class SentryStore extends Frame\Sentry
* filename: non-empty-string,
* lineno: positive-int,
* abs_path: non-empty-string,
* context_line: non-empty-string,
* context_line: non-empty-string
* }
* }
* }>
Expand Down
2 changes: 0 additions & 2 deletions src/Sender/Console/Renderer/Sentry/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* @implements RendererInterface<Frame\Binary>
*
* @internal
* @psalm-internal Buggregator\Trap\Sender\Console\Renderer
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Sender/Console/Renderer/Sentry/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* @implements RendererInterface<Frame\Binary>
*
* @internal
*/
final class Header
Expand Down
6 changes: 4 additions & 2 deletions src/Socket/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ public function process(): void
throw new \RuntimeException('Socket select failed.');
}

/** @psalm-suppress RedundantCondition */
if ($read !== []) {
$this->readMessage();
}

/** @psalm-suppress RedundantCondition */
if ($write !== [] && $this->writeQueue !== []) {
$this->writeQueue();
}

/** @psalm-suppress RedundantCondition */
if ($except !== [] || \socket_last_error($this->socket) !== 0) {
throw new \RuntimeException('Socket exception.');
}
Expand Down Expand Up @@ -150,14 +153,13 @@ private function readMessage(): void

/**
* @param positive-int $length
*
* @return non-empty-string
*/
private function readBytes(int $length, bool $canBeLess = false): string
{
while (($left = $length - \strlen($this->readBuffer)) > 0) {
$data = '';
$read = @\socket_recv($this->socket, $data, $left, 0);
/** @psalm-suppress TypeDoesNotContainNull */
if ($read === false || $data === null) {
if ($this->readBuffer !== '') {
$result = $this->readBuffer;
Expand Down
2 changes: 1 addition & 1 deletion src/Traffic/Message/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private function setHeaders(array $headers): void
*/
private function validateAndTrimHeader(string $header, $values): array
{
if (!\is_string($header) || 1 !== \preg_match("@^[!#$%&'*+.^_`|~0-9A-Za-z-]+$@D", $header)) {
if (1 !== \preg_match("@^[!#$%&'*+.^_`|~0-9A-Za-z-]+$@D", $header)) {
throw new \InvalidArgumentException('Header name must be an RFC 7230 compatible string');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Traffic/StreamClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Simple abstraction over a client two-way stream.
* @internal
* @psalm-internal Buggregator\Trap\Traffic
* @psalm-internal Buggregator\Trap
* @extends \IteratorAggregate<int, string>
*/
interface StreamClient extends \IteratorAggregate
Expand Down
1 change: 1 addition & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function trap(mixed ...$values): void

// Dump sequence of values
foreach ($values as $key => $value) {
/** @psalm-suppress TooManyArguments */
VarDumper::dump($value, $key);
}
}
Expand Down

0 comments on commit 5b7b0fa

Please sign in to comment.