Skip to content

Commit

Permalink
Apply fixes for Psalm 5.17 (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee authored Dec 4, 2023
1 parent 4955aa9 commit 0aa7117
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ unit-tests:
./vendor/bin/phpunit -c config/phpunit.xml.dist

mutation-tests: ## run mutation tests
./vendor/bin/roave-infection-static-analysis-plugin run --configuration=config/infection.json.dist --psalm-config=config/psalm.xml
./vendor/bin/roave-infection-static-analysis-plugin --configuration=config/infection.json.dist --psalm-config=config/psalm.xml

code-coverage: unit-tests ## generate and upload test coverage metrics to https://coveralls.io/
./vendor/bin/php-coveralls -x var/clover.xml -o var/coveralls-upload.json -v
Expand Down
21 changes: 11 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/Psl/Internal/box.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ function box(Closure $fun): array
$last_message = $message;
});

/**
* @var string|null $last_message
*/
if (null !== $last_message && Str\contains($last_message, '): ')) {
$last_message = Str\after(
Str\lowercase($last_message),
Expand Down
7 changes: 5 additions & 2 deletions src/Psl/Network/Internal/socket_connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Revolt\EventLoop;

use function fclose;
use function is_resource;
use function stream_context_create;
use function stream_socket_client;

Expand Down Expand Up @@ -42,10 +43,12 @@ function socket_connect(string $uri, array $context = [], ?float $timeout = null
$timeout_watcher = '';
if (null !== $timeout) {
$timeout_watcher = EventLoop::delay($timeout, static function () use ($suspension, &$write_watcher, $socket) {
/** @var string $write_watcher */
EventLoop::cancel($write_watcher);

fclose($socket);
/** @psalm-suppress RedundantCondition - it can be resource|closed-resource */
if (is_resource($socket)) {
fclose($socket);
}

$suspension->throw(new Exception\TimeoutException('Connection to socket timed out.'));
});
Expand Down
9 changes: 0 additions & 9 deletions src/Psl/Shell/execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ static function (array $m) use (
return $m[0];
}

/** @var array<string, string> $variable_cache */
if (isset($variable_cache[$m[0]])) {
/** @var string */
return $variable_cache[$m[0]];
Expand All @@ -101,15 +100,8 @@ static function (array $m) use (
return '"' . $value . '"';
}

/**
* @var string $var
* @var int $variable_count
*/
$var = $identifier . ((string) ++$variable_count);

/**
* @var array<string, string> $environment
*/
$environment[$var] = '"' . Regex\replace(
Str\Byte\replace_every(
$value,
Expand Down Expand Up @@ -137,7 +129,6 @@ static function (array $m) use (
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
/** @var array<string, string> $environment */
$process = proc_open($commandline, $descriptor, $pipes, $working_directory, $environment, $options);
// @codeCoverageIgnoreStart
// not sure how to replicate this, but it can happen \_o.o_/
Expand Down

0 comments on commit 0aa7117

Please sign in to comment.