Background
I'm trying to use the leeway property of jwt-auth as recommended here to circumvent weird timezone differences.
The code in jwt is pretty straight forward, A DateTimeTrait trait is used, at first with an instance variable called leeway:
trait DatetimeTrait
{
/**
* Time leeway in seconds.
*
* @var int
*/
protected $leeway = 0;
later on this helper method is used to determine if a given timestamp is in the future:
/**
* Determine whether the value is in the future.
*
* @param mixed $value
*
* @return bool
*/
protected function isFuture($value)
{
return Utils::isFuture($value, $this->leeway);
}
I was going over the code, and I realized that the value of leeway changes randomly. At some point I figured we're calling different trait classes so i used the spl_object_hash to know if we're using the same object, it turns out we do:
public function setLeeway($leeway)
{
$this->leeway = $leeway;
var_dump("set leeway: ".$this->leeway." on object: ".spl_object_hash($this));
return $this;
}
protected function isFuture($value)
{
var_dump("calling is future with leeway :".$this->leeway. " on object: ".spl_object_hash($this));
return Utils::isFuture($value, $this->leeway);
}
but see the logs:
string(60) "set leeway: 5000 on object: <obj-hash-1>"
/vendor/tymon/jwt-auth/src/Claims/DatetimeTrait.php:97:
string(60) "set leeway: 5000 on object: <obj-hash-2>"
/vendor/tymon/jwt-auth/src/Claims/DatetimeTrait.php:71:
string(76) "calling is future with leeway :0 on object: <obj-hash-1>"
where:
<obj-hash-1>
is000000007386f4100000000038d49b05
<obj-hash-2>
is000000007386f4160000000038d49b05
Question
How it possible for the same trait to sometimes have the same instance variable 0, and then 500, without that instance variable being updated using a setter? How can I at least debug that property being updated (if it's not done through a setter)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire