diff --git a/composer.json b/composer.json index eb3ab6a2..497d6aab 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "phpbench/phpbench": "^1.2.3", "phpunit/phpunit": "^9.5.16", "vimeo/psalm": "^5.0.0", - "php-standard-library/psalm-plugin": "^2.1.0", + "php-standard-library/psalm-plugin": "^2.2", "php-coveralls/php-coveralls": "^2.5.2", "roave/infection-static-analysis-plugin": "^1.26.0" }, diff --git a/composer.lock b/composer.lock index 3dfa57d2..172cc14d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2d02d049618845dae9527ba963e7243d", + "content-hash": "f4b1a45577e1b1e696ae63372a6eda70", "packages": [ { "name": "revolt/event-loop", @@ -2260,16 +2260,16 @@ }, { "name": "php-standard-library/psalm-plugin", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/php-standard-library/psalm-plugin.git", - "reference": "bf223f6865595c07d542a8af0d9afb0d054efb70" + "reference": "613569397ec5d9fe4357cfbbcb6c0d036395983a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-standard-library/psalm-plugin/zipball/bf223f6865595c07d542a8af0d9afb0d054efb70", - "reference": "bf223f6865595c07d542a8af0d9afb0d054efb70", + "url": "https://api.github.com/repos/php-standard-library/psalm-plugin/zipball/613569397ec5d9fe4357cfbbcb6c0d036395983a", + "reference": "613569397ec5d9fe4357cfbbcb6c0d036395983a", "shasum": "" }, "require": { @@ -2308,9 +2308,9 @@ "description": "Psalm plugin for the PHP Standard Library", "support": { "issues": "https://github.com/php-standard-library/psalm-plugin/issues", - "source": "https://github.com/php-standard-library/psalm-plugin/tree/2.1.0" + "source": "https://github.com/php-standard-library/psalm-plugin/tree/2.2.0" }, - "time": "2022-11-30T19:58:09+00:00" + "time": "2022-12-05T15:54:20+00:00" }, { "name": "phpbench/container", @@ -6400,16 +6400,16 @@ }, { "name": "vimeo/psalm", - "version": "5.0.0", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8" + "reference": "4defa177c89397c5e14737a80fe4896584130674" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8", - "reference": "4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/4defa177c89397c5e14737a80fe4896584130674", + "reference": "4defa177c89397c5e14737a80fe4896584130674", "shasum": "" }, "require": { @@ -6498,9 +6498,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/5.0.0" + "source": "https://github.com/vimeo/psalm/tree/5.1.0" }, - "time": "2022-11-30T06:06:01+00:00" + "time": "2022-12-02T01:23:35+00:00" }, { "name": "webmozart/assert", diff --git a/src/Psl/IO/streaming.php b/src/Psl/IO/streaming.php index 1a84bda3..e3ba873d 100644 --- a/src/Psl/IO/streaming.php +++ b/src/Psl/IO/streaming.php @@ -33,7 +33,7 @@ * @throws Exception\RuntimeException If an error occurred during the operation. * @throws Exception\TimeoutException If $timeout is reached before being able to read all the handles until the end. * - * @return Generator + * @return Generator */ function streaming(iterable $handles, ?float $timeout = null): Generator { diff --git a/src/Psl/Network/ServerInterface.php b/src/Psl/Network/ServerInterface.php index aa9d7a50..98a30fbd 100644 --- a/src/Psl/Network/ServerInterface.php +++ b/src/Psl/Network/ServerInterface.php @@ -27,7 +27,7 @@ public function nextConnection(): SocketInterface; * * @throws Exception\RuntimeException In case failed to accept incoming connection. * - * @return Generator + * @return Generator */ public function incoming(): Generator; diff --git a/src/Psl/Network/StreamServerInterface.php b/src/Psl/Network/StreamServerInterface.php index fa3dd920..d9d73c2d 100644 --- a/src/Psl/Network/StreamServerInterface.php +++ b/src/Psl/Network/StreamServerInterface.php @@ -22,7 +22,7 @@ public function nextConnection(): StreamSocketInterface; /** * {@inheritDoc} * - * @return Generator + * @return Generator */ public function incoming(): Generator; } diff --git a/tests/static-analysis/Fun/pipe.php b/tests/static-analysis/Fun/pipe.php index dcc4d2fe..a86e9a22 100644 --- a/tests/static-analysis/Fun/pipe.php +++ b/tests/static-analysis/Fun/pipe.php @@ -6,38 +6,36 @@ use function Psl\Fun\pipe; -/** - * @psalm-suppress TooFewArguments, UnusedClosureParam - */ -function test_too_few_argument_count_issues(): void +function test_too_few_argument_dont_matter(): int { $stages = pipe( static fn (): int => 2, ); - $stages('hello'); + + return $stages('hello'); } /** - * @psalm-suppress TooManyArguments, UnusedClosureParam, InvalidArgument + * @psalm-suppress InvalidArgument, UnusedClosureParam */ -function test_too_many_argument_count_issues(): void +function test_too_many_argument_count_issues(): int { $stages = pipe( static fn (string $x, string $y): int => 2, ); - $stages('hello'); + return $stages('hello'); } /** - * @psalm-suppress UnusedClosureParam, InvalidArgument + * @psalm-suppress UnusedClosureParam */ -function test_variadic_and_default_params(): void +function test_variadic_and_default_params(): int { $stages = pipe( static fn (int $y, string $x = 'hello'): float => 1.2, static fn (float ...$items): int => 23 ); - $stages('hello'); + return $stages(123); } /** @@ -46,11 +44,12 @@ function test_variadic_and_default_params(): void * @see https://github.com/vimeo/psalm/issues/7244 * * @psalm-suppress InvalidArgument + * @psalm-suppress NoValue - Resolves into "\Closure(never): never" because of the issue linked above. */ -function test_empty_pipe(): void +function test_empty_pipe(): string { $stages = pipe(); - $stages('hello'); + return $stages('hello'); } /** @@ -66,27 +65,27 @@ function test_invalid_arguments(): void } /** - * @psalm-suppress UnusedClosureParam, InvalidArgument + * @psalm-suppress InvalidScalarArgument, UnusedClosureParam */ -function test_invalid_return_to_input_type(): void +function test_invalid_return_to_input_type(): float { $stages = pipe( static fn (string $x): int => 2, static fn (string $y): float => 1.2 ); - $stages('hello'); + return $stages('hello'); } /** * @psalm-suppress UnusedClosureParam, InvalidArgument */ -function test_invalid_input_type(): void +function test_invalid_input_type(): float { $stages = pipe( static fn (string $x): int => 2, static fn (int $y): float => 1.2 ); - $stages(143); + return $stages(143); } /** @@ -106,11 +105,11 @@ function test_output_type_is_known(): void /** * @psalm-suppress UnusedClosureParam */ -function test_currently_unparsed_input_types(): void +function test_first_class_callables(): int { $stages = pipe( $assignment = static fn (string $x): int => 2, (static fn (): int => 2)(...), ); - $stages('hello'); + return $stages('hello'); }