@ -0,0 +1,7 @@ | |||
<?php | |||
// autoload.php @generated by Composer | |||
require_once __DIR__ . '/composer/autoload_real.php'; | |||
return ComposerAutoloaderInitb38c14e1074142d17acbc6b991f56fab::getLoader(); |
@ -0,0 +1,14 @@ | |||
#!/usr/bin/env sh | |||
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../symfony/var-dumper/Resources/bin" && pwd) | |||
if [ -d /proc/cygdrive ]; then | |||
case $(which php) in | |||
$(readlink -n /proc/cygdrive)/*) | |||
# We are in Cygwin using Windows php, so the path must be translated | |||
dir=$(cygpath -m "$dir"); | |||
;; | |||
esac | |||
fi | |||
"${dir}/var-dump-server" "$@" |
@ -0,0 +1,4 @@ | |||
@ECHO OFF | |||
setlocal DISABLEDELAYEDEXPANSION | |||
SET BIN_TARGET=%~dp0/../symfony/var-dumper/Resources/bin/var-dump-server | |||
php "%BIN_TARGET%" %* |
@ -0,0 +1,445 @@ | |||
<?php | |||
/* | |||
* This file is part of Composer. | |||
* | |||
* (c) Nils Adermann <naderman@naderman.de> | |||
* Jordi Boggiano <j.boggiano@seld.be> | |||
* | |||
* For the full copyright and license information, please view the LICENSE | |||
* file that was distributed with this source code. | |||
*/ | |||
namespace Composer\Autoload; | |||
/** | |||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader. | |||
* | |||
* $loader = new \Composer\Autoload\ClassLoader(); | |||
* | |||
* // register classes with namespaces | |||
* $loader->add('Symfony\Component', __DIR__.'/component'); | |||
* $loader->add('Symfony', __DIR__.'/framework'); | |||
* | |||
* // activate the autoloader | |||
* $loader->register(); | |||
* | |||
* // to enable searching the include path (eg. for PEAR packages) | |||
* $loader->setUseIncludePath(true); | |||
* | |||
* In this example, if you try to use a class in the Symfony\Component | |||
* namespace or one of its children (Symfony\Component\Console for instance), | |||
* the autoloader will first look for the class under the component/ | |||
* directory, and it will then fallback to the framework/ directory if not | |||
* found before giving up. | |||
* | |||
* This class is loosely based on the Symfony UniversalClassLoader. | |||
* | |||
* @author Fabien Potencier <fabien@symfony.com> | |||
* @author Jordi Boggiano <j.boggiano@seld.be> | |||
* @see http://www.php-fig.org/psr/psr-0/ | |||
* @see http://www.php-fig.org/psr/psr-4/ | |||
*/ | |||
class ClassLoader | |||
{ | |||
// PSR-4 | |||
private $prefixLengthsPsr4 = array(); | |||
private $prefixDirsPsr4 = array(); | |||
private $fallbackDirsPsr4 = array(); | |||
// PSR-0 | |||
private $prefixesPsr0 = array(); | |||
private $fallbackDirsPsr0 = array(); | |||
private $useIncludePath = false; | |||
private $classMap = array(); | |||
private $classMapAuthoritative = false; | |||
private $missingClasses = array(); | |||
private $apcuPrefix; | |||
public function getPrefixes() | |||
{ | |||
if (!empty($this->prefixesPsr0)) { | |||
return call_user_func_array('array_merge', $this->prefixesPsr0); | |||
} | |||
return array(); | |||
} | |||
public function getPrefixesPsr4() | |||
{ | |||
return $this->prefixDirsPsr4; | |||
} | |||
public function getFallbackDirs() | |||
{ | |||
return $this->fallbackDirsPsr0; | |||
} | |||
public function getFallbackDirsPsr4() | |||
{ | |||
return $this->fallbackDirsPsr4; | |||
} | |||
public function getClassMap() | |||
{ | |||
return $this->classMap; | |||
} | |||
/** | |||
* @param array $classMap Class to filename map | |||
*/ | |||
public function addClassMap(array $classMap) | |||
{ | |||
if ($this->classMap) { | |||
$this->classMap = array_merge($this->classMap, $classMap); | |||
} else { | |||
$this->classMap = $classMap; | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-0 directories for a given prefix, either | |||
* appending or prepending to the ones previously set for this prefix. | |||
* | |||
* @param string $prefix The prefix | |||
* @param array|string $paths The PSR-0 root directories | |||
* @param bool $prepend Whether to prepend the directories | |||
*/ | |||
public function add($prefix, $paths, $prepend = false) | |||
{ | |||
if (!$prefix) { | |||
if ($prepend) { | |||
$this->fallbackDirsPsr0 = array_merge( | |||
(array) $paths, | |||
$this->fallbackDirsPsr0 | |||
); | |||
} else { | |||
$this->fallbackDirsPsr0 = array_merge( | |||
$this->fallbackDirsPsr0, | |||
(array) $paths | |||
); | |||
} | |||
return; | |||
} | |||
$first = $prefix[0]; | |||
if (!isset($this->prefixesPsr0[$first][$prefix])) { | |||
$this->prefixesPsr0[$first][$prefix] = (array) $paths; | |||
return; | |||
} | |||
if ($prepend) { | |||
$this->prefixesPsr0[$first][$prefix] = array_merge( | |||
(array) $paths, | |||
$this->prefixesPsr0[$first][$prefix] | |||
); | |||
} else { | |||
$this->prefixesPsr0[$first][$prefix] = array_merge( | |||
$this->prefixesPsr0[$first][$prefix], | |||
(array) $paths | |||
); | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-4 directories for a given namespace, either | |||
* appending or prepending to the ones previously set for this namespace. | |||
* | |||
* @param string $prefix The prefix/namespace, with trailing '\\' | |||
* @param array|string $paths The PSR-4 base directories | |||
* @param bool $prepend Whether to prepend the directories | |||
* | |||
* @throws \InvalidArgumentException | |||
*/ | |||
public function addPsr4($prefix, $paths, $prepend = false) | |||
{ | |||
if (!$prefix) { | |||
// Register directories for the root namespace. | |||
if ($prepend) { | |||
$this->fallbackDirsPsr4 = array_merge( | |||
(array) $paths, | |||
$this->fallbackDirsPsr4 | |||
); | |||
} else { | |||
$this->fallbackDirsPsr4 = array_merge( | |||
$this->fallbackDirsPsr4, | |||
(array) $paths | |||
); | |||
} | |||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) { | |||
// Register directories for a new namespace. | |||
$length = strlen($prefix); | |||
if ('\\' !== $prefix[$length - 1]) { | |||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |||
} | |||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |||
$this->prefixDirsPsr4[$prefix] = (array) $paths; | |||
} elseif ($prepend) { | |||
// Prepend directories for an already registered namespace. | |||
$this->prefixDirsPsr4[$prefix] = array_merge( | |||
(array) $paths, | |||
$this->prefixDirsPsr4[$prefix] | |||
); | |||
} else { | |||
// Append directories for an already registered namespace. | |||
$this->prefixDirsPsr4[$prefix] = array_merge( | |||
$this->prefixDirsPsr4[$prefix], | |||
(array) $paths | |||
); | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-0 directories for a given prefix, | |||
* replacing any others previously set for this prefix. | |||
* | |||
* @param string $prefix The prefix | |||
* @param array|string $paths The PSR-0 base directories | |||
*/ | |||
public function set($prefix, $paths) | |||
{ | |||
if (!$prefix) { | |||
$this->fallbackDirsPsr0 = (array) $paths; | |||
} else { | |||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-4 directories for a given namespace, | |||
* replacing any others previously set for this namespace. | |||
* | |||
* @param string $prefix The prefix/namespace, with trailing '\\' | |||
* @param array|string $paths The PSR-4 base directories | |||
* | |||
* @throws \InvalidArgumentException | |||
*/ | |||
public function setPsr4($prefix, $paths) | |||
{ | |||
if (!$prefix) { | |||
$this->fallbackDirsPsr4 = (array) $paths; | |||
} else { | |||
$length = strlen($prefix); | |||
if ('\\' !== $prefix[$length - 1]) { | |||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |||
} | |||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |||
$this->prefixDirsPsr4[$prefix] = (array) $paths; | |||
} | |||
} | |||
/** | |||
* Turns on searching the include path for class files. | |||
* | |||
* @param bool $useIncludePath | |||
*/ | |||
public function setUseIncludePath($useIncludePath) | |||
{ | |||
$this->useIncludePath = $useIncludePath; | |||
} | |||
/** | |||
* Can be used to check if the autoloader uses the include path to check | |||
* for classes. | |||
* | |||
* @return bool | |||
*/ | |||
public function getUseIncludePath() | |||
{ | |||
return $this->useIncludePath; | |||
} | |||
/** | |||
* Turns off searching the prefix and fallback directories for classes | |||
* that have not been registered with the class map. | |||
* | |||
* @param bool $classMapAuthoritative | |||
*/ | |||
public function setClassMapAuthoritative($classMapAuthoritative) | |||
{ | |||
$this->classMapAuthoritative = $classMapAuthoritative; | |||
} | |||
/** | |||
* Should class lookup fail if not found in the current class map? | |||
* | |||
* @return bool | |||
*/ | |||
public function isClassMapAuthoritative() | |||
{ | |||
return $this->classMapAuthoritative; | |||
} | |||
/** | |||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled. | |||
* | |||
* @param string|null $apcuPrefix | |||
*/ | |||
public function setApcuPrefix($apcuPrefix) | |||
{ | |||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; | |||
} | |||
/** | |||
* The APCu prefix in use, or null if APCu caching is not enabled. | |||
* | |||
* @return string|null | |||
*/ | |||
public function getApcuPrefix() | |||
{ | |||
return $this->apcuPrefix; | |||
} | |||
/** | |||
* Registers this instance as an autoloader. | |||
* | |||
* @param bool $prepend Whether to prepend the autoloader or not | |||
*/ | |||
public function register($prepend = false) | |||
{ | |||
spl_autoload_register(array($this, 'loadClass'), true, $prepend); | |||
} | |||
/** | |||
* Unregisters this instance as an autoloader. | |||
*/ | |||
public function unregister() | |||
{ | |||
spl_autoload_unregister(array($this, 'loadClass')); | |||
} | |||
/** | |||
* Loads the given class or interface. | |||
* | |||
* @param string $class The name of the class | |||
* @return bool|null True if loaded, null otherwise | |||
*/ | |||
public function loadClass($class) | |||
{ | |||
if ($file = $this->findFile($class)) { | |||
includeFile($file); | |||
return true; | |||
} | |||
} | |||
/** | |||
* Finds the path to the file where the class is defined. | |||
* | |||
* @param string $class The name of the class | |||
* | |||
* @return string|false The path if found, false otherwise | |||
*/ | |||
public function findFile($class) | |||
{ | |||
// class map lookup | |||
if (isset($this->classMap[$class])) { | |||
return $this->classMap[$class]; | |||
} | |||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { | |||
return false; | |||
} | |||
if (null !== $this->apcuPrefix) { | |||
$file = apcu_fetch($this->apcuPrefix.$class, $hit); | |||
if ($hit) { | |||
return $file; | |||
} | |||
} | |||
$file = $this->findFileWithExtension($class, '.php'); | |||
// Search for Hack files if we are running on HHVM | |||
if (false === $file && defined('HHVM_VERSION')) { | |||
$file = $this->findFileWithExtension($class, '.hh'); | |||
} | |||
if (null !== $this->apcuPrefix) { | |||
apcu_add($this->apcuPrefix.$class, $file); | |||
} | |||
if (false === $file) { | |||
// Remember that this class does not exist. | |||
$this->missingClasses[$class] = true; | |||
} | |||
return $file; | |||
} | |||
private function findFileWithExtension($class, $ext) | |||
{ | |||
// PSR-4 lookup | |||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; | |||
$first = $class[0]; | |||
if (isset($this->prefixLengthsPsr4[$first])) { | |||
$subPath = $class; | |||
while (false !== $lastPos = strrpos($subPath, '\\')) { | |||
$subPath = substr($subPath, 0, $lastPos); | |||
$search = $subPath . '\\'; | |||
if (isset($this->prefixDirsPsr4[$search])) { | |||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); | |||
foreach ($this->prefixDirsPsr4[$search] as $dir) { | |||
if (file_exists($file = $dir . $pathEnd)) { | |||
return $file; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// PSR-4 fallback dirs | |||
foreach ($this->fallbackDirsPsr4 as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | |||
return $file; | |||
} | |||
} | |||
// PSR-0 lookup | |||
if (false !== $pos = strrpos($class, '\\')) { | |||
// namespaced class name | |||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) | |||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); | |||
} else { | |||
// PEAR-like class name | |||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; | |||
} | |||
if (isset($this->prefixesPsr0[$first])) { | |||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { | |||
if (0 === strpos($class, $prefix)) { | |||
foreach ($dirs as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |||
return $file; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// PSR-0 fallback dirs | |||
foreach ($this->fallbackDirsPsr0 as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |||
return $file; | |||
} | |||
} | |||
// PSR-0 include paths. | |||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | |||
return $file; | |||
} | |||
return false; | |||
} | |||
} | |||
/** | |||
* Scope isolated include. | |||
* | |||
* Prevents access to $this/self from included files. | |||
*/ | |||
function includeFile($file) | |||
{ | |||
include $file; | |||
} |
@ -0,0 +1,21 @@ | |||
Copyright (c) Nils Adermann, Jordi Boggiano | |||
Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to deal | |||
in the Software without restriction, including without limitation the rights | |||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the Software is furnished | |||
to do so, subject to the following conditions: | |||
The above copyright notice and this permission notice shall be included in all | |||
copies or substantial portions of the Software. | |||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
THE SOFTWARE. | |||
@ -0,0 +1,9 @@ | |||
<?php | |||
// autoload_classmap.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
); |
@ -0,0 +1,13 @@ | |||
<?php | |||
// autoload_files.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
'538ca81a9a966a6716601ecf48f4eaef' => $vendorDir . '/opis/closure/functions.php', | |||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', | |||
'25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php', | |||
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', | |||
); |
@ -0,0 +1,10 @@ | |||
<?php | |||
// autoload_namespaces.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
'' => array($baseDir . '/extend'), | |||
); |
@ -0,0 +1,22 @@ | |||
<?php | |||
// autoload_psr4.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'), | |||
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-cache/src', $vendorDir . '/topthink/think-container/src', $vendorDir . '/topthink/think-log/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'), | |||
'app\\' => array($baseDir . '/app'), | |||
'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'), | |||
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), | |||
'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'), | |||
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), | |||
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), | |||
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), | |||
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), | |||
'Opis\\Closure\\' => array($vendorDir . '/opis/closure/src'), | |||
'League\\Flysystem\\Cached\\' => array($vendorDir . '/league/flysystem-cached-adapter/src'), | |||
'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), | |||
); |
@ -0,0 +1,70 @@ | |||
<?php | |||
// autoload_real.php @generated by Composer | |||
class ComposerAutoloaderInitb38c14e1074142d17acbc6b991f56fab | |||
{ | |||
private static $loader; | |||
public static function loadClassLoader($class) | |||
{ | |||
if ('Composer\Autoload\ClassLoader' === $class) { | |||
require __DIR__ . '/ClassLoader.php'; | |||
} | |||
} | |||
public static function getLoader() | |||
{ | |||
if (null !== self::$loader) { | |||
return self::$loader; | |||
} | |||
spl_autoload_register(array('ComposerAutoloaderInitb38c14e1074142d17acbc6b991f56fab', 'loadClassLoader'), true, true); | |||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | |||
spl_autoload_unregister(array('ComposerAutoloaderInitb38c14e1074142d17acbc6b991f56fab', 'loadClassLoader')); | |||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); | |||
if ($useStaticLoader) { | |||
require_once __DIR__ . '/autoload_static.php'; | |||
call_user_func(\Composer\Autoload\ComposerStaticInitb38c14e1074142d17acbc6b991f56fab::getInitializer($loader)); | |||
} else { | |||
$map = require __DIR__ . '/autoload_namespaces.php'; | |||
foreach ($map as $namespace => $path) { | |||
$loader->set($namespace, $path); | |||
} | |||
$map = require __DIR__ . '/autoload_psr4.php'; | |||
foreach ($map as $namespace => $path) { | |||
$loader->setPsr4($namespace, $path); | |||
} | |||
$classMap = require __DIR__ . '/autoload_classmap.php'; | |||
if ($classMap) { | |||
$loader->addClassMap($classMap); | |||
} | |||
} | |||
$loader->register(true); | |||
if ($useStaticLoader) { | |||
$includeFiles = Composer\Autoload\ComposerStaticInitb38c14e1074142d17acbc6b991f56fab::$files; | |||
} else { | |||
$includeFiles = require __DIR__ . '/autoload_files.php'; | |||
} | |||
foreach ($includeFiles as $fileIdentifier => $file) { | |||
composerRequireb38c14e1074142d17acbc6b991f56fab($fileIdentifier, $file); | |||
} | |||
return $loader; | |||
} | |||
} | |||
function composerRequireb38c14e1074142d17acbc6b991f56fab($fileIdentifier, $file) | |||
{ | |||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { | |||
require $file; | |||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; | |||
} | |||
} |
@ -0,0 +1,123 @@ | |||
<?php | |||
// autoload_static.php @generated by Composer | |||
namespace Composer\Autoload; | |||
class ComposerStaticInitb38c14e1074142d17acbc6b991f56fab | |||
{ | |||
public static $files = array ( | |||
'538ca81a9a966a6716601ecf48f4eaef' => __DIR__ . '/..' . '/opis/closure/functions.php', | |||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', | |||
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php', | |||
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', | |||
); | |||
public static $prefixLengthsPsr4 = array ( | |||
't' => | |||
array ( | |||
'think\\view\\driver\\' => 18, | |||
'think\\' => 6, | |||
), | |||
'a' => | |||
array ( | |||
'app\\' => 4, | |||
), | |||
'S' => | |||
array ( | |||
'Symfony\\Polyfill\\Php72\\' => 23, | |||
'Symfony\\Polyfill\\Mbstring\\' => 26, | |||
'Symfony\\Component\\VarDumper\\' => 28, | |||
), | |||
'P' => | |||
array ( | |||
'Psr\\SimpleCache\\' => 16, | |||
'Psr\\Log\\' => 8, | |||
'Psr\\Container\\' => 14, | |||
'Psr\\Cache\\' => 10, | |||
), | |||
'O' => | |||
array ( | |||
'Opis\\Closure\\' => 13, | |||
), | |||
'L' => | |||
array ( | |||
'League\\Flysystem\\Cached\\' => 24, | |||
'League\\Flysystem\\' => 17, | |||
), | |||
); | |||
public static $prefixDirsPsr4 = array ( | |||
'think\\view\\driver\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/topthink/think-view/src', | |||
), | |||
'think\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/topthink/framework/src/think', | |||
1 => __DIR__ . '/..' . '/topthink/think-cache/src', | |||
2 => __DIR__ . '/..' . '/topthink/think-container/src', | |||
3 => __DIR__ . '/..' . '/topthink/think-log/src', | |||
4 => __DIR__ . '/..' . '/topthink/think-orm/src', | |||
5 => __DIR__ . '/..' . '/topthink/think-template/src', | |||
), | |||
'app\\' => | |||
array ( | |||
0 => __DIR__ . '/../..' . '/app', | |||
), | |||
'Symfony\\Polyfill\\Php72\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/symfony/polyfill-php72', | |||
), | |||
'Symfony\\Polyfill\\Mbstring\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', | |||
), | |||
'Symfony\\Component\\VarDumper\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/symfony/var-dumper', | |||
), | |||
'Psr\\SimpleCache\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/psr/simple-cache/src', | |||
), | |||
'Psr\\Log\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/psr/log/Psr/Log', | |||
), | |||
'Psr\\Container\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/psr/container/src', | |||
), | |||
'Psr\\Cache\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/psr/cache/src', | |||
), | |||
'Opis\\Closure\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/opis/closure/src', | |||
), | |||
'League\\Flysystem\\Cached\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/league/flysystem-cached-adapter/src', | |||
), | |||
'League\\Flysystem\\' => | |||
array ( | |||
0 => __DIR__ . '/..' . '/league/flysystem/src', | |||
), | |||
); | |||
public static $fallbackDirsPsr0 = array ( | |||
0 => __DIR__ . '/../..' . '/extend', | |||
); | |||
public static function getInitializer(ClassLoader $loader) | |||
{ | |||
return \Closure::bind(function () use ($loader) { | |||
$loader->prefixLengthsPsr4 = ComposerStaticInitb38c14e1074142d17acbc6b991f56fab::$prefixLengthsPsr4; | |||
$loader->prefixDirsPsr4 = ComposerStaticInitb38c14e1074142d17acbc6b991f56fab::$prefixDirsPsr4; | |||
$loader->fallbackDirsPsr0 = ComposerStaticInitb38c14e1074142d17acbc6b991f56fab::$fallbackDirsPsr0; | |||
}, null, ClassLoader::class); | |||
} | |||
} |
@ -0,0 +1,10 @@ | |||
; top-most EditorConfig file | |||
root = true | |||
; Unix-style newlines | |||
[*] | |||
end_of_line = LF | |||
[*.php] | |||
indent_style = space | |||
indent_size = 4 |
@ -0,0 +1,4 @@ | |||
coverage | |||
coverage.xml | |||
composer.lock | |||
vendor |
@ -0,0 +1,7 @@ | |||
<?php | |||
return Symfony\CS\Config\Config::create() | |||
->level(Symfony\CS\FixerInterface::PSR2_LEVEL) | |||
->fixers(['-yoda_conditions', 'ordered_use', 'short_array_syntax']) | |||
->finder(Symfony\CS\Finder\DefaultFinder::create() | |||
->in(__DIR__.'/src/')); |
@ -0,0 +1,34 @@ | |||
filter: | |||
paths: [src/*] | |||
checks: | |||
php: | |||
code_rating: true | |||
remove_extra_empty_lines: true | |||
remove_php_closing_tag: true | |||
remove_trailing_whitespace: true | |||
fix_use_statements: | |||
remove_unused: true | |||
preserve_multiple: false | |||
preserve_blanklines: true | |||
order_alphabetically: true | |||
fix_php_opening_tag: true | |||
fix_linefeed: true | |||
fix_line_ending: true | |||
fix_identation_4spaces: true | |||
fix_doc_comments: true | |||
tools: | |||
external_code_coverage: | |||
timeout: 900 | |||
runs: 6 | |||
php_code_coverage: false | |||
php_code_sniffer: | |||
config: | |||
standard: PSR2 | |||
filter: | |||
paths: ['src'] | |||
php_loc: | |||
enabled: true | |||
excluded_dirs: [vendor, spec, stubs] | |||
php_cpd: | |||
enabled: true | |||
excluded_dirs: [vendor, spec, stubs] |
@ -0,0 +1,29 @@ | |||
language: php | |||
php: | |||
- 5.5 | |||
- 5.6 | |||
- 7.0 | |||
- 7.1 | |||
- 7.2 | |||
matrix: | |||
allow_failures: | |||
- php: 5.5 | |||
env: | |||
- COMPOSER_OPTS="" | |||
- COMPOSER_OPTS="--prefer-lowest" | |||
install: | |||
- if [[ "${TRAVIS_PHP_VERSION}" == "5.5" ]]; then composer require phpunit/phpunit:^4.8.36 phpspec/phpspec:^2 --prefer-dist --update-with-dependencies; fi | |||
- if [[ "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then composer require phpunit/phpunit:^6.0 --prefer-dist --update-with-dependencies; fi | |||
- travis_retry composer update --prefer-dist $COMPOSER_OPTS | |||
script: | |||
- vendor/bin/phpspec run | |||
- vendor/bin/phpunit | |||
after_script: | |||
- wget https://scrutinizer-ci.com/ocular.phar' | |||
- php ocular.phar code-coverage:upload --format=php-clover ./clover/phpunit.xml' |
@ -0,0 +1,19 @@ | |||
Copyright (c) 2015 Frank de Jonge | |||
Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to deal | |||
in the Software without restriction, including without limitation the rights | |||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the Software is furnished | |||
to do so, subject to the following conditions: | |||
The above copyright notice and this permission notice shall be included in all | |||
copies or substantial portions of the Software. | |||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
THE SOFTWARE. |
@ -0,0 +1,2 @@ | |||
* | |||
!.gitignore |
@ -0,0 +1,30 @@ | |||
{ | |||
"name": "league/flysystem-cached-adapter", | |||
"description": "An adapter decorator to enable meta-data caching.", | |||
"autoload": { | |||
"psr-4": { | |||
"League\\Flysystem\\Cached\\": "src/" | |||
} | |||
}, | |||
"require": { | |||
"league/flysystem": "~1.0", | |||
"psr/cache": "^1.0.0" | |||
}, | |||
"require-dev": { | |||
"phpspec/phpspec": "^3.4", | |||
"phpunit/phpunit": "^5.7", | |||
"mockery/mockery": "~0.9", | |||
"predis/predis": "~1.0", | |||
"tedivm/stash": "~0.12" | |||
}, | |||
"suggest": { | |||
"ext-phpredis": "Pure C implemented extension for PHP" | |||
}, | |||
"license": "MIT", | |||
"authors": [ | |||
{ | |||
"name": "frankdejonge", | |||
"email": "info@frenky.net" | |||
} | |||
] | |||
} |
@ -0,0 +1,6 @@ | |||
--- | |||
suites: | |||
cached_adapter_suite: | |||
namespace: League\Flysystem\Cached | |||
psr4_prefix: League\Flysystem\Cached | |||
formatter.name: pretty |
@ -0,0 +1,3 @@ | |||
<?php | |||
include __DIR__.'/vendor/autoload.php'; |
@ -0,0 +1,29 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<phpunit backupGlobals="false" | |||
backupStaticAttributes="false" | |||
bootstrap="./phpunit.php" | |||
colors="true" | |||
convertErrorsToExceptions="true" | |||
convertNoticesToExceptions="true" | |||
convertWarningsToExceptions="true" | |||
processIsolation="false" | |||
stopOnFailure="false" | |||
syntaxCheck="true" | |||
verbose="true" | |||
> | |||
<testsuites> | |||
<testsuite name="flysystem/tests"> | |||
<directory suffix=".php">./tests/</directory> | |||
</testsuite> | |||
</testsuites> | |||
<filter> | |||
<whitelist> | |||
<directory suffix=".php">./src/</directory> | |||
</whitelist> | |||
</filter> | |||
<logging> | |||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/> | |||
<log type="coverage-html" target="coverage" showUncoveredFiles="true"/> | |||
<log type="coverage-clover" target="clover/phpunit.xml" showUncoveredFiles="true"/> | |||
</logging> | |||
</phpunit> |
@ -0,0 +1,20 @@ | |||
# Flysystem Cached CachedAdapter | |||
[](https://twitter.com/frankdejonge) | |||
[](https://travis-ci.org/thephpleague/flysystem-cached-adapter) | |||
[](https://scrutinizer-ci.com/g/thephpleague/flysystem-cached-adapter/code-structure) | |||
[](https://scrutinizer-ci.com/g/thephpleague/flysystem-cached-adapter) | |||
[](LICENSE) | |||
[](https://packagist.org/packages/league/flysystem-cached-adapter) | |||
[](https://packagist.org/packages/league/flysystem-cached-adapter) | |||
The adapter decorator caches metadata and directory listings. | |||
```bash | |||
composer require league/flysystem-cached-adapter | |||
``` | |||
## Usage | |||
[Check out the docs.](https://flysystem.thephpleague.com/docs/advanced/caching/) |
@ -0,0 +1,435 @@ | |||
<?php | |||
namespace spec\League\Flysystem\Cached; | |||
use League\Flysystem\AdapterInterface; | |||
use League\Flysystem\Cached\CacheInterface; | |||
use League\Flysystem\Config; | |||
use PhpSpec\ObjectBehavior; | |||
class CachedAdapterSpec extends ObjectBehavior | |||
{ | |||
/** | |||
* @var AdapterInterface | |||
*/ | |||
private $adapter; | |||
/** | |||
* @var CacheInterface | |||
*/ | |||
private $cache; | |||
public function let(AdapterInterface $adapter, CacheInterface $cache) | |||
{ | |||
$this->adapter = $adapter; | |||
$this->cache = $cache; | |||
$this->cache->load()->shouldBeCalled(); | |||
$this->beConstructedWith($adapter, $cache); | |||
} | |||
public function it_is_initializable() | |||
{ | |||
$this->shouldHaveType('League\Flysystem\Cached\CachedAdapter'); | |||
$this->shouldHaveType('League\Flysystem\AdapterInterface'); | |||
} | |||
public function it_should_forward_read_streams() | |||
{ | |||
$path = 'path.txt'; | |||
$response = ['path' => $path]; | |||
$this->adapter->readStream($path)->willReturn($response); | |||
$this->readStream($path)->shouldbe($response); | |||
} | |||
public function it_should_cache_writes() | |||
{ | |||
$type = 'file'; | |||
$path = 'path.txt'; | |||
$contents = 'contents'; | |||
$config = new Config(); | |||
$response = compact('path', 'contents', 'type'); | |||
$this->adapter->write($path, $contents, $config)->willReturn($response); | |||
$this->cache->updateObject($path, $response, true)->shouldBeCalled(); | |||
$this->write($path, $contents, $config)->shouldBe($response); | |||
} | |||
public function it_should_cache_streamed_writes() | |||
{ | |||
$type = 'file'; | |||
$path = 'path.txt'; | |||
$stream = tmpfile(); | |||
$config = new Config(); | |||
$response = compact('path', 'stream', 'type'); | |||
$this->adapter->writeStream($path, $stream, $config)->willReturn($response); | |||
$this->cache->updateObject($path, ['contents' => false] + $response, true)->shouldBeCalled(); | |||
$this->writeStream($path, $stream, $config)->shouldBe($response); | |||
fclose($stream); | |||
} | |||
public function it_should_cache_streamed_updates() | |||
{ | |||
$type = 'file'; | |||
$path = 'path.txt'; | |||
$stream = tmpfile(); | |||
$config = new Config(); | |||
$response = compact('path', 'stream', 'type'); | |||
$this->adapter->updateStream($path, $stream, $config)->willReturn($response); | |||
$this->cache->updateObject($path, ['contents' => false] + $response, true)->shouldBeCalled(); | |||
$this->updateStream($path, $stream, $config)->shouldBe($response); | |||
fclose($stream); | |||
} | |||
public function it_should_ignore_failed_writes() | |||
{ | |||
$path = 'path.txt'; | |||
$contents = 'contents'; | |||
$config = new Config(); | |||
$this->adapter->write($path, $contents, $config)->willReturn(false); | |||
$this->write($path, $contents, $config)->shouldBe(false); | |||
} | |||
public function it_should_ignore_failed_streamed_writes() | |||
{ | |||
$path = 'path.txt'; | |||
$contents = tmpfile(); | |||
$config = new Config(); | |||
$this->adapter->writeStream($path, $contents, $config)->willReturn(false); | |||
$this->writeStream($path, $contents, $config)->shouldBe(false); | |||
fclose($contents); | |||
} | |||
public function it_should_cache_updated() | |||
{ | |||
$type = 'file'; | |||
$path = 'path.txt'; | |||
$contents = 'contents'; | |||
$config = new Config(); | |||
$response = compact('path', 'contents', 'type'); | |||
$this->adapter->update($path, $contents, $config)->willReturn($response); | |||
$this->cache->updateObject($path, $response, true)->shouldBeCalled(); | |||
$this->update($path, $contents, $config)->shouldBe($response); | |||
} | |||
public function it_should_ignore_failed_updates() | |||
{ | |||
$path = 'path.txt'; | |||
$contents = 'contents'; | |||
$config = new Config(); | |||
$this->adapter->update($path, $contents, $config)->willReturn(false); | |||
$this->update($path, $contents, $config)->shouldBe(false); | |||
} | |||
public function it_should_ignore_failed_streamed_updates() | |||
{ | |||
$path = 'path.txt'; | |||
$contents = tmpfile(); | |||
$config = new Config(); | |||
$this->adapter->updateStream($path, $contents, $config)->willReturn(false); | |||
$this->updateStream($path, $contents, $config)->shouldBe(false); | |||
fclose($contents); | |||
} | |||
public function it_should_cache_renames() | |||
{ | |||
$old = 'old.txt'; | |||
$new = 'new.txt'; | |||
$this->adapter->rename($old, $new)->willReturn(true); | |||
$this->cache->rename($old, $new)->shouldBeCalled(); | |||
$this->rename($old, $new)->shouldBe(true); | |||
} | |||
public function it_should_ignore_rename_fails() | |||
{ | |||
$old = 'old.txt'; | |||
$new = 'new.txt'; | |||
$this->adapter->rename($old, $new)->willReturn(false); | |||
$this->rename($old, $new)->shouldBe(false); | |||
} | |||
public function it_should_cache_copies() | |||
{ | |||
$old = 'old.txt'; | |||
$new = 'new.txt'; | |||
$this->adapter->copy($old, $new)->willReturn(true); | |||
$this->cache->copy($old, $new)->shouldBeCalled(); | |||
$this->copy($old, $new)->shouldBe(true); | |||
} | |||
public function it_should_ignore_copy_fails() | |||
{ | |||
$old = 'old.txt'; | |||
$new = 'new.txt'; | |||
$this->adapter->copy($old, $new)->willReturn(false); | |||
$this->copy($old, $new)->shouldBe(false); | |||
} | |||
public function it_should_cache_deletes() | |||
{ | |||
$delete = 'delete.txt'; | |||
$this->adapter->delete($delete)->willReturn(true); | |||
$this->cache->delete($delete)->shouldBeCalled(); | |||
$this->delete($delete)->shouldBe(true); | |||
} | |||
public function it_should_ignore_delete_fails() | |||
{ | |||
$delete = 'delete.txt'; | |||
$this->adapter->delete($delete)->willReturn(false); | |||
$this->delete($delete)->shouldBe(false); | |||
} | |||
public function it_should_cache_dir_deletes() | |||
{ | |||
$delete = 'delete'; | |||
$this->adapter->deleteDir($delete)->willReturn(true); | |||
$this->cache->deleteDir($delete)->shouldBeCalled(); | |||
$this->deleteDir($delete)->shouldBe(true); | |||
} | |||
public function it_should_ignore_delete_dir_fails() | |||
{ | |||
$delete = 'delete'; | |||
$this->adapter->deleteDir($delete)->willReturn(false); | |||
$this->deleteDir($delete)->shouldBe(false); | |||
} | |||
public function it_should_cache_dir_creates() | |||
{ | |||
$dirname = 'dirname'; | |||
$config = new Config(); | |||
$response = ['path' => $dirname, 'type' => 'dir']; | |||
$this->adapter->createDir($dirname, $config)->willReturn($response); | |||
$this->cache->updateObject($dirname, $response, true)->shouldBeCalled(); | |||
$this->createDir($dirname, $config)->shouldBe($response); | |||
} | |||
public function it_should_ignore_create_dir_fails() | |||
{ | |||
$dirname = 'dirname'; | |||
$config = new Config(); | |||
$this->adapter->createDir($dirname, $config)->willReturn(false); | |||
$this->createDir($dirname, $config)->shouldBe(false); | |||
} | |||
public function it_should_cache_set_visibility() | |||
{ | |||
$path = 'path.txt'; | |||
$visibility = AdapterInterface::VISIBILITY_PUBLIC; | |||
$this->adapter->setVisibility($path, $visibility)->willReturn(true); | |||
$this->cache->updateObject($path, ['path' => $path, 'visibility' => $visibility], true)->shouldBeCalled(); | |||
$this->setVisibility($path, $visibility)->shouldBe(true); | |||
} | |||
public function it_should_ignore_set_visibility_fails() | |||
{ | |||
$dirname = 'delete'; | |||
$visibility = AdapterInterface::VISIBILITY_PUBLIC; | |||
$this->adapter->setVisibility($dirname, $visibility)->willReturn(false); | |||
$this->setVisibility($dirname, $visibility)->shouldBe(false); | |||
} | |||
public function it_should_indicate_missing_files() | |||
{ | |||
$this->cache->has($path = 'path.txt')->willReturn(false); | |||
$this->has($path)->shouldBe(false); | |||
} | |||
public function it_should_indicate_file_existance() | |||
{ | |||
$this->cache->has($path = 'path.txt')->willReturn(true); | |||
$this->has($path)->shouldBe(true); | |||
} | |||
public function it_should_cache_missing_files() | |||
{ | |||
$this->cache->has($path = 'path.txt')->willReturn(null); | |||
$this->adapter->has($path)->willReturn(false); | |||
$this->cache->storeMiss($path)->shouldBeCalled(); | |||
$this->has($path)->shouldBe(false); | |||
} | |||
public function it_should_delete_when_metadata_is_missing() | |||
{ | |||
$path = 'path.txt'; | |||
$this->cache->has($path)->willReturn(true); | |||
$this->cache->getSize($path)->willReturn(['path' => $path]); | |||
$this->adapter->getSize($path)->willReturn($response = ['path' => $path, 'size' => 1024]); | |||
$this->cache->updateObject($path, $response, true)->shouldBeCalled(); | |||
$this->getSize($path)->shouldBe($response); | |||
} | |||
public function it_should_cache_has() | |||
{ | |||
$this->cache->has($path = 'path.txt')->willReturn(null); | |||
$this->adapter->has($path)->willReturn(true); | |||
$this->cache->updateObject($path, compact('path'), true)->shouldBeCalled(); | |||
$this->has($path)->shouldBe(true); | |||
} | |||
public function it_should_list_cached_contents() | |||
{ | |||
$this->cache->isComplete($dirname = 'dirname', $recursive = true)->willReturn(true); | |||
$response = [['path' => 'path.txt']]; | |||
$this->cache->listContents($dirname, $recursive)->willReturn($response); | |||
$this->listContents($dirname, $recursive)->shouldBe($response); | |||
} | |||
public function it_should_ignore_failed_list_contents() | |||
{ | |||
$this->cache->isComplete($dirname = 'dirname', $recursive = true)->willReturn(false); | |||
$this->adapter->listContents($dirname, $recursive)->willReturn(false); | |||
$this->listContents($dirname, $recursive)->shouldBe(false); | |||
} | |||
public function it_should_cache_contents_listings() | |||
{ | |||
$this->cache->isComplete($dirname = 'dirname', $recursive = true)->willReturn(false); | |||
$response = [['path' => 'path.txt']]; | |||
$this->adapter->listContents($dirname, $recursive)->willReturn($response); | |||
$this->cache->storeContents($dirname, $response, $recursive)->shouldBeCalled(); | |||
$this->listContents($dirname, $recursive)->shouldBe($response); | |||
} | |||
public function it_should_use_cached_visibility() | |||
{ | |||
$this->make_it_use_getter_cache('getVisibility', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'visibility' => AdapterInterface::VISIBILITY_PUBLIC, | |||
]); | |||
} | |||
public function it_should_cache_get_visibility() | |||
{ | |||
$path = 'path.txt'; | |||
$response = ['visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'path' => $path]; | |||
$this->make_it_cache_getter('getVisibility', $path, $response); | |||
} | |||
public function it_should_ignore_failed_get_visibility() | |||
{ | |||
$path = 'path.txt'; | |||
$this->make_it_ignore_failed_getter('getVisibility', $path); | |||
} | |||
public function it_should_use_cached_timestamp() | |||
{ | |||
$this->make_it_use_getter_cache('getTimestamp', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'timestamp' => 1234, | |||
]); | |||
} | |||
public function it_should_cache_timestamps() | |||
{ | |||
$this->make_it_cache_getter('getTimestamp', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'timestamp' => 1234, | |||
]); | |||
} | |||
public function it_should_ignore_failed_get_timestamps() | |||
{ | |||
$this->make_it_ignore_failed_getter('getTimestamp', 'path.txt'); | |||
} | |||
public function it_should_cache_get_metadata() | |||
{ | |||
$path = 'path.txt'; | |||
$response = ['visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'path' => $path]; | |||
$this->make_it_cache_getter('getMetadata', $path, $response); | |||
} | |||
public function it_should_use_cached_metadata() | |||
{ | |||
$this->make_it_use_getter_cache('getMetadata', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'timestamp' => 1234, | |||
]); | |||
} | |||
public function it_should_ignore_failed_get_metadata() | |||
{ | |||
$this->make_it_ignore_failed_getter('getMetadata', 'path.txt'); | |||
} | |||
public function it_should_cache_get_size() | |||
{ | |||
$path = 'path.txt'; | |||
$response = ['size' => 1234, 'path' => $path]; | |||
$this->make_it_cache_getter('getSize', $path, $response); | |||
} | |||
public function it_should_use_cached_size() | |||
{ | |||
$this->make_it_use_getter_cache('getSize', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'size' => 1234, | |||
]); | |||
} | |||
public function it_should_ignore_failed_get_size() | |||
{ | |||
$this->make_it_ignore_failed_getter('getSize', 'path.txt'); | |||
} | |||
public function it_should_cache_get_mimetype() | |||
{ | |||
$path = 'path.txt'; | |||
$response = ['mimetype' => 'text/plain', 'path' => $path]; | |||
$this->make_it_cache_getter('getMimetype', $path, $response); | |||
} | |||
public function it_should_use_cached_mimetype() | |||
{ | |||
$this->make_it_use_getter_cache('getMimetype', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'mimetype' => 'text/plain', | |||
]); | |||
} | |||
public function it_should_ignore_failed_get_mimetype() | |||
{ | |||
$this->make_it_ignore_failed_getter('getMimetype', 'path.txt'); | |||
} | |||
public function it_should_cache_reads() | |||
{ | |||
$path = 'path.txt'; | |||
$response = ['path' => $path, 'contents' => 'contents']; | |||
$this->make_it_cache_getter('read', $path, $response); | |||
} | |||
public function it_should_use_cached_file_contents() | |||
{ | |||
$this->make_it_use_getter_cache('read', 'path.txt', [ | |||
'path' => 'path.txt', | |||
'contents' => 'contents' | |||
]); | |||
} | |||
public function it_should_ignore_failed_reads() | |||
{ | |||
$this->make_it_ignore_failed_getter('read', 'path.txt'); | |||
} | |||
protected function make_it_use_getter_cache($method, $path, $response) | |||
{ | |||
$this->cache->{$method}($path)->willReturn($response); | |||
$this->{$method}($path)->shouldBe($response); | |||
} | |||
protected function make_it_cache_getter($method, $path, $response) | |||
{ | |||
$this->cache->{$method}($path)->willReturn(false); | |||
$this->adapter->{$method}($path)->willReturn($response); | |||
$this->cache->updateObject($path, $response, true)->shouldBeCalled(); | |||
$this->{$method}($path)->shouldBe($response); | |||
} | |||
protected function make_it_ignore_failed_getter($method, $path) | |||
{ | |||
$this->cache->{$method}($path)->willReturn(false); | |||
$this->adapter->{$method}($path)->willReturn(false); | |||
$this->{$method}($path)->shouldBe(false); | |||
} | |||
} |
@ -0,0 +1,101 @@ | |||
<?php | |||
namespace League\Flysystem\Cached; | |||
use League\Flysystem\ReadInterface; | |||
interface CacheInterface extends ReadInterface | |||
{ | |||
/** | |||
* Check whether the directory listing of a given directory is complete. | |||
* | |||
* @param string $dirname | |||
* @param bool $recursive | |||
* | |||
* @return bool | |||
*/ | |||
public function isComplete($dirname, $recursive); | |||
/** | |||
* Set a directory to completely listed. | |||
* | |||
* @param string $dirname | |||
* @param bool $recursive | |||
*/ | |||
public function setComplete($dirname, $recursive); | |||
/** | |||
* Store the contents of a directory. | |||
* | |||
* @param string $directory | |||
* @param array $contents | |||
* @param bool $recursive | |||
*/ | |||
public function storeContents($directory, array $contents, $recursive); | |||
/** | |||
* Flush the cache. | |||
*/ | |||
public function flush(); | |||
/** | |||
* Autosave trigger. | |||
*/ | |||
public function autosave(); | |||
/** | |||
* Store the cache. | |||
*/ | |||
public function save(); | |||
/** | |||
* Load the cache. | |||
*/ | |||
public function load(); | |||
/** | |||
* Rename a file. | |||
* | |||
* @param string $path | |||
* @param string $newpath | |||
*/ | |||
public function rename($path, $newpath); | |||
/** | |||
* Copy a file. | |||
* | |||
* @param string $path | |||
* @param string $newpath | |||
*/ | |||
public function copy($path, $newpath); | |||
/** | |||
* Delete an object from cache. | |||
* | |||
* @param string $path object path | |||
*/ | |||
public function delete($path); | |||
/** | |||
* Delete all objects from from a directory. | |||
* | |||
* @param string $dirname directory path | |||
*/ | |||
public function deleteDir($dirname); | |||
/** | |||
* Update the metadata for an object. | |||
* | |||
* @param string $path object path | |||
* @param array $object object metadata | |||
* @param bool $autosave whether to trigger the autosave routine | |||
*/ | |||
public function updateObject($path, array $object, $autosave = false); | |||
/** | |||
* Store object hit miss. | |||
* | |||
* @param string $path | |||
*/ | |||
public function storeMiss($path); | |||
} |
@ -0,0 +1,324 @@ | |||
<?php | |||
namespace League\Flysystem\Cached; | |||
use League\Flysystem\AdapterInterface; | |||
use League\Flysystem\Config; | |||
class CachedAdapter implements AdapterInterface | |||
{ | |||
/** | |||
* @var AdapterInterface | |||
*/ | |||
private $adapter; | |||
/** | |||
* @var CacheInterface | |||
*/ | |||
private $cache; | |||
/** | |||
* Constructor. | |||
* | |||
* @param AdapterInterface $adapter | |||
* @param CacheInterface $cache | |||
*/ | |||
public function __construct(AdapterInterface $adapter, CacheInterface $cache) | |||
{ | |||
$this->adapter = $adapter; | |||
$this->cache = $cache; | |||
$this->cache->load(); | |||
} | |||
/** | |||
* Get the underlying Adapter implementation. | |||
* | |||
* @return AdapterInterface | |||
*/ | |||
public function getAdapter() | |||
{ | |||
return $this->adapter; | |||
} | |||
/** | |||
* Get the used Cache implementation. | |||
* | |||
* @return CacheInterface | |||
*/ | |||
public function getCache() | |||
{ | |||
return $this->cache; | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function write($path, $contents, Config $config) | |||
{ | |||
$result = $this->adapter->write($path, $contents, $config); | |||
if ($result !== false) { | |||
$result['type'] = 'file'; | |||
$this->cache->updateObject($path, $result + compact('path', 'contents'), true); | |||
} | |||
return $result; | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function writeStream($path, $resource, Config $config) | |||
{ | |||
$result = $this->adapter->writeStream($path, $resource, $config); | |||
if ($result !== false) { | |||
$result['type'] = 'file'; | |||
$contents = false; | |||
$this->cache->updateObject($path, $result + compact('path', 'contents'), true); | |||
} | |||
return $result; | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function update($path, $contents, Config $config) | |||
{ | |||
$result = $this->adapter->update($path, $contents, $config); | |||
if ($result !== false) { | |||
$result['type'] = 'file'; | |||
$this->cache->updateObject($path, $result + compact('path', 'contents'), true); | |||
} | |||
return $result; | |||
} | |||