put() public static method

Set cache.
public static put ( mixed $contents )
$contents mixed
Example #1
0
 /**
  * Check the files.
  *
  * @param array $files
  * @param bool  $cache
  *
  * @return array
  */
 public function lint($files = [], $cache = true)
 {
     if (empty($files)) {
         $files = $this->getFiles();
     }
     $processCallback = is_callable($this->processCallback) ? $this->processCallback : function () {
     };
     $errors = [];
     $running = [];
     $newCache = [];
     while (!empty($files) || !empty($running)) {
         for ($i = count($running); !empty($files) && $i < $this->procLimit; ++$i) {
             $file = array_shift($files);
             $filename = $file->getRealpath();
             if (!isset($this->cache[$filename]) || $this->cache[$filename] !== md5_file($filename)) {
                 $running[$filename] = new Lint(PHP_BINARY . ' -d error_reporting=E_ALL -d display_errors=On -l ' . escapeshellarg($filename));
                 $running[$filename]->start();
             } else {
                 $newCache[$filename] = $this->cache[$filename];
             }
         }
         foreach ($running as $filename => $lintProcess) {
             if ($lintProcess->isRunning()) {
                 continue;
             }
             unset($running[$filename]);
             if ($lintProcess->hasSyntaxError()) {
                 $processCallback('error', $filename);
                 $errors[$filename] = array_merge(['file' => $filename], $lintProcess->getSyntaxError());
             } else {
                 $newCache[$filename] = md5_file($filename);
                 $processCallback('ok', $filename);
             }
         }
         $cache && Cache::put($newCache);
     }
     return $errors;
 }