diff --git a/.travis.yml b/.travis.yml index 9e8c6cb..de853f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ matrix: install: - composer self-update - - if [[ $USE_PSALM -eq 1 ]]; then composer require --dev "vimeo/psalm:^1|^2"; fi + - if [[ $USE_PSALM -eq 1 ]]; then composer require --dev "vimeo/psalm:^1|^3"; fi - composer update script: diff --git a/composer.json b/composer.json index 3db077f..5124931 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ }, "require-dev": { "composer/composer": "^1", - "phpunit/phpunit": "^4|^5|^6" + "phpunit/phpunit": "^4|^5|^6|^7" }, "scripts": { "post-autoload-dump": [ diff --git a/src/Bundle.php b/src/Bundle.php index faf3c47..81af42b 100644 --- a/src/Bundle.php +++ b/src/Bundle.php @@ -68,6 +68,7 @@ public function __construct( $this->signature = $signature; $this->chronicleHash = $chronicleHash; if (!empty($customValidator)) { + /** @psalm-suppress MixedMethodCall */ if (\class_exists($customValidator)) { $newClass = new $customValidator(); if (!($newClass instanceof Validator)) { @@ -177,6 +178,8 @@ public function getChronicleHash() * * @return Validator * @throws CertaintyException + * + * @psalm-suppress DocblockTypeContradiction */ public function getValidator() { diff --git a/src/LocalCACertBuilder.php b/src/LocalCACertBuilder.php index a4f44ee..121b20c 100644 --- a/src/LocalCACertBuilder.php +++ b/src/LocalCACertBuilder.php @@ -8,6 +8,7 @@ use ParagonIE\Certainty\Exception\FilesystemException; use ParagonIE\Certainty\Exception\InvalidResponseException; use ParagonIE\ConstantTime\Base64UrlSafe; +use ParagonIE\ConstantTime\Binary; use ParagonIE\ConstantTime\Hex; /** @@ -226,6 +227,8 @@ public function getPublicKey($raw = false) * @return bool * @throws CertaintyException * @throws \SodiumException + * + * @psalm-suppress RedundantConditionGivenDocblockType */ public function save() { @@ -311,9 +314,9 @@ public function setChronicle( $clientId = '', $repository = 'paragonie/certainty' ) { - if (\ParagonIE_Sodium_Core_Util::strlen($publicKey) === 64) { + if (Binary::safeStrlen($publicKey) === 64) { $publicKey = Hex::decode($publicKey); - } elseif (\ParagonIE_Sodium_Core_Util::strlen($publicKey) !== 32) { + } elseif (Binary::safeStrlen($publicKey) !== 32) { throw new CryptoException( 'Signing secret keys must be SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES bytes long.' ); @@ -332,6 +335,8 @@ public function setChronicle( * @param string $string * @return self * @throws \TypeError + * + * @psalm-suppress MixedMethodCall */ public function setCustomValidator($string = '') { @@ -381,9 +386,9 @@ public function setOutputJsonFile($string = '') public function setSigningKey($secretKey = '') { // Handle hex-encoded strings. - if (\ParagonIE_Sodium_Core_Util::strlen($secretKey) === 128) { + if (Binary::safeStrlen($secretKey) === 128) { $secretKey = Hex::decode($secretKey); - } elseif (\ParagonIE_Sodium_Core_Util::strlen($secretKey) !== 64) { + } elseif (Binary::safeStrlen($secretKey) !== 64) { throw new CryptoException( 'Signing secret keys must be SODIUM_CRYPTO_SIGN_SECRETKEYBYTES bytes long.' ); diff --git a/src/Validator.php b/src/Validator.php index 43c43f9..caa44a7 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -190,7 +190,7 @@ public function checkChronicleHash(Bundle $bundle) $ok = false; } if (!$ok) { - if (self::THROW_MORE_EXCEPTIONS) { + if (static::THROW_MORE_EXCEPTIONS) { if (isset($json['error'])) { /** @var string $jsonError */ $jsonError = $json['error'];