@@ -38,11 +38,13 @@ class JWT
3838 /**
3939 * Decodes a JWT string into a PHP object.
4040 *
41- * @param string $jwt The JWT
42- * @param string|Array|null $key The secret key, or map of keys
43- * @param Array $allowed_algs List of supported verification algorithms
41+ * @param string $jwt The JWT
42+ * @param string|array|null $key The key, or map of keys.
43+ * If the algorithm used is asymmetric, this is the public key
44+ * @param array $allowed_algs List of supported verification algorithms
45+ * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
4446 *
45- * @return object The JWT's payload as a PHP object
47+ * @return object The JWT's payload as a PHP object
4648 *
4749 * @throws DomainException Algorithm was not provided
4850 * @throws UnexpectedValueException Provided JWT was invalid
@@ -120,13 +122,15 @@ public static function decode($jwt, $key = null, $allowed_algs = array())
120122 /**
121123 * Converts and signs a PHP object or array into a JWT string.
122124 *
123- * @param object|array $payload PHP object or array
124- * @param string $key The secret key
125- * @param string $alg The signing algorithm. Supported
126- * algorithms are 'HS256', 'HS384' and 'HS512'
127- * @param array $head An array with header elements to attach
125+ * @param object|array $payload PHP object or array
126+ * @param string $key The secret key.
127+ * If the algorithm used is asymmetric, this is the private key
128+ * @param string $alg The signing algorithm.
129+ * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
130+ * @param array $head An array with header elements to attach
131+ *
132+ * @return string A signed JWT
128133 *
129- * @return string A signed JWT
130134 * @uses jsonEncode
131135 * @uses urlsafeB64Encode
132136 */
@@ -153,12 +157,13 @@ public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $he
153157 /**
154158 * Sign a string with a given key and algorithm.
155159 *
156- * @param string $msg The message to sign
157- * @param string|resource $key The secret key
158- * @param string $alg The signing algorithm. Supported algorithms
159- * are 'HS256', 'HS384', 'HS512' and 'RS256'
160+ * @param string $msg The message to sign
161+ * @param string|resource $key The secret key
162+ * @param string $alg The signing algorithm.
163+ * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
164+ *
165+ * @return string An encrypted message
160166 *
161- * @return string An encrypted message
162167 * @throws DomainException Unsupported algorithm was specified
163168 */
164169 public static function sign ($ msg , $ key , $ alg = 'HS256 ' )
@@ -182,13 +187,16 @@ public static function sign($msg, $key, $alg = 'HS256')
182187 }
183188
184189 /**
185- * Verify a signature with the mesage , key and method. Not all methods
190+ * Verify a signature with the message , key and method. Not all methods
186191 * are symmetric, so we must have a separate verify and sign method.
187- * @param string $msg the original message
188- * @param string $signature
189- * @param string|resource $key for HS*, a string key works. for RS*, must be a resource of an openssl public key
190- * @param string $alg
192+ *
193+ * @param string $msg The original message (header and body)
194+ * @param string $signature The original signature
195+ * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
196+ * @param string $alg The algorithm
197+ *
191198 * @return bool
199+ *
192200 * @throws DomainException Invalid Algorithm or OpenSSL failure
193201 */
194202 private static function verify ($ msg , $ signature , $ key , $ alg )
@@ -229,7 +237,8 @@ private static function verify($msg, $signature, $key, $alg)
229237 *
230238 * @param string $input JSON string
231239 *
232- * @return object Object representation of JSON string
240+ * @return object Object representation of JSON string
241+ *
233242 * @throws DomainException Provided string was invalid JSON
234243 */
235244 public static function jsonDecode ($ input )
@@ -263,7 +272,8 @@ public static function jsonDecode($input)
263272 *
264273 * @param object|array $input A PHP object or array
265274 *
266- * @return string JSON representation of the PHP object or array
275+ * @return string JSON representation of the PHP object or array
276+ *
267277 * @throws DomainException Provided object could not be encoded to valid JSON
268278 */
269279 public static function jsonEncode ($ input )
@@ -331,6 +341,7 @@ private static function handleJsonError($errno)
331341 * Get the number of bytes in cryptographic strings.
332342 *
333343 * @param string
344+ *
334345 * @return int
335346 */
336347 private static function safeStrlen ($ str )
0 commit comments