From 19bf73051b3a9d1197aed8838e91d481e938d00f Mon Sep 17 00:00:00 2001 From: azjezz Date: Wed, 19 Jul 2023 21:05:35 +0100 Subject: [PATCH] chore: always run psalm using 1 thread ref: https://github.com/vimeo/psalm/issues/9185 Signed-off-by: azjezz --- Makefile | 8 ++++---- config/psalm-baseline.xml | 9 +-------- src/Psl/File/Internal/ResourceHandle.php | 5 ++--- src/Psl/Filesystem/create_temporary_file.php | 1 - src/Psl/IO/Internal/ResourceHandle.php | 5 ----- 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 387c3423..0dd639c3 100644 --- a/Makefile +++ b/Makefile @@ -22,14 +22,14 @@ compare-benchmark-to-reference: ./vendor/bin/phpbench run --config config/phpbench.json --ref=benchmark_reference static-analysis: ## run static analysis checks - ./vendor/bin/psalm -c config/psalm.xml --show-info=true --no-cache - ./vendor/bin/psalm -c config/psalm.xml tests/static-analysis --no-cache + ./vendor/bin/psalm -c config/psalm.xml --show-info=true --no-cache --threads=1 + ./vendor/bin/psalm -c config/psalm.xml tests/static-analysis --no-cache --threads=1 type-coverage: ## send static analysis type coverage metrics to https://shepherd.dev/ - ./vendor/bin/psalm -c config/psalm.xml --shepherd --stats + ./vendor/bin/psalm -c config/psalm.xml --shepherd --stats --threads=1 security-analysis: ## run static analysis security checks - ./vendor/bin/psalm -c config/psalm.xml --taint-analysis + ./vendor/bin/psalm -c config/psalm.xml --taint-analysis --threads=1 unit-tests: ## run unit test suite ./vendor/bin/phpunit -c config/phpunit.xml.dist diff --git a/config/psalm-baseline.xml b/config/psalm-baseline.xml index b2254c55..51b41ef5 100644 --- a/config/psalm-baseline.xml +++ b/config/psalm-baseline.xml @@ -1,9 +1,2 @@ - - - - SEPARATOR - SEPARATOR - - - + diff --git a/src/Psl/File/Internal/ResourceHandle.php b/src/Psl/File/Internal/ResourceHandle.php index b66f503f..836fd7f1 100644 --- a/src/Psl/File/Internal/ResourceHandle.php +++ b/src/Psl/File/Internal/ResourceHandle.php @@ -23,6 +23,8 @@ use const SEEK_END; /** + * @psalm-suppress PossiblyInvalidArgument + * * @internal */ final class ResourceHandle extends IO\Internal\ResourceHandle implements File\ReadWriteHandleInterface @@ -63,7 +65,6 @@ public function getSize(): int throw new File\Exception\RuntimeException($previous->getMessage(), previous: $previous); } - /** @psalm-suppress PossiblyInvalidArgument */ $result = @fseek($this->stream, 0, SEEK_END); if ($result === -1) { $error = error_get_last(); @@ -108,7 +109,6 @@ public function tryLock(LockType $type): Lock } $operations = LOCK_NB | ($type === LockType::EXCLUSIVE ? LOCK_EX : LOCK_SH); - /** @psalm-suppress PossiblyInvalidArgument */ $success = @flock($this->stream, $operations, $would_block); // @codeCoverageIgnoreStart if ($would_block) { @@ -130,7 +130,6 @@ public function tryLock(LockType $type): Lock throw new Exception\AlreadyClosedException('Handle was closed before releasing the lock.'); } - /** @psalm-suppress PossiblyInvalidArgument */ if (!@flock($this->stream, LOCK_UN)) { throw new File\Exception\RuntimeException(Str\format( 'Could not release lock for "%s".', diff --git a/src/Psl/Filesystem/create_temporary_file.php b/src/Psl/Filesystem/create_temporary_file.php index faf4fff3..52d12bbb 100644 --- a/src/Psl/Filesystem/create_temporary_file.php +++ b/src/Psl/Filesystem/create_temporary_file.php @@ -34,7 +34,6 @@ function create_temporary_file(?string $directory = null, ?string $prefix = null throw Exception\NotDirectoryException::for($directory); } - /** @var non-empty-string $separator */ $separator = namespace\SEPARATOR; if (null !== $prefix) { /** @psalm-suppress MissingThrowsDocblock - $offset is within bounds. */ diff --git a/src/Psl/IO/Internal/ResourceHandle.php b/src/Psl/IO/Internal/ResourceHandle.php index 2b57334e..ca908ec7 100644 --- a/src/Psl/IO/Internal/ResourceHandle.php +++ b/src/Psl/IO/Internal/ResourceHandle.php @@ -210,7 +210,6 @@ public function tryWrite(string $bytes): int throw new Exception\AlreadyClosedException('Handle has already been closed.'); } - /** @psalm-suppress PossiblyInvalidArgument */ $result = @fwrite($this->stream, $bytes); if ($result === false) { $error = error_get_last(); @@ -230,7 +229,6 @@ public function seek(int $offset): void throw new Exception\AlreadyClosedException('Handle has already been closed.'); } - /** @psalm-suppress PossiblyInvalidArgument */ $result = @fseek($this->stream, $offset); if (0 !== $result) { throw new Exception\RuntimeException('Failed to seek the specified position.'); @@ -246,7 +244,6 @@ public function tell(): int throw new Exception\AlreadyClosedException('Handle has already been closed.'); } - /** @psalm-suppress PossiblyInvalidArgument */ $result = @ftell($this->stream); if ($result === false) { $error = error_get_last(); @@ -282,7 +279,6 @@ public function tryRead(?int $max_bytes = null): string $max_bytes = self::MAXIMUM_READ_BUFFER_SIZE; } - /** @psalm-suppress PossiblyInvalidArgument */ $result = fread($this->stream, $max_bytes); if ($result === false) { /** @var array{message: string} $error */ @@ -326,7 +322,6 @@ public function close(): void // don't close the stream if `$this->close` is false, or if it's already closed. if ($this->close && is_resource($this->stream)) { - /** @psalm-suppress PossiblyInvalidArgument */ $stream = $this->stream; $this->stream = null; $result = @fclose($stream);