for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tymon\JWTAuth\Providers\JWT;
use Exception;
use Namshi\JOSE\JWS;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
class NamshiAdapter extends JWTProvider implements JWTInterface
{
/**
* @var \Namshi\JOSE\JWS
*/
protected $jws;
* @param string $secret
* @param string $algo
* @param null $driver
public function __construct($secret, $algo, $driver = null)
parent::__construct($secret, $algo);
$this->jws = $driver ?: new JWS(['typ' => 'JWT', 'alg' => $algo]);
}
* Create a JSON Web Token
*
* @return string
* @throws \Tymon\JWTAuth\Exceptions\JWTException
public function encode(array $payload)
try {
$this->jws->setPayload($payload)->sign($this->secret);
$this->secret
string
resource
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return $this->jws->getTokenString();
} catch (Exception $e) {
throw new JWTException('Could not create token: ' . $e->getMessage());
* Decode a JSON Web Token
* @param string $token
* @return array
public function decode($token)
$jws = JWS::load($token);
throw new TokenInvalidException('Could not decode token: ' . $e->getMessage());
if (! $jws->verify($this->secret, $this->algo)) {
throw new TokenInvalidException('Token Signature could not be verified.');
return $jws->getPayload();
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: