for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ByJG\Cache\Psr6;
use Psr\Cache\CacheItemInterface;
class CacheItem implements CacheItemInterface
{
/**
* @var string
*/
protected $key;
* @var mixed
protected $value;
* @var boolean
protected $hit;
* @var \DateTime
protected $expiration;
* CacheItem constructor.
* @param string $key
* @param mixed $value
* @param bool $hit
public function __construct($key, $value, $hit = true)
$this->key = $key;
$this->value = $value;
$this->hit = $hit;
$this->expiresAt(null);
}
* {@inheritdoc}
public function getKey()
return $this->key;
public function get()
return $this->isHit() ? $this->value : null;
public function set($value = null)
$this->hit = !is_null($value);
return $this;
public function isHit()
return $this->hit;
public function expiresAt($expiration)
if (is_null($expiration)) {
$this->expiration = new \DateTime('now +1 year');
} else {
assert('$expiration instanceof \DateTimeInterface');
$this->expiration = $expiration;
$expiration
object<DateTimeInterface>
object<DateTime>
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
public function expiresAfter($time)
if (is_null($time)) {
} elseif (is_numeric($time)) {
$this->expiration = new \DateTime('now +' . $time . ' seconds');
assert('$time instanceof DateInterval');
$expiration = new \DateTime();
$expiration->add($time);
* @return \DateTime
public function getExpiresAt()
return $this->expiration;
public function getExpiresInSecs()
return $this->getExpiresAt()->getTimestamp() - (new \DateTime('now'))->getTimestamp();
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..