Based on explicit input/output files does a full change check on cache before compiling.

@param string  $in
@param string  $out
@param boolean $force

@return string Compiled CSS results

@throws \Leafo\ScssPhp\Exception\ServerException
517018
public function checkedCachedCompile($in, $out, $force = false)
    {
        if (! is_file($in) || ! is_readable($in)) {
            throw new ServerException('Invalid or unreadable input file specified.');
        }

        if (is_dir($out) || ! is_writable(file_exists($out) ? $out : dirname($out))) {
            throw new ServerException('Invalid or unwritable output file specified.');
        }

        if ($force || $this->needsCompile($out, $etag)) {
            list($css, $etag) = $this->compile($in, $out);
        } else {
            $css = file_get_contents($out);
        }

        return $css;
    }
1349213
public function filter($in, $out, &$consumed, $closing)
    {
        while ($bucket = stream_bucket_make_writeable($in)) {
            $bucket->data = $this->transformCode($bucket->data);
            $consumed += $bucket->datalen;
            stream_bucket_append($out, $bucket);
        }

        return PSFS_PASS_ON;
    }
378875
public function serialize($resource, OutputStream $out): OutputStream
    {
        $out->write($this->xmlSerializerFacade->serializeToXml($resource));
        return $out;
    }
249985
public function getAllPermissions($force = false)
    {
        if (empty($this->cachedPermissions) or $force) {
            $this->cachedPermissions = $this->getFreshAllPermissions();
        }

        return $this->cachedPermissions;
    }
991462
public function check($force = false)
    {
        /*
         * Already know about updates, never retry.
         */
        $oldCount = Parameter::get('system::update.count');
        if ($oldCount > 0) {
            return $oldCount;
        }

        /*
         * Retry period not passed, skipping.
         */
        if (!$force
            && ($retryTimestamp = Parameter::get('system::update.retry'))
            && Carbon::createFromTimeStamp($retryTimestamp)->isFuture()
        ) {
            return $oldCount;
        }

        try {
            $result = $this->requestUpdateList();
            $newCount = array_get($result, 'update', 0);
        }
        catch (Exception $ex) {
            $newCount = 0;
        }

        /*
         * Remember update count, set retry date
         */
        Parameter::set('system::update.count', $newCount);
        Parameter::set('system::update.retry', Carbon::now()->addHours(24)->timestamp);

        return $newCount;
    }
1296372
public function compile($source, $destination = null, $include = null)
    {
        $include = array_merge($this->includes, (array) $include);
        
        $useCache = null == $destination && null !== $this->cache;
         
        if ($useCache) {
            if ($this->cache->hasItem($source)) {
                return $this->cache->getItem($source);
            }
        }

        $arguments = implode(' ', array_map('escapeshellarg', $this->arguments));
        $arguments .= ' ' . $this->getCommandArguments($source, $destination, $include);
        
        $command = "{$this->compiler} $arguments" . ' 2>&1'; 

        $result = exec($command, $output, $exitCode);
        if ($exitCode != 0) {
            throw new \Exception(sprintf('Error compiling CSS "%s": %s', 
                $source, 
                implode(PHP_EOL, $output)));
        }
        
        $css = implode(PHP_EOL, $output);
        
        if ($useCache) {
            $this->cache->setItem($source, $css);
        }
        
        return $css;
    }
718245
public function squash($force = false) {
        if ($this->cache !== null && !$force) return $this->cache;
        if ($this->parent) {
            return $this->cache = array_merge($this->parent->squash($force), $this->data);
        } else {
            return $this->cache = $this->data;
        }
    }
1073580
protected function getOutput($test, $outputFolder, $extension)
    {
        if (empty($outputFolder)) {
            return;
        }

        $file = replace_suite_paths($test->suite, make_path([
            make_path([$test->suite->project->path, $outputFolder]),
            str_replace(['.php', '::', '\\', '/'], ['', '.', '', ''], $test->name).$extension,
        ]));

        return file_exists($file) ? $this->renderHtml(file_get_contents($file)) : null;
    }
1329955
public function getCustomStyle($force = false)
    {
        if ($this->getCustomStyleSetID() > 0 || $force) {
            $csr = StyleSet::getByID($this->getCustomStyleSetID());
            $theme = $this->c->getCollectionThemeObject();
            switch ($this->getBlockTypeHandle()) {
                case BLOCK_HANDLE_LAYOUT_PROXY:
                    $bs = new CoreAreaLayoutCustomStyle($csr, $this, $theme);
                    break;
                default:
                    $bs = new CustomStyle($csr, $this, $theme);
                    break;
            }

            return $bs;
        }
    }
737836
public function transmute($inFilename, Specification $targetFormat, $outFilename)
    {
        $extractedFile = $this->extractor->extract($inFilename, $targetFormat);

        if (!$extractedFile) {
            return null;
        }

        $this->converter->convert($extractedFile, $targetFormat, $outFilename);

        return $outFilename;
    }
509076
public function flushCacheState(bool $force = false): void
    {
        if ((!empty($this->newCacheState) && is_writable($this->cacheDir)) || $force) {
            $fullCacheMap = $this->newCacheState + $this->cacheState;
            $cachePath    = substr(var_export($this->cacheDir, true), 1, -1);
            $rootPath     = substr(var_export($this->appDir, true), 1, -1);
            $cacheData    = '<?php return ' . var_export($fullCacheMap, true) . ';';
            $cacheData    = strtr($cacheData, [
                '\'' . $cachePath => 'AOP_CACHE_DIR . \'',
                '\'' . $rootPath  => 'AOP_ROOT_DIR . \''
            ]);
            $fullCacheFileName = $this->cacheDir . self::CACHE_FILE_NAME;
            file_put_contents($fullCacheFileName, $cacheData, LOCK_EX);
            // For cache files we don't want executable bits by default
            chmod($fullCacheFileName, $this->fileMode & (~0111));

            if (function_exists('opcache_invalidate')) {
                opcache_invalidate($fullCacheFileName, true);
            }
            $this->cacheState    = $this->newCacheState + $this->cacheState;
            $this->newCacheState = [];
        }
    }
801511
public function serialize($resource, OutputStream $out): OutputStream
    {
        $out->write(json_encode($resource));
        return $out;
    }
115355
static public function getSize( $force = FALSE ){
/*		preg_match_all("/rows.([0-9]+);.columns.([0-9]+);/", strtolower(exec('stty -a |grep columns')), $output);
		if(sizeof($output) == 3) {
			self::$width	= $output[2][0];
			self::$height	= $output[1][0];
		}*/
		return (object) array(
			'colors'	=> self::getColors(),
			'height'	=> self::getHeight(),
			'width'		=> self::getWidth(),
		);
	}
802934
protected function execute(InputInterface $in, OutputInterface $out)
    {
        $this->in = $in;
        $this->out = $out;
        $serializer = $this->serializer;
        $namespaceResolver = $this->namespaceResolver;
        $entityClass = $this->in->getArgument('entity');
        $group = $this->in->getOption('entity-group');
        $version = $this->in->getOption('entity-version');
        $rawOutput = $this->in->getOption('raw-output');

        if (!$rawOutput) {
            $this->out->writeln('<info>####################################</info>');
            $this->out->writeln('<info>##    Random Fixture generator    ##</info>');
            $this->out->writeln('<info>####################################</info>');
            $this->out->writeln('');
        }

        $entityNamespace = $namespaceResolver->resolveNamespaceForClass($entityClass);

        $randomFixtureGenerator = $this->randomFixtureGenerator;
        $entity = $randomFixtureGenerator->generate($entityNamespace, $group, $version);
        $context = ContextFactory::createSerializationContextForFixtures($group, $version);

        $result = $serializer->serialize($entity, 'json', $context);
        if (!$rawOutput) {
            $this->out->writeln('');
            $this->out->writeln('<info>Random fixture successfully generated.</info>');
            $this->out->writeln('');
        }

        $this->out->writeln($result);
    }
729792
public function initConfig($force = false) {
		$pluginName = $this->_getPluginName();
		$checkPath = $this->_getCheckPath();
		$configFile = $this->_getConfigFile();
		$language = (string)Configure::read('Config.language');
		if (!$force && !empty($checkPath) && Configure::check($checkPath)) {
			return;
		}

		// Local config without extra config file
		$conf = $this->getConfig();

		$cachePath = 'static_cfg_' . Inflector::underscore($pluginName) . '_' . $language;
		$cached = Cache::read($cachePath, CAKE_CONFIG_PLUGIN_CACHE_CFG);
		if ($cached !== false) {
			$conf = Hash::mergeDiff($conf, (array)$cached);
			Configure::write($pluginName, $conf);

			return;
		}
		Configure::config('phpcfg', new PhpReader($this->path));
		// Fallback to Plugin config which can be overwritten via local app config.
		Configure::load($pluginName . '.' . $configFile, 'phpcfg', false);
		$defaultConf = $this->getConfig();

		// Local app config
		if (file_exists($this->path . $configFile . '.php')) {
			Configure::load($configFile, 'phpcfg', false);
			$localConf = $this->getConfig();
			$conf = Hash::mergeDiff($conf, $localConf);
		}
		Configure::drop('phpcfg');
		// BC comp:
		$conf = Hash::mergeDiff($conf, $defaultConf);
		Cache::write($cachePath, $conf, CAKE_CONFIG_PLUGIN_CACHE_CFG);
		Configure::write($pluginName, $conf);
	}
1109070
public function serialize($resource, OutputStream $out): OutputStream
    {
        if (is_scalar($resource) || $resource instanceof Error) {
            $out->writeLine((string) $resource);
        } elseif (is_array($resource) || $resource instanceof \Traversable) {
            $this->serializeIterable($resource, $out);
        } elseif (is_object($resource)) {
            $this->serializeIterable(castToArray($resource), $out);
        } else {
            trigger_error(
                    'Resource of type ' . typeOf($resource)
                    . ' can not be serialized to csv',
                    E_USER_ERROR
            );
        }

        return $out;
    }
1182143
public function output($output = '', $contentType = 'text/html', array $cookies = array())
    {
        if(!self::isTest()) {
            Logger::log('Start output response');
            ob_start();
            $this->setReponseHeaders($contentType, $cookies);
            header('Content-length: ' . strlen($output));
            header('CRC: ' . crc32($output));

            $needCache = Cache::needCache();
            $cache = Cache::getInstance();
            list($path, $cacheDataName) = $cache->getRequestCacheHash();
            if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) {
                Logger::log('Saving output response into cache');
                $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output);
                $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON);
            } elseif (Request::getInstance()->getMethod() !== 'GET') {
                $cache->flushCache();
            }
            echo $output;

            ob_flush();
            ob_end_clean();
            Logger::log('End output response');
            $this->closeRender();
        } else {
            return $output;
        }
    }