: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Nextend\Framework\Cache;
class Manifest extends AbstractCache {
public function __construct($group, $isAccessible = false, $isRaw = false) {
parent::__construct($group, $isAccessible);
protected function decode($data) {
* @param callback $callable
public function makeCache($fileName, $hash, $callable) {
if (!$this->isCached($fileName, $hash)) {
$return = call_user_func($callable, $this);
return $this->createCacheFile($fileName, $hash, $return);
if ($this->isAccessible) {
return $this->getPath($fileName);
return $this->decode($this->get($fileName));
private function isCached($fileName, $hash) {
$manifestKey = $this->getManifestKey($fileName);
if ($this->exists($manifestKey)) {
$this->manifestData = json_decode($this->get($manifestKey), true);
if (!$this->isCacheValid($this->manifestData) || $this->manifestData['hash'] != $hash || !$this->exists($fileName)) {
protected function createCacheFile($fileName, $hash, $content) {
$this->manifestData = array();
$this->manifestData['hash'] = $hash;
$this->addManifestData($this->manifestData);
$this->set($this->getManifestKey($fileName), json_encode($this->manifestData));
$this->set($fileName, $this->isRaw ? $content : json_encode($content));
if ($this->isAccessible) {
return $this->getPath($fileName);
protected function isCacheValid(&$manifestData) {
protected function addManifestData(&$manifestData) {
public function clean($fileName) {
$this->remove($this->getManifestKey($fileName));
$this->remove($fileName);
protected function getManifestKey($fileName) {
return $fileName . '.manifest';
public function getData($key, $default = 0) {
return isset($this->manifestData[$key]) ? $this->manifestData[$key] : $default;