Skip to content

Commit

Permalink
chore: always run psalm using 1 thread
Browse files Browse the repository at this point in the history
ref: vimeo/psalm#9185
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Jul 19, 2023
1 parent fab1d6a commit 19bf730
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions config/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@641587635d1fabd5539c23385ced18e9840cce45">
<file src="../src/Psl/Filesystem/create_temporary_file.php">
<MixedArgument occurrences="2">
<code>SEPARATOR</code>
<code>SEPARATOR</code>
</MixedArgument>
</file>
</files>
<files psalm-version="5.13.1@086b94371304750d1c673315321a55d15fc59015"/>
5 changes: 2 additions & 3 deletions src/Psl/File/Internal/ResourceHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use const SEEK_END;

/**
* @psalm-suppress PossiblyInvalidArgument
*
* @internal
*/
final class ResourceHandle extends IO\Internal\ResourceHandle implements File\ReadWriteHandleInterface
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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".',
Expand Down
1 change: 0 additions & 1 deletion src/Psl/Filesystem/create_temporary_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
5 changes: 0 additions & 5 deletions src/Psl/IO/Internal/ResourceHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.');
Expand All @@ -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();
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 19bf730

Please sign in to comment.