From 822b796d4006f3f03290a149f55f33fe80ff26b1 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Sun, 9 Apr 2023 14:10:12 +0200 Subject: [PATCH] phpstan fixes --- README.md | 2 ++ src/Collection/PropertyBag.php | 25 ++++++++++++++++++------- src/JWTToken.php | 9 ++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5f0a617..73d79c5 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ $key = new JWTDerivedKey("secret", "salt"); $key = new JWTPlaintextKey("This Should Be Binary Data.."); ``` +`JWTDerivedKey` uses hash_pbkdf2. + ### Generating tokens diff --git a/src/Collection/PropertyBag.php b/src/Collection/PropertyBag.php index 5f9a854..52b83cb 100644 --- a/src/Collection/PropertyBag.php +++ b/src/Collection/PropertyBag.php @@ -21,8 +21,8 @@ class PropertyBag /** * Add a property value, fails if the property exists * - * @param string Property name - * @param mixed Value + * @param string $prop Property name + * @param mixed $value Value * @throws PropertyException if the property already exists */ public function add(string $prop, $value) @@ -37,14 +37,19 @@ class PropertyBag * Set a property value, create the property if it doesn't * exist. * - * @param string Property name - * @param mixed Value + * @param string $prop Property name + * @param mixed $value Value */ public function set(string $prop, $value) { $this->props[$prop] = $value; } + /** + * Apply properties without removing anything. + * + * @param array $props The properties to apply + */ public function setAll(array $props) { $this->props = array_merge( @@ -57,7 +62,7 @@ class PropertyBag * Get the value of a property, fails if the property does not exist. * Use the value() method to get with a default value * - * @param string Property name + * @param string $prop Property name * @return mixed * @throws PropertyException if the property does not exist */ @@ -92,8 +97,8 @@ class PropertyBag /** * Get the value of the property, or use the provided default value. * - * @param string Property name - * @param mixed Default value + * @param string $prop Property name + * @param mixed|null $default Default value * @return mixed */ public function valueOf(string $prop, $default=null) @@ -105,6 +110,8 @@ class PropertyBag /** * Remove a property + * + * @param string $prop Property name */ public function delete(string $prop) { @@ -113,6 +120,8 @@ class PropertyBag /** * Check if a property is present + * + * @param string $prop Property name */ public function has(string $prop): bool { @@ -121,6 +130,8 @@ class PropertyBag /** * Check if all the provided properties are present + * + * @param array $props Property names */ public function hasAll(array $props) { diff --git a/src/JWTToken.php b/src/JWTToken.php index 4ef2876..d0d1cf0 100644 --- a/src/JWTToken.php +++ b/src/JWTToken.php @@ -10,8 +10,8 @@ use NoccyLabs\SimpleJWT\Key\KeyInterface; * * * - * @property-read header PropertyBag - * @property-read claim PropertyBag + * @property-read PropertyBag $header + * @property-read PropertyBag $claims */ class JWTToken { @@ -30,7 +30,8 @@ class JWTToken * Constructor * * - * @param KeyInterface The key used to sign the token + * @param KeyInterface $key The key used to sign the token + * @param string|null $token Token data */ public function __construct(KeyInterface $key, ?string $token=null) { @@ -127,6 +128,8 @@ class JWTToken case 'm': $fact = 60; break; + default: + throw new \InvalidArgumentException(); } $this->header->set('exp', time() + (intval($match[1]) * $fact)); } else {