updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -55,10 +55,10 @@ class Arr
continue;
}
$results = array_merge($results, $values);
$results[] = $values;
}
return $results;
return array_merge([], ...$results);
}
/**
@@ -213,10 +213,14 @@ class Arr
if (! is_array($item)) {
$result[] = $item;
} elseif ($depth === 1) {
$result = array_merge($result, array_values($item));
} else {
$result = array_merge($result, static::flatten($item, $depth - 1));
$values = $depth === 1
? array_values($item)
: static::flatten($item, $depth - 1);
foreach ($values as $value) {
$result[] = $value;
}
}
}
@@ -271,7 +275,7 @@ class Arr
* Get an item from an array using "dot" notation.
*
* @param \ArrayAccess|array $array
* @param string $key
* @param string|int $key
* @param mixed $default
* @return mixed
*/
@@ -313,17 +317,9 @@ class Arr
*/
public static function has($array, $keys)
{
if (is_null($keys)) {
return false;
}
$keys = (array) $keys;
if (! $array) {
return false;
}
if ($keys === []) {
if (! $array || $keys === []) {
return false;
}
@@ -385,7 +381,7 @@ class Arr
{
$results = [];
list($value, $key) = static::explodePluckParameters($value, $key);
[$value, $key] = static::explodePluckParameters($value, $key);
foreach ($array as $item) {
$itemValue = data_get($item, $value);
@@ -549,11 +545,9 @@ class Arr
if (is_null($seed)) {
shuffle($array);
} else {
srand($seed);
usort($array, function () {
return rand(-1, 1);
});
mt_srand($seed);
shuffle($array);
mt_srand();
}
return $array;
@@ -594,6 +588,17 @@ class Arr
return $array;
}
/**
* Convert the array into a query string.
*
* @param array $array
* @return string
*/
public static function query($array)
{
return http_build_query($array, null, '&', PHP_QUERY_RFC3986);
}
/**
* Filter the array using the given callback.
*
@@ -618,6 +623,6 @@ class Arr
return [];
}
return ! is_array($value) ? [$value] : $value;
return is_array($value) ? $value : [$value];
}
}

View File

@@ -2,47 +2,9 @@
namespace Illuminate\Support;
use JsonSerializable;
use Carbon\Carbon as BaseCarbon;
use Illuminate\Support\Traits\Macroable;
class Carbon extends BaseCarbon implements JsonSerializable
class Carbon extends BaseCarbon
{
use Macroable;
/**
* The custom Carbon JSON serializer.
*
* @var callable|null
*/
protected static $serializer;
/**
* Prepare the object for JSON serialization.
*
* @return array|string
*/
public function jsonSerialize()
{
if (static::$serializer) {
return call_user_func(static::$serializer, $this);
}
$carbon = $this;
return call_user_func(function () use ($carbon) {
return get_object_vars($carbon);
});
}
/**
* JSON serialize all Carbon instances using the given callback.
*
* @param callable $callback
* @return void
*/
public static function serializeUsing($callback)
{
static::$serializer = $callback;
}
//
}

View File

@@ -11,9 +11,9 @@ use ArrayIterator;
use CachingIterator;
use JsonSerializable;
use IteratorAggregate;
use Illuminate\Support\Debug\Dumper;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Jsonable;
use Symfony\Component\VarDumper\VarDumper;
use Illuminate\Contracts\Support\Arrayable;
/**
@@ -36,8 +36,6 @@ use Illuminate\Contracts\Support\Arrayable;
* @property-read HigherOrderCollectionProxy $sortByDesc
* @property-read HigherOrderCollectionProxy $sum
* @property-read HigherOrderCollectionProxy $unique
*
* Class Collection
*/
class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable
{
@@ -58,7 +56,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
protected static $proxies = [
'average', 'avg', 'contains', 'each', 'every', 'filter', 'first',
'flatMap', 'groupBy', 'keyBy', 'map', 'max', 'min', 'partition',
'reject', 'sortBy', 'sortByDesc', 'sum', 'unique',
'reject', 'some', 'sortBy', 'sortByDesc', 'sum', 'unique',
];
/**
@@ -145,8 +143,16 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
*/
public function avg($callback = null)
{
if ($count = $this->count()) {
return $this->sum($callback) / $count;
$callback = $this->valueRetriever($callback);
$items = $this->map(function ($value) use ($callback) {
return $callback($value);
})->filter(function ($value) {
return ! is_null($value);
});
if ($count = $items->count()) {
return $items->sum() / $count;
}
}
@@ -164,20 +170,22 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
/**
* Get the median of a given key.
*
* @param null $key
* @param string|array|null $key
* @return mixed
*/
public function median($key = null)
{
$count = $this->count();
$values = (isset($key) ? $this->pluck($key) : $this)
->filter(function ($item) {
return ! is_null($item);
})->sort()->values();
if ($count == 0) {
$count = $values->count();
if ($count === 0) {
return;
}
$values = (isset($key) ? $this->pluck($key) : $this)
->sort()->values();
$middle = (int) ($count / 2);
if ($count % 2) {
@@ -192,14 +200,12 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
/**
* Get the mode of a given key.
*
* @param mixed $key
* @param string|array|null $key
* @return array|null
*/
public function mode($key = null)
{
$count = $this->count();
if ($count == 0) {
if ($this->count() === 0) {
return;
}
@@ -230,6 +236,19 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static(Arr::collapse($this->items));
}
/**
* Alias for the "contains" method.
*
* @param mixed $key
* @param mixed $operator
* @param mixed $value
* @return bool
*/
public function some($key, $operator = null, $value = null)
{
return $this->contains(...func_get_args());
}
/**
* Determine if an item exists in the collection.
*
@@ -291,6 +310,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
/**
* Dump the collection and end the script.
*
* @param mixed ...$args
* @return void
*/
public function dd(...$args)
@@ -310,7 +330,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
(new static(func_get_args()))
->push($this)
->each(function ($item) {
(new Dumper)->dump($item);
VarDumper::dump($item);
});
return $this;
@@ -385,6 +405,64 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static(array_diff_ukey($this->items, $this->getArrayableItems($items), $callback));
}
/**
* Retrieve duplicate items from the collection.
*
* @param callable|null $callback
* @param bool $strict
* @return static
*/
public function duplicates($callback = null, $strict = false)
{
$items = $this->map($this->valueRetriever($callback));
$uniqueItems = $items->unique(null, $strict);
$compare = $this->duplicateComparator($strict);
$duplicates = new static;
foreach ($items as $key => $value) {
if ($uniqueItems->isNotEmpty() && $compare($value, $uniqueItems->first())) {
$uniqueItems->shift();
} else {
$duplicates[$key] = $value;
}
}
return $duplicates;
}
/**
* Retrieve duplicate items from the collection using strict comparison.
*
* @param callable|null $callback
* @return static
*/
public function duplicatesStrict($callback = null)
{
return $this->duplicates($callback, true);
}
/**
* Get the comparison function to detect duplicates.
*
* @param bool $strict
* @return \Closure
*/
protected function duplicateComparator($strict)
{
if ($strict) {
return function ($a, $b) {
return $a === $b;
};
}
return function ($a, $b) {
return $a == $b;
};
}
/**
* Execute a callback over each item.
*
@@ -493,6 +571,30 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return $this;
}
/**
* Apply the callback if the collection is empty.
*
* @param callable $callback
* @param callable $default
* @return static|mixed
*/
public function whenEmpty(callable $callback, callable $default = null)
{
return $this->when($this->isEmpty(), $callback, $default);
}
/**
* Apply the callback if the collection is not empty.
*
* @param callable $callback
* @param callable $default
* @return static|mixed
*/
public function whenNotEmpty(callable $callback, callable $default = null)
{
return $this->when($this->isNotEmpty(), $callback, $default);
}
/**
* Apply the callback if the value is falsy.
*
@@ -506,6 +608,30 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return $this->when(! $value, $callback, $default);
}
/**
* Apply the callback unless the collection is empty.
*
* @param callable $callback
* @param callable $default
* @return static|mixed
*/
public function unlessEmpty(callable $callback, callable $default = null)
{
return $this->whenNotEmpty($callback, $default);
}
/**
* Apply the callback unless the collection is not empty.
*
* @param callable $callback
* @param callable $default
* @return static|mixed
*/
public function unlessNotEmpty(callable $callback, callable $default = null)
{
return $this->whenEmpty($callback, $default);
}
/**
* Filter items by the given key value pair.
*
@@ -514,7 +640,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* @param mixed $value
* @return static
*/
public function where($key, $operator, $value = null)
public function where($key, $operator = null, $value = null)
{
return $this->filter($this->operatorForWhere(...func_get_args()));
}
@@ -527,8 +653,14 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* @param mixed $value
* @return \Closure
*/
protected function operatorForWhere($key, $operator, $value = null)
protected function operatorForWhere($key, $operator = null, $value = null)
{
if (func_num_args() === 1) {
$value = true;
$operator = '=';
}
if (func_num_args() === 2) {
$value = $operator;
@@ -603,6 +735,32 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return $this->whereIn($key, $values, true);
}
/**
* Filter items such that the value of the given key is between the given values.
*
* @param string $key
* @param array $values
* @return static
*/
public function whereBetween($key, $values)
{
return $this->where($key, '>=', reset($values))->where($key, '<=', end($values));
}
/**
* Filter items such that the value of the given key is not between the given values.
*
* @param string $key
* @param array $values
* @return static
*/
public function whereNotBetween($key, $values)
{
return $this->filter(function ($item) use ($key, $values) {
return data_get($item, $key) < reset($values) || data_get($item, $key) > end($values);
});
}
/**
* Filter items by the given key value pair.
*
@@ -646,7 +804,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
}
/**
* Get the first item from the collection.
* Get the first item from the collection passing the given truth test.
*
* @param callable|null $callback
* @param mixed $default
@@ -663,9 +821,9 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* @param string $key
* @param mixed $operator
* @param mixed $value
* @return static
* @return mixed
*/
public function firstWhere($key, $operator, $value = null)
public function firstWhere($key, $operator = null, $value = null)
{
return $this->first($this->operatorForWhere(...func_get_args()));
}
@@ -725,7 +883,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
/**
* Group an associative array by a field or using a callback.
*
* @param callable|string $groupBy
* @param array|callable|string $groupBy
* @param bool $preserveKeys
* @return static
*/
@@ -885,6 +1043,36 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return ! is_string($value) && is_callable($value);
}
/**
* Join all items from the collection using a string. The final items can use a separate glue string.
*
* @param string $glue
* @param string $finalGlue
* @return string
*/
public function join($glue, $finalGlue = '')
{
if ($finalGlue === '') {
return $this->implode($glue);
}
$count = $this->count();
if ($count === 0) {
return '';
}
if ($count === 1) {
return $this->last();
}
$collection = new static($this->items);
$finalItem = $collection->pop();
return $collection->implode($glue).$finalGlue.$finalItem;
}
/**
* Get the keys of the collection items.
*
@@ -1070,6 +1258,17 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static(array_merge($this->items, $this->getArrayableItems($items)));
}
/**
* Recursively merge the collection with the given items.
*
* @param mixed $items
* @return static
*/
public function mergeRecursive($items)
{
return new static(array_merge_recursive($this->items, $this->getArrayableItems($items)));
}
/**
* Create a collection by using this collection for keys and another for its values.
*
@@ -1102,11 +1301,11 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
{
$callback = $this->valueRetriever($callback);
return $this->filter(function ($value) {
return $this->map(function ($value) use ($callback) {
return $callback($value);
})->filter(function ($value) {
return ! is_null($value);
})->reduce(function ($result, $item) use ($callback) {
$value = $callback($item);
})->reduce(function ($result, $value) {
return is_null($result) || $value < $result ? $value : $result;
});
}
@@ -1244,7 +1443,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
/**
* Push all of the given items onto the collection.
*
* @param \Traversable|array $source
* @param iterable $source
* @return static
*/
public function concat($source)
@@ -1319,19 +1518,39 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* @param callable|mixed $callback
* @return static
*/
public function reject($callback)
public function reject($callback = true)
{
if ($this->useAsCallable($callback)) {
return $this->filter(function ($value, $key) use ($callback) {
return ! $callback($value, $key);
});
}
$useAsCallable = $this->useAsCallable($callback);
return $this->filter(function ($item) use ($callback) {
return $item != $callback;
return $this->filter(function ($value, $key) use ($callback, $useAsCallable) {
return $useAsCallable
? ! $callback($value, $key)
: $value != $callback;
});
}
/**
* Replace the collection items with the given items.
*
* @param mixed $items
* @return static
*/
public function replace($items)
{
return new static(array_replace($this->items, $this->getArrayableItems($items)));
}
/**
* Recursively replace the collection items with the given items.
*
* @param mixed $items
* @return static
*/
public function replaceRecursive($items)
{
return new static(array_replace_recursive($this->items, $this->getArrayableItems($items)));
}
/**
* Reverse items order.
*
@@ -1409,9 +1628,29 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static;
}
$groupSize = ceil($this->count() / $numberOfGroups);
$groups = new static;
return $this->chunk($groupSize);
$groupSize = floor($this->count() / $numberOfGroups);
$remain = $this->count() % $numberOfGroups;
$start = 0;
for ($i = 0; $i < $numberOfGroups; $i++) {
$size = $groupSize;
if ($i < $remain) {
$size++;
}
if ($size) {
$groups->push(new static(array_slice($this->items, $start, $size)));
$start += $size;
}
}
return $groups;
}
/**
@@ -1648,7 +1887,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
/**
* Get a value retrieving callback.
*
* @param string $value
* @param callable|string|null $value
* @return callable
*/
protected function valueRetriever($value)
@@ -1770,6 +2009,38 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return count($this->items);
}
/**
* Count the number of items in the collection using a given truth test.
*
* @param callable|null $callback
* @return static
*/
public function countBy($callback = null)
{
if (is_null($callback)) {
$callback = function ($value) {
return $value;
};
}
return new static($this->groupBy($callback)->map(function ($value) {
return $value->count();
}));
}
/**
* Add an item to the collection.
*
* @param mixed $item
* @return $this
*/
public function add($item)
{
$this->items[] = $item;
return $this;
}
/**
* Get a base Support collection instance from this collection.
*
@@ -1856,7 +2127,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
} elseif ($items instanceof Jsonable) {
return json_decode($items->toJson(), true);
} elseif ($items instanceof JsonSerializable) {
return $items->jsonSerialize();
return (array) $items->jsonSerialize();
} elseif ($items instanceof Traversable) {
return iterator_to_array($items);
}

View File

@@ -18,7 +18,7 @@ class Composer
/**
* The working path to regenerate from.
*
* @var string
* @var string|null
*/
protected $workingPath;
@@ -38,16 +38,16 @@ class Composer
/**
* Regenerate the Composer autoloader files.
*
* @param string $extra
* @param string|array $extra
* @return void
*/
public function dumpAutoloads($extra = '')
{
$process = $this->getProcess();
$extra = $extra ? (array) $extra : [];
$process->setCommandLine(trim($this->findComposer().' dump-autoload '.$extra));
$command = array_merge($this->findComposer(), ['dump-autoload'], $extra);
$process->run();
$this->getProcess($command)->run();
}
/**
@@ -63,25 +63,36 @@ class Composer
/**
* Get the composer command for the environment.
*
* @return string
* @return array
*/
protected function findComposer()
{
if ($this->files->exists($this->workingPath.'/composer.phar')) {
return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)).' composer.phar';
return [$this->phpBinary(), 'composer.phar'];
}
return 'composer';
return ['composer'];
}
/**
* Get the PHP binary.
*
* @return string
*/
protected function phpBinary()
{
return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
}
/**
* Get a new Symfony process instance.
*
* @param array $command
* @return \Symfony\Component\Process\Process
*/
protected function getProcess()
protected function getProcess(array $command)
{
return (new Process('', $this->workingPath))->setTimeout(null);
return (new Process($command, $this->workingPath))->setTimeout(null);
}
/**

View File

@@ -0,0 +1,189 @@
<?php
namespace Illuminate\Support;
use InvalidArgumentException;
class ConfigurationUrlParser
{
/**
* The drivers aliases map.
*
* @var array
*/
protected static $driverAliases = [
'mssql' => 'sqlsrv',
'mysql2' => 'mysql', // RDS
'postgres' => 'pgsql',
'postgresql' => 'pgsql',
'sqlite3' => 'sqlite',
];
/**
* Parse the database configuration, hydrating options using a database configuration URL if possible.
*
* @param array|string $config
* @return array
*/
public function parseConfiguration($config)
{
if (is_string($config)) {
$config = ['url' => $config];
}
$url = $config['url'] ?? null;
$config = Arr::except($config, 'url');
if (! $url) {
return $config;
}
$parsedUrl = $this->parseUrl($url);
return array_merge(
$config,
$this->getPrimaryOptions($parsedUrl),
$this->getQueryOptions($parsedUrl)
);
}
/**
* Get the primary database connection options.
*
* @param array $url
* @return array
*/
protected function getPrimaryOptions($url)
{
return array_filter([
'driver' => $this->getDriver($url),
'database' => $this->getDatabase($url),
'host' => $url['host'] ?? null,
'port' => $url['port'] ?? null,
'username' => $url['user'] ?? null,
'password' => $url['pass'] ?? null,
], function ($value) {
return ! is_null($value);
});
}
/**
* Get the database driver from the URL.
*
* @param array $url
* @return string|null
*/
protected function getDriver($url)
{
$alias = $url['scheme'] ?? null;
if (! $alias) {
return;
}
return static::$driverAliases[$alias] ?? $alias;
}
/**
* Get the database name from the URL.
*
* @param array $url
* @return string|null
*/
protected function getDatabase($url)
{
$path = $url['path'] ?? null;
return $path ? substr($path, 1) : null;
}
/**
* Get all of the additional database options from the query string.
*
* @param array $url
* @return array
*/
protected function getQueryOptions($url)
{
$queryString = $url['query'] ?? null;
if (! $queryString) {
return [];
}
$query = [];
parse_str($queryString, $query);
return $this->parseStringsToNativeTypes($query);
}
/**
* Parse the string URL to an array of components.
*
* @param string $url
* @return array
*/
protected function parseUrl($url)
{
$url = preg_replace('#^(sqlite3?):///#', '$1://null/', $url);
$parsedUrl = parse_url($url);
if ($parsedUrl === false) {
throw new InvalidArgumentException('The database configuration URL is malformed.');
}
return $this->parseStringsToNativeTypes(
array_map('rawurldecode', $parsedUrl)
);
}
/**
* Convert string casted values to their native types.
*
* @param mixed $value
* @return mixed
*/
protected function parseStringsToNativeTypes($value)
{
if (is_array($value)) {
return array_map([$this, 'parseStringsToNativeTypes'], $value);
}
if (! is_string($value)) {
return $value;
}
$parsedValue = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE) {
return $parsedValue;
}
return $value;
}
/**
* Get all of the current drivers aliases.
*
* @return array
*/
public static function getDriverAliases()
{
return static::$driverAliases;
}
/**
* Add the given driver alias to the driver aliases array.
*
* @param string $alias
* @param string $driver
* @return void
*/
public static function addDriverAlias($alias, $driver)
{
static::$driverAliases[$alias] = $driver;
}
}

View File

@@ -0,0 +1,230 @@
<?php
namespace Illuminate\Support;
use Carbon\Factory;
use InvalidArgumentException;
/**
* @see https://carbon.nesbot.com/docs/
* @see https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Factory.php
*
* @method static Carbon create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null)
* @method static Carbon createFromDate($year = null, $month = null, $day = null, $tz = null)
* @method static Carbon|false createFromFormat($format, $time, $tz = null)
* @method static Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null)
* @method static Carbon createFromTimeString($time, $tz = null)
* @method static Carbon createFromTimestamp($timestamp, $tz = null)
* @method static Carbon createFromTimestampMs($timestamp, $tz = null)
* @method static Carbon createFromTimestampUTC($timestamp)
* @method static Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null)
* @method static Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
* @method static Carbon disableHumanDiffOption($humanDiffOption)
* @method static Carbon enableHumanDiffOption($humanDiffOption)
* @method static mixed executeWithLocale($locale, $func)
* @method static Carbon fromSerialized($value)
* @method static array getAvailableLocales()
* @method static array getDays()
* @method static int getHumanDiffOptions()
* @method static array getIsoUnits()
* @method static Carbon getLastErrors()
* @method static string getLocale()
* @method static int getMidDayAt()
* @method static Carbon getTestNow()
* @method static \Symfony\Component\Translation\TranslatorInterface getTranslator()
* @method static int getWeekEndsAt()
* @method static int getWeekStartsAt()
* @method static array getWeekendDays()
* @method static bool hasFormat($date, $format)
* @method static bool hasMacro($name)
* @method static bool hasRelativeKeywords($time)
* @method static bool hasTestNow()
* @method static Carbon instance($date)
* @method static bool isImmutable()
* @method static bool isModifiableUnit($unit)
* @method static Carbon isMutable()
* @method static bool isStrictModeEnabled()
* @method static bool localeHasDiffOneDayWords($locale)
* @method static bool localeHasDiffSyntax($locale)
* @method static bool localeHasDiffTwoDayWords($locale)
* @method static bool localeHasPeriodSyntax($locale)
* @method static bool localeHasShortUnits($locale)
* @method static void macro($name, $macro)
* @method static Carbon|null make($var)
* @method static Carbon maxValue()
* @method static Carbon minValue()
* @method static void mixin($mixin)
* @method static Carbon now($tz = null)
* @method static Carbon parse($time = null, $tz = null)
* @method static string pluralUnit(string $unit)
* @method static void resetMonthsOverflow()
* @method static void resetToStringFormat()
* @method static void resetYearsOverflow()
* @method static void serializeUsing($callback)
* @method static Carbon setHumanDiffOptions($humanDiffOptions)
* @method static bool setLocale($locale)
* @method static void setMidDayAt($hour)
* @method static Carbon setTestNow($testNow = null)
* @method static void setToStringFormat($format)
* @method static void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator)
* @method static Carbon setUtf8($utf8)
* @method static void setWeekEndsAt($day)
* @method static void setWeekStartsAt($day)
* @method static void setWeekendDays($days)
* @method static bool shouldOverflowMonths()
* @method static bool shouldOverflowYears()
* @method static string singularUnit(string $unit)
* @method static Carbon today($tz = null)
* @method static Carbon tomorrow($tz = null)
* @method static void useMonthsOverflow($monthsOverflow = true)
* @method static Carbon useStrictMode($strictModeEnabled = true)
* @method static void useYearsOverflow($yearsOverflow = true)
* @method static Carbon yesterday($tz = null)
*/
class DateFactory
{
/**
* The default class that will be used for all created dates.
*
* @var string
*/
const DEFAULT_CLASS_NAME = Carbon::class;
/**
* The type (class) of dates that should be created.
*
* @var string
*/
protected static $dateClass;
/**
* This callable may be used to intercept date creation.
*
* @var callable
*/
protected static $callable;
/**
* The Carbon factory that should be used when creating dates.
*
* @var object
*/
protected static $factory;
/**
* Use the given handler when generating dates (class name, callable, or factory).
*
* @param mixed $handler
*
* @throws \InvalidArgumentException
*/
public static function use($handler)
{
if (is_callable($handler) && is_object($handler)) {
return static::useCallable($handler);
} elseif (is_string($handler)) {
return static::useClass($handler);
} elseif ($handler instanceof Factory) {
return static::useFactory($handler);
}
throw new InvalidArgumentException('Invalid date creation handler. Please provide a class name, callable, or Carbon factory.');
}
/**
* Use the default date class when generating dates.
*
* @return void
*/
public static function useDefault()
{
static::$dateClass = null;
static::$callable = null;
static::$factory = null;
}
/**
* Execute the given callable on each date creation.
*
* @param callable $callable
* @return void
*/
public static function useCallable(callable $callable)
{
static::$callable = $callable;
static::$dateClass = null;
static::$factory = null;
}
/**
* Use the given date type (class) when generating dates.
*
* @param string $dateClass
* @return void
*/
public static function useClass($dateClass)
{
static::$dateClass = $dateClass;
static::$factory = null;
static::$callable = null;
}
/**
* Use the given Carbon factory when generating dates.
*
* @param object $factory
* @return void
*/
public static function useFactory($factory)
{
static::$factory = $factory;
static::$dateClass = null;
static::$callable = null;
}
/**
* Handle dynamic calls to generate dates.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \RuntimeException
*/
public function __call($method, $parameters)
{
$defaultClassName = static::DEFAULT_CLASS_NAME;
// Using callable to generate dates...
if (static::$callable) {
return call_user_func(static::$callable, $defaultClassName::$method(...$parameters));
}
// Using Carbon factory to generate dates...
if (static::$factory) {
return static::$factory->$method(...$parameters);
}
$dateClass = static::$dateClass ?: $defaultClassName;
// Check if date can be created using public class method...
if (method_exists($dateClass, $method) ||
method_exists($dateClass, 'hasMacro') && $dateClass::hasMacro($method)) {
return $dateClass::$method(...$parameters);
}
// If that fails, create the date with the default class..
$date = $defaultClassName::$method(...$parameters);
// If the configured class has an "instance" method, we'll try to pass our date into there...
if (method_exists($dateClass, 'instance')) {
return $dateClass::instance($date);
}
// Otherwise, assume the configured class has a DateTime compatible constructor...
return new $dateClass($date->format('Y-m-d H:i:s.u'), $date->getTimezone());
}
}

View File

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

View File

@@ -1,29 +0,0 @@
<?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 = [
'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

@@ -5,17 +5,44 @@ namespace Illuminate\Support\Facades;
/**
* @method static string version()
* @method static string basePath()
* @method static string environment()
* @method static string bootstrapPath(string $path = '')
* @method static string configPath(string $path = '')
* @method static string databasePath(string $path = '')
* @method static string environmentPath()
* @method static string resourcePath(string $path = '')
* @method static string storagePath(string $path = '')
* @method static string|bool environment(string|array ...$environments)
* @method static bool runningInConsole()
* @method static bool runningUnitTests()
* @method static bool isDownForMaintenance()
* @method static void registerConfiguredProviders()
* @method static \Illuminate\Support\ServiceProvider register(\Illuminate\Support\ServiceProvider|string $provider, array $options = [], bool $force = false)
* @method static \Illuminate\Support\ServiceProvider register(\Illuminate\Support\ServiceProvider|string $provider, bool $force = false)
* @method static void registerDeferredProvider(string $provider, string $service = null)
* @method static \Illuminate\Support\ServiceProvider resolveProvider(string $provider)
* @method static void boot()
* @method static void booting(mixed $callback)
* @method static void booted(mixed $callback)
* @method static void booting(callable $callback)
* @method static void booted(callable $callback)
* @method static void bootstrapWith(array $bootstrappers)
* @method static bool configurationIsCached()
* @method static string detectEnvironment(callable $callback)
* @method static string environmentFile()
* @method static string environmentFilePath()
* @method static string getCachedConfigPath()
* @method static string getCachedServicesPath()
* @method static string getCachedPackagesPath()
* @method static string getCachedRoutesPath()
* @method static string getLocale()
* @method static string getNamespace()
* @method static array getProviders(\Illuminate\Support\ServiceProvider|string $provider)
* @method static bool hasBeenBootstrapped()
* @method static void loadDeferredProviders()
* @method static \Illuminate\Contracts\Foundation\Application loadEnvironmentFrom(string $file)
* @method static bool routesAreCached()
* @method static void setLocale(string $locale)
* @method static bool shouldSkipMiddleware()
* @method static void terminate()
*
* @see \Illuminate\Foundation\Application
* @see \Illuminate\Contracts\Foundation\Application
*/
class App extends Facade
{

View File

@@ -5,11 +5,12 @@ namespace Illuminate\Support\Facades;
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
/**
* @method static int handle(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output = null)
* @method static int call(string $command, array $parameters = [], $outputBuffer = null)
* @method static int queue(string $command, array $parameters = [])
* @method static int handle(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface|null $output = null)
* @method static int call(string $command, array $parameters = [], \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch queue(string $command, array $parameters = [])
* @method static array all()
* @method static string output()
* @method static void terminate(\Symfony\Component\Console\Input\InputInterface $input, int $status)
*
* @see \Illuminate\Contracts\Console\Kernel
*/

View File

@@ -44,10 +44,11 @@ class Auth extends Facade
/**
* Register the typical authentication routes for an application.
*
* @param array $options
* @return void
*/
public static function routes()
public static function routes(array $options = [])
{
static::$app->make('router')->auth();
static::$app->make('router')->auth($options);
}
}

View File

@@ -3,20 +3,20 @@
namespace Illuminate\Support\Facades;
/**
* @method static void compile($path = null)
* @method static void compile(string|null $path = null)
* @method static string getPath()
* @method static void setPath($path)
* @method static string compileString($value)
* @method static string stripParentheses($expression)
* @method static void setPath(string $path)
* @method static string compileString(string $value)
* @method static string stripParentheses(string $expression)
* @method static void extend(callable $compiler)
* @method static array getExtensions()
* @method static void if($name, callable $callback)
* @method static bool check($name, ...$parameters)
* @method static void component($path, $alias = null)
* @method static void include($path, $alias = null)
* @method static void directive($name, callable $handler)
* @method static void if(string $name, callable $callback)
* @method static bool check(string $name, array ...$parameters)
* @method static void component(string $path, string|null $alias = null)
* @method static void include(string $path, string|null $alias = null)
* @method static void directive(string $name, callable $handler)
* @method static array getCustomDirectives()
* @method static void setEchoFormat($format)
* @method static void setEchoFormat(string $format)
* @method static void withDoubleEncoding()
* @method static void withoutDoubleEncoding()
*
@@ -31,6 +31,6 @@ class Blade extends Facade
*/
protected static function getFacadeAccessor()
{
return static::$app['view']->getEngineResolver()->resolve('blade')->getCompiler();
return 'blade.compiler';
}
}

View File

@@ -20,11 +20,13 @@ class Bus extends Facade
/**
* Replace the bound instance with a fake.
*
* @return void
* @return \Illuminate\Support\Testing\Fakes\BusFake
*/
public static function fake()
{
static::swap(new BusFake);
static::swap($fake = new BusFake);
return $fake;
}
/**

View File

@@ -5,14 +5,15 @@ namespace Illuminate\Support\Facades;
/**
* @method static \Illuminate\Contracts\Cache\Repository store(string|null $name = null)
* @method static bool has(string $key)
* @method static bool missing(string $key)
* @method static mixed get(string $key, mixed $default = null)
* @method static mixed pull(string $key, mixed $default = null)
* @method static void put(string $key, $value, \DateTimeInterface|\DateInterval|float|int $minutes)
* @method static bool add(string $key, $value, \DateTimeInterface|\DateInterval|float|int $minutes)
* @method static bool put(string $key, $value, \DateTimeInterface|\DateInterval|int $ttl)
* @method static bool add(string $key, $value, \DateTimeInterface|\DateInterval|int $ttl)
* @method static int|bool increment(string $key, $value = 1)
* @method static int|bool decrement(string $key, $value = 1)
* @method static void forever(string $key, $value)
* @method static mixed remember(string $key, \DateTimeInterface|\DateInterval|float|int $minutes, \Closure $callback)
* @method static bool forever(string $key, $value)
* @method static mixed remember(string $key, \DateTimeInterface|\DateInterval|int $ttl, \Closure $callback)
* @method static mixed sear(string $key, \Closure $callback)
* @method static mixed rememberForever(string $key, \Closure $callback)
* @method static bool forget(string $key)

View File

@@ -27,7 +27,7 @@ class Cookie extends Facade
*
* @param string $key
* @param mixed $default
* @return string
* @return string|array|null
*/
public static function get($key = null, $default = null)
{

View File

@@ -3,8 +3,13 @@
namespace Illuminate\Support\Facades;
/**
* @method static string encrypt(string $value, bool $serialize = true)
* @method static string decrypt(string $payload, bool $unserialize = true)
* @method static bool supported(string $key, string $cipher)
* @method static string generateKey(string $cipher)
* @method static string encrypt(mixed $value, bool $serialize = true)
* @method static string encryptString(string $value)
* @method static mixed decrypt(string $payload, bool $unserialize = true)
* @method static string decryptString(string $payload)
* @method static string getKey()
*
* @see \Illuminate\Encryption\Encrypter
*/

View File

@@ -0,0 +1,115 @@
<?php
namespace Illuminate\Support\Facades;
use Illuminate\Support\DateFactory;
/**
* @see https://carbon.nesbot.com/docs/
* @see https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Factory.php
*
* @method static \Illuminate\Support\Carbon create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null)
* @method static \Illuminate\Support\Carbon createFromDate($year = null, $month = null, $day = null, $tz = null)
* @method static \Illuminate\Support\Carbon|false createFromFormat($format, $time, $tz = null)
* @method static \Illuminate\Support\Carbon createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null)
* @method static \Illuminate\Support\Carbon createFromTimeString($time, $tz = null)
* @method static \Illuminate\Support\Carbon createFromTimestamp($timestamp, $tz = null)
* @method static \Illuminate\Support\Carbon createFromTimestampMs($timestamp, $tz = null)
* @method static \Illuminate\Support\Carbon createFromTimestampUTC($timestamp)
* @method static \Illuminate\Support\Carbon createMidnightDate($year = null, $month = null, $day = null, $tz = null)
* @method static \Illuminate\Support\Carbon|false createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
* @method static \Illuminate\Support\Carbon disableHumanDiffOption($humanDiffOption)
* @method static \Illuminate\Support\Carbon enableHumanDiffOption($humanDiffOption)
* @method static mixed executeWithLocale($locale, $func)
* @method static \Illuminate\Support\Carbon fromSerialized($value)
* @method static array getAvailableLocales()
* @method static array getDays()
* @method static int getHumanDiffOptions()
* @method static array getIsoUnits()
* @method static \Illuminate\Support\Carbon getLastErrors()
* @method static string getLocale()
* @method static int getMidDayAt()
* @method static \Illuminate\Support\Carbon getTestNow()
* @method static \Symfony\Component\Translation\TranslatorInterface getTranslator()
* @method static int getWeekEndsAt()
* @method static int getWeekStartsAt()
* @method static array getWeekendDays()
* @method static bool hasFormat($date, $format)
* @method static bool hasMacro($name)
* @method static bool hasRelativeKeywords($time)
* @method static bool hasTestNow()
* @method static \Illuminate\Support\Carbon instance($date)
* @method static bool isImmutable()
* @method static bool isModifiableUnit($unit)
* @method static \Illuminate\Support\Carbon isMutable()
* @method static bool isStrictModeEnabled()
* @method static bool localeHasDiffOneDayWords($locale)
* @method static bool localeHasDiffSyntax($locale)
* @method static bool localeHasDiffTwoDayWords($locale)
* @method static bool localeHasPeriodSyntax($locale)
* @method static bool localeHasShortUnits($locale)
* @method static void macro($name, $macro)
* @method static \Illuminate\Support\Carbon|null make($var)
* @method static \Illuminate\Support\Carbon maxValue()
* @method static \Illuminate\Support\Carbon minValue()
* @method static void mixin($mixin)
* @method static \Illuminate\Support\Carbon now($tz = null)
* @method static \Illuminate\Support\Carbon parse($time = null, $tz = null)
* @method static string pluralUnit(string $unit)
* @method static void resetMonthsOverflow()
* @method static void resetToStringFormat()
* @method static void resetYearsOverflow()
* @method static void serializeUsing($callback)
* @method static \Illuminate\Support\Carbon setHumanDiffOptions($humanDiffOptions)
* @method static bool setLocale($locale)
* @method static void setMidDayAt($hour)
* @method static \Illuminate\Support\Carbon setTestNow($testNow = null)
* @method static void setToStringFormat($format)
* @method static void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator)
* @method static \Illuminate\Support\Carbon setUtf8($utf8)
* @method static void setWeekEndsAt($day)
* @method static void setWeekStartsAt($day)
* @method static void setWeekendDays($days)
* @method static bool shouldOverflowMonths()
* @method static bool shouldOverflowYears()
* @method static string singularUnit(string $unit)
* @method static \Illuminate\Support\Carbon today($tz = null)
* @method static \Illuminate\Support\Carbon tomorrow($tz = null)
* @method static void useMonthsOverflow($monthsOverflow = true)
* @method static \Illuminate\Support\Carbon useStrictMode($strictModeEnabled = true)
* @method static void useYearsOverflow($yearsOverflow = true)
* @method static \Illuminate\Support\Carbon yesterday($tz = null)
*/
class Date extends Facade
{
const DEFAULT_FACADE = DateFactory::class;
/**
* Get the registered name of the component.
*
* @return string
*
* @throws \RuntimeException
*/
protected static function getFacadeAccessor()
{
return 'date';
}
/**
* Resolve the facade root instance from the container.
*
* @param string $name
* @return mixed
*/
protected static function resolveFacadeInstance($name)
{
if (! isset(static::$resolvedInstance[$name]) && ! isset(static::$app, static::$app[$name])) {
$class = static::DEFAULT_FACADE;
static::swap(new $class);
}
return parent::resolveFacadeInstance($name);
}
}

View File

@@ -6,15 +6,19 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Testing\Fakes\EventFake;
/**
* @method static void listen(string | array $events, $listener)
* @method static void listen(string|array $events, mixed $listener)
* @method static bool hasListeners(string $eventName)
* @method static void subscribe(object | string $subscriber)
* @method static array|null until(string | object $event, $payload = [])
* @method static array|null dispatch(string | object $event, $payload = [], bool $halt = false)
* @method static void push(string $event, array $payload = [])
* @method static void flush(string $event)
* @method static void subscribe(object|string $subscriber)
* @method static array|null until(string|object $event, mixed $payload = [])
* @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false)
* @method static array getListeners(string $eventName)
* @method static \Closure makeListener(\Closure|string $listener, bool $wildcard = false)
* @method static \Closure createClassListener(string $listener, bool $wildcard = false)
* @method static void forget(string $event)
* @method static void forgetPushed()
* @method static \Illuminate\Events\Dispatcher setQueueResolver(callable $resolver)
*
* @see \Illuminate\Events\Dispatcher
*/
@@ -24,20 +28,22 @@ class Event extends Facade
* Replace the bound instance with a fake.
*
* @param array|string $eventsToFake
* @return void
* @return \Illuminate\Support\Testing\Fakes\EventFake
*/
public static function fake($eventsToFake = [])
{
static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake));
Model::setEventDispatcher($fake);
return $fake;
}
/**
* Replace the bound instance with a fake during the given callable's execution.
*
* @param callable $callable
* @param array|string $eventsToFake
* @param array $eventsToFake
* @return callable
*/
public static function fakeFor(callable $callable, array $eventsToFake = [])

View File

@@ -2,6 +2,7 @@
namespace Illuminate\Support\Facades;
use Closure;
use Mockery;
use RuntimeException;
use Mockery\MockInterface;
@@ -22,6 +23,19 @@ abstract class Facade
*/
protected static $resolvedInstance;
/**
* Run a Closure when the facade has been resolved.
*
* @param \Closure $callback
* @return void
*/
public static function resolved(Closure $callback)
{
static::$app->afterResolving(static::getFacadeAccessor(), function ($service) use ($callback) {
$callback($service);
});
}
/**
* Convert the facade into a Mockery spy.
*
@@ -145,7 +159,7 @@ abstract class Facade
/**
* Resolve the facade root instance from the container.
*
* @param string|object $name
* @param object|string $name
* @return mixed
*/
protected static function resolveFacadeInstance($name)
@@ -158,7 +172,9 @@ abstract class Facade
return static::$resolvedInstance[$name];
}
return static::$resolvedInstance[$name] = static::$app[$name];
if (static::$app) {
return static::$resolvedInstance[$name] = static::$app[$name];
}
}
/**

View File

@@ -9,10 +9,11 @@ namespace Illuminate\Support\Facades;
* @method static mixed getRequire(string $path)
* @method static mixed requireOnce(string $file)
* @method static string hash(string $path)
* @method static int put(string $path, string $contents, bool $lock = false)
* @method static int|bool put(string $path, string $contents, bool $lock = false)
* @method static void replace(string $path, string $content)
* @method static int prepend(string $path, string $data)
* @method static int append(string $path, string $data)
* @method static mixed chmod(string $path, int $mode = null)
* @method static mixed chmod(string $path, int|null $mode = null)
* @method static bool delete(string|array $paths)
* @method static bool move(string $path, string $target)
* @method static bool copy(string $path, string $target)
@@ -33,10 +34,11 @@ namespace Illuminate\Support\Facades;
* @method static \Symfony\Component\Finder\SplFileInfo[] files(string $directory, bool $hidden = false)
* @method static \Symfony\Component\Finder\SplFileInfo[] allFiles(string $directory, bool $hidden = false)
* @method static array directories(string $directory)
* @method static bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false)
* @method static bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false)
* @method static bool moveDirectory(string $from, string $to, bool $overwrite = false)
* @method static bool copyDirectory(string $directory, string $destination, int $options = null)
* @method static bool copyDirectory(string $directory, string $destination, int|null $options = null)
* @method static bool deleteDirectory(string $directory, bool $preserve = false)
* @method static bool deleteDirectories(string $directory)
* @method static bool cleanDirectory(string $directory)
*
* @see \Illuminate\Filesystem\Filesystem

View File

@@ -6,17 +6,18 @@ use Illuminate\Contracts\Auth\Access\Gate as GateContract;
/**
* @method static bool has(string $ability)
* @method static \Illuminate\Contracts\Auth\Access\Gate define(string $ability, callable | string $callback)
* @method static \Illuminate\Contracts\Auth\Access\Gate define(string $ability, callable|string $callback)
* @method static \Illuminate\Contracts\Auth\Access\Gate policy(string $class, string $policy)
* @method static \Illuminate\Contracts\Auth\Access\Gate before(callable $callback)
* @method static \Illuminate\Contracts\Auth\Access\Gate after(callable $callback)
* @method static bool allows(string $ability, array | mixed $arguments = [])
* @method static bool denies(string $ability, array | mixed $arguments = [])
* @method static bool check(iterable | string $abilities, array | mixed $arguments = [])
* @method static bool any(iterable | string $abilities, array | mixed $arguments = [])
* @method static \Illuminate\Auth\Access\Response authorize(string $ability, array | mixed $arguments = [])
* @method static mixed getPolicyFor(object | string $class)
* @method static \Illuminate\Contracts\Auth\Access\Gate forUser(\Illuminate\Contracts\Auth\Authenticatable | mixed $user)
* @method static bool allows(string $ability, array|mixed $arguments = [])
* @method static bool denies(string $ability, array|mixed $arguments = [])
* @method static bool check(iterable|string $abilities, array|mixed $arguments = [])
* @method static bool any(iterable|string $abilities, array|mixed $arguments = [])
* @method static \Illuminate\Auth\Access\Response authorize(string $ability, array|mixed $arguments = [])
* @method static mixed raw(string $ability, array|mixed $arguments = [])
* @method static mixed getPolicyFor(object|string $class)
* @method static \Illuminate\Contracts\Auth\Access\Gate forUser(\Illuminate\Contracts\Auth\Authenticatable|mixed $user)
* @method static array abilities()
*
* @see \Illuminate\Contracts\Auth\Access\Gate

View File

@@ -3,6 +3,43 @@
namespace Illuminate\Support\Facades;
/**
* @method static bool matchesType(string $actual, string $type)
* @method static bool isJson()
* @method static bool expectsJson()
* @method static bool wantsJson()
* @method static bool accepts(string|array $contentTypes)
* @method static bool prefers(string|array $contentTypes)
* @method static bool acceptsAnyContentType()
* @method static bool acceptsJson()
* @method static bool acceptsHtml()
* @method static string format($default = 'html')
* @method static string|array old(string|null $key = null, string|array|null $default = null)
* @method static void flash()
* @method static void flashOnly(array|mixed $keys)
* @method static void flashExcept(array|mixed $keys)
* @method static void flush()
* @method static string|array|null server(string|null $key = null, string|array|null $default = null)
* @method static bool hasHeader(string $key)
* @method static string|array|null header(string|null $key = null, string|array|null $default = null)
* @method static string|null bearerToken()
* @method static bool exists(string|array $key)
* @method static bool has(string|array $key)
* @method static bool hasAny(string|array $key)
* @method static bool filled(string|array $key)
* @method static bool anyFilled(string|array $key)
* @method static array keys()
* @method static array all(array|mixed|null $keys = null)
* @method static string|array|null input(string|null $key = null, string|array|null $default = null)
* @method static array only(array|mixed $keys)
* @method static array except(array|mixed $keys)
* @method static string|array|null query(string|null $key = null, string|array|null $default = null)
* @method static string|array|null post(string|null $key = null, string|array|null $default = null)
* @method static bool hasCookie(string $key)
* @method static string|array|null cookie(string|null $key = null, string|array|null $default = null)
* @method static array allFiles()
* @method static bool hasFile(string $key)
* @method static \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]|array|null file(string|null $key = null, mixed $default = null)
* @method static \Illuminate\Http\Request capture()
* @method static \Illuminate\Http\Request instance()
* @method static string method()
* @method static string root()
@@ -13,23 +50,28 @@ namespace Illuminate\Support\Facades;
* @method static string decodedPath()
* @method static string|null segment(int $index, string|null $default = null)
* @method static array segments()
* @method static bool is(...$patterns)
* @method static bool routeIs(...$patterns)
* @method static bool fullUrlIs(...$patterns)
* @method static bool is(mixed ...$patterns)
* @method static bool routeIs(mixed ...$patterns)
* @method static bool fullUrlIs(mixed ...$patterns)
* @method static bool ajax()
* @method static bool pjax()
* @method static bool prefetch()
* @method static bool secure()
* @method static string ip()
* @method static string|null ip()
* @method static array ips()
* @method static string userAgent()
* @method static \Illuminate\Http\Request merge(array $input)
* @method static \Illuminate\Http\Request replace(array $input)
* @method static \Symfony\Component\HttpFoundation\ParameterBag|mixed json(string $key = null, $default = null)
* @method static \Symfony\Component\HttpFoundation\ParameterBag|mixed json(string|null $key = null, mixed $default = null)
* @method static \Illuminate\Http\Request createFrom(\Illuminate\Http\Request $from, \Illuminate\Http\Request|null $to = null)
* @method static \Illuminate\Http\Request createFromBase(\Symfony\Component\HttpFoundation\Request $request)
* @method static \Illuminate\Http\Request duplicate(array|null $query = null, array|null $request = null, array|null $attributes = null, array|null $cookies = null, array|null $files = null, array|null $server = null)
* @method static mixed filterFiles(mixed $files)
* @method static \Illuminate\Session\Store session()
* @method static \Illuminate\Session\Store|null getSession()
* @method static void setLaravelSession(\Illuminate\Contracts\Session\Session $session)
* @method static mixed user(string|null $guard = null)
* @method static \Illuminate\Routing\Route|object|string route(string|null $param = null)
* @method static \Illuminate\Routing\Route|object|string route(string|null $param = null, string|null $default = null)
* @method static string fingerprint()
* @method static \Illuminate\Http\Request setJson(\Symfony\Component\HttpFoundation\ParameterBag $json)
* @method static \Closure getUserResolver()
@@ -39,7 +81,7 @@ namespace Illuminate\Support\Facades;
* @method static array toArray()
* @method static bool offsetExists(string $offset)
* @method static mixed offsetGet(string $offset)
* @method static void offsetSet(string $offset, $value)
* @method static void offsetSet(string $offset, mixed $value)
* @method static void offsetUnset(string $offset)
*
* @see \Illuminate\Http\Request
@@ -51,7 +93,7 @@ class Input extends Facade
*
* This method is used for all request verbs (GET, POST, PUT, and DELETE)
*
* @param string $key
* @param string|null $key
* @param mixed $default
* @return mixed
*/

View File

@@ -4,7 +4,7 @@ namespace Illuminate\Support\Facades;
/**
* @method static mixed trans(string $key, array $replace = [], string $locale = null)
* @method static string transChoice(string $key, int | array | \Countable $number, array $replace = [], string $locale = null)
* @method static string transChoice(string $key, int|array|\Countable $number, array $replace = [], string $locale = null)
* @method static string getLocale()
* @method static void setLocale(string $locale)
* @method static string|array|null get(string $key, array $replace = [], string $locale = null, bool $fallback = true)

View File

@@ -2,8 +2,6 @@
namespace Illuminate\Support\Facades;
use Psr\Log\LoggerInterface;
/**
* @method static void emergency(string $message, array $context = [])
* @method static void alert(string $message, array $context = [])
@@ -28,6 +26,6 @@ class Log extends Facade
*/
protected static function getFacadeAccessor()
{
return LoggerInterface::class;
return 'log';
}
}

View File

@@ -12,19 +12,32 @@ use Illuminate\Support\Testing\Fakes\MailFake;
* @method static array failures()
* @method static mixed queue(string|array|\Illuminate\Contracts\Mail\Mailable $view, string $queue = null)
* @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, string|array|\Illuminate\Contracts\Mail\Mailable $view, string $queue = null)
* @method static void assertSent(string $mailable, \Closure|string $callback = null)
* @method static void assertNotSent(string $mailable, \Closure|string $callback = null)
* @method static void assertNothingSent()
* @method static void assertQueued(string $mailable, \Closure|string $callback = null)
* @method static void assertNotQueued(string $mailable, \Closure|string $callback = null)
* @method static void assertNothingQueued()
* @method static \Illuminate\Support\Collection sent(string $mailable, \Closure|string $callback = null)
* @method static bool hasSent(string $mailable)
* @method static \Illuminate\Support\Collection queued(string $mailable, \Closure|string $callback = null)
* @method static bool hasQueued(string $mailable)
*
* @see \Illuminate\Mail\Mailer
* @see \Illuminate\Support\Testing\Fakes\MailFake
*/
class Mail extends Facade
{
/**
* Replace the bound instance with a fake.
*
* @return void
* @return \Illuminate\Support\Testing\Fakes\MailFake
*/
public static function fake()
{
static::swap(new MailFake);
static::swap($fake = new MailFake);
return $fake;
}
/**

View File

@@ -10,6 +10,7 @@ use Illuminate\Support\Testing\Fakes\NotificationFake;
* @method static void send(\Illuminate\Support\Collection|array|mixed $notifiables, $notification)
* @method static void sendNow(\Illuminate\Support\Collection|array|mixed $notifiables, $notification)
* @method static mixed channel(string|null $name = null)
* @method static \Illuminate\Notifications\ChannelManager locale(string|null $locale)
*
* @see \Illuminate\Notifications\ChannelManager
*/

View File

@@ -2,6 +2,8 @@
namespace Illuminate\Support\Facades;
use Illuminate\Contracts\Auth\PasswordBroker;
/**
* @method static string sendResetLink(array $credentials)
* @method static mixed reset(array $credentials, \Closure $callback)
@@ -17,35 +19,35 @@ class Password extends Facade
*
* @var string
*/
const RESET_LINK_SENT = 'passwords.sent';
const RESET_LINK_SENT = PasswordBroker::RESET_LINK_SENT;
/**
* Constant representing a successfully reset password.
*
* @var string
*/
const PASSWORD_RESET = 'passwords.reset';
const PASSWORD_RESET = PasswordBroker::PASSWORD_RESET;
/**
* Constant representing the user not found response.
*
* @var string
*/
const INVALID_USER = 'passwords.user';
const INVALID_USER = PasswordBroker::INVALID_USER;
/**
* Constant representing an invalid password.
*
* @var string
*/
const INVALID_PASSWORD = 'passwords.password';
const INVALID_PASSWORD = PasswordBroker::INVALID_PASSWORD;
/**
* Constant representing an invalid token.
*
* @var string
*/
const INVALID_TOKEN = 'passwords.token';
const INVALID_TOKEN = PasswordBroker::INVALID_TOKEN;
/**
* Get the registered name of the component.

View File

@@ -6,12 +6,12 @@ use Illuminate\Support\Testing\Fakes\QueueFake;
/**
* @method static int size(string $queue = null)
* @method static mixed push(string|object $job, string $data = '', $queue = null)
* @method static mixed pushOn(string $queue, string|object $job, $data = '')
* @method static mixed push(string|object $job, mixed $data = '', $queue = null)
* @method static mixed pushOn(string $queue, string|object $job, mixed $data = '')
* @method static mixed pushRaw(string $payload, string $queue = null, array $options = [])
* @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, string|object $job, $data = '', string $queue = null)
* @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, string|object $job, $data = '')
* @method static mixed bulk(array $jobs, $data = '', string $queue = null)
* @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, string|object $job, mixed $data = '', string $queue = null)
* @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, string|object $job, mixed $data = '')
* @method static mixed bulk(array $jobs, mixed $data = '', string $queue = null)
* @method static \Illuminate\Contracts\Queue\Job|null pop(string $queue = null)
* @method static string getConnectionName()
* @method static \Illuminate\Contracts\Queue\Queue setConnectionName(string $name)
@@ -24,11 +24,13 @@ class Queue extends Facade
/**
* Replace the bound instance with a fake.
*
* @return void
* @return \Illuminate\Support\Testing\Fakes\QueueFake
*/
public static function fake()
{
static::swap(new QueueFake(static::getFacadeApplication()));
static::swap($fake = new QueueFake(static::getFacadeApplication()));
return $fake;
}
/**

View File

@@ -6,17 +6,19 @@ use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract;
/**
* @method static \Illuminate\Http\Response make(string $content = '', int $status = 200, array $headers = [])
* @method static \Illuminate\Http\Response noContent($status = 204, array $headers = [])
* @method static \Illuminate\Http\Response view(string $view, array $data = [], int $status = 200, array $headers = [])
* @method static \Illuminate\Http\JsonResponse json(string | array $data = [], int $status = 200, array $headers = [], int $options = 0)
* @method static \Illuminate\Http\JsonResponse jsonp(string $callback, string | array $data = [], int $status = 200, array $headers = [], int $options = 0)
* @method static \Illuminate\Http\JsonResponse json(string|array $data = [], int $status = 200, array $headers = [], int $options = 0)
* @method static \Illuminate\Http\JsonResponse jsonp(string $callback, string|array $data = [], int $status = 200, array $headers = [], int $options = 0)
* @method static \Symfony\Component\HttpFoundation\StreamedResponse stream(\Closure $callback, int $status = 200, array $headers = [])
* @method static \Symfony\Component\HttpFoundation\StreamedResponse streamDownload(\Closure $callback, string | null $name = null, array $headers = [], string | null $disposition = 'attachment')
* @method static \Symfony\Component\HttpFoundation\BinaryFileResponse download(\SplFileInfo | string $file, string | null $name = null, array $headers = [], string | null $disposition = 'attachment')
* @method static \Illuminate\Http\RedirectResponse redirectTo(string $path, int $status = 302, array $headers = [], bool | null $secure = null)
* @method static \Symfony\Component\HttpFoundation\StreamedResponse streamDownload(\Closure $callback, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')
* @method static \Symfony\Component\HttpFoundation\BinaryFileResponse download(\SplFileInfo|string $file, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')
* @method static \Symfony\Component\HttpFoundation\BinaryFileResponse file($file, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse redirectTo(string $path, int $status = 302, array $headers = [], bool|null $secure = null)
* @method static \Illuminate\Http\RedirectResponse redirectToRoute(string $route, array $parameters = [], int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse redirectToAction(string $action, array $parameters = [], int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse redirectGuest(string $path, int $status = 302, array $headers = [], bool | null $secure = null)
* @method static \Illuminate\Http\RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool | null $secure = null)
* @method static \Illuminate\Http\RedirectResponse redirectGuest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)
* @method static \Illuminate\Http\RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)
*
* @see \Illuminate\Contracts\Routing\ResponseFactory
*/

View File

@@ -3,14 +3,14 @@
namespace Illuminate\Support\Facades;
/**
* @method static \Illuminate\Routing\Route get(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route post(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route put(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route delete(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route patch(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route options(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route any(string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route get(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route post(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route put(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route delete(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route patch(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route options(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route any(string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, \Closure|array|string|callable|null $action = null)
* @method static \Illuminate\Routing\RouteRegistrar prefix(string $prefix)
* @method static \Illuminate\Routing\RouteRegistrar where(array $where)
* @method static \Illuminate\Routing\PendingResourceRegistration resource(string $name, string $controller, array $options = [])
@@ -24,9 +24,11 @@ namespace Illuminate\Support\Facades;
* @method static \Illuminate\Routing\RouteRegistrar name(string $value)
* @method static \Illuminate\Routing\RouteRegistrar namespace(string $value)
* @method static \Illuminate\Routing\Router|\Illuminate\Routing\RouteRegistrar group(array|\Closure|string $attributes, \Closure|string $routes)
* @method static \Illuminate\Routing\Route redirect(string $uri, string $destination, int $status = 301)
* @method static \Illuminate\Routing\Route redirect(string $uri, string $destination, int $status = 302)
* @method static \Illuminate\Routing\Route permanentRedirect(string $uri, string $destination)
* @method static \Illuminate\Routing\Route view(string $uri, string $view, array $data = [])
* @method static void bind(string $key, string|callable $binder)
* @method static void model(string $key, string $class, \Closure|null $callback = null)
* @method static \Illuminate\Routing\Route current()
* @method static string|null currentRouteName()
* @method static string|null currentRouteAction()

View File

@@ -7,7 +7,14 @@ namespace Illuminate\Support\Facades;
* @method static \Illuminate\Database\Schema\Builder drop(string $table)
* @method static \Illuminate\Database\Schema\Builder dropIfExists(string $table)
* @method static \Illuminate\Database\Schema\Builder table(string $table, \Closure $callback)
* @method static \Illuminate\Database\Schema\Builder rename(string $from, string $to)
* @method static void defaultStringLength(int $length)
* @method static bool hasTable(string $table)
* @method static bool hasColumn(string $table, string $column)
* @method static bool hasColumns(string $table, array $columns)
* @method static \Illuminate\Database\Schema\Builder disableForeignKeyConstraints()
* @method static \Illuminate\Database\Schema\Builder enableForeignKeyConstraints()
* @method static void registerCustomDoctrineType(string $class, string $name, string $type)
*
* @see \Illuminate\Database\Schema\Builder
*/
@@ -16,7 +23,7 @@ class Schema extends Facade
/**
* Get a schema builder instance for a connection.
*
* @param string $name
* @param string|null $name
* @return \Illuminate\Database\Schema\Builder
*/
public static function connection($name)

View File

@@ -12,6 +12,7 @@ namespace Illuminate\Support\Facades;
* @method static bool exists(string|array $key)
* @method static bool has(string|array $key)
* @method static mixed get(string $key, $default = null)
* @method static mixed pull(string $key, $default = null)
* @method static void put(string|array $key, $value = null)
* @method static string token()
* @method static mixed remove(string $key)

View File

@@ -16,7 +16,7 @@ class Storage extends Facade
*
* @param string|null $disk
*
* @return void
* @return \Illuminate\Filesystem\Filesystem
*/
public static function fake($disk = null)
{
@@ -26,22 +26,26 @@ class Storage extends Facade
$root = storage_path('framework/testing/disks/'.$disk)
);
static::set($disk, self::createLocalDriver(['root' => $root]));
static::set($disk, $fake = self::createLocalDriver(['root' => $root]));
return $fake;
}
/**
* Replace the given disk with a persistent local testing disk.
*
* @param string|null $disk
* @return void
* @return \Illuminate\Filesystem\Filesystem
*/
public static function persistentFake($disk = null)
{
$disk = $disk ?: self::$app['config']->get('filesystems.default');
static::set($disk, self::createLocalDriver([
static::set($disk, $fake = self::createLocalDriver([
'root' => storage_path('framework/testing/disks/'.$disk),
]));
return $fake;
}
/**

View File

@@ -12,9 +12,9 @@ namespace Illuminate\Support\Facades;
* @method static string route(string $name, $parameters = [], bool $absolute = true)
* @method static string action(string $action, $parameters = [], bool $absolute = true)
* @method static \Illuminate\Contracts\Routing\UrlGenerator setRootControllerNamespace(string $rootNamespace)
* @method static string signedRoute(string $name, array $parameters = [], \DateTimeInterface|int $expiration = null)
* @method static string temporarySignedRoute(string $name, \DateTimeInterface|int $expiration, array $parameters = [])
* @method static string hasValidSignature(\Illuminate\Http\Request $request)
* @method static string signedRoute(string $name, array $parameters = [], \DateTimeInterface|\DateInterval|int $expiration = null, bool $absolute = true)
* @method static string temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, array $parameters = [], bool $absolute = true)
* @method static string hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true)
* @method static void defaults(array $defaults)
*
* @see \Illuminate\Routing\UrlGenerator

View File

@@ -4,9 +4,9 @@ namespace Illuminate\Support\Facades;
/**
* @method static \Illuminate\Contracts\Validation\Validator make(array $data, array $rules, array $messages = [], array $customAttributes = [])
* @method static void extend(string $rule, \Closure | string $extension, string $message = null)
* @method static void extendImplicit(string $rule, \Closure | string $extension, string $message = null)
* @method static void replacer(string $rule, \Closure | string $replacer)
* @method static void extend(string $rule, \Closure|string $extension, string $message = null)
* @method static void extendImplicit(string $rule, \Closure|string $extension, string $message = null)
* @method static void replacer(string $rule, \Closure|string $replacer)
*
* @see \Illuminate\Validation\Factory
*/

View File

@@ -6,11 +6,11 @@ namespace Illuminate\Support\Facades;
* @method static bool exists(string $view)
* @method static \Illuminate\Contracts\View\View file(string $path, array $data = [], array $mergeData = [])
* @method static \Illuminate\Contracts\View\View make(string $view, array $data = [], array $mergeData = [])
* @method static mixed share(array | string $key, $value = null)
* @method static array composer(array | string $views, \Closure | string $callback)
* @method static array creator(array | string $views, \Closure | string $callback)
* @method static \Illuminate\Contracts\View\Factory addNamespace(string $namespace, string | array $hints)
* @method static \Illuminate\Contracts\View\Factory replaceNamespace(string $namespace, string | array $hints)
* @method static mixed share(array|string $key, $value = null)
* @method static array composer(array|string $views, \Closure|string $callback)
* @method static array creator(array|string $views, \Closure|string $callback)
* @method static \Illuminate\Contracts\View\Factory addNamespace(string $namespace, string|array $hints)
* @method static \Illuminate\Contracts\View\Factory replaceNamespace(string $namespace, string|array $hints)
*
* @see \Illuminate\View\Factory
*/

View File

@@ -10,16 +10,16 @@ use Illuminate\Contracts\Support\Arrayable;
class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
{
/**
* All of the attributes set on the container.
* All of the attributes set on the fluent instance.
*
* @var array
*/
protected $attributes = [];
/**
* Create a new fluent container instance.
* Create a new fluent instance.
*
* @param array|object $attributes
* @param array|object $attributes
* @return void
*/
public function __construct($attributes = [])
@@ -30,7 +30,7 @@ class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
}
/**
* Get an attribute from the container.
* Get an attribute from the fluent instance.
*
* @param string $key
* @param mixed $default
@@ -46,7 +46,7 @@ class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
}
/**
* Get the attributes from the container.
* Get the attributes from the fluent instance.
*
* @return array
*/
@@ -56,7 +56,7 @@ class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
}
/**
* Convert the Fluent instance to an array.
* Convert the fluent instance to an array.
*
* @return array
*/
@@ -76,7 +76,7 @@ class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
}
/**
* Convert the Fluent instance to JSON.
* Convert the fluent instance to JSON.
*
* @param int $options
* @return string
@@ -132,7 +132,7 @@ class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
}
/**
* Handle dynamic calls to the container to set attributes.
* Handle dynamic calls to the fluent instance to set attributes.
*
* @param string $method
* @param array $parameters

View File

@@ -34,7 +34,7 @@ trait InteractsWithTime
return $delay instanceof DateTimeInterface
? $delay->getTimestamp()
: Carbon::now()->addSeconds($delay)->getTimestamp();
: Carbon::now()->addRealSeconds($delay)->getTimestamp();
}
/**

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Taylor Otwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -10,7 +10,7 @@ abstract class Manager
/**
* The application instance.
*
* @var \Illuminate\Foundation\Application
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
@@ -31,7 +31,7 @@ abstract class Manager
/**
* Create a new manager instance.
*
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
@@ -84,9 +84,9 @@ abstract class Manager
*/
protected function createDriver($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.
// First, we will determine if a custom driver creator exists for the given driver and
// if it does not we will check for a creator method for the driver. Custom creator
// callbacks allow developers to build their own "drivers" easily using Closures.
if (isset($this->customCreators[$driver])) {
return $this->callCustomCreator($driver);
} else {

View File

@@ -34,8 +34,9 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
public function __construct(array $messages = [])
{
foreach ($messages as $key => $value) {
$this->messages[$key] = $value instanceof Arrayable
? $value->toArray() : (array) $value;
$value = $value instanceof Arrayable ? $value->toArray() : (array) $value;
$this->messages[$key] = array_unique($value);
}
}
@@ -50,7 +51,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Add a message to the bag.
* Add a message to the message bag.
*
* @param string $key
* @param string $message
@@ -80,7 +81,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Merge a new array of messages into the bag.
* Merge a new array of messages into the message bag.
*
* @param \Illuminate\Contracts\Support\MessageProvider|array $messages
* @return $this
@@ -104,6 +105,10 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
*/
public function has($key)
{
if ($this->isEmpty()) {
return false;
}
if (is_null($key)) {
return $this->any();
}
@@ -127,6 +132,10 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
*/
public function hasAny($keys = [])
{
if ($this->isEmpty()) {
return false;
}
$keys = is_array($keys) ? $keys : func_get_args();
foreach ($keys as $key) {
@@ -139,7 +148,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get the first message from the bag for a given key.
* Get the first message from the message bag for a given key.
*
* @param string $key
* @param string $format
@@ -155,7 +164,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get all of the messages from the bag for a given key.
* Get all of the messages from the message bag for a given key.
*
* @param string $key
* @param string $format
@@ -163,9 +172,9 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
*/
public function get($key, $format = null)
{
// If the message exists in the container, we will transform it and return
// the message. Otherwise, we'll check if the key is implicit & collect
// all the messages that match a given key and output it as an array.
// If the message exists in the message bag, we will transform it and return
// the message. Otherwise, we will check if the key is implicit & collect
// all the messages that match the given key and output it as an array.
if (array_key_exists($key, $this->messages)) {
return $this->transform(
$this->messages[$key], $this->checkFormat($format), $key
@@ -200,7 +209,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get all of the messages for every key in the bag.
* Get all of the messages for every key in the message bag.
*
* @param string $format
* @return array
@@ -219,7 +228,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get all of the unique messages for every key in the bag.
* Get all of the unique messages for every key in the message bag.
*
* @param string $format
* @return array
@@ -260,7 +269,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get the raw messages in the container.
* Get the raw messages in the message bag.
*
* @return array
*/
@@ -270,7 +279,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get the raw messages in the container.
* Get the raw messages in the message bag.
*
* @return array
*/
@@ -343,7 +352,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
}
/**
* Get the number of messages in the container.
* Get the number of messages in the message bag.
*
* @return int
*/

View File

@@ -74,7 +74,7 @@ class NamespacedItemResolver
*/
protected function parseNamespacedSegments($key)
{
list($namespace, $item) = explode('::', $key);
[$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

View File

@@ -45,7 +45,7 @@ class Optional implements ArrayAccess
/**
* Dynamically check a property exists on the underlying object.
*
* @param $name
* @param mixed $name
* @return bool
*/
public function __isset($name)

View File

@@ -45,6 +45,8 @@ class Pluralizer
'pokemon',
'police',
'rain',
'recommended',
'related',
'rice',
'series',
'sheep',

View File

@@ -3,6 +3,7 @@
namespace Illuminate\Support;
use Illuminate\Console\Application as Artisan;
use Illuminate\Contracts\Support\DeferrableProvider;
abstract class ServiceProvider
{
@@ -16,6 +17,8 @@ abstract class ServiceProvider
/**
* Indicates if loading of the provider is deferred.
*
* @deprecated Implement the \Illuminate\Contracts\Support\DeferrableProvider interface instead. Will be removed in Laravel 6.0.
*
* @var bool
*/
protected $defer = false;
@@ -45,6 +48,16 @@ abstract class ServiceProvider
$this->app = $app;
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Merge the given configuration with the existing configuration.
*
@@ -81,7 +94,7 @@ abstract class ServiceProvider
*/
protected function loadViewsFrom($path, $namespace)
{
if (is_array($this->app->config['view']['paths'])) {
if (isset($this->app->config['view']['paths']) && is_array($this->app->config['view']['paths'])) {
foreach ($this->app->config['view']['paths'] as $viewPath) {
if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
$this->app['view']->addNamespace($namespace, $appPath);
@@ -134,16 +147,16 @@ abstract class ServiceProvider
* Register paths to be published by the publish command.
*
* @param array $paths
* @param string $group
* @param mixed $groups
* @return void
*/
protected function publishes(array $paths, $group = null)
protected function publishes(array $paths, $groups = null)
{
$this->ensurePublishArrayInitialized($class = static::class);
static::$publishes[$class] = array_merge(static::$publishes[$class], $paths);
if ($group) {
foreach ((array) $groups as $group) {
$this->addPublishGroup($group, $paths);
}
}
@@ -295,6 +308,6 @@ abstract class ServiceProvider
*/
public function isDeferred()
{
return $this->defer;
return $this->defer || $this instanceof DeferrableProvider;
}
}

View File

@@ -112,6 +112,24 @@ class Str
return false;
}
/**
* Determine if a given string contains all array values.
*
* @param string $haystack
* @param array $needles
* @return bool
*/
public static function containsAll($haystack, array $needles)
{
foreach ($needles as $needle) {
if (! static::contains($haystack, $needle)) {
return false;
}
}
return true;
}
/**
* Determine if a given string ends with a given substring.
*
@@ -280,6 +298,22 @@ class Str
return Pluralizer::plural($value, $count);
}
/**
* Pluralize the last word of an English, studly caps case string.
*
* @param string $value
* @param int $count
* @return string
*/
public static function pluralStudly($value, $count = 2)
{
$parts = preg_split('/(.)(?=[A-Z])/u', $value, -1, PREG_SPLIT_DELIM_CAPTURE);
$lastWord = array_pop($parts);
return implode('', $parts).self::plural($lastWord, $count);
}
/**
* Generate a more truly "random" alpha-numeric string.
*
@@ -311,11 +345,15 @@ class Str
*/
public static function replaceArray($search, array $replace, $subject)
{
foreach ($replace as $value) {
$subject = static::replaceFirst($search, $value, $subject);
$segments = explode($search, $subject);
$result = array_shift($segments);
foreach ($segments as $segment) {
$result .= (array_shift($replace) ?? $search).$segment;
}
return $subject;
return $result;
}
/**
@@ -412,15 +450,15 @@ class Str
*
* @param string $title
* @param string $separator
* @param string $language
* @param string|null $language
* @return string
*/
public static function slug($title, $separator = '-', $language = 'en')
{
$title = static::ascii($title, $language);
$title = $language ? static::ascii($title, $language) : $title;
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
$flip = $separator === '-' ? '_' : '-';
$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
@@ -428,7 +466,7 @@ class Str
$title = str_replace('@', $separator.'at'.$separator, $title);
// 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));
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', static::lower($title));
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
@@ -580,38 +618,38 @@ class Str
'7' => ['⁷', '₇', '۷', ''],
'8' => ['⁸', '₈', '۸', ''],
'9' => ['⁹', '₉', '۹', ''],
'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', '', 'ä'],
'b' => ['б', 'β', 'ب', 'ဗ', 'ბ', ''],
'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', '', 'ä', 'א'],
'b' => ['б', 'β', 'ب', 'ဗ', 'ბ', '', 'ב'],
'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ', ''],
'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ', ''],
'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ', '', 'ד'],
'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए', 'إ', 'ئ', ''],
'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ', ''],
'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ', ''],
'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ', ''],
'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', 'इ', 'ی', ''],
'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ', '', 'פ', 'ף'],
'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ', '', 'ג'],
'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ', '', 'ה'],
'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', 'इ', 'ی', '', 'י'],
'j' => ['ĵ', 'ј', 'Ј', 'ჯ', 'ج', ''],
'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', 'ک', ''],
'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ', ''],
'm' => ['м', 'μ', 'م', 'မ', 'მ', ''],
'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', 'ნ', ''],
'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', '', 'ö'],
'p' => ['п', 'π', 'ပ', 'პ', 'پ', ''],
'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', 'ک', '', 'ק'],
'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ', '', 'ל'],
'm' => ['м', 'μ', 'م', 'မ', 'მ', '', 'מ', 'ם'],
'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', 'ნ', '', 'נ'],
'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'о', 'و', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', '', 'ö'],
'p' => ['п', 'π', 'ပ', 'პ', 'پ', '', 'פ', 'ף'],
'q' => ['', ''],
'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ', ''],
's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', 'ſ', 'ს', ''],
't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', 'თ', 'ტ', ''],
'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ', '', 'ר'],
's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', 'ſ', 'ს', '', 'ס'],
't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', 'თ', 'ტ', '', 'ת'],
'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', 'ဉ', 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ', '', 'ў', 'ü'],
'v' => ['в', 'ვ', 'ϐ', ''],
'v' => ['в', 'ვ', 'ϐ', '', 'ו'],
'w' => ['ŵ', 'ω', 'ώ', '', 'ွ', ''],
'x' => ['χ', 'ξ', ''],
'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ', ''],
'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ', ''],
'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ', '', 'ז'],
'aa' => ['ع', 'आ', 'آ'],
'ae' => ['æ', 'ǽ'],
'ai' => ['ऐ'],
'ch' => ['ч', 'ჩ', 'ჭ', 'چ'],
'dj' => ['ђ', 'đ'],
'dz' => ['џ', 'ძ'],
'dz' => ['џ', 'ძ', 'דז'],
'ei' => ['ऍ'],
'gh' => ['غ', 'ღ'],
'ii' => ['ई'],
@@ -623,11 +661,11 @@ class Str
'oi' => ['ऑ'],
'oii' => ['ऒ'],
'ps' => ['ψ'],
'sh' => ['ш', 'შ', 'ش'],
'sh' => ['ш', 'შ', 'ش', 'ש'],
'shch' => ['щ'],
'ss' => ['ß'],
'sx' => ['ŝ'],
'th' => ['þ', 'ϑ', 'ث', 'ذ', 'ظ'],
'th' => ['þ', 'ϑ', 'θ', 'ث', 'ذ', 'ظ'],
'ts' => ['ц', 'ც', 'წ'],
'ue' => ['ü'],
'uu' => ['ऊ'],
@@ -649,7 +687,7 @@ class Str
'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ', 'Ľ', 'Ŀ', 'ल', ''],
'M' => ['М', 'Μ', ''],
'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν', ''],
'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ', '', 'Ö'],
'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό', 'О', 'Ө', 'Ǒ', 'Ǿ', '', 'Ö'],
'P' => ['П', 'Π', ''],
'Q' => [''],
'R' => ['Ř', 'Ŕ', 'Р', 'Ρ', 'Ŗ', ''],
@@ -674,13 +712,13 @@ class Str
'Nj' => ['Њ'],
'Oe' => ['Œ'],
'Ps' => ['Ψ'],
'Sh' => ['Ш'],
'Sh' => ['Ш', 'ש'],
'Shch' => ['Щ'],
'Ss' => ['ẞ'],
'Th' => ['Þ'],
'Th' => ['Þ', 'Θ', 'ת'],
'Ts' => ['Ц'],
'Ya' => ['Я'],
'Yu' => ['Ю'],
'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", "\xEF\xBE\xA0"],
];
@@ -706,10 +744,24 @@ class Str
['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'],
['h', 'H', 'sht', 'SHT', 'a', 'А', 'y', 'Y'],
],
'da' => [
['æ', 'ø', 'å', 'Æ', 'Ø', 'Å'],
['ae', 'oe', 'aa', 'Ae', 'Oe', 'Aa'],
],
'de' => [
['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'],
['ae', 'oe', 'ue', 'AE', 'OE', 'UE'],
],
'he' => [
['א', 'ב', 'ג', 'ד', 'ה', 'ו'],
['ז', 'ח', 'ט', 'י', 'כ', 'ל'],
['מ', 'נ', 'ס', 'ע', 'פ', 'צ'],
['ק', 'ר', 'ש', 'ת', 'ן', 'ץ', 'ך', 'ם', 'ף'],
],
'ro' => [
['ă', 'â', 'î', 'ș', 'ț', 'Ă', 'Â', 'Î', 'Ș', 'Ț'],
['a', 'a', 'i', 's', 't', 'A', 'A', 'I', 'S', 'T'],
],
];
}

View File

@@ -127,7 +127,7 @@ class BusFake implements Dispatcher
*/
public function pipeThrough(array $pipes)
{
//
return $this;
}
/**

View File

@@ -183,19 +183,6 @@ class EventFake implements Dispatcher
//
}
/**
* Fire an event and call the listeners.
*
* @param string|object $event
* @param mixed $payload
* @param bool $halt
* @return array|null
*/
public function fire($event, $payload = [], $halt = false)
{
return $this->dispatch($event, $payload, $halt);
}
/**
* Fire an event and call the listeners.
*
@@ -211,7 +198,7 @@ class EventFake implements Dispatcher
if ($this->shouldFakeEvent($name, $payload)) {
$this->events[$name][] = func_get_args();
} else {
$this->dispatcher->dispatch($event, $payload, $halt);
return $this->dispatcher->dispatch($event, $payload, $halt);
}
}

View File

@@ -4,10 +4,11 @@ namespace Illuminate\Support\Testing\Fakes;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Contracts\Mail\MailQueue;
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailFake implements Mailer
class MailFake implements Mailer, MailQueue
{
/**
* All of the mailables that have been sent.
@@ -262,11 +263,11 @@ class MailFake implements Mailer
}
/**
* Send a new message when only a raw text part.
* Send a new message with only a raw text part.
*
* @param string $text
* @param \Closure|string $callback
* @return int
* @return void
*/
public function raw($text, $callback)
{
@@ -310,6 +311,19 @@ class MailFake implements Mailer
$this->queuedMailables[] = $view;
}
/**
* Queue a new e-mail message for sending after (n) seconds.
*
* @param \DateTimeInterface|\DateInterval|int $delay
* @param string|array|\Illuminate\Contracts\Mail\Mailable $view
* @param string $queue
* @return mixed
*/
public function later($delay, $view, $queue = null)
{
$this->queue($view, $queue);
}
/**
* Get the array of failed recipients.
*
@@ -317,6 +331,6 @@ class MailFake implements Mailer
*/
public function failures()
{
//
return [];
}
}

View File

@@ -4,12 +4,16 @@ namespace Illuminate\Support\Testing\Fakes;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Contracts\Notifications\Factory as NotificationFactory;
use Illuminate\Contracts\Notifications\Dispatcher as NotificationDispatcher;
class NotificationFake implements NotificationFactory, NotificationDispatcher
{
use Macroable;
/**
* All of the notifications that have been sent.
*
@@ -17,6 +21,13 @@ class NotificationFake implements NotificationFactory, NotificationDispatcher
*/
protected $notifications = [];
/**
* Locale used when sending notifications.
*
* @var string|null
*/
public $locale;
/**
* Assert if a notification was sent based on a truth-test callback.
*
@@ -162,11 +173,7 @@ class NotificationFake implements NotificationFactory, NotificationDispatcher
*/
protected function notificationsFor($notifiable, $notification)
{
if (isset($this->notifications[get_class($notifiable)][$notifiable->getKey()][$notification])) {
return $this->notifications[get_class($notifiable)][$notifiable->getKey()][$notification];
}
return [];
return $this->notifications[get_class($notifiable)][$notifiable->getKey()][$notification] ?? [];
}
/**
@@ -186,9 +193,10 @@ class NotificationFake implements NotificationFactory, NotificationDispatcher
*
* @param \Illuminate\Support\Collection|array|mixed $notifiables
* @param mixed $notification
* @param array|null $channels
* @return void
*/
public function sendNow($notifiables, $notification)
public function sendNow($notifiables, $notification, array $channels = null)
{
if (! $notifiables instanceof Collection && ! is_array($notifiables)) {
$notifiables = [$notifiables];
@@ -201,8 +209,13 @@ class NotificationFake implements NotificationFactory, NotificationDispatcher
$this->notifications[get_class($notifiable)][$notifiable->getKey()][get_class($notification)][] = [
'notification' => $notification,
'channels' => $notification->via($notifiable),
'channels' => $channels ?: $notification->via($notifiable),
'notifiable' => $notifiable,
'locale' => $notification->locale ?? $this->locale ?? value(function () use ($notifiable) {
if ($notifiable instanceof HasLocalePreference) {
return $notifiable->preferredLocale();
}
}),
];
}
}
@@ -217,4 +230,17 @@ class NotificationFake implements NotificationFactory, NotificationDispatcher
{
//
}
/**
* Set the locale of notifications.
*
* @param string $locale
* @return $this
*/
public function locale($locale)
{
$this->locale = $locale;
return $this;
}
}

View File

@@ -2,8 +2,8 @@
namespace Illuminate\Support\Testing\Fakes;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\PendingMail;
use Illuminate\Contracts\Mail\Mailable;
class PendingMailFake extends PendingMail
{
@@ -21,7 +21,7 @@ class PendingMailFake extends PendingMail
/**
* Send a new mailable message instance.
*
* @param \Illuminate\Mail\Mailable $mailable
* @param \Illuminate\Contracts\Mail\Mailable $mailable;
* @return mixed
*/
public function send(Mailable $mailable)
@@ -32,7 +32,7 @@ class PendingMailFake extends PendingMail
/**
* Send a mailable message immediately.
*
* @param \Illuminate\Mail\Mailable $mailable
* @param \Illuminate\Contracts\Mail\Mailable $mailable;
* @return mixed
*/
public function sendNow(Mailable $mailable)
@@ -43,7 +43,7 @@ class PendingMailFake extends PendingMail
/**
* Push the given mailable onto the queue.
*
* @param \Illuminate\Mail\Mailable $mailable
* @param \Illuminate\Contracts\Mail\Mailable $mailable;
* @return mixed
*/
public function queue(Mailable $mailable)

View File

@@ -2,6 +2,7 @@
namespace Illuminate\Support\Testing\Fakes;
use BadMethodCallException;
use Illuminate\Queue\QueueManager;
use Illuminate\Contracts\Queue\Queue;
use PHPUnit\Framework\Assert as PHPUnit;
@@ -146,10 +147,9 @@ class QueueFake extends QueueManager implements Queue
*/
protected function isChainOfObjects($chain)
{
return collect($chain)->count() == collect($chain)
->filter(function ($job) {
return is_object($job);
})->count();
return ! collect($chain)->contains(function ($job) {
return ! is_object($job);
});
}
/**
@@ -224,12 +224,14 @@ class QueueFake extends QueueManager implements Queue
/**
* Get the size of the queue.
*
* @param string $queue
* @param string|null $queue
* @return int
*/
public function size($queue = null)
{
return count($this->jobs);
return collect($this->jobs)->flatten(1)->filter(function ($job) use ($queue) {
return $job['queue'] === $queue;
})->count();
}
/**
@@ -237,7 +239,7 @@ class QueueFake extends QueueManager implements Queue
*
* @param string $job
* @param mixed $data
* @param string $queue
* @param string|null $queue
* @return mixed
*/
public function push($job, $data = '', $queue = null)
@@ -252,7 +254,7 @@ class QueueFake extends QueueManager implements Queue
* Push a raw payload onto the queue.
*
* @param string $payload
* @param string $queue
* @param string|null $queue
* @param array $options
* @return mixed
*/
@@ -264,10 +266,10 @@ class QueueFake extends QueueManager implements Queue
/**
* Push a new job onto the queue after a delay.
*
* @param \DateTime|int $delay
* @param \DateTimeInterface|\DateInterval|int $delay
* @param string $job
* @param mixed $data
* @param string $queue
* @param string|null $queue
* @return mixed
*/
public function later($delay, $job, $data = '', $queue = null)
@@ -292,7 +294,7 @@ class QueueFake extends QueueManager implements Queue
* Push a new job onto the queue after a delay.
*
* @param string $queue
* @param \DateTime|int $delay
* @param \DateTimeInterface|\DateInterval|int $delay
* @param string $job
* @param mixed $data
* @return mixed
@@ -305,7 +307,7 @@ class QueueFake extends QueueManager implements Queue
/**
* Pop the next job off of the queue.
*
* @param string $queue
* @param string|null $queue
* @return \Illuminate\Contracts\Queue\Job|null
*/
public function pop($queue = null)
@@ -318,7 +320,7 @@ class QueueFake extends QueueManager implements Queue
*
* @param array $jobs
* @param mixed $data
* @param string $queue
* @param string|null $queue
* @return mixed
*/
public function bulk($jobs, $data = '', $queue = null)
@@ -328,6 +330,16 @@ class QueueFake extends QueueManager implements Queue
}
}
/**
* Get the jobs that have been pushed.
*
* @return array
*/
public function pushedJobs()
{
return $this->jobs;
}
/**
* Get the connection name for the queue.
*
@@ -348,4 +360,18 @@ class QueueFake extends QueueManager implements Queue
{
return $this;
}
/**
* Override the QueueManager to prevent circular dependency.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
throw new BadMethodCallException(sprintf(
'Call to undefined method %s::%s()', static::class, $method
));
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Illuminate\Support\Traits;
use Error;
use BadMethodCallException;
trait ForwardsCalls
{
/**
* Forward a method call to the given object.
*
* @param mixed $object
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
protected function forwardCallTo($object, $method, $parameters)
{
try {
return $object->{$method}(...$parameters);
} catch (Error | BadMethodCallException $e) {
$pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~';
if (! preg_match($pattern, $e->getMessage(), $matches)) {
throw $e;
}
if ($matches['class'] != get_class($object) ||
$matches['method'] != $method) {
throw $e;
}
static::throwBadMethodCallException($method);
}
}
/**
* Throw a bad method call exception for the given method.
*
* @param string $method
* @return void
*
* @throws \BadMethodCallException
*/
protected static function throwBadMethodCallException($method)
{
throw new BadMethodCallException(sprintf(
'Call to undefined method %s::%s()', static::class, $method
));
}
}

View File

@@ -2,30 +2,33 @@
namespace Illuminate\Support\Traits;
use Illuminate\Container\Container;
trait Localizable
{
/**
* Run the callback with the given locale.
*
* @param string $locale
* @param \Illuminate\Contracts\Translation\Translator $translator
* @param \Closure $callback
* @return bool
* @param string $locale
* @param \Closure $callback
* @return mixed
*/
public function withLocale($locale, $translator, $callback)
public function withLocale($locale, $callback)
{
if (! $locale || ! $translator) {
if (! $locale) {
return $callback();
}
$original = $translator->getLocale();
$app = Container::getInstance();
$original = $app->getLocale();
try {
$translator->setLocale($locale);
$app->setLocale($locale);
return $callback();
} finally {
$translator->setLocale($original);
$app->setLocale($original);
}
}
}

View File

@@ -33,19 +33,22 @@ trait Macroable
* Mix another object into the class.
*
* @param object $mixin
* @param bool $replace
* @return void
*
* @throws \ReflectionException
*/
public static function mixin($mixin)
public static function mixin($mixin, $replace = true)
{
$methods = (new ReflectionClass($mixin))->getMethods(
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
);
foreach ($methods as $method) {
$method->setAccessible(true);
static::macro($method->name, $method->invoke($mixin));
if ($replace || ! static::hasMacro($method->name)) {
$method->setAccessible(true);
static::macro($method->name, $method->invoke($mixin));
}
}
}
@@ -64,7 +67,7 @@ trait Macroable
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
@@ -77,18 +80,20 @@ trait Macroable
));
}
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters);
$macro = static::$macros[$method];
if ($macro instanceof Closure) {
return call_user_func_array(Closure::bind($macro, null, static::class), $parameters);
}
return call_user_func_array(static::$macros[$method], $parameters);
return $macro(...$parameters);
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
@@ -107,6 +112,6 @@ trait Macroable
return call_user_func_array($macro->bindTo($this, static::class), $parameters);
}
return call_user_func_array($macro, $parameters);
return $macro(...$parameters);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Illuminate\Support\Traits;
trait Tappable
{
/**
* Call the given Closure with this instance then return the instance.
*
* @param callable|null $callback
* @return mixed
*/
public function tap($callback = null)
{
return tap($this, $callback);
}
}

View File

@@ -15,10 +15,11 @@
],
"require": {
"php": "^7.1.3",
"ext-json": "*",
"ext-mbstring": "*",
"doctrine/inflector": "~1.1",
"illuminate/contracts": "5.6.*",
"nesbot/carbon": "1.25.*"
"doctrine/inflector": "^1.1",
"illuminate/contracts": "5.8.*",
"nesbot/carbon": "^1.26.3 || ^2.0"
},
"conflict": {
"tightenco/collect": "<5.5.33"
@@ -33,14 +34,16 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.6-dev"
"dev-master": "5.8-dev"
}
},
"suggest": {
"illuminate/filesystem": "Required to use the composer class (5.6.*).",
"illuminate/filesystem": "Required to use the composer class (5.8.*).",
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
"ramsey/uuid": "Required to use Str::uuid() (^3.7).",
"symfony/process": "Required to use the composer class (~4.0).",
"symfony/var-dumper": "Required to use the dd function (~4.0)."
"symfony/process": "Required to use the composer class (^4.2).",
"symfony/var-dumper": "Required to use the dd function (^4.2).",
"vlucas/phpdotenv": "Required to use the env helper (^3.3)."
},
"config": {
"sort-packages": true

View File

@@ -1,12 +1,16 @@
<?php
use PhpOption\Option;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Optional;
use Illuminate\Support\Collection;
use Illuminate\Support\Debug\Dumper;
use Dotenv\Environment\DotenvFactory;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\HigherOrderTapProxy;
use Dotenv\Environment\Adapter\PutenvAdapter;
use Dotenv\Environment\Adapter\EnvConstAdapter;
use Dotenv\Environment\Adapter\ServerConstAdapter;
if (! function_exists('append_config')) {
/**
@@ -39,6 +43,8 @@ if (! function_exists('array_add')) {
* @param string $key
* @param mixed $value
* @return array
*
* @deprecated Arr::add() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_add($array, $key, $value)
{
@@ -52,6 +58,8 @@ if (! function_exists('array_collapse')) {
*
* @param array $array
* @return array
*
* @deprecated Arr::collapse() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_collapse($array)
{
@@ -65,6 +73,8 @@ if (! function_exists('array_divide')) {
*
* @param array $array
* @return array
*
* @deprecated Arr::divide() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_divide($array)
{
@@ -79,6 +89,8 @@ if (! function_exists('array_dot')) {
* @param array $array
* @param string $prepend
* @return array
*
* @deprecated Arr::dot() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_dot($array, $prepend = '')
{
@@ -93,6 +105,8 @@ if (! function_exists('array_except')) {
* @param array $array
* @param array|string $keys
* @return array
*
* @deprecated Arr::except() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_except($array, $keys)
{
@@ -108,6 +122,8 @@ if (! function_exists('array_first')) {
* @param callable|null $callback
* @param mixed $default
* @return mixed
*
* @deprecated Arr::first() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_first($array, callable $callback = null, $default = null)
{
@@ -122,6 +138,8 @@ if (! function_exists('array_flatten')) {
* @param array $array
* @param int $depth
* @return array
*
* @deprecated Arr::flatten() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_flatten($array, $depth = INF)
{
@@ -136,6 +154,8 @@ if (! function_exists('array_forget')) {
* @param array $array
* @param array|string $keys
* @return void
*
* @deprecated Arr::forget() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_forget(&$array, $keys)
{
@@ -151,6 +171,8 @@ if (! function_exists('array_get')) {
* @param string $key
* @param mixed $default
* @return mixed
*
* @deprecated Arr::get() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_get($array, $key, $default = null)
{
@@ -165,6 +187,8 @@ if (! function_exists('array_has')) {
* @param \ArrayAccess|array $array
* @param string|array $keys
* @return bool
*
* @deprecated Arr::has() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_has($array, $keys)
{
@@ -180,6 +204,8 @@ if (! function_exists('array_last')) {
* @param callable|null $callback
* @param mixed $default
* @return mixed
*
* @deprecated Arr::last() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_last($array, callable $callback = null, $default = null)
{
@@ -194,6 +220,8 @@ if (! function_exists('array_only')) {
* @param array $array
* @param array|string $keys
* @return array
*
* @deprecated Arr::only() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_only($array, $keys)
{
@@ -209,6 +237,8 @@ if (! function_exists('array_pluck')) {
* @param string|array $value
* @param string|array|null $key
* @return array
*
* @deprecated Arr::pluck() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_pluck($array, $value, $key = null)
{
@@ -224,6 +254,8 @@ if (! function_exists('array_prepend')) {
* @param mixed $value
* @param mixed $key
* @return array
*
* @deprecated Arr::prepend() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_prepend($array, $value, $key = null)
{
@@ -239,6 +271,8 @@ if (! function_exists('array_pull')) {
* @param string $key
* @param mixed $default
* @return mixed
*
* @deprecated Arr::pull() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_pull(&$array, $key, $default = null)
{
@@ -253,6 +287,8 @@ if (! function_exists('array_random')) {
* @param array $array
* @param int|null $num
* @return mixed
*
* @deprecated Arr::random() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_random($array, $num = null)
{
@@ -270,6 +306,8 @@ if (! function_exists('array_set')) {
* @param string $key
* @param mixed $value
* @return array
*
* @deprecated Arr::set() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_set(&$array, $key, $value)
{
@@ -284,6 +322,8 @@ if (! function_exists('array_sort')) {
* @param array $array
* @param callable|string|null $callback
* @return array
*
* @deprecated Arr::sort() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_sort($array, $callback = null)
{
@@ -297,6 +337,8 @@ if (! function_exists('array_sort_recursive')) {
*
* @param array $array
* @return array
*
* @deprecated Arr::sortRecursive() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_sort_recursive($array)
{
@@ -311,6 +353,8 @@ if (! function_exists('array_where')) {
* @param array $array
* @param callable $callback
* @return array
*
* @deprecated Arr::where() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_where($array, callable $callback)
{
@@ -324,6 +368,8 @@ if (! function_exists('array_wrap')) {
*
* @param mixed $value
* @return array
*
* @deprecated Arr::wrap() should be used directly instead. Will be removed in Laravel 6.0.
*/
function array_wrap($value)
{
@@ -366,6 +412,8 @@ if (! function_exists('camel_case')) {
*
* @param string $value
* @return string
*
* @deprecated Str::camel() should be used directly instead. Will be removed in Laravel 6.0.
*/
function camel_case($value)
{
@@ -444,7 +492,7 @@ if (! function_exists('data_get')) {
* Get an item from an array or object using "dot" notation.
*
* @param mixed $target
* @param string|array $key
* @param string|array|int $key
* @param mixed $default
* @return mixed
*/
@@ -464,7 +512,11 @@ if (! function_exists('data_get')) {
return value($default);
}
$result = Arr::pluck($target, $key);
$result = [];
foreach ($target as $item) {
$result[] = data_get($item, $key);
}
return in_array('*', $key) ? Arr::collapse($result) : $result;
}
@@ -544,26 +596,9 @@ if (! function_exists('data_set')) {
}
}
if (! function_exists('dd')) {
/**
* Dump the passed variables and end the script.
*
* @param mixed $args
* @return void
*/
function dd(...$args)
{
foreach ($args as $x) {
(new Dumper)->dump($x);
}
die(1);
}
}
if (! function_exists('e')) {
/**
* Escape HTML special characters in a string.
* Encode HTML special characters in a string.
*
* @param \Illuminate\Contracts\Support\Htmlable|string $value
* @param bool $doubleEncode
@@ -586,6 +621,8 @@ if (! function_exists('ends_with')) {
* @param string $haystack
* @param string|array $needles
* @return bool
*
* @deprecated Str::endsWith() should be used directly instead. Will be removed in Laravel 6.0.
*/
function ends_with($haystack, $needles)
{
@@ -603,32 +640,38 @@ if (! function_exists('env')) {
*/
function env($key, $default = null)
{
$value = getenv($key);
static $variables;
if ($value === false) {
return value($default);
if ($variables === null) {
$variables = (new DotenvFactory([new EnvConstAdapter, new PutenvAdapter, new ServerConstAdapter]))->createImmutable();
}
switch (strtolower($value)) {
case 'true':
case '(true)':
return true;
case 'false':
case '(false)':
return false;
case 'empty':
case '(empty)':
return '';
case 'null':
case '(null)':
return;
}
return Option::fromValue($variables->get($key))
->map(function ($value) {
switch (strtolower($value)) {
case 'true':
case '(true)':
return true;
case 'false':
case '(false)':
return false;
case 'empty':
case '(empty)':
return '';
case 'null':
case '(null)':
return;
}
if (($valueLength = strlen($value)) > 1 && $value[0] === '"' && $value[$valueLength - 1] === '"') {
return substr($value, 1, -1);
}
if (preg_match('/\A([\'"])(.*)\1\z/', $value, $matches)) {
return $matches[2];
}
return $value;
return $value;
})
->getOrCall(function () use ($default) {
return value($default);
});
}
}
@@ -664,6 +707,8 @@ if (! function_exists('kebab_case')) {
*
* @param string $value
* @return string
*
* @deprecated Str::kebab() should be used directly instead. Will be removed in Laravel 6.0.
*/
function kebab_case($value)
{
@@ -755,19 +800,23 @@ if (! function_exists('retry')) {
* @param int $times
* @param callable $callback
* @param int $sleep
* @param callable $when
* @return mixed
*
* @throws \Exception
*/
function retry($times, callable $callback, $sleep = 0)
function retry($times, callable $callback, $sleep = 0, $when = null)
{
$attempts = 0;
$times--;
beginning:
$attempts++;
try {
return $callback();
return $callback($attempts);
} catch (Exception $e) {
if (! $times) {
if (! $times || ($when && ! $when($e))) {
throw $e;
}
@@ -789,6 +838,8 @@ if (! function_exists('snake_case')) {
* @param string $value
* @param string $delimiter
* @return string
*
* @deprecated Str::snake() should be used directly instead. Will be removed in Laravel 6.0.
*/
function snake_case($value, $delimiter = '_')
{
@@ -803,6 +854,8 @@ if (! function_exists('starts_with')) {
* @param string $haystack
* @param string|array $needles
* @return bool
*
* @deprecated Str::startsWith() should be used directly instead. Will be removed in Laravel 6.0.
*/
function starts_with($haystack, $needles)
{
@@ -817,6 +870,8 @@ if (! function_exists('str_after')) {
* @param string $subject
* @param string $search
* @return string
*
* @deprecated Str::after() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_after($subject, $search)
{
@@ -831,6 +886,8 @@ if (! function_exists('str_before')) {
* @param string $subject
* @param string $search
* @return string
*
* @deprecated Str::before() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_before($subject, $search)
{
@@ -845,6 +902,8 @@ if (! function_exists('str_contains')) {
* @param string $haystack
* @param string|array $needles
* @return bool
*
* @deprecated Str::contains() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_contains($haystack, $needles)
{
@@ -859,6 +918,8 @@ if (! function_exists('str_finish')) {
* @param string $value
* @param string $cap
* @return string
*
* @deprecated Str::finish() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_finish($value, $cap)
{
@@ -873,6 +934,8 @@ if (! function_exists('str_is')) {
* @param string|array $pattern
* @param string $value
* @return bool
*
* @deprecated Str::is() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_is($pattern, $value)
{
@@ -888,6 +951,8 @@ if (! function_exists('str_limit')) {
* @param int $limit
* @param string $end
* @return string
*
* @deprecated Str::limit() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_limit($value, $limit = 100, $end = '...')
{
@@ -902,6 +967,8 @@ if (! function_exists('str_plural')) {
* @param string $value
* @param int $count
* @return string
*
* @deprecated Str::plural() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_plural($value, $count = 2)
{
@@ -917,6 +984,8 @@ if (! function_exists('str_random')) {
* @return string
*
* @throws \RuntimeException
*
* @deprecated Str::random() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_random($length = 16)
{
@@ -932,6 +1001,8 @@ if (! function_exists('str_replace_array')) {
* @param array $replace
* @param string $subject
* @return string
*
* @deprecated Str::replaceArray() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_replace_array($search, array $replace, $subject)
{
@@ -947,6 +1018,8 @@ if (! function_exists('str_replace_first')) {
* @param string $replace
* @param string $subject
* @return string
*
* @deprecated Str::replaceFirst() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_replace_first($search, $replace, $subject)
{
@@ -962,6 +1035,8 @@ if (! function_exists('str_replace_last')) {
* @param string $replace
* @param string $subject
* @return string
*
* @deprecated Str::replaceLast() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_replace_last($search, $replace, $subject)
{
@@ -975,6 +1050,8 @@ if (! function_exists('str_singular')) {
*
* @param string $value
* @return string
*
* @deprecated Str::singular() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_singular($value)
{
@@ -990,6 +1067,8 @@ if (! function_exists('str_slug')) {
* @param string $separator
* @param string $language
* @return string
*
* @deprecated Str::slug() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_slug($title, $separator = '-', $language = 'en')
{
@@ -1004,6 +1083,8 @@ if (! function_exists('str_start')) {
* @param string $value
* @param string $prefix
* @return string
*
* @deprecated Str::start() should be used directly instead. Will be removed in Laravel 6.0.
*/
function str_start($value, $prefix)
{
@@ -1017,6 +1098,8 @@ if (! function_exists('studly_case')) {
*
* @param string $value
* @return string
*
* @deprecated Str::studly() should be used directly instead. Will be removed in Laravel 6.0.
*/
function studly_case($value)
{
@@ -1052,6 +1135,7 @@ if (! function_exists('throw_if')) {
* @param \Throwable|string $exception
* @param array ...$parameters
* @return mixed
*
* @throws \Throwable
*/
function throw_if($condition, $exception, ...$parameters)
@@ -1090,6 +1174,8 @@ if (! function_exists('title_case')) {
*
* @param string $value
* @return string
*
* @deprecated Str::title() should be used directly instead. Will be removed in Laravel 6.0.
*/
function title_case($value)
{