update v 1.0.7.5

This commit is contained in:
Sujit Prasad
2016-06-13 20:41:55 +05:30
parent aa9786d829
commit 283d97e3ea
5078 changed files with 339851 additions and 175995 deletions

View File

@@ -1,53 +1,52 @@
<?php namespace Illuminate\Support;
<?php
class AggregateServiceProvider extends ServiceProvider {
namespace Illuminate\Support;
/**
* The provider class names.
*
* @var array
*/
protected $providers = [];
class AggregateServiceProvider extends ServiceProvider
{
/**
* The provider class names.
*
* @var array
*/
protected $providers = [];
/**
* An array of the service provider instances.
*
* @var array
*/
protected $instances = [];
/**
* An array of the service provider instances.
*
* @var array
*/
protected $instances = [];
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->instances = [];
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->instances = [];
foreach ($this->providers as $provider)
{
$this->instances[] = $this->app->register($provider);
}
}
foreach ($this->providers as $provider) {
$this->instances[] = $this->app->register($provider);
}
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
$provides = [];
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
$provides = [];
foreach ($this->providers as $provider)
{
$instance = $this->app->resolveProviderClass($provider);
foreach ($this->providers as $provider) {
$instance = $this->app->resolveProviderClass($provider);
$provides = array_merge($provides, $instance->provides());
}
return $provides;
}
$provides = array_merge($provides, $instance->provides());
}
return $provides;
}
}

View File

@@ -1,407 +1,528 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use ArrayAccess;
use Illuminate\Support\Traits\Macroable;
class Arr {
class Arr
{
use Macroable;
use Macroable;
/**
* Determine whether the given value is array accessible.
*
* @param mixed $value
* @return bool
*/
public static function accessible($value)
{
return is_array($value) || $value instanceof ArrayAccess;
}
/**
* Add an element to an array using "dot" notation if it doesn't exist.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
public static function add($array, $key, $value)
{
if (is_null(static::get($array, $key)))
{
static::set($array, $key, $value);
}
/**
* Add an element to an array using "dot" notation if it doesn't exist.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
public static function add($array, $key, $value)
{
if (is_null(static::get($array, $key))) {
static::set($array, $key, $value);
}
return $array;
}
return $array;
}
/**
* Build a new array using a callback.
*
* @param array $array
* @param callable $callback
* @return array
*/
public static function build($array, callable $callback)
{
$results = [];
/**
* Build a new array using a callback.
*
* @param array $array
* @param callable $callback
* @return array
*
* @deprecated since version 5.2.
*/
public static function build($array, callable $callback)
{
$results = [];
foreach ($array as $key => $value)
{
list($innerKey, $innerValue) = call_user_func($callback, $key, $value);
foreach ($array as $key => $value) {
list($innerKey, $innerValue) = call_user_func($callback, $key, $value);
$results[$innerKey] = $innerValue;
}
$results[$innerKey] = $innerValue;
}
return $results;
}
return $results;
}
/**
* Collapse an array of arrays into a single array.
*
* @param array|\ArrayAccess $array
* @return array
*/
public static function collapse($array)
{
$results = [];
/**
* Collapse an array of arrays into a single array.
*
* @param array $array
* @return array
*/
public static function collapse($array)
{
$results = [];
foreach ($array as $values)
{
if ($values instanceof Collection) $values = $values->all();
foreach ($array as $values) {
if ($values instanceof Collection) {
$values = $values->all();
} elseif (! is_array($values)) {
continue;
}
$results = array_merge($results, $values);
}
$results = array_merge($results, $values);
}
return $results;
}
return $results;
}
/**
* Divide an array into two arrays. One with keys and the other with values.
*
* @param array $array
* @return array
*/
public static function divide($array)
{
return [array_keys($array), array_values($array)];
}
/**
* Divide an array into two arrays. One with keys and the other with values.
*
* @param array $array
* @return array
*/
public static function divide($array)
{
return [array_keys($array), array_values($array)];
}
/**
* Flatten a multi-dimensional associative array with dots.
*
* @param array $array
* @param string $prepend
* @return array
*/
public static function dot($array, $prepend = '')
{
$results = [];
/**
* Flatten a multi-dimensional associative array with dots.
*
* @param array $array
* @param string $prepend
* @return array
*/
public static function dot($array, $prepend = '')
{
$results = [];
foreach ($array as $key => $value)
{
if (is_array($value))
{
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
}
else
{
$results[$prepend.$key] = $value;
}
}
foreach ($array as $key => $value) {
if (is_array($value) && ! empty($value)) {
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
} else {
$results[$prepend.$key] = $value;
}
}
return $results;
}
return $results;
}
/**
* Get all of the given array except for a specified array of items.
*
* @param array $array
* @param array|string $keys
* @return array
*/
public static function except($array, $keys)
{
static::forget($array, $keys);
/**
* Get all of the given array except for a specified array of items.
*
* @param array $array
* @param array|string $keys
* @return array
*/
public static function except($array, $keys)
{
static::forget($array, $keys);
return $array;
}
return $array;
}
/**
* Fetch a flattened array of a nested array element.
*
* @param array $array
* @param string $key
* @return array
*/
public static function fetch($array, $key)
{
foreach (explode('.', $key) as $segment)
{
$results = [];
/**
* Determine if the given key exists in the provided array.
*
* @param \ArrayAccess|array $array
* @param string|int $key
* @return bool
*/
public static function exists($array, $key)
{
if ($array instanceof ArrayAccess) {
return $array->offsetExists($key);
}
foreach ($array as $value)
{
if (array_key_exists($segment, $value = (array) $value))
{
$results[] = $value[$segment];
}
}
return array_key_exists($key, $array);
}
$array = array_values($results);
}
/**
* Return the first element in an array passing a given truth test.
*
* @param array $array
* @param callable|null $callback
* @param mixed $default
* @return mixed
*/
public static function first($array, callable $callback = null, $default = null)
{
if (is_null($callback)) {
return empty($array) ? value($default) : reset($array);
}
return array_values($results);
}
foreach ($array as $key => $value) {
if (call_user_func($callback, $key, $value)) {
return $value;
}
}
/**
* Return the first element in an array passing a given truth test.
*
* @param array $array
* @param callable $callback
* @param mixed $default
* @return mixed
*/
public static function first($array, callable $callback, $default = null)
{
foreach ($array as $key => $value)
{
if (call_user_func($callback, $key, $value)) return $value;
}
return value($default);
}
return value($default);
}
/**
* Return the last element in an array passing a given truth test.
*
* @param array $array
* @param callable|null $callback
* @param mixed $default
* @return mixed
*/
public static function last($array, callable $callback = null, $default = null)
{
if (is_null($callback)) {
return empty($array) ? value($default) : end($array);
}
/**
* Return the last element in an array passing a given truth test.
*
* @param array $array
* @param callable $callback
* @param mixed $default
* @return mixed
*/
public static function last($array, callable $callback, $default = null)
{
return static::first(array_reverse($array), $callback, $default);
}
return static::first(array_reverse($array), $callback, $default);
}
/**
* Flatten a multi-dimensional array into a single level.
*
* @param array $array
* @return array
*/
public static function flatten($array)
{
$return = [];
/**
* Flatten a multi-dimensional array into a single level.
*
* @param array $array
* @param int $depth
* @return array
*/
public static function flatten($array, $depth = INF)
{
$result = [];
array_walk_recursive($array, function($x) use (&$return) { $return[] = $x; });
foreach ($array as $item) {
$item = $item instanceof Collection ? $item->all() : $item;
return $return;
}
if (is_array($item)) {
if ($depth === 1) {
$result = array_merge($result, $item);
continue;
}
/**
* Remove one or many array items from a given array using "dot" notation.
*
* @param array $array
* @param array|string $keys
* @return void
*/
public static function forget(&$array, $keys)
{
$original =& $array;
$result = array_merge($result, static::flatten($item, $depth - 1));
continue;
}
foreach ((array) $keys as $key)
{
$parts = explode('.', $key);
$result[] = $item;
}
while (count($parts) > 1)
{
$part = array_shift($parts);
return $result;
}
if (isset($array[$part]) && is_array($array[$part]))
{
$array =& $array[$part];
}
}
/**
* Remove one or many array items from a given array using "dot" notation.
*
* @param array $array
* @param array|string $keys
* @return void
*/
public static function forget(&$array, $keys)
{
$original = &$array;
unset($array[array_shift($parts)]);
$keys = (array) $keys;
// clean up after each pass
$array =& $original;
}
}
if (count($keys) === 0) {
return;
}
/**
* Get an item from an array using "dot" notation.
*
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get($array, $key, $default = null)
{
if (is_null($key)) return $array;
foreach ($keys as $key) {
// if the exact key exists in the top-level, remove it
if (static::exists($array, $key)) {
unset($array[$key]);
if (isset($array[$key])) return $array[$key];
continue;
}
foreach (explode('.', $key) as $segment)
{
if ( ! is_array($array) || ! array_key_exists($segment, $array))
{
return value($default);
}
$parts = explode('.', $key);
$array = $array[$segment];
}
// clean up before each pass
$array = &$original;
return $array;
}
while (count($parts) > 1) {
$part = array_shift($parts);
/**
* Check if an item exists in an array using "dot" notation.
*
* @param array $array
* @param string $key
* @return bool
*/
public static function has($array, $key)
{
if (empty($array) || is_null($key)) return false;
if (isset($array[$part]) && is_array($array[$part])) {
$array = &$array[$part];
} else {
continue 2;
}
}
if (array_key_exists($key, $array)) return true;
unset($array[array_shift($parts)]);
}
}
foreach (explode('.', $key) as $segment)
{
if ( ! is_array($array) || ! array_key_exists($segment, $array))
{
return false;
}
/**
* Get an item from an array using "dot" notation.
*
* @param \ArrayAccess|array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get($array, $key, $default = null)
{
if (! static::accessible($array)) {
return value($default);
}
$array = $array[$segment];
}
if (is_null($key)) {
return $array;
}
return true;
}
if (static::exists($array, $key)) {
return $array[$key];
}
/**
* Get a subset of the items from the given array.
*
* @param array $array
* @param array|string $keys
* @return array
*/
public static function only($array, $keys)
{
return array_intersect_key($array, array_flip((array) $keys));
}
foreach (explode('.', $key) as $segment) {
if (static::accessible($array) && static::exists($array, $segment)) {
$array = $array[$segment];
} else {
return value($default);
}
}
/**
* Pluck an array of values from an array.
*
* @param array $array
* @param string $value
* @param string $key
* @return array
*/
public static function pluck($array, $value, $key = null)
{
$results = [];
return $array;
}
foreach ($array as $item)
{
$itemValue = data_get($item, $value);
/**
* Check if an item exists in an array using "dot" notation.
*
* @param \ArrayAccess|array $array
* @param string $key
* @return bool
*/
public static function has($array, $key)
{
if (! $array) {
return false;
}
// If the key is "null", we will just append the value to the array and keep
// looping. Otherwise we will key the array using the value of the key we
// received from the developer. Then we'll return the final array form.
if (is_null($key))
{
$results[] = $itemValue;
}
else
{
$itemKey = data_get($item, $key);
if (is_null($key)) {
return false;
}
$results[$itemKey] = $itemValue;
}
}
if (static::exists($array, $key)) {
return true;
}
return $results;
}
foreach (explode('.', $key) as $segment) {
if (static::accessible($array) && static::exists($array, $segment)) {
$array = $array[$segment];
} else {
return false;
}
}
/**
* Get a value from the array, and remove it.
*
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function pull(&$array, $key, $default = null)
{
$value = static::get($array, $key, $default);
return true;
}
static::forget($array, $key);
/**
* Determines if an array is associative.
*
* An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
*
* @param array $array
* @return bool
*/
public static function isAssoc(array $array)
{
$keys = array_keys($array);
return $value;
}
return array_keys($keys) !== $keys;
}
/**
* Set an array item to a given value using "dot" notation.
*
* If no key is given to the method, the entire array will be replaced.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
public static function set(&$array, $key, $value)
{
if (is_null($key)) return $array = $value;
/**
* Get a subset of the items from the given array.
*
* @param array $array
* @param array|string $keys
* @return array
*/
public static function only($array, $keys)
{
return array_intersect_key($array, array_flip((array) $keys));
}
$keys = explode('.', $key);
/**
* Pluck an array of values from an array.
*
* @param array $array
* @param string|array $value
* @param string|array|null $key
* @return array
*/
public static function pluck($array, $value, $key = null)
{
$results = [];
while (count($keys) > 1)
{
$key = array_shift($keys);
list($value, $key) = static::explodePluckParameters($value, $key);
// If the key doesn't exist at this depth, we will just create an empty array
// to hold the next value, allowing us to create the arrays to hold final
// values at the correct depth. Then we'll keep digging into the array.
if ( ! isset($array[$key]) || ! is_array($array[$key]))
{
$array[$key] = [];
}
foreach ($array as $item) {
$itemValue = data_get($item, $value);
$array =& $array[$key];
}
// If the key is "null", we will just append the value to the array and keep
// looping. Otherwise we will key the array using the value of the key we
// received from the developer. Then we'll return the final array form.
if (is_null($key)) {
$results[] = $itemValue;
} else {
$itemKey = data_get($item, $key);
$array[array_shift($keys)] = $value;
$results[$itemKey] = $itemValue;
}
}
return $array;
}
return $results;
}
/**
* Sort the array using the given callback.
*
* @param array $array
* @param callable $callback
* @return array
*/
public static function sort($array, callable $callback)
{
return Collection::make($array)->sortBy($callback)->all();
}
/**
* Explode the "value" and "key" arguments passed to "pluck".
*
* @param string|array $value
* @param string|array|null $key
* @return array
*/
protected static function explodePluckParameters($value, $key)
{
$value = is_string($value) ? explode('.', $value) : $value;
/**
* Filter the array using the given callback.
*
* @param array $array
* @param callable $callback
* @return array
*/
public static function where($array, callable $callback)
{
$filtered = [];
$key = is_null($key) || is_array($key) ? $key : explode('.', $key);
foreach ($array as $key => $value)
{
if (call_user_func($callback, $key, $value)) $filtered[$key] = $value;
}
return [$value, $key];
}
return $filtered;
}
/**
* Push an item onto the beginning of an array.
*
* @param array $array
* @param mixed $value
* @param mixed $key
* @return array
*/
public static function prepend($array, $value, $key = null)
{
if (is_null($key)) {
array_unshift($array, $value);
} else {
$array = [$key => $value] + $array;
}
return $array;
}
/**
* Get a value from the array, and remove it.
*
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function pull(&$array, $key, $default = null)
{
$value = static::get($array, $key, $default);
static::forget($array, $key);
return $value;
}
/**
* Set an array item to a given value using "dot" notation.
*
* If no key is given to the method, the entire array will be replaced.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
public static function set(&$array, $key, $value)
{
if (is_null($key)) {
return $array = $value;
}
$keys = explode('.', $key);
while (count($keys) > 1) {
$key = array_shift($keys);
// If the key doesn't exist at this depth, we will just create an empty array
// to hold the next value, allowing us to create the arrays to hold final
// values at the correct depth. Then we'll keep digging into the array.
if (! isset($array[$key]) || ! is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
$array[array_shift($keys)] = $value;
return $array;
}
/**
* Sort the array using the given callback.
*
* @param array $array
* @param callable $callback
* @return array
*/
public static function sort($array, callable $callback)
{
return Collection::make($array)->sortBy($callback)->all();
}
/**
* Recursively sort an array by keys and values.
*
* @param array $array
* @return array
*/
public static function sortRecursive($array)
{
foreach ($array as &$value) {
if (is_array($value)) {
$value = static::sortRecursive($value);
}
}
if (static::isAssoc($array)) {
ksort($array);
} else {
sort($array);
}
return $array;
}
/**
* Filter the array using the given callback.
*
* @param array $array
* @param callable $callback
* @return array
*/
public static function where($array, callable $callback)
{
$filtered = [];
foreach ($array as $key => $value) {
if (call_user_func($callback, $key, $value)) {
$filtered[$key] = $value;
}
}
return $filtered;
}
}

View File

@@ -1,107 +1,104 @@
<?php namespace Illuminate\Support;
<?php
class ClassLoader {
namespace Illuminate\Support;
/**
* The registered directories.
*
* @var array
*/
protected static $directories = array();
class ClassLoader
{
/**
* The registered directories.
*
* @var array
*/
protected static $directories = [];
/**
* Indicates if a ClassLoader has been registered.
*
* @var bool
*/
protected static $registered = false;
/**
* Indicates if a ClassLoader has been registered.
*
* @var bool
*/
protected static $registered = false;
/**
* Load the given class file.
*
* @param string $class
* @return bool
*/
public static function load($class)
{
$class = static::normalizeClass($class);
/**
* Load the given class file.
*
* @param string $class
* @return bool
*/
public static function load($class)
{
$class = static::normalizeClass($class);
foreach (static::$directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$class))
{
require_once $path;
foreach (static::$directories as $directory) {
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$class)) {
require_once $path;
return true;
}
}
return true;
}
}
return false;
}
return false;
}
/**
* Get the normal file name for a class.
*
* @param string $class
* @return string
*/
public static function normalizeClass($class)
{
if ($class[0] == '\\') $class = substr($class, 1);
/**
* Get the normal file name for a class.
*
* @param string $class
* @return string
*/
public static function normalizeClass($class)
{
if ($class[0] == '\\') {
$class = substr($class, 1);
}
return str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class).'.php';
}
return str_replace(['\\', '_'], DIRECTORY_SEPARATOR, $class).'.php';
}
/**
* Register the given class loader on the auto-loader stack.
*
* @return void
*/
public static function register()
{
if ( ! static::$registered)
{
static::$registered = spl_autoload_register(array('\Illuminate\Support\ClassLoader', 'load'));
}
}
/**
* Register the given class loader on the auto-loader stack.
*
* @return void
*/
public static function register()
{
if (! static::$registered) {
static::$registered = spl_autoload_register([static::class, 'load']);
}
}
/**
* Add directories to the class loader.
*
* @param string|array $directories
* @return void
*/
public static function addDirectories($directories)
{
static::$directories = array_unique(array_merge(static::$directories, (array) $directories));
}
/**
* Add directories to the class loader.
*
* @param string|array $directories
* @return void
*/
public static function addDirectories($directories)
{
static::$directories = array_unique(array_merge(static::$directories, (array) $directories));
}
/**
* Remove directories from the class loader.
*
* @param string|array $directories
* @return void
*/
public static function removeDirectories($directories = null)
{
if (is_null($directories))
{
static::$directories = array();
}
else
{
static::$directories = array_diff(static::$directories, (array) $directories);
}
}
/**
* Gets all the directories registered with the loader.
*
* @return array
*/
public static function getDirectories()
{
return static::$directories;
}
/**
* Remove directories from the class loader.
*
* @param string|array $directories
* @return void
*/
public static function removeDirectories($directories = null)
{
if (is_null($directories)) {
static::$directories = [];
} else {
static::$directories = array_diff(static::$directories, (array) $directories);
}
}
/**
* Gets all the directories registered with the loader.
*
* @return array
*/
public static function getDirectories()
{
return static::$directories;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
<?php
namespace Illuminate\Support;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessUtils;
use Symfony\Component\Process\PhpExecutableFinder;
class Composer
{
/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* The working path to regenerate from.
*
* @var string
*/
protected $workingPath;
/**
* Create a new Composer manager instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string|null $workingPath
* @return void
*/
public function __construct(Filesystem $files, $workingPath = null)
{
$this->files = $files;
$this->workingPath = $workingPath;
}
/**
* Regenerate the Composer autoloader files.
*
* @param string $extra
* @return void
*/
public function dumpAutoloads($extra = '')
{
$process = $this->getProcess();
$process->setCommandLine(trim($this->findComposer().' dump-autoload '.$extra));
$process->run();
}
/**
* Regenerate the optimized Composer autoloader files.
*
* @return void
*/
public function dumpOptimized()
{
$this->dumpAutoloads('--optimize');
}
/**
* Get the composer command for the environment.
*
* @return string
*/
protected function findComposer()
{
if (! $this->files->exists($this->workingPath.'/composer.phar')) {
return 'composer';
}
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
if (defined('HHVM_VERSION')) {
$binary .= ' --php';
}
return "{$binary} composer.phar";
}
/**
* Get a new Symfony process instance.
*
* @return \Symfony\Component\Process\Process
*/
protected function getProcess()
{
return (new Process('', $this->workingPath))->setTimeout(null);
}
/**
* Set the working path used by the class.
*
* @param string $path
* @return $this
*/
public function setWorkingPath($path)
{
$this->workingPath = realpath($path);
return $this;
}
}

View File

@@ -1,21 +1,26 @@
<?php namespace Illuminate\Support\Debug;
<?php
namespace Illuminate\Support\Debug;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Cloner\VarCloner;
class Dumper {
/**
* Dump a value with elegance.
*
* @param mixed $value
* @return void
*/
public function dump($value)
{
$dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
$dumper->dump((new VarCloner)->cloneVar($value));
}
class Dumper
{
/**
* Dump a value with elegance.
*
* @param mixed $value
* @return void
*/
public function dump($value)
{
if (class_exists(CliDumper::class)) {
$dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
$dumper->dump((new VarCloner)->cloneVar($value));
} else {
var_dump($value);
}
}
}

View File

@@ -1,28 +1,29 @@
<?php namespace Illuminate\Support\Debug;
<?php
namespace Illuminate\Support\Debug;
use Symfony\Component\VarDumper\Dumper\HtmlDumper as SymfonyHtmlDumper;
class HtmlDumper extends SymfonyHtmlDumper {
/**
* Colour definitions for output.
*
* @var array
*/
protected $styles = array(
'default' => 'background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
'num' => 'color:#a71d5d',
'const' => 'color:#795da3',
'str' => 'color:#df5000',
'cchr' => 'color:#222',
'note' => 'color:#a71d5d',
'ref' => 'color:#a0a0a0',
'public' => 'color:#795da3',
'protected' => 'color:#795da3',
'private' => 'color:#795da3',
'meta' => 'color:#b729d9',
'key' => 'color:#df5000',
'index' => 'color:#a71d5d',
);
class HtmlDumper extends SymfonyHtmlDumper
{
/**
* Colour definitions for output.
*
* @var array
*/
protected $styles = [
'default' => 'background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
'num' => 'color:#a71d5d',
'const' => 'color:#795da3',
'str' => 'color:#df5000',
'cchr' => 'color:#222',
'note' => 'color:#a71d5d',
'ref' => 'color:#a0a0a0',
'public' => 'color:#795da3',
'protected' => 'color:#795da3',
'private' => 'color:#795da3',
'meta' => 'color:#b729d9',
'key' => 'color:#df5000',
'index' => 'color:#a71d5d',
];
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Foundation\Application
*/
class App extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'app';
}
class App extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'app';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Foundation\Artisan
* @see \Illuminate\Contracts\Console\Kernel
*/
class Artisan extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Console\Kernel';
}
class Artisan extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Console\Kernel';
}
}

View File

@@ -1,19 +1,22 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Auth\AuthManager
* @see \Illuminate\Auth\Guard
* @see \Illuminate\Contracts\Auth\Factory
* @see \Illuminate\Contracts\Auth\Guard
* @see \Illuminate\Contracts\Auth\StatefulGuard
*/
class Auth extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'auth';
}
class Auth extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'auth';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\View\Compilers\BladeCompiler
*/
class Blade extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return static::$app['view']->getEngineResolver()->resolve('blade')->getCompiler();
}
class Blade extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return static::$app['view']->getEngineResolver()->resolve('blade')->getCompiler();
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Bus\Dispatcher
* @see \Illuminate\Contracts\Bus\Dispatcher
*/
class Bus extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Bus\Dispatcher';
}
class Bus extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Bus\Dispatcher';
}
}

View File

@@ -1,19 +1,20 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Cache\CacheManager
* @see \Illuminate\Cache\Repository
*/
class Cache extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'cache';
}
class Cache extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'cache';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Config\Repository
*/
class Config extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'config';
}
class Config extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'config';
}
}

View File

@@ -1,41 +1,42 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Cookie\CookieJar
*/
class Cookie extends Facade {
class Cookie extends Facade
{
/**
* Determine if a cookie exists on the request.
*
* @param string $key
* @return bool
*/
public static function has($key)
{
return ! is_null(static::$app['request']->cookie($key, null));
}
/**
* Determine if a cookie exists on the request.
*
* @param string $key
* @return bool
*/
public static function has($key)
{
return ! is_null(static::$app['request']->cookie($key, null));
}
/**
* Retrieve a cookie from the request.
*
* @param string $key
* @param mixed $default
* @return string
*/
public static function get($key = null, $default = null)
{
return static::$app['request']->cookie($key, $default);
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'cookie';
}
/**
* Retrieve a cookie from the request.
*
* @param string $key
* @param mixed $default
* @return string
*/
public static function get($key = null, $default = null)
{
return static::$app['request']->cookie($key, $default);
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'cookie';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Encryption\Encrypter
*/
class Crypt extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'encrypter';
}
class Crypt extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'encrypter';
}
}

View File

@@ -1,19 +1,20 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Database\DatabaseManager
* @see \Illuminate\Database\Connection
*/
class DB extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'db';
}
class DB extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'db';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Events\Dispatcher
*/
class Event extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'events';
}
class Event extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'events';
}
}

View File

@@ -1,226 +1,228 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
use Mockery;
use RuntimeException;
use Mockery\MockInterface;
abstract class Facade {
abstract class Facade
{
/**
* The application instance being facaded.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected static $app;
/**
* The application instance being facaded.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected static $app;
/**
* The resolved object instances.
*
* @var array
*/
protected static $resolvedInstance;
/**
* The resolved object instances.
*
* @var array
*/
protected static $resolvedInstance;
/**
* Hotswap the underlying instance behind the facade.
*
* @param mixed $instance
* @return void
*/
public static function swap($instance)
{
static::$resolvedInstance[static::getFacadeAccessor()] = $instance;
/**
* Hotswap the underlying instance behind the facade.
*
* @param mixed $instance
* @return void
*/
public static function swap($instance)
{
static::$resolvedInstance[static::getFacadeAccessor()] = $instance;
static::$app->instance(static::getFacadeAccessor(), $instance);
}
static::$app->instance(static::getFacadeAccessor(), $instance);
}
/**
* Initiate a mock expectation on the facade.
*
* @param mixed
* @return \Mockery\Expectation
*/
public static function shouldReceive()
{
$name = static::getFacadeAccessor();
/**
* Initiate a mock expectation on the facade.
*
* @param mixed
* @return \Mockery\Expectation
*/
public static function shouldReceive()
{
$name = static::getFacadeAccessor();
if (static::isMock()) {
$mock = static::$resolvedInstance[$name];
} else {
$mock = static::createFreshMockInstance($name);
}
if (static::isMock())
{
$mock = static::$resolvedInstance[$name];
}
else
{
$mock = static::createFreshMockInstance($name);
}
return call_user_func_array([$mock, 'shouldReceive'], func_get_args());
}
return call_user_func_array(array($mock, 'shouldReceive'), func_get_args());
}
/**
* Create a fresh mock instance for the given class.
*
* @param string $name
* @return \Mockery\Expectation
*/
protected static function createFreshMockInstance($name)
{
static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
/**
* Create a fresh mock instance for the given class.
*
* @param string $name
* @return \Mockery\Expectation
*/
protected static function createFreshMockInstance($name)
{
static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
$mock->shouldAllowMockingProtectedMethods();
if (isset(static::$app))
{
static::$app->instance($name, $mock);
}
if (isset(static::$app)) {
static::$app->instance($name, $mock);
}
return $mock;
}
return $mock;
}
/**
* Create a fresh mock instance for the given class.
*
* @param string $name
* @return \Mockery\Expectation
*/
protected static function createMockByName($name)
{
$class = static::getMockableClass($name);
/**
* Create a fresh mock instance for the given class.
*
* @param string $name
* @return \Mockery\Expectation
*/
protected static function createMockByName($name)
{
$class = static::getMockableClass($name);
return $class ? Mockery::mock($class) : Mockery::mock();
}
return $class ? Mockery::mock($class) : Mockery::mock();
}
/**
* Determines whether a mock is set as the instance of the facade.
*
* @return bool
*/
protected static function isMock()
{
$name = static::getFacadeAccessor();
/**
* Determines whether a mock is set as the instance of the facade.
*
* @return bool
*/
protected static function isMock()
{
$name = static::getFacadeAccessor();
return isset(static::$resolvedInstance[$name]) && static::$resolvedInstance[$name] instanceof MockInterface;
}
return isset(static::$resolvedInstance[$name]) && static::$resolvedInstance[$name] instanceof MockInterface;
}
/**
* Get the mockable class for the bound instance.
*
* @return string
*/
protected static function getMockableClass()
{
if ($root = static::getFacadeRoot()) return get_class($root);
}
/**
* Get the mockable class for the bound instance.
*
* @return string|null
*/
protected static function getMockableClass()
{
if ($root = static::getFacadeRoot()) {
return get_class($root);
}
}
/**
* Get the root object behind the facade.
*
* @return mixed
*/
public static function getFacadeRoot()
{
return static::resolveFacadeInstance(static::getFacadeAccessor());
}
/**
* Get the root object behind the facade.
*
* @return mixed
*/
public static function getFacadeRoot()
{
return static::resolveFacadeInstance(static::getFacadeAccessor());
}
/**
* Get the registered name of the component.
*
* @return string
*
* @throws \RuntimeException
*/
protected static function getFacadeAccessor()
{
throw new RuntimeException("Facade does not implement getFacadeAccessor method.");
}
/**
* Get the registered name of the component.
*
* @return string
*
* @throws \RuntimeException
*/
protected static function getFacadeAccessor()
{
throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
}
/**
* Resolve the facade root instance from the container.
*
* @param string $name
* @return mixed
*/
protected static function resolveFacadeInstance($name)
{
if (is_object($name)) return $name;
/**
* Resolve the facade root instance from the container.
*
* @param string|object $name
* @return mixed
*/
protected static function resolveFacadeInstance($name)
{
if (is_object($name)) {
return $name;
}
if (isset(static::$resolvedInstance[$name]))
{
return static::$resolvedInstance[$name];
}
if (isset(static::$resolvedInstance[$name])) {
return static::$resolvedInstance[$name];
}
return static::$resolvedInstance[$name] = static::$app[$name];
}
return static::$resolvedInstance[$name] = static::$app[$name];
}
/**
* Clear a resolved facade instance.
*
* @param string $name
* @return void
*/
public static function clearResolvedInstance($name)
{
unset(static::$resolvedInstance[$name]);
}
/**
* Clear a resolved facade instance.
*
* @param string $name
* @return void
*/
public static function clearResolvedInstance($name)
{
unset(static::$resolvedInstance[$name]);
}
/**
* Clear all of the resolved instances.
*
* @return void
*/
public static function clearResolvedInstances()
{
static::$resolvedInstance = array();
}
/**
* Clear all of the resolved instances.
*
* @return void
*/
public static function clearResolvedInstances()
{
static::$resolvedInstance = [];
}
/**
* Get the application instance behind the facade.
*
* @return \Illuminate\Contracts\Foundation\Application
*/
public static function getFacadeApplication()
{
return static::$app;
}
/**
* Get the application instance behind the facade.
*
* @return \Illuminate\Contracts\Foundation\Application
*/
public static function getFacadeApplication()
{
return static::$app;
}
/**
* Set the application instance.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public static function setFacadeApplication($app)
{
static::$app = $app;
}
/**
* Set the application instance.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public static function setFacadeApplication($app)
{
static::$app = $app;
}
/**
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$instance = static::getFacadeRoot();
/**
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array $args
* @return mixed
*
* @throws \RuntimeException
*/
public static function __callStatic($method, $args)
{
$instance = static::getFacadeRoot();
switch (count($args))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
return $instance->$method($args[0], $args[1], $args[2]);
case 4:
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
default:
return call_user_func_array(array($instance, $method), $args);
}
}
if (! $instance) {
throw new RuntimeException('A facade root has not been set.');
}
switch (count($args)) {
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
return $instance->$method($args[0], $args[1], $args[2]);
case 4:
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
default:
return call_user_func_array([$instance, $method], $args);
}
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Filesystem\Filesystem
*/
class File extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'files';
}
class File extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'files';
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Contracts\Auth\Access\Gate
*/
class Gate extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Auth\Access\Gate';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Hashing\BcryptHasher
*/
class Hash extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'hash';
}
class Hash extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'hash';
}
}

View File

@@ -1,32 +1,33 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Http\Request
*/
class Input extends Facade {
/**
* Get an item from the input data.
*
* This method is used for all request verbs (GET, POST, PUT, and DELETE)
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get($key = null, $default = null)
{
return static::$app['request']->input($key, $default);
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'request';
}
class Input extends Facade
{
/**
* Get an item from the input data.
*
* This method is used for all request verbs (GET, POST, PUT, and DELETE)
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get($key = null, $default = null)
{
return static::$app['request']->input($key, $default);
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'request';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Translation\Translator
*/
class Lang extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'translator';
}
class Lang extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'translator';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Log\Writer
*/
class Log extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'log';
}
class Log extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'log';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Mail\Mailer
*/
class Mail extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'mailer';
}
class Mail extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'mailer';
}
}

View File

@@ -1,53 +1,54 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Auth\Passwords\PasswordBroker
*/
class Password extends Facade {
class Password extends Facade
{
/**
* Constant representing a successfully sent reminder.
*
* @var string
*/
const RESET_LINK_SENT = 'passwords.sent';
/**
* Constant representing a successfully sent reminder.
*
* @var string
*/
const RESET_LINK_SENT = 'passwords.sent';
/**
* Constant representing a successfully reset password.
*
* @var string
*/
const PASSWORD_RESET = 'passwords.reset';
/**
* Constant representing a successfully reset password.
*
* @var string
*/
const PASSWORD_RESET = 'passwords.reset';
/**
* Constant representing the user not found response.
*
* @var string
*/
const INVALID_USER = 'passwords.user';
/**
* Constant representing the user not found response.
*
* @var string
*/
const INVALID_USER = 'passwords.user';
/**
* Constant representing an invalid password.
*
* @var string
*/
const INVALID_PASSWORD = 'passwords.password';
/**
* Constant representing an invalid password.
*
* @var string
*/
const INVALID_PASSWORD = 'passwords.password';
/**
* Constant representing an invalid token.
*
* @var string
*/
const INVALID_TOKEN = 'passwords.token';
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'auth.password';
}
/**
* Constant representing an invalid token.
*
* @var string
*/
const INVALID_TOKEN = 'passwords.token';
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'auth.password';
}
}

View File

@@ -1,19 +1,20 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Queue\QueueManager
* @see \Illuminate\Queue\Queue
*/
class Queue extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'queue';
}
class Queue extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'queue';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Routing\Redirector
*/
class Redirect extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'redirect';
}
class Redirect extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'redirect';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Redis\Database
*/
class Redis extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'redis';
}
class Redis extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'redis';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Http\Request
*/
class Request extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'request';
}
class Request extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'request';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Contracts\Routing\ResponseFactory
*/
class Response extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Routing\ResponseFactory';
}
class Response extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Routing\ResponseFactory';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Routing\Router
*/
class Route extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'router';
}
class Route extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'router';
}
}

View File

@@ -1,29 +1,30 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Database\Schema\Builder
*/
class Schema extends Facade {
/**
* Get a schema builder instance for a connection.
*
* @param string $name
* @return \Illuminate\Database\Schema\Builder
*/
public static function connection($name)
{
return static::$app['db']->connection($name)->getSchemaBuilder();
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return static::$app['db']->connection()->getSchemaBuilder();
}
class Schema extends Facade
{
/**
* Get a schema builder instance for a connection.
*
* @param string $name
* @return \Illuminate\Database\Schema\Builder
*/
public static function connection($name)
{
return static::$app['db']->connection($name)->getSchemaBuilder();
}
/**
* Get a schema builder instance for the default connection.
*
* @return \Illuminate\Database\Schema\Builder
*/
protected static function getFacadeAccessor()
{
return static::$app['db']->connection()->getSchemaBuilder();
}
}

View File

@@ -1,19 +1,20 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Session\SessionManager
* @see \Illuminate\Session\Store
*/
class Session extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'session';
}
class Session extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'session';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Filesystem\FilesystemManager
*/
class Storage extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'filesystem';
}
class Storage extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'filesystem';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Routing\UrlGenerator
*/
class URL extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'url';
}
class URL extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'url';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Validation\Factory
*/
class Validator extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'validator';
}
class Validator extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'validator';
}
}

View File

@@ -1,18 +1,19 @@
<?php namespace Illuminate\Support\Facades;
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\View\Factory
*/
class View extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'view';
}
class View extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'view';
}
}

View File

@@ -1,193 +1,192 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use ArrayAccess;
use JsonSerializable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable {
class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
{
/**
* All of the attributes set on the container.
*
* @var array
*/
protected $attributes = [];
/**
* All of the attributes set on the container.
*
* @var array
*/
protected $attributes = array();
/**
* Create a new fluent container instance.
*
* @param array|object $attributes
* @return void
*/
public function __construct($attributes = [])
{
foreach ($attributes as $key => $value) {
$this->attributes[$key] = $value;
}
}
/**
* Create a new fluent container instance.
*
* @param array|object $attributes
* @return void
*/
public function __construct($attributes = array())
{
foreach ($attributes as $key => $value)
{
$this->attributes[$key] = $value;
}
}
/**
* Get an attribute from the container.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
if (array_key_exists($key, $this->attributes)) {
return $this->attributes[$key];
}
/**
* Get an attribute from the container.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
if (array_key_exists($key, $this->attributes))
{
return $this->attributes[$key];
}
return value($default);
}
return value($default);
}
/**
* Get the attributes from the container.
*
* @return array
*/
public function getAttributes()
{
return $this->attributes;
}
/**
* Get the attributes from the container.
*
* @return array
*/
public function getAttributes()
{
return $this->attributes;
}
/**
* Convert the Fluent instance to an array.
*
* @return array
*/
public function toArray()
{
return $this->attributes;
}
/**
* Convert the Fluent instance to an array.
*
* @return array
*/
public function toArray()
{
return $this->attributes;
}
/**
* Convert the object into something JSON serializable.
*
* @return array
*/
public function jsonSerialize()
{
return $this->toArray();
}
/**
* Convert the object into something JSON serializable.
*
* @return array
*/
public function jsonSerialize()
{
return $this->toArray();
}
/**
* Convert the Fluent instance to JSON.
*
* @param int $options
* @return string
*/
public function toJson($options = 0)
{
return json_encode($this->jsonSerialize(), $options);
}
/**
* Convert the Fluent instance to JSON.
*
* @param int $options
* @return string
*/
public function toJson($options = 0)
{
return json_encode($this->toArray(), $options);
}
/**
* Determine if the given offset exists.
*
* @param string $offset
* @return bool
*/
public function offsetExists($offset)
{
return isset($this->{$offset});
}
/**
* Determine if the given offset exists.
*
* @param string $offset
* @return bool
*/
public function offsetExists($offset)
{
return isset($this->{$offset});
}
/**
* Get the value for a given offset.
*
* @param string $offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->{$offset};
}
/**
* Get the value for a given offset.
*
* @param string $offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->{$offset};
}
/**
* Set the value at the given offset.
*
* @param string $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value)
{
$this->{$offset} = $value;
}
/**
* Set the value at the given offset.
*
* @param string $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value)
{
$this->{$offset} = $value;
}
/**
* Unset the value at the given offset.
*
* @param string $offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->{$offset});
}
/**
* Unset the value at the given offset.
*
* @param string $offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->{$offset});
}
/**
* Handle dynamic calls to the container to set attributes.
*
* @param string $method
* @param array $parameters
* @return $this
*/
public function __call($method, $parameters)
{
$this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true;
/**
* Handle dynamic calls to the container to set attributes.
*
* @param string $method
* @param array $parameters
* @return $this
*/
public function __call($method, $parameters)
{
$this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true;
return $this;
}
return $this;
}
/**
* Dynamically retrieve the value of an attribute.
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
return $this->get($key);
}
/**
* Dynamically retrieve the value of an attribute.
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
return $this->get($key);
}
/**
* Dynamically set the value of an attribute.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function __set($key, $value)
{
$this->attributes[$key] = $value;
}
/**
* Dynamically set the value of an attribute.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function __set($key, $value)
{
$this->attributes[$key] = $value;
}
/**
* Dynamically check if an attribute is set.
*
* @param string $key
* @return void
*/
public function __isset($key)
{
return isset($this->attributes[$key]);
}
/**
* Dynamically unset an attribute.
*
* @param string $key
* @return void
*/
public function __unset($key)
{
unset($this->attributes[$key]);
}
/**
* Dynamically check if an attribute is set.
*
* @param string $key
* @return bool
*/
public function __isset($key)
{
return isset($this->attributes[$key]);
}
/**
* Dynamically unset an attribute.
*
* @param string $key
* @return void
*/
public function __unset($key)
{
unset($this->attributes[$key]);
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Illuminate\Support;
use Illuminate\Contracts\Support\Htmlable;
class HtmlString implements Htmlable
{
/**
* The HTML string.
*
* @var string
*/
protected $html;
/**
* Create a new HTML string instance.
*
* @param string $html
* @return void
*/
public function __construct($html)
{
$this->html = $html;
}
/**
* Get the the HTML string.
*
* @return string
*/
public function toHtml()
{
return $this->html;
}
/**
* Get the the HTML string.
*
* @return string
*/
public function __toString()
{
return $this->toHtml();
}
}

View File

@@ -1,142 +1,139 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use Closure;
use InvalidArgumentException;
abstract class Manager {
abstract class Manager
{
/**
* The application instance.
*
* @var \Illuminate\Foundation\Application
*/
protected $app;
/**
* The application instance.
*
* @var \Illuminate\Foundation\Application
*/
protected $app;
/**
* The registered custom driver creators.
*
* @var array
*/
protected $customCreators = [];
/**
* The registered custom driver creators.
*
* @var array
*/
protected $customCreators = array();
/**
* The array of created "drivers".
*
* @var array
*/
protected $drivers = [];
/**
* The array of created "drivers".
*
* @var array
*/
protected $drivers = array();
/**
* Create a new manager instance.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
public function __construct($app)
{
$this->app = $app;
}
/**
* Create a new manager instance.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
public function __construct($app)
{
$this->app = $app;
}
/**
* Get the default driver name.
*
* @return string
*/
abstract public function getDefaultDriver();
/**
* Get the default driver name.
*
* @return string
*/
abstract public function getDefaultDriver();
/**
* Get a driver instance.
*
* @param string $driver
* @return mixed
*/
public function driver($driver = null)
{
$driver = $driver ?: $this->getDefaultDriver();
/**
* Get a driver instance.
*
* @param string $driver
* @return mixed
*/
public function driver($driver = null)
{
$driver = $driver ?: $this->getDefaultDriver();
// If the given driver has not been created before, we will create the instances
// here and cache it so we can return it next time very quickly. If there is
// already a driver created by this name, we'll just return that instance.
if (! isset($this->drivers[$driver])) {
$this->drivers[$driver] = $this->createDriver($driver);
}
// If the given driver has not been created before, we will create the instances
// here and cache it so we can return it next time very quickly. If there is
// already a driver created by this name, we'll just return that instance.
if ( ! isset($this->drivers[$driver]))
{
$this->drivers[$driver] = $this->createDriver($driver);
}
return $this->drivers[$driver];
}
return $this->drivers[$driver];
}
/**
* Create a new driver instance.
*
* @param string $driver
* @return mixed
*
* @throws \InvalidArgumentException
*/
protected function createDriver($driver)
{
$method = 'create'.Str::studly($driver).'Driver';
/**
* Create a new driver instance.
*
* @param string $driver
* @return mixed
*
* @throws \InvalidArgumentException
*/
protected function createDriver($driver)
{
$method = 'create'.ucfirst($driver).'Driver';
// We'll check to see if a creator method exists for the given driver. If not we
// will check for a custom driver creator, which allows developers to create
// drivers using their own customized driver creator Closure to create it.
if (isset($this->customCreators[$driver])) {
return $this->callCustomCreator($driver);
} elseif (method_exists($this, $method)) {
return $this->$method();
}
// We'll check to see if a creator method exists for the given driver. If not we
// will check for a custom driver creator, which allows developers to create
// drivers using their own customized driver creator Closure to create it.
if (isset($this->customCreators[$driver]))
{
return $this->callCustomCreator($driver);
}
elseif (method_exists($this, $method))
{
return $this->$method();
}
throw new InvalidArgumentException("Driver [$driver] not supported.");
}
throw new InvalidArgumentException("Driver [$driver] not supported.");
}
/**
* Call a custom driver creator.
*
* @param string $driver
* @return mixed
*/
protected function callCustomCreator($driver)
{
return $this->customCreators[$driver]($this->app);
}
/**
* Call a custom driver creator.
*
* @param string $driver
* @return mixed
*/
protected function callCustomCreator($driver)
{
return $this->customCreators[$driver]($this->app);
}
/**
* Register a custom driver creator Closure.
*
* @param string $driver
* @param \Closure $callback
* @return $this
*/
public function extend($driver, Closure $callback)
{
$this->customCreators[$driver] = $callback;
/**
* Register a custom driver creator Closure.
*
* @param string $driver
* @param \Closure $callback
* @return $this
*/
public function extend($driver, Closure $callback)
{
$this->customCreators[$driver] = $callback;
return $this;
}
return $this;
}
/**
* Get all of the created "drivers".
*
* @return array
*/
public function getDrivers()
{
return $this->drivers;
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array(array($this->driver(), $method), $parameters);
}
/**
* Get all of the created "drivers".
*
* @return array
*/
public function getDrivers()
{
return $this->drivers;
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array([$this->driver(), $method], $parameters);
}
}

View File

@@ -1,4 +1,6 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use Countable;
use JsonSerializable;
@@ -7,308 +9,322 @@ use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\MessageProvider;
use Illuminate\Contracts\Support\MessageBag as MessageBagContract;
class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, MessageBagContract, MessageProvider {
class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, MessageBagContract, MessageProvider
{
/**
* All of the registered messages.
*
* @var array
*/
protected $messages = [];
/**
* All of the registered messages.
*
* @var array
*/
protected $messages = array();
/**
* Default format for message output.
*
* @var string
*/
protected $format = ':message';
/**
* Default format for message output.
*
* @var string
*/
protected $format = ':message';
/**
* Create a new message bag instance.
*
* @param array $messages
* @return void
*/
public function __construct(array $messages = [])
{
foreach ($messages as $key => $value) {
$this->messages[$key] = (array) $value;
}
}
/**
* Create a new message bag instance.
*
* @param array $messages
* @return void
*/
public function __construct(array $messages = array())
{
foreach ($messages as $key => $value)
{
$this->messages[$key] = (array) $value;
}
}
/**
* Get the keys present in the message bag.
*
* @return array
*/
public function keys()
{
return array_keys($this->messages);
}
/**
* Get the keys present in the message bag.
*
* @return array
*/
public function keys()
{
return array_keys($this->messages);
}
/**
* Add a message to the bag.
*
* @param string $key
* @param string $message
* @return $this
*/
public function add($key, $message)
{
if ($this->isUnique($key, $message)) {
$this->messages[$key][] = $message;
}
/**
* Add a message to the bag.
*
* @param string $key
* @param string $message
* @return $this
*/
public function add($key, $message)
{
if ($this->isUnique($key, $message))
{
$this->messages[$key][] = $message;
}
return $this;
}
return $this;
}
/**
* Merge a new array of messages into the bag.
*
* @param \Illuminate\Contracts\Support\MessageProvider|array $messages
* @return $this
*/
public function merge($messages)
{
if ($messages instanceof MessageProvider) {
$messages = $messages->getMessageBag()->getMessages();
}
/**
* Merge a new array of messages into the bag.
*
* @param \Illuminate\Contracts\Support\MessageProvider|array $messages
* @return $this
*/
public function merge($messages)
{
if ($messages instanceof MessageProvider)
{
$messages = $messages->getMessageBag()->getMessages();
}
$this->messages = array_merge_recursive($this->messages, $messages);
$this->messages = array_merge_recursive($this->messages, $messages);
return $this;
}
return $this;
}
/**
* Determine if a key and message combination already exists.
*
* @param string $key
* @param string $message
* @return bool
*/
protected function isUnique($key, $message)
{
$messages = (array) $this->messages;
/**
* Determine if a key and message combination already exists.
*
* @param string $key
* @param string $message
* @return bool
*/
protected function isUnique($key, $message)
{
$messages = (array) $this->messages;
return ! isset($messages[$key]) || ! in_array($message, $messages[$key]);
}
return ! isset($messages[$key]) || ! in_array($message, $messages[$key]);
}
/**
* Determine if messages exist for a given key.
*
* @param string $key
* @return bool
*/
public function has($key = null)
{
return $this->first($key) !== '';
}
/**
* Determine if messages exist for a given key.
*
* @param string $key
* @return bool
*/
public function has($key = null)
{
return $this->first($key) !== '';
}
/**
* Get the first message from the bag for a given key.
*
* @param string $key
* @param string $format
* @return string
*/
public function first($key = null, $format = null)
{
$messages = is_null($key) ? $this->all($format) : $this->get($key, $format);
/**
* Get the first message from the bag for a given key.
*
* @param string $key
* @param string $format
* @return string
*/
public function first($key = null, $format = null)
{
$messages = is_null($key) ? $this->all($format) : $this->get($key, $format);
return count($messages) > 0 ? $messages[0] : '';
}
return count($messages) > 0 ? $messages[0] : '';
}
/**
* Get all of the messages from the bag for a given key.
*
* @param string $key
* @param string $format
* @return array
*/
public function get($key, $format = null)
{
// If the message exists in the container, we will transform it and return
// the message. Otherwise, we'll return an empty array since the entire
// methods is to return back an array of messages in the first place.
if (array_key_exists($key, $this->messages)) {
return $this->transform($this->messages[$key], $this->checkFormat($format), $key);
}
/**
* Get all of the messages from the bag for a given key.
*
* @param string $key
* @param string $format
* @return array
*/
public function get($key, $format = null)
{
// If the message exists in the container, we will transform it and return
// the message. Otherwise, we'll return an empty array since the entire
// methods is to return back an array of messages in the first place.
if (array_key_exists($key, $this->messages))
{
return $this->transform($this->messages[$key], $this->checkFormat($format), $key);
}
return [];
}
return array();
}
/**
* Get all of the messages for every key in the bag.
*
* @param string $format
* @return array
*/
public function all($format = null)
{
$format = $this->checkFormat($format);
/**
* Get all of the messages for every key in the bag.
*
* @param string $format
* @return array
*/
public function all($format = null)
{
$format = $this->checkFormat($format);
$all = [];
$all = array();
foreach ($this->messages as $key => $messages) {
$all = array_merge($all, $this->transform($messages, $format, $key));
}
foreach ($this->messages as $key => $messages)
{
$all = array_merge($all, $this->transform($messages, $format, $key));
}
return $all;
}
return $all;
}
/**
* Get all of the unique messages for every key in the bag.
*
* @param string $format
* @return array
*/
public function unique($format = null)
{
return array_unique($this->all($format));
}
/**
* Format an array of messages.
*
* @param array $messages
* @param string $format
* @param string $messageKey
* @return array
*/
protected function transform($messages, $format, $messageKey)
{
$messages = (array) $messages;
/**
* Format an array of messages.
*
* @param array $messages
* @param string $format
* @param string $messageKey
* @return array
*/
protected function transform($messages, $format, $messageKey)
{
$messages = (array) $messages;
// We will simply spin through the given messages and transform each one
// replacing the :message place holder with the real message allowing
// the messages to be easily formatted to each developer's desires.
$replace = array(':message', ':key');
// We will simply spin through the given messages and transform each one
// replacing the :message place holder with the real message allowing
// the messages to be easily formatted to each developer's desires.
$replace = [':message', ':key'];
foreach ($messages as &$message)
{
$message = str_replace($replace, array($message, $messageKey), $format);
}
foreach ($messages as &$message) {
$message = str_replace($replace, [$message, $messageKey], $format);
}
return $messages;
}
return $messages;
}
/**
* Get the appropriate format based on the given format.
*
* @param string $format
* @return string
*/
protected function checkFormat($format)
{
return $format ?: $this->format;
}
/**
* Get the appropriate format based on the given format.
*
* @param string $format
* @return string
*/
protected function checkFormat($format)
{
return $format ?: $this->format;
}
/**
* Get the raw messages in the container.
*
* @return array
*/
public function getMessages()
{
return $this->messages;
}
/**
* Get the raw messages in the container.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
/**
* Get the messages for the instance.
*
* @return \Illuminate\Support\MessageBag
*/
public function getMessageBag()
{
return $this;
}
/**
* Get the raw messages in the container.
*
* @return array
*/
public function getMessages()
{
return $this->messages();
}
/**
* Get the default message format.
*
* @return string
*/
public function getFormat()
{
return $this->format;
}
/**
* Get the messages for the instance.
*
* @return \Illuminate\Support\MessageBag
*/
public function getMessageBag()
{
return $this;
}
/**
* Set the default message format.
*
* @param string $format
* @return \Illuminate\Support\MessageBag
*/
public function setFormat($format = ':message')
{
$this->format = $format;
/**
* Get the default message format.
*
* @return string
*/
public function getFormat()
{
return $this->format;
}
return $this;
}
/**
* Set the default message format.
*
* @param string $format
* @return \Illuminate\Support\MessageBag
*/
public function setFormat($format = ':message')
{
$this->format = $format;
/**
* Determine if the message bag has any messages.
*
* @return bool
*/
public function isEmpty()
{
return ! $this->any();
}
return $this;
}
/**
* Determine if the message bag has any messages.
*
* @return bool
*/
public function any()
{
return $this->count() > 0;
}
/**
* Determine if the message bag has any messages.
*
* @return bool
*/
public function isEmpty()
{
return ! $this->any();
}
/**
* Get the number of messages in the container.
*
* @return int
*/
public function count()
{
return count($this->messages, COUNT_RECURSIVE) - count($this->messages);
}
/**
* Determine if the message bag has any messages.
*
* @return bool
*/
public function any()
{
return $this->count() > 0;
}
/**
* Get the instance as an array.
*
* @return array
*/
public function toArray()
{
return $this->getMessages();
}
/**
* Get the number of messages in the container.
*
* @return int
*/
public function count()
{
return count($this->messages, COUNT_RECURSIVE) - count($this->messages);
}
/**
* Convert the object into something JSON serializable.
*
* @return array
*/
public function jsonSerialize()
{
return $this->toArray();
}
/**
* Get the instance as an array.
*
* @return array
*/
public function toArray()
{
return $this->getMessages();
}
/**
* Convert the object to its JSON representation.
*
* @param int $options
* @return string
*/
public function toJson($options = 0)
{
return json_encode($this->toArray(), $options);
}
/**
* Convert the object into something JSON serializable.
*
* @return array
*/
public function jsonSerialize()
{
return $this->toArray();
}
/**
* Convert the message bag to its string representation.
*
* @return string
*/
public function __toString()
{
return $this->toJson();
}
/**
* Convert the object to its JSON representation.
*
* @param int $options
* @return string
*/
public function toJson($options = 0)
{
return json_encode($this->jsonSerialize(), $options);
}
/**
* Convert the message bag to its string representation.
*
* @return string
*/
public function __toString()
{
return $this->toJson();
}
}

View File

@@ -1,109 +1,104 @@
<?php namespace Illuminate\Support;
<?php
class NamespacedItemResolver {
namespace Illuminate\Support;
/**
* A cache of the parsed items.
*
* @var array
*/
protected $parsed = array();
class NamespacedItemResolver
{
/**
* A cache of the parsed items.
*
* @var array
*/
protected $parsed = [];
/**
* Parse a key into namespace, group, and item.
*
* @param string $key
* @return array
*/
public function parseKey($key)
{
// If we've already parsed the given key, we'll return the cached version we
// already have, as this will save us some processing. We cache off every
// key we parse so we can quickly return it on all subsequent requests.
if (isset($this->parsed[$key]))
{
return $this->parsed[$key];
}
/**
* Parse a key into namespace, group, and item.
*
* @param string $key
* @return array
*/
public function parseKey($key)
{
// If we've already parsed the given key, we'll return the cached version we
// already have, as this will save us some processing. We cache off every
// key we parse so we can quickly return it on all subsequent requests.
if (isset($this->parsed[$key])) {
return $this->parsed[$key];
}
// If the key does not contain a double colon, it means the key is not in a
// namespace, and is just a regular configuration item. Namespaces are a
// tool for organizing configuration items for things such as modules.
if (strpos($key, '::') === false)
{
$segments = explode('.', $key);
// If the key does not contain a double colon, it means the key is not in a
// namespace, and is just a regular configuration item. Namespaces are a
// tool for organizing configuration items for things such as modules.
if (strpos($key, '::') === false) {
$segments = explode('.', $key);
$parsed = $this->parseBasicSegments($segments);
}
else
{
$parsed = $this->parseNamespacedSegments($key);
}
$parsed = $this->parseBasicSegments($segments);
} else {
$parsed = $this->parseNamespacedSegments($key);
}
// Once we have the parsed array of this key's elements, such as its groups
// and namespace, we will cache each array inside a simple list that has
// the key and the parsed array for quick look-ups for later requests.
return $this->parsed[$key] = $parsed;
}
// Once we have the parsed array of this key's elements, such as its groups
// and namespace, we will cache each array inside a simple list that has
// the key and the parsed array for quick look-ups for later requests.
return $this->parsed[$key] = $parsed;
}
/**
* Parse an array of basic segments.
*
* @param array $segments
* @return array
*/
protected function parseBasicSegments(array $segments)
{
// The first segment in a basic array will always be the group, so we can go
// ahead and grab that segment. If there is only one total segment we are
// just pulling an entire group out of the array and not a single item.
$group = $segments[0];
/**
* Parse an array of basic segments.
*
* @param array $segments
* @return array
*/
protected function parseBasicSegments(array $segments)
{
// The first segment in a basic array will always be the group, so we can go
// ahead and grab that segment. If there is only one total segment we are
// just pulling an entire group out of the array and not a single item.
$group = $segments[0];
if (count($segments) == 1)
{
return array(null, $group, null);
}
if (count($segments) == 1) {
return [null, $group, null];
}
// If there is more than one segment in this group, it means we are pulling
// a specific item out of a groups and will need to return the item name
// as well as the group so we know which item to pull from the arrays.
else
{
$item = implode('.', array_slice($segments, 1));
// If there is more than one segment in this group, it means we are pulling
// a specific item out of a groups and will need to return the item name
// as well as the group so we know which item to pull from the arrays.
else {
$item = implode('.', array_slice($segments, 1));
return array(null, $group, $item);
}
}
return [null, $group, $item];
}
}
/**
* Parse an array of namespaced segments.
*
* @param string $key
* @return array
*/
protected function parseNamespacedSegments($key)
{
list($namespace, $item) = explode('::', $key);
/**
* Parse an array of namespaced segments.
*
* @param string $key
* @return array
*/
protected function parseNamespacedSegments($key)
{
list($namespace, $item) = explode('::', $key);
// First we'll just explode the first segment to get the namespace and group
// since the item should be in the remaining segments. Once we have these
// two pieces of data we can proceed with parsing out the item's value.
$itemSegments = explode('.', $item);
// First we'll just explode the first segment to get the namespace and group
// since the item should be in the remaining segments. Once we have these
// two pieces of data we can proceed with parsing out the item's value.
$itemSegments = explode('.', $item);
$groupAndItem = array_slice($this->parseBasicSegments($itemSegments), 1);
$groupAndItem = array_slice($this->parseBasicSegments($itemSegments), 1);
return array_merge(array($namespace), $groupAndItem);
}
/**
* Set the parsed value of a key.
*
* @param string $key
* @param array $parsed
* @return void
*/
public function setParsedKey($key, $parsed)
{
$this->parsed[$key] = $parsed;
}
return array_merge([$namespace], $groupAndItem);
}
/**
* Set the parsed value of a key.
*
* @param string $key
* @param array $parsed
* @return void
*/
public function setParsedKey($key, $parsed)
{
$this->parsed[$key] = $parsed;
}
}

View File

@@ -1,103 +1,105 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use Doctrine\Common\Inflector\Inflector;
class Pluralizer {
class Pluralizer
{
/**
* Uncountable word forms.
*
* @var array
*/
public static $uncountable = [
'audio',
'bison',
'chassis',
'compensation',
'coreopsis',
'data',
'deer',
'education',
'equipment',
'fish',
'gold',
'information',
'knowledge',
'love',
'rain',
'money',
'moose',
'nutrition',
'offspring',
'plankton',
'police',
'rice',
'series',
'sheep',
'species',
'swine',
'traffic',
];
/**
* Uncountable word forms.
*
* @var array
*/
public static $uncountable = array(
'audio',
'bison',
'chassis',
'compensation',
'coreopsis',
'data',
'deer',
'education',
'equipment',
'fish',
'gold',
'information',
'money',
'moose',
'offspring',
'plankton',
'police',
'rice',
'series',
'sheep',
'species',
'swine',
'traffic',
);
/**
* Get the plural form of an English word.
*
* @param string $value
* @param int $count
* @return string
*/
public static function plural($value, $count = 2)
{
if ($count === 1 || static::uncountable($value)) {
return $value;
}
/**
* Get the plural form of an English word.
*
* @param string $value
* @param int $count
* @return string
*/
public static function plural($value, $count = 2)
{
if ($count === 1 || static::uncountable($value))
{
return $value;
}
$plural = Inflector::pluralize($value);
$plural = Inflector::pluralize($value);
return static::matchCase($plural, $value);
}
return static::matchCase($plural, $value);
}
/**
* Get the singular form of an English word.
*
* @param string $value
* @return string
*/
public static function singular($value)
{
$singular = Inflector::singularize($value);
/**
* Get the singular form of an English word.
*
* @param string $value
* @return string
*/
public static function singular($value)
{
$singular = Inflector::singularize($value);
return static::matchCase($singular, $value);
}
return static::matchCase($singular, $value);
}
/**
* Determine if the given value is uncountable.
*
* @param string $value
* @return bool
*/
protected static function uncountable($value)
{
return in_array(strtolower($value), static::$uncountable);
}
/**
* Determine if the given value is uncountable.
*
* @param string $value
* @return bool
*/
protected static function uncountable($value)
{
return in_array(strtolower($value), static::$uncountable);
}
/**
* Attempt to match the case on two strings.
*
* @param string $value
* @param string $comparison
* @return string
*/
protected static function matchCase($value, $comparison)
{
$functions = ['mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords'];
/**
* Attempt to match the case on two strings.
*
* @param string $value
* @param string $comparison
* @return string
*/
protected static function matchCase($value, $comparison)
{
$functions = array('mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords');
foreach ($functions as $function)
{
if (call_user_func($function, $comparison) === $comparison)
{
return call_user_func($function, $value);
}
}
return $value;
}
foreach ($functions as $function) {
if (call_user_func($function, $comparison) === $comparison) {
return call_user_func($function, $value);
}
}
return $value;
}
}

View File

@@ -1,229 +1,239 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use BadMethodCallException;
use Illuminate\Console\Events\ArtisanStarting;
abstract class ServiceProvider {
abstract class ServiceProvider
{
/**
* The application instance.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
/**
* The application instance.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* The paths that should be published.
*
* @var array
*/
protected static $publishes = [];
/**
* The paths that should be published.
*
* @var array
*/
protected static $publishes = [];
/**
* The paths that should be published by group.
*
* @var array
*/
protected static $publishGroups = [];
/**
* The paths that should be published by group.
*
* @var array
*/
protected static $publishGroups = [];
/**
* Create a new service provider instance.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
{
$this->app = $app;
}
/**
* Create a new service provider instance.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
{
$this->app = $app;
}
/**
* Register the service provider.
*
* @return void
*/
abstract public function register();
/**
* Register the service provider.
*
* @return void
*/
abstract public function register();
/**
* Merge the given configuration with the existing configuration.
*
* @param string $path
* @param string $key
* @return void
*/
protected function mergeConfigFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
/**
* Merge the given configuration with the existing configuration.
*
* @param string $path
* @param string $key
* @return void
*/
protected function mergeConfigFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
$this->app['config']->set($key, array_merge(require $path, $config));
}
$this->app['config']->set($key, array_merge(require $path, $config));
}
/**
* Register a view file namespace.
*
* @param string $path
* @param string $namespace
* @return void
*/
protected function loadViewsFrom($path, $namespace)
{
if (is_dir($appPath = $this->app->basePath().'/resources/views/vendor/'.$namespace)) {
$this->app['view']->addNamespace($namespace, $appPath);
}
/**
* Register a view file namespace.
*
* @param string $path
* @param string $namespace
* @return void
*/
protected function loadViewsFrom($path, $namespace)
{
if (is_dir($appPath = $this->app->basePath().'/resources/views/vendor/'.$namespace))
{
$this->app['view']->addNamespace($namespace, $appPath);
}
$this->app['view']->addNamespace($namespace, $path);
}
$this->app['view']->addNamespace($namespace, $path);
}
/**
* Register a translation file namespace.
*
* @param string $path
* @param string $namespace
* @return void
*/
protected function loadTranslationsFrom($path, $namespace)
{
$this->app['translator']->addNamespace($namespace, $path);
}
/**
* Register a translation file namespace.
*
* @param string $path
* @param string $namespace
* @return void
*/
protected function loadTranslationsFrom($path, $namespace)
{
$this->app['translator']->addNamespace($namespace, $path);
}
/**
* Register paths to be published by the publish command.
*
* @param array $paths
* @param string $group
* @return void
*/
protected function publishes(array $paths, $group = null)
{
$class = static::class;
/**
* Register paths to be published by the publish command.
*
* @param array $paths
* @param string $group
* @return void
*/
protected function publishes(array $paths, $group = null)
{
$class = get_class($this);
if (! array_key_exists($class, static::$publishes)) {
static::$publishes[$class] = [];
}
if ( ! array_key_exists($class, static::$publishes))
{
static::$publishes[$class] = [];
}
static::$publishes[$class] = array_merge(static::$publishes[$class], $paths);
static::$publishes[$class] = array_merge(static::$publishes[$class], $paths);
if ($group) {
if (! array_key_exists($group, static::$publishGroups)) {
static::$publishGroups[$group] = [];
}
if ($group)
{
static::$publishGroups[$group] = $paths;
}
}
static::$publishGroups[$group] = array_merge(static::$publishGroups[$group], $paths);
}
}
/**
* Get the paths to publish.
*
* @param string $provider
* @param string $group
* @return array
*/
public static function pathsToPublish($provider = null, $group = null)
{
if ($group && array_key_exists($group, static::$publishGroups))
{
return static::$publishGroups[$group];
}
/**
* Get the paths to publish.
*
* @param string $provider
* @param string $group
* @return array
*/
public static function pathsToPublish($provider = null, $group = null)
{
if ($provider && $group) {
if (empty(static::$publishes[$provider]) || empty(static::$publishGroups[$group])) {
return [];
}
if ($provider && array_key_exists($provider, static::$publishes))
{
return static::$publishes[$provider];
}
return array_intersect_key(static::$publishes[$provider], static::$publishGroups[$group]);
}
if ($group || $provider)
{
return [];
}
if ($group && array_key_exists($group, static::$publishGroups)) {
return static::$publishGroups[$group];
}
$paths = [];
if ($provider && array_key_exists($provider, static::$publishes)) {
return static::$publishes[$provider];
}
foreach (static::$publishes as $class => $publish)
{
$paths = array_merge($paths, $publish);
}
if ($group || $provider) {
return [];
}
return $paths;
}
$paths = [];
/**
* Register the package's custom Artisan commands.
*
* @param array $commands
* @return void
*/
public function commands($commands)
{
$commands = is_array($commands) ? $commands : func_get_args();
foreach (static::$publishes as $class => $publish) {
$paths = array_merge($paths, $publish);
}
// To register the commands with Artisan, we will grab each of the arguments
// passed into the method and listen for Artisan "start" event which will
// give us the Artisan console instance which we will give commands to.
$events = $this->app['events'];
return $paths;
}
$events->listen('artisan.start', function($artisan) use ($commands)
{
$artisan->resolveCommands($commands);
});
}
/**
* Register the package's custom Artisan commands.
*
* @param array|mixed $commands
* @return void
*/
public function commands($commands)
{
$commands = is_array($commands) ? $commands : func_get_args();
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
// To register the commands with Artisan, we will grab each of the arguments
// passed into the method and listen for Artisan "start" event which will
// give us the Artisan console instance which we will give commands to.
$events = $this->app['events'];
/**
* Get the events that trigger this service provider to register.
*
* @return array
*/
public function when()
{
return [];
}
$events->listen(ArtisanStarting::class, function ($event) use ($commands) {
$event->artisan->resolveCommands($commands);
});
}
/**
* Determine if the provider is deferred.
*
* @return bool
*/
public function isDeferred()
{
return $this->defer;
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
/**
* Get a list of files that should be compiled for the package.
*
* @return array
*/
public static function compiles()
{
return [];
}
/**
* Get the events that trigger this service provider to register.
*
* @return array
*/
public function when()
{
return [];
}
/**
* Dynamically handle missing method calls.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if ($method == 'boot') return;
/**
* Determine if the provider is deferred.
*
* @return bool
*/
public function isDeferred()
{
return $this->defer;
}
throw new BadMethodCallException("Call to undefined method [{$method}]");
}
/**
* Get a list of files that should be compiled for the package.
*
* @return array
*/
public static function compiles()
{
return [];
}
/**
* Dynamically handle missing method calls.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{
if ($method == 'boot') {
return;
}
throw new BadMethodCallException("Call to undefined method [{$method}]");
}
}

View File

@@ -1,392 +1,598 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use RuntimeException;
use Stringy\StaticStringy;
use Illuminate\Support\Traits\Macroable;
class Str {
class Str
{
use Macroable;
use Macroable;
/**
* The cache of snake-cased words.
*
* @var array
*/
protected static $snakeCache = [];
/**
* The cache of snake-cased words.
*
* @var array
*/
protected static $snakeCache = [];
/**
* The cache of camel-cased words.
*
* @var array
*/
protected static $camelCache = [];
/**
* The cache of camel-cased words.
*
* @var array
*/
protected static $camelCache = [];
/**
* The cache of studly-cased words.
*
* @var array
*/
protected static $studlyCache = [];
/**
* The cache of studly-cased words.
*
* @var array
*/
protected static $studlyCache = [];
/**
* Transliterate a UTF-8 value to ASCII.
*
* @param string $value
* @return string
*/
public static function ascii($value)
{
foreach (static::charsArray() as $key => $val) {
$value = str_replace($val, $key, $value);
}
/**
* Transliterate a UTF-8 value to ASCII.
*
* @param string $value
* @return string
*/
public static function ascii($value)
{
return StaticStringy::toAscii($value);
}
return preg_replace('/[^\x20-\x7E]/u', '', $value);
}
/**
* Convert a value to camel case.
*
* @param string $value
* @return string
*/
public static function camel($value)
{
if (isset(static::$camelCache[$value]))
{
return static::$camelCache[$value];
}
/**
* Convert a value to camel case.
*
* @param string $value
* @return string
*/
public static function camel($value)
{
if (isset(static::$camelCache[$value])) {
return static::$camelCache[$value];
}
return static::$camelCache[$value] = lcfirst(static::studly($value));
}
return static::$camelCache[$value] = lcfirst(static::studly($value));
}
/**
* Determine if a given string contains a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function contains($haystack, $needles)
{
foreach ((array) $needles as $needle)
{
if ($needle != '' && strpos($haystack, $needle) !== false) return true;
}
/**
* Determine if a given string contains a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function contains($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
}
return false;
}
return false;
}
/**
* Determine if a given string ends with a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function endsWith($haystack, $needles)
{
foreach ((array) $needles as $needle)
{
if ((string) $needle === substr($haystack, -strlen($needle))) return true;
}
/**
* Determine if a given string ends with a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function endsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ((string) $needle === static::substr($haystack, -static::length($needle))) {
return true;
}
}
return false;
}
return false;
}
/**
* Cap a string with a single instance of a given value.
*
* @param string $value
* @param string $cap
* @return string
*/
public static function finish($value, $cap)
{
$quoted = preg_quote($cap, '/');
/**
* Cap a string with a single instance of a given value.
*
* @param string $value
* @param string $cap
* @return string
*/
public static function finish($value, $cap)
{
$quoted = preg_quote($cap, '/');
return preg_replace('/(?:'.$quoted.')+$/', '', $value).$cap;
}
return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
}
/**
* Determine if a given string matches a given pattern.
*
* @param string $pattern
* @param string $value
* @return bool
*/
public static function is($pattern, $value)
{
if ($pattern == $value) return true;
/**
* Determine if a given string matches a given pattern.
*
* @param string $pattern
* @param string $value
* @return bool
*/
public static function is($pattern, $value)
{
if ($pattern == $value) {
return true;
}
$pattern = preg_quote($pattern, '#');
$pattern = preg_quote($pattern, '#');
// Asterisks are translated into zero-or-more regular expression wildcards
// to make it convenient to check if the strings starts with the given
// pattern such as "library/*", making any string check convenient.
$pattern = str_replace('\*', '.*', $pattern).'\z';
// Asterisks are translated into zero-or-more regular expression wildcards
// to make it convenient to check if the strings starts with the given
// pattern such as "library/*", making any string check convenient.
$pattern = str_replace('\*', '.*', $pattern);
return (bool) preg_match('#^'.$pattern.'#', $value);
}
return (bool) preg_match('#^'.$pattern.'\z#u', $value);
}
/**
* Return the length of the given string.
*
* @param string $value
* @return int
*/
public static function length($value)
{
return mb_strlen($value);
}
/**
* Return the length of the given string.
*
* @param string $value
* @return int
*/
public static function length($value)
{
return mb_strlen($value);
}
/**
* Limit the number of characters in a string.
*
* @param string $value
* @param int $limit
* @param string $end
* @return string
*/
public static function limit($value, $limit = 100, $end = '...')
{
if (mb_strlen($value) <= $limit) return $value;
/**
* Limit the number of characters in a string.
*
* @param string $value
* @param int $limit
* @param string $end
* @return string
*/
public static function limit($value, $limit = 100, $end = '...')
{
if (mb_strwidth($value, 'UTF-8') <= $limit) {
return $value;
}
return rtrim(mb_substr($value, 0, $limit, 'UTF-8')).$end;
}
return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
}
/**
* Convert the given string to lower-case.
*
* @param string $value
* @return string
*/
public static function lower($value)
{
return mb_strtolower($value);
}
/**
* Convert the given string to lower-case.
*
* @param string $value
* @return string
*/
public static function lower($value)
{
return mb_strtolower($value, 'UTF-8');
}
/**
* Limit the number of words in a string.
*
* @param string $value
* @param int $words
* @param string $end
* @return string
*/
public static function words($value, $words = 100, $end = '...')
{
preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
/**
* Limit the number of words in a string.
*
* @param string $value
* @param int $words
* @param string $end
* @return string
*/
public static function words($value, $words = 100, $end = '...')
{
preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
if ( ! isset($matches[0]) || strlen($value) === strlen($matches[0])) return $value;
if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) {
return $value;
}
return rtrim($matches[0]).$end;
}
return rtrim($matches[0]).$end;
}
/**
* Parse a Class@method style callback into class and method.
*
* @param string $callback
* @param string $default
* @return array
*/
public static function parseCallback($callback, $default)
{
return static::contains($callback, '@') ? explode('@', $callback, 2) : array($callback, $default);
}
/**
* Parse a Class@method style callback into class and method.
*
* @param string $callback
* @param string $default
* @return array
*/
public static function parseCallback($callback, $default)
{
return static::contains($callback, '@') ? explode('@', $callback, 2) : [$callback, $default];
}
/**
* Get the plural form of an English word.
*
* @param string $value
* @param int $count
* @return string
*/
public static function plural($value, $count = 2)
{
return Pluralizer::plural($value, $count);
}
/**
* Get the plural form of an English word.
*
* @param string $value
* @param int $count
* @return string
*/
public static function plural($value, $count = 2)
{
return Pluralizer::plural($value, $count);
}
/**
* Generate a more truly "random" alpha-numeric string.
*
* @param int $length
* @return string
*
* @throws \RuntimeException
*/
public static function random($length = 16)
{
$string = '';
/**
* Generate a more truly "random" alpha-numeric string.
*
* @param int $length
* @return string
*/
public static function random($length = 16)
{
$string = '';
while (($len = strlen($string)) < $length)
{
$size = $length - $len;
$bytes = static::randomBytes($size);
$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}
while (($len = static::length($string)) < $length) {
$size = $length - $len;
return $string;
}
$bytes = random_bytes($size);
/**
* Generate a more truly "random" bytes.
*
* @param int $length
* @return string
*
* @throws \RuntimeException
*/
public static function randomBytes($length = 16)
{
if (function_exists('random_bytes'))
{
$bytes = random_bytes($length);
}
elseif (function_exists('openssl_random_pseudo_bytes'))
{
$bytes = openssl_random_pseudo_bytes($length, $strong);
if ($bytes === false || $strong === false)
{
throw new RuntimeException('Unable to generate random string.');
}
}
else
{
throw new RuntimeException('OpenSSL extension is required for PHP 5 users.');
}
$string .= static::substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}
return $bytes;
}
return $string;
}
/**
* Generate a "random" alpha-numeric string.
*
* Should not be considered sufficient for cryptography, etc.
*
* @param int $length
* @return string
*/
public static function quickRandom($length = 16)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
/**
* Generate a more truly "random" bytes.
*
* @param int $length
* @return string
*
* @deprecated since version 5.2. Use random_bytes instead.
*/
public static function randomBytes($length = 16)
{
return random_bytes($length);
}
return substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
}
/**
* Generate a "random" alpha-numeric string.
*
* Should not be considered sufficient for cryptography, etc.
*
* @param int $length
* @return string
*/
public static function quickRandom($length = 16)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
/**
* Convert the given string to upper-case.
*
* @param string $value
* @return string
*/
public static function upper($value)
{
return mb_strtoupper($value);
}
return static::substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
}
/**
* Convert the given string to title case.
*
* @param string $value
* @return string
*/
public static function title($value)
{
return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
}
/**
* Compares two strings using a constant-time algorithm.
*
* Note: This method will leak length information.
*
* Note: Adapted from Symfony\Component\Security\Core\Util\StringUtils.
*
* @param string $knownString
* @param string $userInput
* @return bool
*
* @deprecated since version 5.2. Use hash_equals instead.
*/
public static function equals($knownString, $userInput)
{
return hash_equals($knownString, $userInput);
}
/**
* Get the singular form of an English word.
*
* @param string $value
* @return string
*/
public static function singular($value)
{
return Pluralizer::singular($value);
}
/**
* Replace the first occurrence of a given value in the string.
*
* @param string $search
* @param string $replace
* @param string $subject
* @return string
*/
public static function replaceFirst($search, $replace, $subject)
{
$position = strpos($subject, $search);
/**
* Generate a URL friendly "slug" from a given string.
*
* @param string $title
* @param string $separator
* @return string
*/
public static function slug($title, $separator = '-')
{
$title = static::ascii($title);
if ($position !== false) {
return substr_replace($subject, $replace, $position, strlen($search));
}
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
return $subject;
}
$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
/**
* Replace the last occurrence of a given value in the string.
*
* @param string $search
* @param string $replace
* @param string $subject
* @return string
*/
public static function replaceLast($search, $replace, $subject)
{
$position = strrpos($subject, $search);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
if ($position !== false) {
return substr_replace($subject, $replace, $position, strlen($search));
}
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
return $subject;
}
return trim($title, $separator);
}
/**
* Convert the given string to upper-case.
*
* @param string $value
* @return string
*/
public static function upper($value)
{
return mb_strtoupper($value, 'UTF-8');
}
/**
* Convert a string to snake case.
*
* @param string $value
* @param string $delimiter
* @return string
*/
public static function snake($value, $delimiter = '_')
{
$key = $value.$delimiter;
/**
* Convert the given string to title case.
*
* @param string $value
* @return string
*/
public static function title($value)
{
return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
}
if (isset(static::$snakeCache[$key]))
{
return static::$snakeCache[$key];
}
/**
* Get the singular form of an English word.
*
* @param string $value
* @return string
*/
public static function singular($value)
{
return Pluralizer::singular($value);
}
if ( ! ctype_lower($value))
{
$value = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1'.$delimiter, $value));
}
/**
* Generate a URL friendly "slug" from a given string.
*
* @param string $title
* @param string $separator
* @return string
*/
public static function slug($title, $separator = '-')
{
$title = static::ascii($title);
return static::$snakeCache[$key] = $value;
}
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
/**
* Determine if a given string starts with a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function startsWith($haystack, $needles)
{
foreach ((array) $needles as $needle)
{
if ($needle != '' && strpos($haystack, $needle) === 0) return true;
}
$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
return false;
}
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
/**
* Convert a value to studly caps case.
*
* @param string $value
* @return string
*/
public static function studly($value)
{
$key = $value;
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
if (isset(static::$studlyCache[$key]))
{
return static::$studlyCache[$key];
}
return trim($title, $separator);
}
$value = ucwords(str_replace(array('-', '_'), ' ', $value));
/**
* Convert a string to snake case.
*
* @param string $value
* @param string $delimiter
* @return string
*/
public static function snake($value, $delimiter = '_')
{
$key = $value.$delimiter;
return static::$studlyCache[$key] = str_replace(' ', '', $value);
}
if (isset(static::$snakeCache[$key])) {
return static::$snakeCache[$key];
}
if (! ctype_lower($value)) {
$value = preg_replace('/\s+/u', '', $value);
$value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
}
return static::$snakeCache[$key] = $value;
}
/**
* Determine if a given string starts with a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
public static function startsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && mb_strpos($haystack, $needle) === 0) {
return true;
}
}
return false;
}
/**
* Convert a value to studly caps case.
*
* @param string $value
* @return string
*/
public static function studly($value)
{
$key = $value;
if (isset(static::$studlyCache[$key])) {
return static::$studlyCache[$key];
}
$value = ucwords(str_replace(['-', '_'], ' ', $value));
return static::$studlyCache[$key] = str_replace(' ', '', $value);
}
/**
* Returns the portion of string specified by the start and length parameters.
*
* @param string $string
* @param int $start
* @param int|null $length
* @return string
*/
public static function substr($string, $start, $length = null)
{
return mb_substr($string, $start, $length, 'UTF-8');
}
/**
* Make a string's first character uppercase.
*
* @param string $string
* @return string
*/
public static function ucfirst($string)
{
return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
}
/**
* Returns the replacements for the ascii method.
*
* Note: Adapted from Stringy\Stringy.
*
* @see https://github.com/danielstjules/Stringy/blob/2.3.1/LICENSE.txt
*
* @return array
*/
protected static function charsArray()
{
static $charsArray;
if (isset($charsArray)) {
return $charsArray;
}
return $charsArray = [
'0' => ['°', '₀', '۰'],
'1' => ['¹', '₁', '۱'],
'2' => ['²', '₂', '۲'],
'3' => ['³', '₃', '۳'],
'4' => ['⁴', '₄', '۴', '٤'],
'5' => ['⁵', '₅', '۵', '٥'],
'6' => ['⁶', '₆', '۶', '٦'],
'7' => ['⁷', '₇', '۷'],
'8' => ['⁸', '₈', '۸'],
'9' => ['⁹', '₉', '۹'],
'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا'],
'b' => ['б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ'],
'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ'],
'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ'],
'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए', 'إ', 'ئ'],
'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ'],
'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ'],
'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ'],
'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', 'इ'],
'j' => ['ĵ', 'ј', 'Ј', 'ჯ', 'ج'],
'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', 'ک'],
'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ'],
'm' => ['м', 'μ', 'م', 'မ', 'მ'],
'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', 'ნ'],
'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ'],
'p' => ['п', 'π', 'ပ', 'პ', 'پ'],
'q' => [''],
'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ'],
's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', 'ſ', 'ს'],
't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', 'თ', 'ტ'],
'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', 'ဉ', 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ'],
'v' => ['в', 'ვ', 'ϐ'],
'w' => ['ŵ', 'ω', 'ώ', '', 'ွ'],
'x' => ['χ', 'ξ'],
'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ'],
'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ'],
'aa' => ['ع', 'आ', 'آ'],
'ae' => ['ä', 'æ', 'ǽ'],
'ai' => ['ऐ'],
'at' => ['@'],
'ch' => ['ч', 'ჩ', 'ჭ', 'چ'],
'dj' => ['ђ', 'đ'],
'dz' => ['џ', 'ძ'],
'ei' => ['ऍ'],
'gh' => ['غ', 'ღ'],
'ii' => ['ई'],
'ij' => ['ij'],
'kh' => ['х', 'خ', 'ხ'],
'lj' => ['љ'],
'nj' => ['њ'],
'oe' => ['ö', 'œ', 'ؤ'],
'oi' => ['ऑ'],
'oii' => ['ऒ'],
'ps' => ['ψ'],
'sh' => ['ш', 'შ', 'ش'],
'shch' => ['щ'],
'ss' => ['ß'],
'sx' => ['ŝ'],
'th' => ['þ', 'ϑ', 'ث', 'ذ', 'ظ'],
'ts' => ['ц', 'ც', 'წ'],
'ue' => ['ü'],
'uu' => ['ऊ'],
'ya' => ['я'],
'yu' => ['ю'],
'zh' => ['ж', 'ჟ', 'ژ'],
'(c)' => ['©'],
'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ǻ', 'Ǎ'],
'B' => ['Б', 'Β', 'ब'],
'C' => ['Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'],
'D' => ['Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'],
'E' => ['É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', 'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ', 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', 'Є', 'Ə'],
'F' => ['Ф', 'Φ'],
'G' => ['Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'],
'H' => ['Η', 'Ή', 'Ħ'],
'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', 'Ǐ', 'ϒ'],
'K' => ['К', 'Κ'],
'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ', 'Ľ', 'Ŀ', 'ल'],
'M' => ['М', 'Μ'],
'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'],
'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ'],
'P' => ['П', 'Π'],
'R' => ['Ř', 'Ŕ', 'Р', 'Ρ', 'Ŗ'],
'S' => ['Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'],
'T' => ['Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'],
'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', 'Ự', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', 'Ǔ', 'Ǖ', 'Ǘ', 'Ǚ', 'Ǜ'],
'V' => ['В'],
'W' => ['Ω', 'Ώ', 'Ŵ'],
'X' => ['Χ', 'Ξ'],
'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ'],
'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ'],
'AE' => ['Ä', 'Æ', 'Ǽ'],
'CH' => ['Ч'],
'DJ' => ['Ђ'],
'DZ' => ['Џ'],
'GX' => ['Ĝ'],
'HX' => ['Ĥ'],
'IJ' => ['IJ'],
'JX' => ['Ĵ'],
'KH' => ['Х'],
'LJ' => ['Љ'],
'NJ' => ['Њ'],
'OE' => ['Ö', 'Œ'],
'PS' => ['Ψ'],
'SH' => ['Ш'],
'SHCH' => ['Щ'],
'SS' => ['ẞ'],
'TH' => ['Þ'],
'TS' => ['Ц'],
'UE' => ['Ü'],
'YA' => ['Я'],
'YU' => ['Ю'],
'ZH' => ['Ж'],
' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", "\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80"],
];
}
}

View File

@@ -1,69 +1,69 @@
<?php namespace Illuminate\Support\Traits;
<?php
namespace Illuminate\Support\Traits;
use Illuminate\Support\Fluent;
use Illuminate\Contracts\Container\Container;
trait CapsuleManagerTrait {
trait CapsuleManagerTrait
{
/**
* The current globally used instance.
*
* @var object
*/
protected static $instance;
/**
* The current globally used instance.
*
* @var object
*/
protected static $instance;
/**
* The container instance.
*
* @var \Illuminate\Contracts\Container\Container
*/
protected $container;
/**
* The container instance.
*
* @var \Illuminate\Contracts\Container\Container
*/
protected $container;
/**
* Setup the IoC container instance.
*
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
protected function setupContainer(Container $container)
{
$this->container = $container;
/**
* Setup the IoC container instance.
*
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
protected function setupContainer(Container $container)
{
$this->container = $container;
if (! $this->container->bound('config')) {
$this->container->instance('config', new Fluent);
}
}
if ( ! $this->container->bound('config'))
{
$this->container->instance('config', new Fluent);
}
}
/**
* Make this capsule instance available globally.
*
* @return void
*/
public function setAsGlobal()
{
static::$instance = $this;
}
/**
* Make this capsule instance available globally.
*
* @return void
*/
public function setAsGlobal()
{
static::$instance = $this;
}
/**
* Get the IoC container instance.
*
* @return \Illuminate\Contracts\Container\Container
*/
public function getContainer()
{
return $this->container;
}
/**
* Set the IoC container instance.
*
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
public function setContainer(Container $container)
{
$this->container = $container;
}
/**
* Get the IoC container instance.
*
* @return \Illuminate\Contracts\Container\Container
*/
public function getContainer()
{
return $this->container;
}
/**
* Set the IoC container instance.
*
* @param \Illuminate\Contracts\Container\Container $container
* @return void
*/
public function setContainer(Container $container)
{
$this->container = $container;
}
}

View File

@@ -1,90 +1,83 @@
<?php namespace Illuminate\Support\Traits;
<?php
namespace Illuminate\Support\Traits;
use Closure;
use BadMethodCallException;
trait Macroable {
trait Macroable
{
/**
* The registered string macros.
*
* @var array
*/
protected static $macros = [];
/**
* The registered string macros.
*
* @var array
*/
protected static $macros = array();
/**
* Register a custom macro.
*
* @param string $name
* @param callable $macro
* @return void
*/
public static function macro($name, callable $macro)
{
static::$macros[$name] = $macro;
}
/**
* Register a custom macro.
*
* @param string $name
* @param callable $macro
* @return void
*/
public static function macro($name, callable $macro)
{
static::$macros[$name] = $macro;
}
/**
* Checks if macro is registered.
*
* @param string $name
* @return bool
*/
public static function hasMacro($name)
{
return isset(static::$macros[$name]);
}
/**
* Checks if macro is registered.
*
* @param string $name
* @return bool
*/
public static function hasMacro($name)
{
return isset(static::$macros[$name]);
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public static function __callStatic($method, $parameters)
{
if (static::hasMacro($method)) {
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters);
} else {
return call_user_func_array(static::$macros[$method], $parameters);
}
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public static function __callStatic($method, $parameters)
{
if (static::hasMacro($method))
{
if (static::$macros[$method] instanceof Closure)
{
return call_user_func_array(Closure::bind(static::$macros[$method], null, get_called_class()), $parameters);
}
else
{
return call_user_func_array(static::$macros[$method], $parameters);
}
}
throw new BadMethodCallException("Method {$method} does not exist.");
}
throw new BadMethodCallException("Method {$method} does not exist.");
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method))
{
if (static::$macros[$method] instanceof Closure)
{
return call_user_func_array(static::$macros[$method]->bindTo($this, get_class($this)), $parameters);
}
else
{
return call_user_func_array(static::$macros[$method], $parameters);
}
}
throw new BadMethodCallException("Method {$method} does not exist.");
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
} else {
return call_user_func_array(static::$macros[$method], $parameters);
}
}
throw new BadMethodCallException("Method {$method} does not exist.");
}
}

View File

@@ -1,106 +1,107 @@
<?php namespace Illuminate\Support;
<?php
namespace Illuminate\Support;
use Countable;
use Illuminate\Contracts\Support\MessageBag as MessageBagContract;
class ViewErrorBag implements Countable {
class ViewErrorBag implements Countable
{
/**
* The array of the view error bags.
*
* @var array
*/
protected $bags = [];
/**
* The array of the view error bags.
*
* @var array
*/
protected $bags = [];
/**
* Checks if a named MessageBag exists in the bags.
*
* @param string $key
* @return bool
*/
public function hasBag($key = 'default')
{
return isset($this->bags[$key]);
}
/**
* Checks if a named MessageBag exists in the bags.
*
* @param string $key
* @return bool
*/
public function hasBag($key = 'default')
{
return isset($this->bags[$key]);
}
/**
* Get a MessageBag instance from the bags.
*
* @param string $key
* @return \Illuminate\Contracts\Support\MessageBag
*/
public function getBag($key)
{
return Arr::get($this->bags, $key) ?: new MessageBag;
}
/**
* Get a MessageBag instance from the bags.
*
* @param string $key
* @return \Illuminate\Contracts\Support\MessageBag
*/
public function getBag($key)
{
return array_get($this->bags, $key, new MessageBag);
}
/**
* Get all the bags.
*
* @return array
*/
public function getBags()
{
return $this->bags;
}
/**
* Get all the bags.
*
* @return array
*/
public function getBags()
{
return $this->bags;
}
/**
* Add a new MessageBag instance to the bags.
*
* @param string $key
* @param \Illuminate\Contracts\Support\MessageBag $bag
* @return $this
*/
public function put($key, MessageBagContract $bag)
{
$this->bags[$key] = $bag;
/**
* Add a new MessageBag instance to the bags.
*
* @param string $key
* @param \Illuminate\Contracts\Support\MessageBag $bag
* @return $this
*/
public function put($key, MessageBagContract $bag)
{
$this->bags[$key] = $bag;
return $this;
}
return $this;
}
/**
* Get the number of messages in the default bag.
*
* @return int
*/
public function count()
{
return $this->default->count();
}
/**
* Get the number of messages in the default bag.
*
* @return int
*/
public function count()
{
return $this->default->count();
}
/**
* Dynamically call methods on the default bag.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array([$this->default, $method], $parameters);
}
/**
* Dynamically call methods on the default bag.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array(array($this->default, $method), $parameters);
}
/**
* Dynamically access a view error bag.
*
* @param string $key
* @return \Illuminate\Contracts\Support\MessageBag
*/
public function __get($key)
{
return array_get($this->bags, $key, new MessageBag);
}
/**
* Dynamically set a view error bag.
*
* @param string $key
* @param \Illuminate\Contracts\Support\MessageBag $value
* @return void
*/
public function __set($key, $value)
{
array_set($this->bags, $key, $value);
}
/**
* Dynamically access a view error bag.
*
* @param string $key
* @return \Illuminate\Contracts\Support\MessageBag
*/
public function __get($key)
{
return $this->getBag($key);
}
/**
* Dynamically set a view error bag.
*
* @param string $key
* @param \Illuminate\Contracts\Support\MessageBag $value
* @return void
*/
public function __set($key, $value)
{
$this->put($key, $value);
}
}

View File

@@ -14,11 +14,11 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=5.5.9",
"ext-mbstring": "*",
"illuminate/contracts": "5.0.*",
"doctrine/inflector": "~1.0",
"danielstjules/stringy": "~1.8"
"illuminate/contracts": "5.2.*",
"paragonie/random_compat": "~1.4"
},
"autoload": {
"psr-4": {
@@ -30,12 +30,15 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
"dev-master": "5.2-dev"
}
},
"suggest": {
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.0).",
"symfony/var-dumper": "Required to use the dd function (2.6.*)."
"illuminate/filesystem": "Required to use the composer class (5.2.*).",
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.2).",
"symfony/polyfill-php56": "Required to use the hash_equals function on PHP 5.5 (~1.0).",
"symfony/process": "Required to use the composer class (2.8.*|3.0.*).",
"symfony/var-dumper": "Improves the dd function (2.8.*|3.0.*)."
},
"minimum-stability": "dev"
}

File diff suppressed because it is too large Load Diff