Skip to content

Commit

Permalink
Merge pull request #198 from spaze/spaze/psalm-6
Browse files Browse the repository at this point in the history
Use Psalm 6
  • Loading branch information
paragonie-security authored Mar 9, 2025
2 parents 8f1be6c + cb289fe commit 79729bc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['8.3']
php-versions: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -22,13 +23,10 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: psalm:4
coverage: none

- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
with:
composer-options: --no-dev

- name: Static Analysis
run: psalm
- name: Psalm static analysis
run: vendor/bin/psalm
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^9",
"vimeo/psalm": "^4"
"vimeo/psalm": "^6.8"
},
"scripts": {
"test": "phpunit && phpstan && psalm"
Expand Down
14 changes: 14 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@
<PropertyNotSetInConstructor errorLevel="suppress" />
<RedundantCondition errorLevel="suppress" />
<RedundantConditionGivenDocblockType errorLevel="suppress" />
<UnusedClass errorLevel="suppress" />
<UnusedConstructor errorLevel="suppress" />
<UnusedParam errorLevel="suppress" />
<PossiblyUnusedMethod errorLevel="suppress" />
<PossiblyUnusedParam errorLevel="suppress" />
<PossiblyUnusedReturnValue errorLevel="suppress" />

<TypeDoesNotContainType errorLevel="info" />
<ArgumentTypeCoercion errorLevel="info" />
<RedundantCast errorLevel="info" />
<NonInvariantDocblockPropertyType errorLevel="info" />
<ClassMustBeFinal errorLevel="info" />
<MissingOverrideAttribute errorLevel="info" />
<RiskyTruthyFalsyComparison errorLevel="info" />
<InvalidFalsableReturnType errorLevel="info" />
<FalsableReturnStatement errorLevel="info" />
<PossiblyFalsePropertyAssignmentValue errorLevel="info" />
<PossiblyFalseArgument errorLevel="info" />
<PossiblyInvalidArrayAccess errorLevel="info" />
</issueHandlers>
</psalm>
1 change: 0 additions & 1 deletion src/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function fetch(
throw new InvalidType('Cookie value is not a string');
}
$config = self::getConfig($stored);
/** @var string|bool $encoding */
$encoding = $config->ENCODING;
$decrypted = Crypto::decrypt(
$stored,
Expand Down
2 changes: 0 additions & 2 deletions src/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public static function needsRehash(
if (Binary::safeStrlen($stored) < ((int) $config->SHORTEST_CIPHERTEXT_LENGTH * 4 / 3)) {
throw new InvalidMessage('Encrypted password hash is too short.');
}
/** @var string|bool $encoding */
$encoding = $config->ENCODING;

// First let's decrypt the hash
Expand Down Expand Up @@ -225,7 +224,6 @@ public static function verify(
'Encrypted password hash is too short.'
);
}
/** @var string|bool $encoding */
$encoding = $config->ENCODING;

// First let's decrypt the hash
Expand Down
1 change: 0 additions & 1 deletion src/Stream/MutableFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ public function readBytes(int $num, bool $skipTests = false): string
// @codeCoverageIgnoreEnd
}
$bufSize = min($remaining, self::CHUNK);
/** @var string|false $read */
$read = fread($this->fp, $bufSize);
if (!is_string($read)) {
// @codeCoverageIgnoreStart
Expand Down
1 change: 0 additions & 1 deletion src/Stream/ReadOnlyFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public function __construct($file, ?Key $key = null)
'Could not open file for reading'
);
}
/** @var resource|false $fp */
$fp = fopen($file, 'rb');
// @codeCoverageIgnoreStart
if (!is_resource($fp)) {
Expand Down

0 comments on commit 79729bc

Please sign in to comment.