Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver;
|
||||
|
||||
use Dflydev\PlaceholderResolver\Cache\Cache;
|
||||
use Dflydev\PlaceholderResolver\Cache\CacheInterface;
|
||||
|
||||
abstract class AbstractPlaceholderResolver implements PlaceholderResolverInterface
|
||||
{
|
||||
private $cache;
|
||||
protected $maxReplacementDepth = 10;
|
||||
|
||||
/**
|
||||
* Set maximum depth for recursive replacement
|
||||
*
|
||||
* @param int $maxReplacementDepth
|
||||
*
|
||||
* @return PlaceholderResolver
|
||||
*/
|
||||
public function setMaxReplacementDepth($maxReplacementDepth)
|
||||
{
|
||||
$this->maxReplacementDepth = $maxReplacementDepth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache
|
||||
*
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache()
|
||||
{
|
||||
if (null === $this->cache) {
|
||||
$this->cache = new Cache;
|
||||
}
|
||||
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache
|
||||
*
|
||||
* @param CacheInterface $cache
|
||||
*/
|
||||
public function setCache(CacheInterface $cache)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
}
|
||||
}
|
62
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/Cache.php
vendored
Normal file
62
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/Cache.php
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver\Cache;
|
||||
|
||||
class Cache implements CacheInterface
|
||||
{
|
||||
private $cache = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exists($placeholder)
|
||||
{
|
||||
if (is_array($placeholder)) {
|
||||
throw new \RuntimeException('Placeholder is an array');
|
||||
}
|
||||
|
||||
return array_key_exists((string) $placeholder, $this->cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($placeholder)
|
||||
{
|
||||
if (is_array($placeholder)) {
|
||||
throw new \RuntimeException('Placeholder is an array');
|
||||
}
|
||||
|
||||
return array_key_exists((string) $placeholder, $this->cache)
|
||||
? $this->cache[(string) $placeholder]
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($placeholder, $value = null)
|
||||
{
|
||||
if (is_array($placeholder)) {
|
||||
throw new \RuntimeException('Placeholder is an array');
|
||||
}
|
||||
$this->cache[(string) $placeholder] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->cache = array();
|
||||
}
|
||||
}
|
48
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/CacheInterface.php
vendored
Normal file
48
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/CacheInterface.php
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver\Cache;
|
||||
|
||||
interface CacheInterface
|
||||
{
|
||||
/**
|
||||
* Does specified placeholder exist?
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($placeholder);
|
||||
|
||||
/**
|
||||
* Get placeholder's value
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($placeholder);
|
||||
|
||||
/**
|
||||
* Set placeholder's value
|
||||
*
|
||||
* @param string $placeholder
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function set($placeholder, $value = null);
|
||||
|
||||
/**
|
||||
* Flush cache
|
||||
*/
|
||||
public function flush();
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver\DataSource;
|
||||
|
||||
/**
|
||||
* Array Data Source
|
||||
*
|
||||
* Simple array based implementation of the Data Source Interface
|
||||
*
|
||||
* @author Beau Simensen <beau@dflydev.com>
|
||||
*/
|
||||
class ArrayDataSource implements DataSourceInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $array;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function __construct(array $array = array())
|
||||
{
|
||||
$this->array = $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exists($key, $system = false)
|
||||
{
|
||||
if ($system) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($this->array[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($key, $system = false)
|
||||
{
|
||||
if ($system) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return isset($this->array[$key]) ? $this->array[$key] : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver\DataSource;
|
||||
|
||||
interface DataSourceInterface
|
||||
{
|
||||
/**
|
||||
* Does specified key exist?
|
||||
*
|
||||
* If $system is true, check system data. Otherwise,
|
||||
* use application data. (think system == $_SERVER)
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool|null $system
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key, $system = false);
|
||||
|
||||
/**
|
||||
* Get key's value
|
||||
*
|
||||
* If $system is true, check system data. Otherwise,
|
||||
* use application data. (think system == $_SERVER)
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool|null $system
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($key, $system = false);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver;
|
||||
|
||||
interface PlaceholderResolverInterface
|
||||
{
|
||||
/**
|
||||
* Resolve a placeholder
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function resolvePlaceholder($placeholder);
|
||||
}
|
69
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/RegexPlaceholderResolver.php
vendored
Normal file
69
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/RegexPlaceholderResolver.php
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver;
|
||||
|
||||
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
|
||||
|
||||
class RegexPlaceholderResolver extends AbstractPlaceholderResolver
|
||||
{
|
||||
/**
|
||||
* @var PlaceholderResolverCallback
|
||||
*/
|
||||
private $placeholderResolverCallback;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pattern;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DataSourceInterface $dataSource
|
||||
* @param string|null $placeholderPrefix
|
||||
* @param string|null $placeholderSuffix
|
||||
*/
|
||||
public function __construct(DataSourceInterface $dataSource, $placeholderPrefix = '${', $placeholderSuffix = '}')
|
||||
{
|
||||
$this->placeholderResolverCallback = new RegexPlaceholderResolverCallback($dataSource);
|
||||
$placeholderPrefix = preg_quote($placeholderPrefix);
|
||||
$placeholderSuffix = preg_quote($placeholderSuffix);
|
||||
$this->pattern = "/{$placeholderPrefix}([a-zA-Z0-9\.\(\)_\:]+?){$placeholderSuffix}/";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolvePlaceholder($placeholder)
|
||||
{
|
||||
if ($this->getCache()->exists($placeholder)) {
|
||||
return $this->getCache()->get($placeholder);
|
||||
}
|
||||
|
||||
$value = $placeholder;
|
||||
$counter = 0;
|
||||
|
||||
while ($counter++ < $this->maxReplacementDepth) {
|
||||
$newValue = preg_replace_callback(
|
||||
$this->pattern,
|
||||
array($this->placeholderResolverCallback, 'callback'),
|
||||
$value
|
||||
);
|
||||
if ($newValue === $value) { break; }
|
||||
$value = $newValue;
|
||||
}
|
||||
|
||||
$this->getCache()->set($placeholder, $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Dflydev\PlaceholderResolver;
|
||||
|
||||
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
|
||||
|
||||
class RegexPlaceholderResolverCallback
|
||||
{
|
||||
/**
|
||||
* @var DataSourceInterface
|
||||
*/
|
||||
private $dataSource;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DataSourceInterface $dataSource
|
||||
*/
|
||||
public function __construct(DataSourceInterface $dataSource)
|
||||
{
|
||||
$this->dataSource = $dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for preg_replace_callback() generally called in PlaceholderResolver
|
||||
*
|
||||
* The expected input will be array($fullMatch, $potentialKey) and the
|
||||
* expected output will be either a value from the data source, a special
|
||||
* value from SERVER or CONSTANT, or the contents of $fullMatch (the key
|
||||
* itself with its wrapped prefix and suffix).
|
||||
*
|
||||
* @param array $matches
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function callback($matches)
|
||||
{
|
||||
list ($fullMatch, $potentialKey) = $matches;
|
||||
if (preg_match('/^(SYSTEM|SERVER|CONSTANT):(\w+)$/', $potentialKey, $specialMatches)) {
|
||||
list ($dummy, $which, $specialKey) = $specialMatches;
|
||||
switch ($which) {
|
||||
case 'SERVER':
|
||||
case 'SYSTEM':
|
||||
if ($this->dataSource->exists($specialKey, true)) {
|
||||
return $this->dataSource->get($specialKey, true);
|
||||
}
|
||||
break;
|
||||
case 'CONSTANT':
|
||||
if (defined($specialKey)) {
|
||||
return constant($specialKey);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->dataSource->exists($potentialKey)) {
|
||||
return $this->dataSource->get($potentialKey);
|
||||
}
|
||||
|
||||
return $fullMatch;
|
||||
}
|
||||
}
|
Reference in a new issue