dependencies-upgrade
This commit is contained in:
@@ -1,664 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use ArrayAccess;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Arr
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
/**
|
||||
* Determine whether the given value is array accessible.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function accessible($value)
|
||||
{
|
||||
return is_array($value) || $value instanceof ArrayAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an element to an array using "dot" notation if it doesn't exist.
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return array
|
||||
*/
|
||||
public static function add($array, $key, $value)
|
||||
{
|
||||
if (is_null(static::get($array, $key))) {
|
||||
static::set($array, $key, $value);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapse an array of arrays into a single array.
|
||||
*
|
||||
* @param iterable $array
|
||||
* @return array
|
||||
*/
|
||||
public static function collapse($array)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
foreach ($array as $values) {
|
||||
if ($values instanceof Collection) {
|
||||
$values = $values->all();
|
||||
} elseif (! is_array($values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = $values;
|
||||
}
|
||||
|
||||
return array_merge([], ...$results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cross join the given arrays, returning all possible permutations.
|
||||
*
|
||||
* @param iterable ...$arrays
|
||||
* @return array
|
||||
*/
|
||||
public static function crossJoin(...$arrays)
|
||||
{
|
||||
$results = [[]];
|
||||
|
||||
foreach ($arrays as $index => $array) {
|
||||
$append = [];
|
||||
|
||||
foreach ($results as $product) {
|
||||
foreach ($array as $item) {
|
||||
$product[$index] = $item;
|
||||
|
||||
$append[] = $product;
|
||||
}
|
||||
}
|
||||
|
||||
$results = $append;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide an array into two arrays. One with keys and the other with values.
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public static function divide($array)
|
||||
{
|
||||
return [array_keys($array), array_values($array)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten a multi-dimensional associative array with dots.
|
||||
*
|
||||
* @param iterable $array
|
||||
* @param string $prepend
|
||||
* @return array
|
||||
*/
|
||||
public static function dot($array, $prepend = '')
|
||||
{
|
||||
$results = [];
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value) && ! empty($value)) {
|
||||
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
|
||||
} else {
|
||||
$results[$prepend.$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the given array except for a specified array of keys.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array|string $keys
|
||||
* @return array
|
||||
*/
|
||||
public static function except($array, $keys)
|
||||
{
|
||||
static::forget($array, $keys);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given key exists in the provided array.
|
||||
*
|
||||
* @param \ArrayAccess|array $array
|
||||
* @param string|int $key
|
||||
* @return bool
|
||||
*/
|
||||
public static function exists($array, $key)
|
||||
{
|
||||
if ($array instanceof ArrayAccess) {
|
||||
return $array->offsetExists($key);
|
||||
}
|
||||
|
||||
return array_key_exists($key, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the first element in an array passing a given truth test.
|
||||
*
|
||||
* @param iterable $array
|
||||
* @param callable|null $callback
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public static function first($array, callable $callback = null, $default = null)
|
||||
{
|
||||
if (is_null($callback)) {
|
||||
if (empty($array)) {
|
||||
return value($default);
|
||||
}
|
||||
|
||||
foreach ($array as $item) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
if ($callback($value, $key)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
return value($default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last element in an array passing a given truth test.
|
||||
*
|
||||
* @param array $array
|
||||
* @param callable|null $callback
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public static function last($array, callable $callback = null, $default = null)
|
||||
{
|
||||
if (is_null($callback)) {
|
||||
return empty($array) ? value($default) : end($array);
|
||||
}
|
||||
|
||||
return static::first(array_reverse($array, true), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten a multi-dimensional array into a single level.
|
||||
*
|
||||
* @param iterable $array
|
||||
* @param int $depth
|
||||
* @return array
|
||||
*/
|
||||
public static function flatten($array, $depth = INF)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($array as $item) {
|
||||
$item = $item instanceof Collection ? $item->all() : $item;
|
||||
|
||||
if (! is_array($item)) {
|
||||
$result[] = $item;
|
||||
} else {
|
||||
$values = $depth === 1
|
||||
? array_values($item)
|
||||
: static::flatten($item, $depth - 1);
|
||||
|
||||
foreach ($values as $value) {
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove one or many array items from a given array using "dot" notation.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array|string $keys
|
||||
* @return void
|
||||
*/
|
||||
public static function forget(&$array, $keys)
|
||||
{
|
||||
$original = &$array;
|
||||
|
||||
$keys = (array) $keys;
|
||||
|
||||
if (count($keys) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
// if the exact key exists in the top-level, remove it
|
||||
if (static::exists($array, $key)) {
|
||||
unset($array[$key]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$parts = explode('.', $key);
|
||||
|
||||
// clean up before each pass
|
||||
$array = &$original;
|
||||
|
||||
while (count($parts) > 1) {
|
||||
$part = array_shift($parts);
|
||||
|
||||
if (isset($array[$part]) && is_array($array[$part])) {
|
||||
$array = &$array[$part];
|
||||
} else {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
unset($array[array_shift($parts)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item from an array using "dot" notation.
|
||||
*
|
||||
* @param \ArrayAccess|array $array
|
||||
* @param string|int|null $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get($array, $key, $default = null)
|
||||
{
|
||||
if (! static::accessible($array)) {
|
||||
return value($default);
|
||||
}
|
||||
|
||||
if (is_null($key)) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
if (static::exists($array, $key)) {
|
||||
return $array[$key];
|
||||
}
|
||||
|
||||
if (strpos($key, '.') === false) {
|
||||
return $array[$key] ?? value($default);
|
||||
}
|
||||
|
||||
foreach (explode('.', $key) as $segment) {
|
||||
if (static::accessible($array) && static::exists($array, $segment)) {
|
||||
$array = $array[$segment];
|
||||
} else {
|
||||
return value($default);
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an item or items exist in an array using "dot" notation.
|
||||
*
|
||||
* @param \ArrayAccess|array $array
|
||||
* @param string|array $keys
|
||||
* @return bool
|
||||
*/
|
||||
public static function has($array, $keys)
|
||||
{
|
||||
$keys = (array) $keys;
|
||||
|
||||
if (! $array || $keys === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$subKeyArray = $array;
|
||||
|
||||
if (static::exists($array, $key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (explode('.', $key) as $segment) {
|
||||
if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
|
||||
$subKeyArray = $subKeyArray[$segment];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if any of the keys exist in an array using "dot" notation.
|
||||
*
|
||||
* @param \ArrayAccess|array $array
|
||||
* @param string|array $keys
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasAny($array, $keys)
|
||||
{
|
||||
if (is_null($keys)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$keys = (array) $keys;
|
||||
|
||||
if (! $array) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($keys === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (static::has($array, $key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if an array is associative.
|
||||
*
|
||||
* An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
|
||||
*
|
||||
* @param array $array
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAssoc(array $array)
|
||||
{
|
||||
$keys = array_keys($array);
|
||||
|
||||
return array_keys($keys) !== $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a subset of the items from the given array.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array|string $keys
|
||||
* @return array
|
||||
*/
|
||||
public static function only($array, $keys)
|
||||
{
|
||||
return array_intersect_key($array, array_flip((array) $keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluck an array of values from an array.
|
||||
*
|
||||
* @param iterable $array
|
||||
* @param string|array $value
|
||||
* @param string|array|null $key
|
||||
* @return array
|
||||
*/
|
||||
public static function pluck($array, $value, $key = null)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
[$value, $key] = static::explodePluckParameters($value, $key);
|
||||
|
||||
foreach ($array as $item) {
|
||||
$itemValue = data_get($item, $value);
|
||||
|
||||
// If the key is "null", we will just append the value to the array and keep
|
||||
// looping. Otherwise we will key the array using the value of the key we
|
||||
// received from the developer. Then we'll return the final array form.
|
||||
if (is_null($key)) {
|
||||
$results[] = $itemValue;
|
||||
} else {
|
||||
$itemKey = data_get($item, $key);
|
||||
|
||||
if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
|
||||
$itemKey = (string) $itemKey;
|
||||
}
|
||||
|
||||
$results[$itemKey] = $itemValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explode the "value" and "key" arguments passed to "pluck".
|
||||
*
|
||||
* @param string|array $value
|
||||
* @param string|array|null $key
|
||||
* @return array
|
||||
*/
|
||||
protected static function explodePluckParameters($value, $key)
|
||||
{
|
||||
$value = is_string($value) ? explode('.', $value) : $value;
|
||||
|
||||
$key = is_null($key) || is_array($key) ? $key : explode('.', $key);
|
||||
|
||||
return [$value, $key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Push an item onto the beginning of an array.
|
||||
*
|
||||
* @param array $array
|
||||
* @param mixed $value
|
||||
* @param mixed $key
|
||||
* @return array
|
||||
*/
|
||||
public static function prepend($array, $value, $key = null)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
array_unshift($array, $value);
|
||||
} else {
|
||||
$array = [$key => $value] + $array;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from the array, and remove it.
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public static function pull(&$array, $key, $default = null)
|
||||
{
|
||||
$value = static::get($array, $key, $default);
|
||||
|
||||
static::forget($array, $key);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one or a specified number of random values from an array.
|
||||
*
|
||||
* @param array $array
|
||||
* @param int|null $number
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function random($array, $number = null)
|
||||
{
|
||||
$requested = is_null($number) ? 1 : $number;
|
||||
|
||||
$count = count($array);
|
||||
|
||||
if ($requested > $count) {
|
||||
throw new InvalidArgumentException(
|
||||
"You requested {$requested} items, but there are only {$count} items available."
|
||||
);
|
||||
}
|
||||
|
||||
if (is_null($number)) {
|
||||
return $array[array_rand($array)];
|
||||
}
|
||||
|
||||
if ((int) $number === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$keys = array_rand($array, $number);
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ((array) $keys as $key) {
|
||||
$results[] = $array[$key];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an array item to a given value using "dot" notation.
|
||||
*
|
||||
* If no key is given to the method, the entire array will be replaced.
|
||||
*
|
||||
* @param array $array
|
||||
* @param string|null $key
|
||||
* @param mixed $value
|
||||
* @return array
|
||||
*/
|
||||
public static function set(&$array, $key, $value)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
return $array = $value;
|
||||
}
|
||||
|
||||
$keys = explode('.', $key);
|
||||
|
||||
foreach ($keys as $i => $key) {
|
||||
if (count($keys) === 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
unset($keys[$i]);
|
||||
|
||||
// If the key doesn't exist at this depth, we will just create an empty array
|
||||
// to hold the next value, allowing us to create the arrays to hold final
|
||||
// values at the correct depth. Then we'll keep digging into the array.
|
||||
if (! isset($array[$key]) || ! is_array($array[$key])) {
|
||||
$array[$key] = [];
|
||||
}
|
||||
|
||||
$array = &$array[$key];
|
||||
}
|
||||
|
||||
$array[array_shift($keys)] = $value;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuffle the given array and return the result.
|
||||
*
|
||||
* @param array $array
|
||||
* @param int|null $seed
|
||||
* @return array
|
||||
*/
|
||||
public static function shuffle($array, $seed = null)
|
||||
{
|
||||
if (is_null($seed)) {
|
||||
shuffle($array);
|
||||
} else {
|
||||
mt_srand($seed);
|
||||
shuffle($array);
|
||||
mt_srand();
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the array using the given callback or "dot" notation.
|
||||
*
|
||||
* @param array $array
|
||||
* @param callable|string|null $callback
|
||||
* @return array
|
||||
*/
|
||||
public static function sort($array, $callback = null)
|
||||
{
|
||||
return Collection::make($array)->sortBy($callback)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively sort an array by keys and values.
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public static function sortRecursive($array)
|
||||
{
|
||||
foreach ($array as &$value) {
|
||||
if (is_array($value)) {
|
||||
$value = static::sortRecursive($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (static::isAssoc($array)) {
|
||||
ksort($array);
|
||||
} else {
|
||||
sort($array);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the array into a query string.
|
||||
*
|
||||
* @param array $array
|
||||
* @return string
|
||||
*/
|
||||
public static function query($array)
|
||||
{
|
||||
return http_build_query($array, '', '&', PHP_QUERY_RFC3986);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the array using the given callback.
|
||||
*
|
||||
* @param array $array
|
||||
* @param callable $callback
|
||||
* @return array
|
||||
*/
|
||||
public static function where($array, callable $callback)
|
||||
{
|
||||
return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given value is not an array and not null, wrap it in one.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return array
|
||||
*/
|
||||
public static function wrap($value)
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return is_array($value) ? $value : [$value];
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,16 @@
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Carbon\Carbon as BaseCarbon;
|
||||
use Carbon\CarbonImmutable as BaseCarbonImmutable;
|
||||
|
||||
class Carbon extends BaseCarbon
|
||||
{
|
||||
//
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function setTestNow($testNow = null)
|
||||
{
|
||||
BaseCarbon::setTestNow($testNow);
|
||||
BaseCarbonImmutable::setTestNow($testNow);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@ class Composer
|
||||
* Regenerate the Composer autoloader files.
|
||||
*
|
||||
* @param string|array $extra
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function dumpAutoloads($extra = '')
|
||||
{
|
||||
@@ -47,17 +47,17 @@ class Composer
|
||||
|
||||
$command = array_merge($this->findComposer(), ['dump-autoload'], $extra);
|
||||
|
||||
$this->getProcess($command)->run();
|
||||
return $this->getProcess($command)->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the optimized Composer autoloader files.
|
||||
*
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function dumpOptimized()
|
||||
{
|
||||
$this->dumpAutoloads('--optimize');
|
||||
return $this->dumpAutoloads('--optimize');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -170,7 +170,7 @@ class ConfigurationUrlParser
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the current drivers aliases.
|
||||
* Get all of the current drivers' aliases.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ use InvalidArgumentException;
|
||||
* @method static Carbon setHumanDiffOptions($humanDiffOptions)
|
||||
* @method static bool setLocale($locale)
|
||||
* @method static void setMidDayAt($hour)
|
||||
* @method static Carbon setTestNow($testNow = null)
|
||||
* @method static void setTestNow($testNow = null)
|
||||
* @method static void setToStringFormat($format)
|
||||
* @method static void setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator)
|
||||
* @method static Carbon setUtf8($utf8)
|
||||
@@ -217,7 +217,7 @@ class DateFactory
|
||||
return $dateClass::$method(...$parameters);
|
||||
}
|
||||
|
||||
// If that fails, create the date with the default class..
|
||||
// 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...
|
||||
|
||||
@@ -1,928 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Countable;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use IteratorAggregate;
|
||||
use JsonSerializable;
|
||||
|
||||
interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Create a new collection instance if the value isn't one already.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public static function make($items = []);
|
||||
|
||||
/**
|
||||
* Create a new instance by invoking the callback a given amount of times.
|
||||
*
|
||||
* @param int $number
|
||||
* @param callable|null $callback
|
||||
* @return static
|
||||
*/
|
||||
public static function times($number, callable $callback = null);
|
||||
|
||||
/**
|
||||
* Wrap the given value in a collection if applicable.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public static function wrap($value);
|
||||
|
||||
/**
|
||||
* Get the underlying items from the given collection if applicable.
|
||||
*
|
||||
* @param array|static $value
|
||||
* @return array
|
||||
*/
|
||||
public static function unwrap($value);
|
||||
|
||||
/**
|
||||
* Get all items in the enumerable.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all();
|
||||
|
||||
/**
|
||||
* Alias for the "avg" method.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function average($callback = null);
|
||||
|
||||
/**
|
||||
* Get the median of a given key.
|
||||
*
|
||||
* @param string|array|null $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function median($key = null);
|
||||
|
||||
/**
|
||||
* Get the mode of a given key.
|
||||
*
|
||||
* @param string|array|null $key
|
||||
* @return array|null
|
||||
*/
|
||||
public function mode($key = null);
|
||||
|
||||
/**
|
||||
* Collapse the items into a single enumerable.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function collapse();
|
||||
|
||||
/**
|
||||
* Alias for the "contains" method.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function some($key, $operator = null, $value = null);
|
||||
|
||||
/**
|
||||
* Determine if an item exists, using strict comparison.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function containsStrict($key, $value = null);
|
||||
|
||||
/**
|
||||
* Get the average value of a given key.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function avg($callback = null);
|
||||
|
||||
/**
|
||||
* Determine if an item exists in the enumerable.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function contains($key, $operator = null, $value = null);
|
||||
|
||||
/**
|
||||
* Dump the collection and end the script.
|
||||
*
|
||||
* @param mixed ...$args
|
||||
* @return void
|
||||
*/
|
||||
public function dd(...$args);
|
||||
|
||||
/**
|
||||
* Dump the collection.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dump();
|
||||
|
||||
/**
|
||||
* Get the items that are not present in the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function diff($items);
|
||||
|
||||
/**
|
||||
* Get the items that are not present in the given items, using the callback.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function diffUsing($items, callable $callback);
|
||||
|
||||
/**
|
||||
* Get the items whose keys and values are not present in the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function diffAssoc($items);
|
||||
|
||||
/**
|
||||
* Get the items whose keys and values are not present in the given items, using the callback.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function diffAssocUsing($items, callable $callback);
|
||||
|
||||
/**
|
||||
* Get the items whose keys are not present in the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function diffKeys($items);
|
||||
|
||||
/**
|
||||
* Get the items whose keys are not present in the given items, using the callback.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function diffKeysUsing($items, callable $callback);
|
||||
|
||||
/**
|
||||
* Retrieve duplicate items.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function duplicates($callback = null, $strict = false);
|
||||
|
||||
/**
|
||||
* Retrieve duplicate items using strict comparison.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return static
|
||||
*/
|
||||
public function duplicatesStrict($callback = null);
|
||||
|
||||
/**
|
||||
* Execute a callback over each item.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function each(callable $callback);
|
||||
|
||||
/**
|
||||
* Execute a callback over each nested chunk of items.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function eachSpread(callable $callback);
|
||||
|
||||
/**
|
||||
* Determine if all items pass the given truth test.
|
||||
*
|
||||
* @param string|callable $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function every($key, $operator = null, $value = null);
|
||||
|
||||
/**
|
||||
* Get all items except for those with the specified keys.
|
||||
*
|
||||
* @param mixed $keys
|
||||
* @return static
|
||||
*/
|
||||
public function except($keys);
|
||||
|
||||
/**
|
||||
* Run a filter over each of the items.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return static
|
||||
*/
|
||||
public function filter(callable $callback = null);
|
||||
|
||||
/**
|
||||
* Apply the callback if the value is truthy.
|
||||
*
|
||||
* @param bool $value
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function when($value, callable $callback, callable $default = null);
|
||||
|
||||
/**
|
||||
* Apply the callback if the collection is empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function whenEmpty(callable $callback, callable $default = null);
|
||||
|
||||
/**
|
||||
* Apply the callback if the collection is not empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function whenNotEmpty(callable $callback, callable $default = null);
|
||||
|
||||
/**
|
||||
* Apply the callback if the value is falsy.
|
||||
*
|
||||
* @param bool $value
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function unless($value, callable $callback, callable $default = null);
|
||||
|
||||
/**
|
||||
* Apply the callback unless the collection is empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function unlessEmpty(callable $callback, callable $default = null);
|
||||
|
||||
/**
|
||||
* Apply the callback unless the collection is not empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function unlessNotEmpty(callable $callback, callable $default = null);
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function where($key, $operator = null, $value = null);
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair using strict comparison.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function whereStrict($key, $value);
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function whereIn($key, $values, $strict = false);
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair using strict comparison.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @return static
|
||||
*/
|
||||
public function whereInStrict($key, $values);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function whereNotIn($key, $values, $strict = false);
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair using strict comparison.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @return static
|
||||
*/
|
||||
public function whereNotInStrict($key, $values);
|
||||
|
||||
/**
|
||||
* Filter the items, removing any items that don't match the given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return static
|
||||
*/
|
||||
public function whereInstanceOf($type);
|
||||
|
||||
/**
|
||||
* Get the first item from the enumerable passing the given truth test.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function first(callable $callback = null, $default = null);
|
||||
|
||||
/**
|
||||
* Get the first item by the given key value pair.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function firstWhere($key, $operator = null, $value = null);
|
||||
|
||||
/**
|
||||
* Flip the values with their keys.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function flip();
|
||||
|
||||
/**
|
||||
* Get an item from the collection by key.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null);
|
||||
|
||||
/**
|
||||
* Group an associative array by a field or using a callback.
|
||||
*
|
||||
* @param array|callable|string $groupBy
|
||||
* @param bool $preserveKeys
|
||||
* @return static
|
||||
*/
|
||||
public function groupBy($groupBy, $preserveKeys = false);
|
||||
|
||||
/**
|
||||
* Key an associative array by a field or using a callback.
|
||||
*
|
||||
* @param callable|string $keyBy
|
||||
* @return static
|
||||
*/
|
||||
public function keyBy($keyBy);
|
||||
|
||||
/**
|
||||
* Determine if an item exists in the collection by key.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key);
|
||||
|
||||
/**
|
||||
* Concatenate values of a given key as a string.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string|null $glue
|
||||
* @return string
|
||||
*/
|
||||
public function implode($value, $glue = null);
|
||||
|
||||
/**
|
||||
* Intersect the collection with the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function intersect($items);
|
||||
|
||||
/**
|
||||
* Intersect the collection with the given items by key.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function intersectByKeys($items);
|
||||
|
||||
/**
|
||||
* Determine if the collection is empty or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty();
|
||||
|
||||
/**
|
||||
* Determine if the collection is not empty.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty();
|
||||
|
||||
/**
|
||||
* 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 = '');
|
||||
|
||||
/**
|
||||
* Get the keys of the collection items.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function keys();
|
||||
|
||||
/**
|
||||
* Get the last item from the collection.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function last(callable $callback = null, $default = null);
|
||||
|
||||
/**
|
||||
* Run a map over each of the items.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function map(callable $callback);
|
||||
|
||||
/**
|
||||
* Run a map over each nested chunk of items.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function mapSpread(callable $callback);
|
||||
|
||||
/**
|
||||
* Run a dictionary map over the items.
|
||||
*
|
||||
* The callback should return an associative array with a single key/value pair.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function mapToDictionary(callable $callback);
|
||||
|
||||
/**
|
||||
* Run a grouping map over the items.
|
||||
*
|
||||
* The callback should return an associative array with a single key/value pair.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function mapToGroups(callable $callback);
|
||||
|
||||
/**
|
||||
* Run an associative map over each of the items.
|
||||
*
|
||||
* The callback should return an associative array with a single key/value pair.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function mapWithKeys(callable $callback);
|
||||
|
||||
/**
|
||||
* Map a collection and flatten the result by a single level.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function flatMap(callable $callback);
|
||||
|
||||
/**
|
||||
* Map the values into a new class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return static
|
||||
*/
|
||||
public function mapInto($class);
|
||||
|
||||
/**
|
||||
* Merge the collection with the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function merge($items);
|
||||
|
||||
/**
|
||||
* Recursively merge the collection with the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function mergeRecursive($items);
|
||||
|
||||
/**
|
||||
* Create a collection by using this collection for keys and another for its values.
|
||||
*
|
||||
* @param mixed $values
|
||||
* @return static
|
||||
*/
|
||||
public function combine($values);
|
||||
|
||||
/**
|
||||
* Union the collection with the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function union($items);
|
||||
|
||||
/**
|
||||
* Get the min value of a given key.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function min($callback = null);
|
||||
|
||||
/**
|
||||
* Get the max value of a given key.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function max($callback = null);
|
||||
|
||||
/**
|
||||
* Create a new collection consisting of every n-th element.
|
||||
*
|
||||
* @param int $step
|
||||
* @param int $offset
|
||||
* @return static
|
||||
*/
|
||||
public function nth($step, $offset = 0);
|
||||
|
||||
/**
|
||||
* Get the items with the specified keys.
|
||||
*
|
||||
* @param mixed $keys
|
||||
* @return static
|
||||
*/
|
||||
public function only($keys);
|
||||
|
||||
/**
|
||||
* "Paginate" the collection by slicing it into a smaller collection.
|
||||
*
|
||||
* @param int $page
|
||||
* @param int $perPage
|
||||
* @return static
|
||||
*/
|
||||
public function forPage($page, $perPage);
|
||||
|
||||
/**
|
||||
* Partition the collection into two arrays using the given callback or key.
|
||||
*
|
||||
* @param callable|string $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function partition($key, $operator = null, $value = null);
|
||||
|
||||
/**
|
||||
* Push all of the given items onto the collection.
|
||||
*
|
||||
* @param iterable $source
|
||||
* @return static
|
||||
*/
|
||||
public function concat($source);
|
||||
|
||||
/**
|
||||
* Get one or a specified number of items randomly from the collection.
|
||||
*
|
||||
* @param int|null $number
|
||||
* @return static|mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function random($number = null);
|
||||
|
||||
/**
|
||||
* Reduce the collection to a single value.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param mixed $initial
|
||||
* @return mixed
|
||||
*/
|
||||
public function reduce(callable $callback, $initial = null);
|
||||
|
||||
/**
|
||||
* Replace the collection items with the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function replace($items);
|
||||
|
||||
/**
|
||||
* Recursively replace the collection items with the given items.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public function replaceRecursive($items);
|
||||
|
||||
/**
|
||||
* Reverse items order.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function reverse();
|
||||
|
||||
/**
|
||||
* Search the collection for a given value and return the corresponding key if successful.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param bool $strict
|
||||
* @return mixed
|
||||
*/
|
||||
public function search($value, $strict = false);
|
||||
|
||||
/**
|
||||
* Shuffle the items in the collection.
|
||||
*
|
||||
* @param int|null $seed
|
||||
* @return static
|
||||
*/
|
||||
public function shuffle($seed = null);
|
||||
|
||||
/**
|
||||
* Skip the first {$count} items.
|
||||
*
|
||||
* @param int $count
|
||||
* @return static
|
||||
*/
|
||||
public function skip($count);
|
||||
|
||||
/**
|
||||
* Get a slice of items from the enumerable.
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int|null $length
|
||||
* @return static
|
||||
*/
|
||||
public function slice($offset, $length = null);
|
||||
|
||||
/**
|
||||
* Split a collection into a certain number of groups.
|
||||
*
|
||||
* @param int $numberOfGroups
|
||||
* @return static
|
||||
*/
|
||||
public function split($numberOfGroups);
|
||||
|
||||
/**
|
||||
* Chunk the collection into chunks of the given size.
|
||||
*
|
||||
* @param int $size
|
||||
* @return static
|
||||
*/
|
||||
public function chunk($size);
|
||||
|
||||
/**
|
||||
* Sort through each item with a callback.
|
||||
*
|
||||
* @param callable|null|int $callback
|
||||
* @return static
|
||||
*/
|
||||
public function sort($callback = null);
|
||||
|
||||
/**
|
||||
* Sort items in descending order.
|
||||
*
|
||||
* @param int $options
|
||||
* @return static
|
||||
*/
|
||||
public function sortDesc($options = SORT_REGULAR);
|
||||
|
||||
/**
|
||||
* Sort the collection using the given callback.
|
||||
*
|
||||
* @param callable|string $callback
|
||||
* @param int $options
|
||||
* @param bool $descending
|
||||
* @return static
|
||||
*/
|
||||
public function sortBy($callback, $options = SORT_REGULAR, $descending = false);
|
||||
|
||||
/**
|
||||
* Sort the collection in descending order using the given callback.
|
||||
*
|
||||
* @param callable|string $callback
|
||||
* @param int $options
|
||||
* @return static
|
||||
*/
|
||||
public function sortByDesc($callback, $options = SORT_REGULAR);
|
||||
|
||||
/**
|
||||
* Sort the collection keys.
|
||||
*
|
||||
* @param int $options
|
||||
* @param bool $descending
|
||||
* @return static
|
||||
*/
|
||||
public function sortKeys($options = SORT_REGULAR, $descending = false);
|
||||
|
||||
/**
|
||||
* Sort the collection keys in descending order.
|
||||
*
|
||||
* @param int $options
|
||||
* @return static
|
||||
*/
|
||||
public function sortKeysDesc($options = SORT_REGULAR);
|
||||
|
||||
/**
|
||||
* Get the sum of the given values.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function sum($callback = null);
|
||||
|
||||
/**
|
||||
* Take the first or last {$limit} items.
|
||||
*
|
||||
* @param int $limit
|
||||
* @return static
|
||||
*/
|
||||
public function take($limit);
|
||||
|
||||
/**
|
||||
* Pass the collection to the given callback and then return it.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function tap(callable $callback);
|
||||
|
||||
/**
|
||||
* Pass the enumerable to the given callback and return the result.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function pipe(callable $callback);
|
||||
|
||||
/**
|
||||
* Get the values of a given key.
|
||||
*
|
||||
* @param string|array $value
|
||||
* @param string|null $key
|
||||
* @return static
|
||||
*/
|
||||
public function pluck($value, $key = null);
|
||||
|
||||
/**
|
||||
* Create a collection of all elements that do not pass a given truth test.
|
||||
*
|
||||
* @param callable|mixed $callback
|
||||
* @return static
|
||||
*/
|
||||
public function reject($callback = true);
|
||||
|
||||
/**
|
||||
* Return only unique items from the collection array.
|
||||
*
|
||||
* @param string|callable|null $key
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function unique($key = null, $strict = false);
|
||||
|
||||
/**
|
||||
* Return only unique items from the collection array using strict comparison.
|
||||
*
|
||||
* @param string|callable|null $key
|
||||
* @return static
|
||||
*/
|
||||
public function uniqueStrict($key = null);
|
||||
|
||||
/**
|
||||
* Reset the keys on the underlying array.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function values();
|
||||
|
||||
/**
|
||||
* Pad collection to the specified length with a value.
|
||||
*
|
||||
* @param int $size
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function pad($size, $value);
|
||||
|
||||
/**
|
||||
* Count the number of items in the collection using a given truth test.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return static
|
||||
*/
|
||||
public function countBy($callback = null);
|
||||
|
||||
/**
|
||||
* Collect the values into a collection.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collect();
|
||||
|
||||
/**
|
||||
* Convert the collection to its string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
|
||||
/**
|
||||
* Add a method to the list of proxied methods.
|
||||
*
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public static function proxy($method);
|
||||
|
||||
/**
|
||||
* Dynamically access collection proxies.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __get($key);
|
||||
}
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Dotenv\Repository\Adapter\EnvConstAdapter;
|
||||
use Dotenv\Repository\Adapter\PutenvAdapter;
|
||||
use Dotenv\Repository\Adapter\ServerConstAdapter;
|
||||
use Dotenv\Repository\RepositoryBuilder;
|
||||
use PhpOption\Option;
|
||||
|
||||
@@ -54,16 +52,13 @@ class Env
|
||||
public static function getRepository()
|
||||
{
|
||||
if (static::$repository === null) {
|
||||
$adapters = array_merge(
|
||||
[new EnvConstAdapter, new ServerConstAdapter],
|
||||
static::$putenv ? [new PutenvAdapter] : []
|
||||
);
|
||||
$builder = RepositoryBuilder::createWithDefaultAdapters();
|
||||
|
||||
static::$repository = RepositoryBuilder::create()
|
||||
->withReaders($adapters)
|
||||
->withWriters($adapters)
|
||||
->immutable()
|
||||
->make();
|
||||
if (static::$putenv) {
|
||||
$builder = $builder->addAdapter(PutenvAdapter::class);
|
||||
}
|
||||
|
||||
static::$repository = $builder->immutable()->make();
|
||||
}
|
||||
|
||||
return static::$repository;
|
||||
|
||||
@@ -7,14 +7,18 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static \Illuminate\Support\ServiceProvider register(\Illuminate\Support\ServiceProvider|string $provider, bool $force = false)
|
||||
* @method static \Illuminate\Support\ServiceProvider resolveProvider(string $provider)
|
||||
* @method static array getProviders(\Illuminate\Support\ServiceProvider|string $provider)
|
||||
* @method static mixed make($abstract, array $parameters = [])
|
||||
* @method static mixed makeWith($abstract, array $parameters = [])
|
||||
* @method static bool configurationIsCached()
|
||||
* @method static bool hasBeenBootstrapped()
|
||||
* @method static bool isDownForMaintenance()
|
||||
* @method static bool isLocal()
|
||||
* @method static bool isProduction()
|
||||
* @method static bool routesAreCached()
|
||||
* @method static bool runningInConsole()
|
||||
* @method static bool runningUnitTests()
|
||||
* @method static bool shouldSkipMiddleware()
|
||||
* @method static string basePath()
|
||||
* @method static string basePath(string $path = '')
|
||||
* @method static string bootstrapPath(string $path = '')
|
||||
* @method static string configPath(string $path = '')
|
||||
* @method static string databasePath(string $path = '')
|
||||
@@ -27,11 +31,13 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static string getCachedRoutesPath()
|
||||
* @method static string getCachedServicesPath()
|
||||
* @method static string getLocale()
|
||||
* @method static string currentLocale()
|
||||
* @method static string getNamespace()
|
||||
* @method static string resourcePath(string $path = '')
|
||||
* @method static string storagePath(string $path = '')
|
||||
* @method static string version()
|
||||
* @method static string|bool environment(string|array ...$environments)
|
||||
* @method static never abort(int $code, string $message = '', array $headers = [])
|
||||
* @method static void boot()
|
||||
* @method static void booted(callable $callback)
|
||||
* @method static void booting(callable $callback)
|
||||
|
||||
@@ -14,6 +14,7 @@ use RuntimeException;
|
||||
* @method static \Illuminate\Contracts\Auth\UserProvider|null createUserProvider(string $provider = null)
|
||||
* @method static \Symfony\Component\HttpFoundation\Response|null onceBasic(string $field = 'email',array $extraConditions = [])
|
||||
* @method static bool attempt(array $credentials = [], bool $remember = false)
|
||||
* @method static bool hasUser()
|
||||
* @method static bool check()
|
||||
* @method static bool guest()
|
||||
* @method static bool once(array $credentials = [])
|
||||
@@ -24,6 +25,7 @@ use RuntimeException;
|
||||
* @method static int|string|null id()
|
||||
* @method static void login(\Illuminate\Contracts\Auth\Authenticatable $user, bool $remember = false)
|
||||
* @method static void logout()
|
||||
* @method static void logoutCurrentDevice()
|
||||
* @method static void setUser(\Illuminate\Contracts\Auth\Authenticatable $user)
|
||||
* @method static void shouldUse(string $name);
|
||||
*
|
||||
@@ -49,6 +51,8 @@ class Auth extends Facade
|
||||
*
|
||||
* @param array $options
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function routes(array $options = [])
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static array getExtensions()
|
||||
* @method static bool check(string $name, array ...$parameters)
|
||||
* @method static string compileString(string $value)
|
||||
* @method static string render(string $string, array $data = [], bool $deleteCachedView = false)
|
||||
* @method static string renderComponent(\Illuminate\View\Component $component)
|
||||
* @method static string getPath()
|
||||
* @method static string stripParentheses(string $expression)
|
||||
* @method static void aliasComponent(string $path, string|null $alias = null)
|
||||
@@ -15,6 +17,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static void compile(string|null $path = null)
|
||||
* @method static void component(string $class, string|null $alias = null, string $prefix = '')
|
||||
* @method static void components(array $components, string $prefix = '')
|
||||
* @method static void componentNamespace(string $namespace, string $prefix)
|
||||
* @method static void directive(string $name, callable $handler)
|
||||
* @method static void extend(callable $compiler)
|
||||
* @method static void if(string $name, callable $callback)
|
||||
@@ -25,6 +28,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static void withDoubleEncoding()
|
||||
* @method static void withoutComponentTags()
|
||||
* @method static void withoutDoubleEncoding()
|
||||
* @method static void stringable(string|callable $class, callable|null $handler = null)
|
||||
*
|
||||
* @see \Illuminate\View\Compilers\BladeCompiler
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,9 @@ use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactoryContract;
|
||||
/**
|
||||
* @method static \Illuminate\Broadcasting\Broadcasters\Broadcaster channel(string $channel, callable|string $callback, array $options = [])
|
||||
* @method static mixed auth(\Illuminate\Http\Request $request)
|
||||
* @method static void connection($name = null);
|
||||
* @method static \Illuminate\Contracts\Broadcasting\Broadcaster connection($name = null);
|
||||
* @method static void routes(array $attributes = null)
|
||||
* @method static \Illuminate\Broadcasting\BroadcastManager socket($request = null)
|
||||
*
|
||||
* @see \Illuminate\Contracts\Broadcasting\Factory
|
||||
*/
|
||||
|
||||
@@ -7,15 +7,29 @@ use Illuminate\Foundation\Bus\PendingChain;
|
||||
use Illuminate\Support\Testing\Fakes\BusFake;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Bus\Batch|null findBatch(string $batchId)
|
||||
* @method static \Illuminate\Bus\PendingBatch batch(array|mixed $jobs)
|
||||
* @method static \Illuminate\Contracts\Bus\Dispatcher map(array $map)
|
||||
* @method static \Illuminate\Contracts\Bus\Dispatcher pipeThrough(array $pipes)
|
||||
* @method static \Illuminate\Foundation\Bus\PendingChain chain(array $jobs)
|
||||
* @method static bool hasCommandHandler($command)
|
||||
* @method static bool|mixed getCommandHandler($command)
|
||||
* @method static mixed dispatch($command)
|
||||
* @method static mixed dispatchNow($command, $handler = null)
|
||||
* @method static void assertDispatched(string $command, callable|int $callback = null)
|
||||
* @method static mixed dispatchSync($command, $handler = null)
|
||||
* @method static void assertDispatched(string|\Closure $command, callable|int $callback = null)
|
||||
* @method static void assertDispatchedTimes(string $command, int $times = 1)
|
||||
* @method static void assertNotDispatched(string $command, callable|int $callback = null)
|
||||
* @method static void assertNotDispatched(string|\Closure $command, callable|int $callback = null)
|
||||
* @method static void assertDispatchedAfterResponse(string|\Closure $command, callable|int $callback = null)
|
||||
* @method static void assertDispatchedAfterResponseTimes(string $command, int $times = 1)
|
||||
* @method static void assertNotDispatchedAfterResponse(string|\Closure $command, callable $callback = null)
|
||||
* @method static void assertBatched(callable $callback)
|
||||
* @method static void assertBatchCount(int $count)
|
||||
* @method static void assertChained(array $expectedChain)
|
||||
* @method static void assertDispatchedSync(string|\Closure $command, callable $callback = null)
|
||||
* @method static void assertDispatchedSyncTimes(string $command, int $times = 1)
|
||||
* @method static void assertNotDispatchedSync(string|\Closure $command, callable $callback = null)
|
||||
* @method static void assertDispatchedWithoutChain(string|\Closure $command, callable $callback = null)
|
||||
*
|
||||
* @see \Illuminate\Contracts\Bus\Dispatcher
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static \Illuminate\Contracts\Cache\Repository store(string|null $name = null)
|
||||
* @method static \Illuminate\Contracts\Cache\Store getStore()
|
||||
* @method static bool add(string $key, $value, \DateTimeInterface|\DateInterval|int $ttl = null)
|
||||
* @method static bool flush()
|
||||
* @method static bool forever(string $key, $value)
|
||||
* @method static bool forget(string $key)
|
||||
* @method static bool has(string $key)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static \Doctrine\DBAL\Driver\PDOConnection getPdo()
|
||||
* @method static \Illuminate\Database\ConnectionInterface connection(string $name = null)
|
||||
* @method static \Illuminate\Database\Query\Builder table(string $table, string $as = null)
|
||||
* @method static \Illuminate\Database\Query\Expression raw($value)
|
||||
@@ -21,11 +22,13 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static mixed selectOne(string $query, array $bindings = [], bool $useReadPdo = true)
|
||||
* @method static mixed transaction(\Closure $callback, int $attempts = 1)
|
||||
* @method static string getDefaultConnection()
|
||||
* @method static void afterCommit(\Closure $callback)
|
||||
* @method static void beginTransaction()
|
||||
* @method static void commit()
|
||||
* @method static void enableQueryLog()
|
||||
* @method static void disableQueryLog()
|
||||
* @method static void flushQueryLog()
|
||||
* @method static \Illuminate\Database\Connection beforeExecuting(\Closure $callback)
|
||||
* @method static void listen(\Closure $callback)
|
||||
* @method static void rollBack(int $toLevel = null)
|
||||
* @method static void setDefaultConnection(string $name)
|
||||
|
||||
@@ -28,7 +28,7 @@ use Illuminate\Support\DateFactory;
|
||||
* @method static \Illuminate\Support\Carbon now($tz = null)
|
||||
* @method static \Illuminate\Support\Carbon parse($time = null, $tz = null)
|
||||
* @method static \Illuminate\Support\Carbon setHumanDiffOptions($humanDiffOptions)
|
||||
* @method static \Illuminate\Support\Carbon setTestNow($testNow = null)
|
||||
* @method static void setTestNow($testNow = null)
|
||||
* @method static \Illuminate\Support\Carbon setUtf8($utf8)
|
||||
* @method static \Illuminate\Support\Carbon today($tz = null)
|
||||
* @method static \Illuminate\Support\Carbon tomorrow($tz = null)
|
||||
|
||||
@@ -13,13 +13,15 @@ use Illuminate\Support\Testing\Fakes\EventFake;
|
||||
* @method static array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false)
|
||||
* @method static array|null until(string|object $event, mixed $payload = [])
|
||||
* @method static bool hasListeners(string $eventName)
|
||||
* @method static void assertDispatched(string $event, callable|int $callback = null)
|
||||
* @method static void assertDispatched(string|\Closure $event, callable|int $callback = null)
|
||||
* @method static void assertDispatchedTimes(string $event, int $times = 1)
|
||||
* @method static void assertNotDispatched(string $event, callable|int $callback = null)
|
||||
* @method static void assertNotDispatched(string|\Closure $event, callable|int $callback = null)
|
||||
* @method static void assertNothingDispatched()
|
||||
* @method static void assertListening(string $expectedEvent, string $expectedListener)
|
||||
* @method static void flush(string $event)
|
||||
* @method static void forget(string $event)
|
||||
* @method static void forgetPushed()
|
||||
* @method static void listen(string|array $events, \Closure|string $listener)
|
||||
* @method static void listen(\Closure|string|array $events, \Closure|string|array $listener = null)
|
||||
* @method static void push(string $event, array $payload = [])
|
||||
* @method static void subscribe(object|string $subscriber)
|
||||
*
|
||||
@@ -43,12 +45,27 @@ class Event extends Facade
|
||||
return $fake;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the bound instance with a fake that fakes all events except the given events.
|
||||
*
|
||||
* @param string[]|string $eventsToAllow
|
||||
* @return \Illuminate\Support\Testing\Fakes\EventFake
|
||||
*/
|
||||
public static function fakeExcept($eventsToAllow)
|
||||
{
|
||||
return static::fake([
|
||||
function ($eventName) use ($eventsToAllow) {
|
||||
return ! in_array($eventName, (array) $eventsToAllow);
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the bound instance with a fake during the given callable's execution.
|
||||
*
|
||||
* @param callable $callable
|
||||
* @param array $eventsToFake
|
||||
* @return callable
|
||||
* @return mixed
|
||||
*/
|
||||
public static function fakeFor(callable $callable, array $eventsToFake = [])
|
||||
{
|
||||
@@ -64,6 +81,27 @@ class Event extends Facade
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the bound instance with a fake during the given callable's execution.
|
||||
*
|
||||
* @param callable $callable
|
||||
* @param array $eventsToAllow
|
||||
* @return mixed
|
||||
*/
|
||||
public static function fakeExceptFor(callable $callable, array $eventsToAllow = [])
|
||||
{
|
||||
$originalDispatcher = static::getFacadeRoot();
|
||||
|
||||
static::fakeExcept($eventsToAllow);
|
||||
|
||||
return tap($callable(), function () use ($originalDispatcher) {
|
||||
static::swap($originalDispatcher);
|
||||
|
||||
Model::setEventDispatcher($originalDispatcher);
|
||||
Cache::refreshEventDispatcher();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Illuminate\Support\Facades;
|
||||
|
||||
use Closure;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
use Mockery\LegacyMockInterface;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class Facade
|
||||
@@ -126,7 +126,7 @@ abstract class Facade
|
||||
$name = static::getFacadeAccessor();
|
||||
|
||||
return isset(static::$resolvedInstance[$name]) &&
|
||||
static::$resolvedInstance[$name] instanceof MockInterface;
|
||||
static::$resolvedInstance[$name] instanceof LegacyMockInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static bool isReadable(string $path)
|
||||
* @method static bool isWritable(string $path)
|
||||
* @method static bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false)
|
||||
* @method static bool missing(string $path)
|
||||
* @method static bool move(string $path, string $target)
|
||||
* @method static bool moveDirectory(string $from, string $to, bool $overwrite = false)
|
||||
* @method static int append(string $path, string $data)
|
||||
@@ -27,8 +28,8 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static int size(string $path)
|
||||
* @method static int|bool put(string $path, string $contents, bool $lock = false)
|
||||
* @method static mixed chmod(string $path, int|null $mode = null)
|
||||
* @method static mixed getRequire(string $path)
|
||||
* @method static mixed requireOnce(string $file)
|
||||
* @method static mixed getRequire(string $path, array $data = [])
|
||||
* @method static mixed requireOnce(string $file, array $data = [])
|
||||
* @method static string basename(string $path)
|
||||
* @method static string dirname(string $path)
|
||||
* @method static string extension(string $path)
|
||||
@@ -38,8 +39,11 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static string sharedGet(string $path)
|
||||
* @method static string type(string $path)
|
||||
* @method static string|false mimeType(string $path)
|
||||
* @method static string|null guessExtension(string $path)
|
||||
* @method static void ensureDirectoryExists(string $path, int $mode = 0755, bool $recursive = true)
|
||||
* @method static void link(string $target, string $link)
|
||||
* @method static \Illuminate\Support\LazyCollection lines(string $path)
|
||||
* @method static void relativeLink(string $target, string $link)
|
||||
* @method static void replace(string $path, string $content)
|
||||
*
|
||||
* @see \Illuminate\Filesystem\Filesystem
|
||||
|
||||
@@ -8,6 +8,8 @@ use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
* @method static \Illuminate\Auth\Access\Gate guessPolicyNamesUsing(callable $callback)
|
||||
* @method static \Illuminate\Auth\Access\Response authorize(string $ability, array|mixed $arguments = [])
|
||||
* @method static \Illuminate\Auth\Access\Response inspect(string $ability, array|mixed $arguments = [])
|
||||
* @method static \Illuminate\Auth\Access\Response allowIf(\Closure|bool $condition, string|null $message = null, mixed $code = null)
|
||||
* @method static \Illuminate\Auth\Access\Response denyIf(\Closure|bool $condition, string|null $message = null, mixed $code = null)
|
||||
* @method static \Illuminate\Contracts\Auth\Access\Gate after(callable $callback)
|
||||
* @method static \Illuminate\Contracts\Auth\Access\Gate before(callable $callback)
|
||||
* @method static \Illuminate\Contracts\Auth\Access\Gate define(string $ability, callable|string $callback)
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static bool check(string $value, string $hashedValue, array $options = [])
|
||||
* @method static bool needsRehash(string $hashedValue, array $options = [])
|
||||
* @method static string make(string $value, array $options = [])
|
||||
* @method static \Illuminate\Hashing\HashManager extend($driver, \Closure $callback)
|
||||
*
|
||||
* @see \Illuminate\Hashing\HashManager
|
||||
*/
|
||||
|
||||
@@ -12,12 +12,16 @@ use Illuminate\Http\Client\Factory;
|
||||
* @method static \Illuminate\Http\Client\PendingRequest asForm()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest asJson()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest asMultipart()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest attach(string $name, string $contents, string|null $filename = null, array $headers = [])
|
||||
* @method static \Illuminate\Http\Client\PendingRequest async()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest attach(string|array $name, string $contents = '', string|null $filename = null, array $headers = [])
|
||||
* @method static \Illuminate\Http\Client\PendingRequest baseUrl(string $url)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest beforeSending(callable $callback)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest bodyFormat(string $format)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest contentType(string $contentType)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest retry(int $times, int $sleep = 0)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest dd()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest dump()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest retry(int $times, int $sleep = 0, ?callable $when = null)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest sink(string|resource $to)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest stub(callable $callback)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest timeout(int $seconds)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withBasicAuth(string $username, string $password)
|
||||
@@ -25,18 +29,27 @@ use Illuminate\Http\Client\Factory;
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withCookies(array $cookies, string $domain)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withDigestAuth(string $username, string $password)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withHeaders(array $headers)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withMiddleware(callable $middleware)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withOptions(array $options)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withToken(string $token, string $type = 'Bearer')
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withUserAgent(string $userAgent)
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withoutRedirecting()
|
||||
* @method static \Illuminate\Http\Client\PendingRequest withoutVerifying()
|
||||
* @method static array pool(callable $callback)
|
||||
* @method static \Illuminate\Http\Client\Response delete(string $url, array $data = [])
|
||||
* @method static \Illuminate\Http\Client\Response get(string $url, array $query = [])
|
||||
* @method static \Illuminate\Http\Client\Response head(string $url, array $query = [])
|
||||
* @method static \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null)
|
||||
* @method static \Illuminate\Http\Client\Response head(string $url, array|string|null $query = null)
|
||||
* @method static \Illuminate\Http\Client\Response patch(string $url, array $data = [])
|
||||
* @method static \Illuminate\Http\Client\Response post(string $url, array $data = [])
|
||||
* @method static \Illuminate\Http\Client\Response put(string $url, array $data = [])
|
||||
* @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = [])
|
||||
* @method static \Illuminate\Http\Client\ResponseSequence fakeSequence(string $urlPattern = '*')
|
||||
* @method static void assertSent(callable $callback)
|
||||
* @method static void assertSentInOrder(array $callbacks)
|
||||
* @method static void assertNotSent(callable $callback)
|
||||
* @method static void assertNothingSent()
|
||||
* @method static void assertSentCount(int $count)
|
||||
* @method static void assertSequencesAreEmpty()
|
||||
*
|
||||
* @see \Illuminate\Http\Client\Factory
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static bool has(string $key)
|
||||
* @method static bool hasForLocale(string $key, string $locale = null)
|
||||
* @method static bool has(string $key, string $locale = null, bool $fallback = true)
|
||||
* @method static mixed get(string $key, array $replace = [], string $locale = null, bool $fallback = true)
|
||||
* @method static string choice(string $key, \Countable|int|array $number, array $replace = [], string $locale = null)
|
||||
* @method static string getLocale()
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace Illuminate\Support\Facades;
|
||||
/**
|
||||
* @method static \Psr\Log\LoggerInterface channel(string $channel = null)
|
||||
* @method static \Psr\Log\LoggerInterface stack(array $channels, string $channel = null)
|
||||
* @method static \Psr\Log\LoggerInterface build(array $config)
|
||||
* @method static \Illuminate\Log\Logger withContext(array $context = [])
|
||||
* @method static \Illuminate\Log\Logger withoutContext()
|
||||
* @method static void alert(string $message, array $context = [])
|
||||
* @method static void critical(string $message, array $context = [])
|
||||
* @method static void debug(string $message, array $context = [])
|
||||
@@ -14,6 +17,8 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static void log($level, string $message, array $context = [])
|
||||
* @method static void notice(string $message, array $context = [])
|
||||
* @method static void warning(string $message, array $context = [])
|
||||
* @method static void write(string $level, string $message, array $context = [])
|
||||
* @method static void listen(\Closure $callback)
|
||||
*
|
||||
* @see \Illuminate\Log\Logger
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,11 @@ namespace Illuminate\Support\Facades;
|
||||
use Illuminate\Support\Testing\Fakes\MailFake;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Mail\Mailer mailer(string|null $name = null)
|
||||
* @method static void alwaysFrom(string $address, string|null $name = null)
|
||||
* @method static void alwaysReplyTo(string $address, string|null $name = null)
|
||||
* @method static void alwaysReturnPath(string $address)
|
||||
* @method static void alwaysTo(string $address, string|null $name = null)
|
||||
* @method static \Illuminate\Mail\PendingMail bcc($users)
|
||||
* @method static \Illuminate\Mail\PendingMail to($users)
|
||||
* @method static \Illuminate\Support\Collection queued(string $mailable, \Closure|string $callback = null)
|
||||
@@ -13,14 +18,18 @@ use Illuminate\Support\Testing\Fakes\MailFake;
|
||||
* @method static bool hasQueued(string $mailable)
|
||||
* @method static bool hasSent(string $mailable)
|
||||
* @method static mixed later(\DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable|string|array $view, string $queue = null)
|
||||
* @method static mixed laterOn(string $queue, \DateTimeInterface|\DateInterval|int $delay, \Illuminate\Contracts\Mail\Mailable|string|array $view)
|
||||
* @method static mixed queue(\Illuminate\Contracts\Mail\Mailable|string|array $view, string $queue = null)
|
||||
* @method static mixed queueOn(string $queue, \Illuminate\Contracts\Mail\Mailable|string|array $view)
|
||||
* @method static void assertNotQueued(string $mailable, callable $callback = null)
|
||||
* @method static void assertNotSent(string $mailable, callable|int $callback = null)
|
||||
* @method static void assertNothingQueued()
|
||||
* @method static void assertNothingSent()
|
||||
* @method static void assertQueued(string $mailable, callable|int $callback = null)
|
||||
* @method static void assertSent(string $mailable, callable|int $callback = null)
|
||||
* @method static void assertQueued(string|\Closure $mailable, callable|int $callback = null)
|
||||
* @method static void assertSent(string|\Closure $mailable, callable|int $callback = null)
|
||||
* @method static void raw(string $text, $callback)
|
||||
* @method static void plain(string $view, array $data, $callback)
|
||||
* @method static void html(string $html, $callback)
|
||||
* @method static void send(\Illuminate\Contracts\Mail\Mailable|string|array $view, array $data = [], \Closure|string $callback = null)
|
||||
*
|
||||
* @see \Illuminate\Mail\Mailer
|
||||
|
||||
@@ -11,9 +11,11 @@ use Illuminate\Support\Testing\Fakes\NotificationFake;
|
||||
* @method static \Illuminate\Support\Collection sent(mixed $notifiable, string $notification, callable $callback = null)
|
||||
* @method static bool hasSent(mixed $notifiable, string $notification)
|
||||
* @method static mixed channel(string|null $name = null)
|
||||
* @method static void assertNotSentTo(mixed $notifiable, string $notification, callable $callback = null)
|
||||
* @method static void assertNotSentTo(mixed $notifiable, string|\Closure $notification, callable $callback = null)
|
||||
* @method static void assertNothingSent()
|
||||
* @method static void assertSentTo(mixed $notifiable, string $notification, callable $callback = null)
|
||||
* @method static void assertSentOnDemand(string|\Closure $notification, callable $callback = null)
|
||||
* @method static void assertSentTo(mixed $notifiable, string|\Closure $notification, callable $callback = null)
|
||||
* @method static void assertSentOnDemandTimes(string $notification, int $times = 1)
|
||||
* @method static void assertSentToTimes(mixed $notifiable, string $notification, int $times = 1)
|
||||
* @method static void assertTimesSent(int $expectedCount, string $notification)
|
||||
* @method static void send(\Illuminate\Support\Collection|array|mixed $notifiables, $notification)
|
||||
|
||||
26
vendor/laravel/framework/src/Illuminate/Support/Facades/ParallelTesting.php
vendored
Normal file
26
vendor/laravel/framework/src/Illuminate/Support/Facades/ParallelTesting.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static void setUpProcess(callable $callback)
|
||||
* @method static void setUpTestCase(callable $callback)
|
||||
* @method static void setUpTestDatabase(callable $callback)
|
||||
* @method static void tearDownProcess(callable $callback)
|
||||
* @method static void tearDownTestCase(callable $callback)
|
||||
* @method static int|false token()
|
||||
*
|
||||
* @see \Illuminate\Testing\ParallelTesting
|
||||
*/
|
||||
class ParallelTesting extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return \Illuminate\Testing\ParallelTesting::class;
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@ use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
|
||||
/**
|
||||
* @method static mixed reset(array $credentials, \Closure $callback)
|
||||
* @method static string sendResetLink(array $credentials)
|
||||
* @method static string sendResetLink(array $credentials, \Closure $callback = null)
|
||||
* @method static \Illuminate\Contracts\Auth\CanResetPassword getUser(array $credentials)
|
||||
* @method static string createToken(\Illuminate\Contracts\Auth\CanResetPassword $user)
|
||||
* @method static void deleteToken(\Illuminate\Contracts\Auth\CanResetPassword $user)
|
||||
* @method static bool tokenExists(\Illuminate\Contracts\Auth\CanResetPassword $user, string $token)
|
||||
* @method static \Illuminate\Auth\Passwords\TokenRepositoryInterface getRepository()
|
||||
* @method static \Illuminate\Contracts\Auth\PasswordBroker broker(string|null $name = null)
|
||||
*
|
||||
* @see \Illuminate\Auth\Passwords\PasswordBroker
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Support\Facades;
|
||||
|
||||
use Illuminate\Queue\Worker;
|
||||
use Illuminate\Support\Testing\Fakes\QueueFake;
|
||||
|
||||
/**
|
||||
@@ -15,10 +16,10 @@ use Illuminate\Support\Testing\Fakes\QueueFake;
|
||||
* @method static mixed pushOn(string $queue, string|object $job, mixed $data = '')
|
||||
* @method static mixed pushRaw(string $payload, string $queue = null, array $options = [])
|
||||
* @method static string getConnectionName()
|
||||
* @method static void assertNotPushed(string $job, callable $callback = null)
|
||||
* @method static void assertNotPushed(string|\Closure $job, callable $callback = null)
|
||||
* @method static void assertNothingPushed()
|
||||
* @method static void assertPushed(string $job, callable|int $callback = null)
|
||||
* @method static void assertPushedOn(string $queue, string $job, callable|int $callback = null)
|
||||
* @method static void assertPushed(string|\Closure $job, callable|int $callback = null)
|
||||
* @method static void assertPushedOn(string $queue, string|\Closure $job, callable $callback = null)
|
||||
* @method static void assertPushedWithChain(string $job, array $expectedChain = [], callable $callback = null)
|
||||
*
|
||||
* @see \Illuminate\Queue\QueueManager
|
||||
@@ -26,6 +27,18 @@ use Illuminate\Support\Testing\Fakes\QueueFake;
|
||||
*/
|
||||
class Queue extends Facade
|
||||
{
|
||||
/**
|
||||
* Register a callback to be executed to pick jobs.
|
||||
*
|
||||
* @param string $workerName
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public static function popUsing($workerName, $callback)
|
||||
{
|
||||
return Worker::popUsing($workerName, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the bound instance with a fake.
|
||||
*
|
||||
|
||||
30
vendor/laravel/framework/src/Illuminate/Support/Facades/RateLimiter.php
vendored
Normal file
30
vendor/laravel/framework/src/Illuminate/Support/Facades/RateLimiter.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Cache\RateLimiter for(string $name, \Closure $callback)
|
||||
* @method static \Closure limiter(string $name)
|
||||
* @method static bool tooManyAttempts($key, $maxAttempts)
|
||||
* @method static int hit($key, $decaySeconds = 60)
|
||||
* @method static mixed attempts($key)
|
||||
* @method static mixed resetAttempts($key)
|
||||
* @method static int retriesLeft($key, $maxAttempts)
|
||||
* @method static void clear($key)
|
||||
* @method static int availableIn($key)
|
||||
* @method static bool attempt($key, $maxAttempts, \Closure $callback, $decaySeconds = 60)
|
||||
*
|
||||
* @see \Illuminate\Cache\RateLimiter
|
||||
*/
|
||||
class RateLimiter extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'Illuminate\Cache\RateLimiter';
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,21 @@
|
||||
namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Http\RedirectResponse action(string $action, array $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse action(string $action, mixed $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse away(string $path, int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse back(int $status = 302, array $headers = [], $fallback = false)
|
||||
* @method static \Illuminate\Http\RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool $secure = null)
|
||||
* @method static \Illuminate\Http\RedirectResponse home(int $status = 302)
|
||||
* @method static \Illuminate\Http\RedirectResponse intended(string $default = '/', int $status = 302, array $headers = [], bool $secure = null)
|
||||
* @method static \Illuminate\Http\RedirectResponse refresh(int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse route(string $route, array $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse route(string $route, mixed $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse secure(string $path, int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse signedRoute(string $name, array $parameters = [], \DateTimeInterface|\DateInterval|int $expiration = null, int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, array $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse signedRoute(string $name, mixed $parameters = [], \DateTimeInterface|\DateInterval|int $expiration = null, int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, mixed $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse to(string $path, int $status = 302, array $headers = [], bool $secure = null)
|
||||
* @method static \Illuminate\Routing\UrlGenerator getUrlGenerator()
|
||||
* @method static void setSession(\Illuminate\Session\Store $session)
|
||||
* @method static void setIntendedUrl(string $url)
|
||||
*
|
||||
* @see \Illuminate\Routing\Redirector
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract;
|
||||
* @method static \Illuminate\Http\RedirectResponse redirectToAction(string $action, mixed $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)
|
||||
* @method static \Illuminate\Http\RedirectResponse redirectToRoute(string $route, mixed $parameters = [], int $status = 302, array $headers = [])
|
||||
* @method static \Illuminate\Http\Response make(string $content = '', int $status = 200, array $headers = [])
|
||||
* @method static \Illuminate\Http\Response make(array|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 \Symfony\Component\HttpFoundation\BinaryFileResponse download(\SplFileInfo|string $file, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')
|
||||
|
||||
@@ -6,11 +6,12 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static \Illuminate\Routing\PendingResourceRegistration apiResource(string $name, string $controller, array $options = [])
|
||||
* @method static \Illuminate\Routing\PendingResourceRegistration resource(string $name, string $controller, array $options = [])
|
||||
* @method static \Illuminate\Routing\Route any(string $uri, array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route current()
|
||||
* @method static \Illuminate\Routing\Route|null current()
|
||||
* @method static \Illuminate\Routing\Route delete(string $uri, array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route fallback(array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route get(string $uri, array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route getCurrentRoute()
|
||||
* @method static \Illuminate\Routing\Route|null getCurrentRoute()
|
||||
* @method static \Illuminate\Routing\RouteCollectionInterface getRoutes()
|
||||
* @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route options(string $uri, array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route patch(string $uri, array|string|callable|null $action = null)
|
||||
@@ -19,23 +20,31 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static \Illuminate\Routing\Route put(string $uri, array|string|callable|null $action = null)
|
||||
* @method static \Illuminate\Routing\Route redirect(string $uri, string $destination, int $status = 302)
|
||||
* @method static \Illuminate\Routing\Route substituteBindings(\Illuminate\Support\Facades\Route $route)
|
||||
* @method static \Illuminate\Routing\Route view(string $uri, string $view, array $data = [])
|
||||
* @method static \Illuminate\Routing\Route view(string $uri, string $view, array $data = [], int|array $status = 200, array $headers = [])
|
||||
* @method static \Illuminate\Routing\RouteRegistrar as(string $value)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar controller(string $controller)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar domain(string $value)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar middleware(array|string|null $middleware)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar name(string $value)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar namespace(string $value)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar prefix(string $prefix)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar where(array $where)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar namespace(string|null $value)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar prefix(string $prefix)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar scopeBindings()
|
||||
* @method static \Illuminate\Routing\RouteRegistrar where(array $where)
|
||||
* @method static \Illuminate\Routing\RouteRegistrar withoutMiddleware(array|string $middleware)
|
||||
* @method static \Illuminate\Routing\Router|\Illuminate\Routing\RouteRegistrar group(\Closure|string|array $attributes, \Closure|string $routes)
|
||||
* @method static \Illuminate\Routing\ResourceRegistrar resourceVerbs(array $verbs = [])
|
||||
* @method static string|null currentRouteAction()
|
||||
* @method static string|null currentRouteName()
|
||||
* @method static void apiResources(array $resources, array $options = [])
|
||||
* @method static void bind(string $key, string|callable $binder)
|
||||
* @method static void model(string $key, string $class, \Closure|null $callback = null)
|
||||
* @method static void pattern(string $key, string $pattern)
|
||||
* @method static void resources(array $resources)
|
||||
* @method static void resources(array $resources, array $options = [])
|
||||
* @method static void substituteImplicitBindings(\Illuminate\Support\Facades\Route $route)
|
||||
* @method static boolean uses(...$patterns)
|
||||
* @method static boolean is(...$patterns)
|
||||
* @method static boolean has(string $name)
|
||||
* @method static mixed input(string $key, string|null $default = null)
|
||||
*
|
||||
* @see \Illuminate\Routing\Router
|
||||
*/
|
||||
|
||||
@@ -4,17 +4,25 @@ namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Schema\Builder create(string $table, \Closure $callback)
|
||||
* @method static \Illuminate\Database\Schema\Builder createDatabase(string $name)
|
||||
* @method static \Illuminate\Database\Schema\Builder disableForeignKeyConstraints()
|
||||
* @method static \Illuminate\Database\Schema\Builder drop(string $table)
|
||||
* @method static \Illuminate\Database\Schema\Builder dropDatabaseIfExists(string $name)
|
||||
* @method static \Illuminate\Database\Schema\Builder dropIfExists(string $table)
|
||||
* @method static \Illuminate\Database\Schema\Builder enableForeignKeyConstraints()
|
||||
* @method static \Illuminate\Database\Schema\Builder rename(string $from, string $to)
|
||||
* @method static \Illuminate\Database\Schema\Builder table(string $table, \Closure $callback)
|
||||
* @method static bool hasColumn(string $table, string $column)
|
||||
* @method static bool hasColumns(string $table, array $columns)
|
||||
* @method static bool dropColumns(string $table, array $columns)
|
||||
* @method static bool hasTable(string $table)
|
||||
* @method static void defaultStringLength(int $length)
|
||||
* @method static void registerCustomDoctrineType(string $class, string $name, string $type)
|
||||
* @method static array getColumnListing(string $table)
|
||||
* @method static string getColumnType(string $table, string $column)
|
||||
* @method static void morphUsingUuids()
|
||||
* @method static \Illuminate\Database\Connection getConnection()
|
||||
* @method static \Illuminate\Database\Schema\Builder setConnection(\Illuminate\Database\Connection $connection)
|
||||
*
|
||||
* @see \Illuminate\Database\Schema\Builder
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static bool save()
|
||||
* @method static bool start()
|
||||
* @method static mixed get(string $key, $default = null)
|
||||
* @method static mixed flash(string $key, $value = true)
|
||||
* @method static mixed pull(string $key, $default = null)
|
||||
* @method static mixed remove(string $key)
|
||||
* @method static string getId()
|
||||
|
||||
@@ -8,7 +8,11 @@ use Illuminate\Filesystem\Filesystem;
|
||||
* @method static \Illuminate\Contracts\Filesystem\Filesystem assertExists(string|array $path)
|
||||
* @method static \Illuminate\Contracts\Filesystem\Filesystem assertMissing(string|array $path)
|
||||
* @method static \Illuminate\Contracts\Filesystem\Filesystem cloud()
|
||||
* @method static \Illuminate\Contracts\Filesystem\Filesystem disk(string $name = null)
|
||||
* @method static \Illuminate\Contracts\Filesystem\Filesystem build(string|array $root)
|
||||
* @method static \Illuminate\Contracts\Filesystem\Filesystem disk(string|null $name = null)
|
||||
* @method static \Illuminate\Filesystem\FilesystemManager extend(string $driver, \Closure $callback)
|
||||
* @method static \Symfony\Component\HttpFoundation\StreamedResponse download(string $path, string|null $name = null, array|null $headers = [])
|
||||
* @method static \Symfony\Component\HttpFoundation\StreamedResponse response(string $path, string|null $name = null, array|null $headers = [], string|null $disposition = 'inline')
|
||||
* @method static array allDirectories(string|null $directory = null)
|
||||
* @method static array allFiles(string|null $directory = null)
|
||||
* @method static array directories(string|null $directory = null, bool $recursive = false)
|
||||
@@ -19,11 +23,10 @@ use Illuminate\Filesystem\Filesystem;
|
||||
* @method static bool deleteDirectory(string $directory)
|
||||
* @method static bool exists(string $path)
|
||||
* @method static bool makeDirectory(string $path)
|
||||
* @method static bool missing(string $path)
|
||||
* @method static bool move(string $from, string $to)
|
||||
* @method static bool prepend(string $path, string $data)
|
||||
* @method static bool put(string $path, string|resource $contents, mixed $options = [])
|
||||
* @method static string|false putFile(string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $file, mixed $options = [])
|
||||
* @method static string|false putFileAs(string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $file, string $name, mixed $options = [])
|
||||
* @method static bool put(string $path, \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $contents, mixed $options = [])
|
||||
* @method static bool setVisibility(string $path, string $visibility)
|
||||
* @method static bool writeStream(string $path, resource $resource, array $options = [])
|
||||
* @method static int lastModified(string $path)
|
||||
@@ -31,8 +34,14 @@ use Illuminate\Filesystem\Filesystem;
|
||||
* @method static resource|null readStream(string $path)
|
||||
* @method static string get(string $path)
|
||||
* @method static string getVisibility(string $path)
|
||||
* @method static string path(string $path)
|
||||
* @method static string temporaryUrl(string $path, \DateTimeInterface $expiration, array $options = [])
|
||||
* @method static string url(string $path)
|
||||
* @method static string|false mimeType(string $path)
|
||||
* @method static string|false putFile(string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $file, mixed $options = [])
|
||||
* @method static string|false putFileAs(string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $file, string $name, mixed $options = [])
|
||||
* @method static void macro(string $name, object|callable $macro)
|
||||
* @method static void buildTemporaryUrlsUsing(\Closure $callback)
|
||||
*
|
||||
* @see \Illuminate\Filesystem\FilesystemManager
|
||||
*/
|
||||
@@ -49,9 +58,13 @@ class Storage extends Facade
|
||||
{
|
||||
$disk = $disk ?: static::$app['config']->get('filesystems.default');
|
||||
|
||||
(new Filesystem)->cleanDirectory(
|
||||
$root = storage_path('framework/testing/disks/'.$disk)
|
||||
);
|
||||
$root = storage_path('framework/testing/disks/'.$disk);
|
||||
|
||||
if ($token = ParallelTesting::token()) {
|
||||
$root = "{$root}_test_{$token}";
|
||||
}
|
||||
|
||||
(new Filesystem)->cleanDirectory($root);
|
||||
|
||||
static::set($disk, $fake = static::createLocalDriver(array_merge($config, [
|
||||
'root' => $root,
|
||||
|
||||
@@ -5,10 +5,13 @@ namespace Illuminate\Support\Facades;
|
||||
/**
|
||||
* @method static \Illuminate\Contracts\Routing\UrlGenerator setRootControllerNamespace(string $rootNamespace)
|
||||
* @method static bool hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true)
|
||||
* @method static string action(string $action, $parameters = [], bool $absolute = true)
|
||||
* @method static string action(string|array $action, $parameters = [], bool $absolute = true)
|
||||
* @method static string asset(string $path, bool $secure = null)
|
||||
* @method static string secureAsset(string $path)
|
||||
* @method static string current()
|
||||
* @method static string full()
|
||||
* @method static void macro(string $name, object|callable $macro)
|
||||
* @method static void mixin(object $mixin, bool $replace = true)
|
||||
* @method static string previous($fallback = false)
|
||||
* @method static string route(string $name, $parameters = [], bool $absolute = true)
|
||||
* @method static string secure(string $path, array $parameters = [])
|
||||
@@ -17,6 +20,7 @@ namespace Illuminate\Support\Facades;
|
||||
* @method static string to(string $path, $extra = [], bool $secure = null)
|
||||
* @method static void defaults(array $defaults)
|
||||
* @method static void forceScheme(string $scheme)
|
||||
* @method static bool isValidUrl(string $path)
|
||||
*
|
||||
* @see \Illuminate\Routing\UrlGenerator
|
||||
*/
|
||||
|
||||
@@ -4,9 +4,11 @@ namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Contracts\Validation\Validator make(array $data, array $rules, array $messages = [], array $customAttributes = [])
|
||||
* @method static void excludeUnvalidatedArrayKeys()
|
||||
* @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 array validate(array $data, array $rules, array $messages = [], array $customAttributes = [])
|
||||
*
|
||||
* @see \Illuminate\Validation\Factory
|
||||
*/
|
||||
|
||||
@@ -4,8 +4,9 @@ namespace Illuminate\Support\Facades;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Contracts\View\Factory addNamespace(string $namespace, string|array $hints)
|
||||
* @method static \Illuminate\Contracts\View\Factory first(array $views, \Illuminate\Contracts\Support\Arrayable|array $data, array $mergeData)
|
||||
* @method static \Illuminate\Contracts\View\View first(array $views, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = [])
|
||||
* @method static \Illuminate\Contracts\View\Factory replaceNamespace(string $namespace, string|array $hints)
|
||||
* @method static \Illuminate\Contracts\View\Factory addExtension(string $extension, string $engine, \Closure|null $resolver = null)
|
||||
* @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 array composer(array|string $views, \Closure|string $callback)
|
||||
|
||||
@@ -70,6 +70,7 @@ class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
@@ -92,6 +93,7 @@ class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
|
||||
* @param string $offset
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->attributes[$offset]);
|
||||
@@ -103,6 +105,7 @@ class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
|
||||
* @param string $offset
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
@@ -115,6 +118,7 @@ class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->attributes[$offset] = $value;
|
||||
@@ -126,6 +130,7 @@ class Fluent implements Arrayable, ArrayAccess, Jsonable, JsonSerializable
|
||||
* @param string $offset
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->attributes[$offset]);
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Support\Enumerable
|
||||
*/
|
||||
class HigherOrderCollectionProxy
|
||||
{
|
||||
/**
|
||||
* The collection being operated on.
|
||||
*
|
||||
* @var \Illuminate\Support\Enumerable
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
/**
|
||||
* The method being proxied.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $method;
|
||||
|
||||
/**
|
||||
* Create a new proxy instance.
|
||||
*
|
||||
* @param \Illuminate\Support\Enumerable $collection
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Enumerable $collection, $method)
|
||||
{
|
||||
$this->method = $method;
|
||||
$this->collection = $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy accessing an attribute onto the collection items.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->collection->{$this->method}(function ($value) use ($key) {
|
||||
return is_array($value) ? $value[$key] : $value->{$key};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy a method call onto the collection items.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->collection->{$this->method}(function ($value) use ($method, $parameters) {
|
||||
return $value->{$method}(...$parameters);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Support\Enumerable
|
||||
*/
|
||||
class HigherOrderWhenProxy
|
||||
{
|
||||
/**
|
||||
* The collection being operated on.
|
||||
*
|
||||
* @var \Illuminate\Support\Enumerable
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
/**
|
||||
* The condition for proxying.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $condition;
|
||||
|
||||
/**
|
||||
* Create a new proxy instance.
|
||||
*
|
||||
* @param \Illuminate\Support\Enumerable $collection
|
||||
* @param bool $condition
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Enumerable $collection, $condition)
|
||||
{
|
||||
$this->condition = $condition;
|
||||
$this->collection = $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy accessing an attribute onto the collection.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->condition
|
||||
? $this->collection->{$key}
|
||||
: $this->collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy a method call onto the collection.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->condition
|
||||
? $this->collection->{$method}(...$parameters)
|
||||
: $this->collection;
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,16 @@ class HtmlString implements Htmlable
|
||||
return $this->html === '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given HTML string is not empty.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty()
|
||||
{
|
||||
return ! $this->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML string.
|
||||
*
|
||||
|
||||
145
vendor/laravel/framework/src/Illuminate/Support/Js.php
vendored
Normal file
145
vendor/laravel/framework/src/Illuminate/Support/Js.php
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use JsonSerializable;
|
||||
|
||||
class Js implements Htmlable
|
||||
{
|
||||
/**
|
||||
* The JavaScript string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $js;
|
||||
|
||||
/**
|
||||
* Flags that should be used when encoding to JSON.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected const REQUIRED_FLAGS = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_THROW_ON_ERROR;
|
||||
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int|null $flags
|
||||
* @param int $depth
|
||||
* @return void
|
||||
*
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function __construct($data, $flags = 0, $depth = 512)
|
||||
{
|
||||
$this->js = $this->convertDataToJavaScriptExpression($data, $flags, $depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new JavaScript string from the given data.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $flags
|
||||
* @param int $depth
|
||||
* @return static
|
||||
*
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public static function from($data, $flags = 0, $depth = 512)
|
||||
{
|
||||
return new static($data, $flags, $depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given data to a JavaScript expression.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $flags
|
||||
* @param int $depth
|
||||
* @return string
|
||||
*
|
||||
* @throws \JsonException
|
||||
*/
|
||||
protected function convertDataToJavaScriptExpression($data, $flags = 0, $depth = 512)
|
||||
{
|
||||
if ($data instanceof self) {
|
||||
return $data->toHtml();
|
||||
}
|
||||
|
||||
$json = $this->jsonEncode($data, $flags, $depth);
|
||||
|
||||
if (is_string($data)) {
|
||||
return "'".substr($json, 1, -1)."'";
|
||||
}
|
||||
|
||||
return $this->convertJsonToJavaScriptExpression($json, $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the given data as JSON.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $flags
|
||||
* @param int $depth
|
||||
* @return string
|
||||
*
|
||||
* @throws \JsonException
|
||||
*/
|
||||
protected function jsonEncode($data, $flags = 0, $depth = 512)
|
||||
{
|
||||
if ($data instanceof Jsonable) {
|
||||
return $data->toJson($flags | static::REQUIRED_FLAGS);
|
||||
}
|
||||
|
||||
if ($data instanceof Arrayable && ! ($data instanceof JsonSerializable)) {
|
||||
$data = $data->toArray();
|
||||
}
|
||||
|
||||
return json_encode($data, $flags | static::REQUIRED_FLAGS, $depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given JSON to a JavaScript expression.
|
||||
*
|
||||
* @param string $json
|
||||
* @param int $flags
|
||||
* @return string
|
||||
*
|
||||
* @throws \JsonException
|
||||
*/
|
||||
protected function convertJsonToJavaScriptExpression($json, $flags = 0)
|
||||
{
|
||||
if ('[]' === $json || '{}' === $json) {
|
||||
return $json;
|
||||
}
|
||||
|
||||
if (Str::startsWith($json, ['"', '{', '['])) {
|
||||
return "JSON.parse('".substr(json_encode($json, $flags | static::REQUIRED_FLAGS), 1, -1)."')";
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string representation of the data for use in HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
return $this->js;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string representation of the data for use in HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toHtml();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,15 +15,6 @@ abstract class Manager
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* The container instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Container\Container
|
||||
*
|
||||
* @deprecated Use the $container property instead.
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The configuration repository instance.
|
||||
*
|
||||
@@ -53,7 +44,6 @@ abstract class Manager
|
||||
*/
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->app = $container;
|
||||
$this->container = $container;
|
||||
$this->config = $container->make('config');
|
||||
}
|
||||
@@ -154,6 +144,41 @@ abstract class Manager
|
||||
return $this->drivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the container instance used by the manager.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Container\Container
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the container instance used by the manager.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Container\Container $container
|
||||
* @return $this
|
||||
*/
|
||||
public function setContainer(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget all of the resolved driver instances.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forgetDrivers()
|
||||
{
|
||||
$this->drivers = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Countable;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use Illuminate\Contracts\Support\MessageBag as MessageBagContract;
|
||||
use Illuminate\Contracts\Support\MessageProvider;
|
||||
use JsonSerializable;
|
||||
|
||||
class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, MessageBagContract, MessageProvider
|
||||
class MessageBag implements Jsonable, JsonSerializable, MessageBagContract, MessageProvider
|
||||
{
|
||||
/**
|
||||
* All of the registered messages.
|
||||
@@ -369,6 +368,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return count($this->messages, COUNT_RECURSIVE) - count($this->messages);
|
||||
@@ -389,6 +389,7 @@ class MessageBag implements Arrayable, Countable, Jsonable, JsonSerializable, Me
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
|
||||
191
vendor/laravel/framework/src/Illuminate/Support/MultipleInstanceManager.php
vendored
Normal file
191
vendor/laravel/framework/src/Illuminate/Support/MultipleInstanceManager.php
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class MultipleInstanceManager
|
||||
{
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The array of resolved instances.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $instances = [];
|
||||
|
||||
/**
|
||||
* The registered custom instance creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators = [];
|
||||
|
||||
/**
|
||||
* Create a new manager instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default instance name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getDefaultInstance();
|
||||
|
||||
/**
|
||||
* Set the default instance name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
abstract public function setDefaultInstance($name);
|
||||
|
||||
/**
|
||||
* Get the instance specific configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getInstanceConfig($name);
|
||||
|
||||
/**
|
||||
* Get an instance instance by name.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function instance($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultInstance();
|
||||
|
||||
return $this->instances[$name] = $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get an instance from the local cache.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get($name)
|
||||
{
|
||||
return $this->instances[$name] ?? $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getInstanceConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Instance [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
if (! array_key_exists('driver', $config)) {
|
||||
throw new RuntimeException("Instance [{$name}] does not specify a driver.");
|
||||
}
|
||||
|
||||
if (isset($this->customCreators[$config['driver']])) {
|
||||
return $this->callCustomCreator($config);
|
||||
} else {
|
||||
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
|
||||
|
||||
if (method_exists($this, $driverMethod)) {
|
||||
return $this->{$driverMethod}($config);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Instance driver [{$config['driver']}] is not supported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a custom instance creator.
|
||||
*
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callCustomCreator(array $config)
|
||||
{
|
||||
return $this->customCreators[$config['driver']]($this->app, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the given instances.
|
||||
*
|
||||
* @param array|string|null $name
|
||||
* @return $this
|
||||
*/
|
||||
public function forgetInstance($name = null)
|
||||
{
|
||||
$name = $name ?? $this->getDefaultInstance();
|
||||
|
||||
foreach ((array) $name as $instanceName) {
|
||||
if (isset($this->instances[$instanceName])) {
|
||||
unset($this->instances[$instanceName]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the given instance and remove from local cache.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return void
|
||||
*/
|
||||
public function purge($name = null)
|
||||
{
|
||||
$name = $name ?? $this->getDefaultInstance();
|
||||
|
||||
unset($this->instances[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom instance creator Closure.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function extend($name, Closure $callback)
|
||||
{
|
||||
$this->customCreators[$name] = $callback->bindTo($this, $this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->instance()->$method(...$parameters);
|
||||
}
|
||||
}
|
||||
@@ -99,4 +99,14 @@ class NamespacedItemResolver
|
||||
{
|
||||
$this->parsed[$key] = $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the cache of parsed keys.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flushParsedKeys()
|
||||
{
|
||||
$this->parsed = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace Illuminate\Support;
|
||||
|
||||
use ArrayAccess;
|
||||
use ArrayObject;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
|
||||
class Optional implements ArrayAccess
|
||||
{
|
||||
use Traits\Macroable {
|
||||
use Macroable {
|
||||
__call as macroCall;
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ class Optional implements ArrayAccess
|
||||
* @param mixed $key
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return Arr::accessible($this->value) && Arr::exists($this->value, $key);
|
||||
@@ -78,6 +80,7 @@ class Optional implements ArrayAccess
|
||||
* @param mixed $key
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return Arr::get($this->value, $key);
|
||||
@@ -90,6 +93,7 @@ class Optional implements ArrayAccess
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
if (Arr::accessible($this->value)) {
|
||||
@@ -103,6 +107,7 @@ class Optional implements ArrayAccess
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
if (Arr::accessible($this->value)) {
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Doctrine\Inflector\CachedWordInflector;
|
||||
use Doctrine\Inflector\Inflector;
|
||||
use Doctrine\Inflector\Rules\English;
|
||||
use Doctrine\Inflector\RulesetInflector;
|
||||
use Doctrine\Inflector\InflectorFactory;
|
||||
|
||||
class Pluralizer
|
||||
{
|
||||
/**
|
||||
* Uncountable word forms.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
public static $uncountable = [
|
||||
'audio',
|
||||
@@ -64,12 +62,16 @@ class Pluralizer
|
||||
* Get the plural form of an English word.
|
||||
*
|
||||
* @param string $value
|
||||
* @param int $count
|
||||
* @param int|array|\Countable $count
|
||||
* @return string
|
||||
*/
|
||||
public static function plural($value, $count = 2)
|
||||
{
|
||||
if ((int) abs($count) === 1 || static::uncountable($value)) {
|
||||
if (is_countable($count)) {
|
||||
$count = count($count);
|
||||
}
|
||||
|
||||
if ((int) abs($count) === 1 || static::uncountable($value) || preg_match('/^(.*)[A-Za-z0-9\x{0080}-\x{FFFF}]$/u', $value) == 0) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -132,14 +134,7 @@ class Pluralizer
|
||||
static $inflector;
|
||||
|
||||
if (is_null($inflector)) {
|
||||
$inflector = new Inflector(
|
||||
new CachedWordInflector(new RulesetInflector(
|
||||
English\Rules::getSingularRuleset()
|
||||
)),
|
||||
new CachedWordInflector(new RulesetInflector(
|
||||
English\Rules::getPluralRuleset()
|
||||
))
|
||||
);
|
||||
$inflector = InflectorFactory::createForLanguage('english')->build();
|
||||
}
|
||||
|
||||
return $inflector;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Illuminate\Support;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionUnionType;
|
||||
|
||||
class Reflector
|
||||
{
|
||||
@@ -69,6 +70,45 @@ class Reflector
|
||||
return;
|
||||
}
|
||||
|
||||
return static::getTypeName($parameter, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class names of the given parameter's type, including union types.
|
||||
*
|
||||
* @param \ReflectionParameter $parameter
|
||||
* @return array
|
||||
*/
|
||||
public static function getParameterClassNames($parameter)
|
||||
{
|
||||
$type = $parameter->getType();
|
||||
|
||||
if (! $type instanceof ReflectionUnionType) {
|
||||
return array_filter([static::getParameterClassName($parameter)]);
|
||||
}
|
||||
|
||||
$unionTypes = [];
|
||||
|
||||
foreach ($type->getTypes() as $listedType) {
|
||||
if (! $listedType instanceof ReflectionNamedType || $listedType->isBuiltin()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$unionTypes[] = static::getTypeName($parameter, $listedType);
|
||||
}
|
||||
|
||||
return array_filter($unionTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the given type's class name.
|
||||
*
|
||||
* @param \ReflectionParameter $parameter
|
||||
* @param \ReflectionNamedType $type
|
||||
* @return string
|
||||
*/
|
||||
protected static function getTypeName($parameter, $type)
|
||||
{
|
||||
$name = $type->getName();
|
||||
|
||||
if (! is_null($class = $parameter->getDeclaringClass())) {
|
||||
@@ -95,8 +135,8 @@ class Reflector
|
||||
{
|
||||
$paramClassName = static::getParameterClassName($parameter);
|
||||
|
||||
return ($paramClassName && class_exists($paramClassName))
|
||||
? (new ReflectionClass($paramClassName))->isSubclassOf($className)
|
||||
: false;
|
||||
return $paramClassName
|
||||
&& (class_exists($paramClassName) || interface_exists($paramClassName))
|
||||
&& (new ReflectionClass($paramClassName))->isSubclassOf($className);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Console\Application as Artisan;
|
||||
use Illuminate\Contracts\Foundation\CachesConfiguration;
|
||||
use Illuminate\Contracts\Foundation\CachesRoutes;
|
||||
@@ -18,6 +19,20 @@ abstract class ServiceProvider
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* All of the registered booting callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bootingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the registered booted callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bootedCallbacks = [];
|
||||
|
||||
/**
|
||||
* The paths that should be published.
|
||||
*
|
||||
@@ -53,6 +68,60 @@ abstract class ServiceProvider
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a booting callback to be run before the "boot" method is called.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public function booting(Closure $callback)
|
||||
{
|
||||
$this->bootingCallbacks[] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a booted callback to be run after the "boot" method is called.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public function booted(Closure $callback)
|
||||
{
|
||||
$this->bootedCallbacks[] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the registered booting callbacks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function callBootingCallbacks()
|
||||
{
|
||||
$index = 0;
|
||||
|
||||
while ($index < count($this->bootingCallbacks)) {
|
||||
$this->app->call($this->bootingCallbacks[$index]);
|
||||
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the registered booted callbacks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function callBootedCallbacks()
|
||||
{
|
||||
$index = 0;
|
||||
|
||||
while ($index < count($this->bootedCallbacks)) {
|
||||
$this->app->call($this->bootedCallbacks[$index]);
|
||||
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the given configuration with the existing configuration.
|
||||
*
|
||||
@@ -168,6 +237,8 @@ abstract class ServiceProvider
|
||||
/**
|
||||
* Register Eloquent model factory paths.
|
||||
*
|
||||
* @deprecated Will be removed in a future Laravel version.
|
||||
*
|
||||
* @param array|string $paths
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use League\CommonMark\GithubFlavoredMarkdownConverter;
|
||||
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
|
||||
use Ramsey\Uuid\Generator\CombGenerator;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
@@ -98,6 +99,19 @@ class Str
|
||||
return ASCII::to_ascii((string) $value, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transliterate a string to its closest ASCII representation.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string|null $unknown
|
||||
* @param bool|null $strict
|
||||
* @return string
|
||||
*/
|
||||
public static function transliterate($string, $unknown = '?', $strict = false)
|
||||
{
|
||||
return ASCII::to_transliterate($string, $unknown, $strict);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the portion of a string before the first occurrence of a given value.
|
||||
*
|
||||
@@ -107,7 +121,13 @@ class Str
|
||||
*/
|
||||
public static function before($subject, $search)
|
||||
{
|
||||
return $search === '' ? $subject : explode($search, $subject)[0];
|
||||
if ($search === '') {
|
||||
return $subject;
|
||||
}
|
||||
|
||||
$result = strstr($subject, (string) $search, true);
|
||||
|
||||
return $result === false ? $subject : $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +230,10 @@ class Str
|
||||
public static function endsWith($haystack, $needles)
|
||||
{
|
||||
foreach ((array) $needles as $needle) {
|
||||
if ($needle !== '' && substr($haystack, -strlen($needle)) === (string) $needle) {
|
||||
if (
|
||||
$needle !== '' && $needle !== null
|
||||
&& substr($haystack, -strlen($needle)) === (string) $needle
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -243,11 +266,15 @@ class Str
|
||||
{
|
||||
$patterns = Arr::wrap($pattern);
|
||||
|
||||
$value = (string) $value;
|
||||
|
||||
if (empty($patterns)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($patterns as $pattern) {
|
||||
$pattern = (string) $pattern;
|
||||
|
||||
// If the given value is an exact match we can of course return true right
|
||||
// from the beginning. Otherwise, we will translate asterisks and do an
|
||||
// actual pattern match against the two strings to see if they match.
|
||||
@@ -370,6 +397,96 @@ class Str
|
||||
return rtrim($matches[0]).$end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts GitHub flavored Markdown into HTML.
|
||||
*
|
||||
* @param string $string
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public static function markdown($string, array $options = [])
|
||||
{
|
||||
$converter = new GithubFlavoredMarkdownConverter($options);
|
||||
|
||||
return (string) $converter->convertToHtml($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Masks a portion of a string with a repeated character.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $character
|
||||
* @param int $index
|
||||
* @param int|null $length
|
||||
* @param string $encoding
|
||||
* @return string
|
||||
*/
|
||||
public static function mask($string, $character, $index, $length = null, $encoding = 'UTF-8')
|
||||
{
|
||||
if ($character === '') {
|
||||
return $string;
|
||||
}
|
||||
|
||||
if (is_null($length) && PHP_MAJOR_VERSION < 8) {
|
||||
$length = mb_strlen($string, $encoding);
|
||||
}
|
||||
|
||||
$segment = mb_substr($string, $index, $length, $encoding);
|
||||
|
||||
if ($segment === '') {
|
||||
return $string;
|
||||
}
|
||||
|
||||
$strlen = mb_strlen($string, $encoding);
|
||||
$startIndex = $index;
|
||||
|
||||
if ($index < 0) {
|
||||
$startIndex = $index < -$strlen ? 0 : $strlen + $index;
|
||||
}
|
||||
|
||||
$start = mb_substr($string, 0, $startIndex, $encoding);
|
||||
$segmentLen = mb_strlen($segment, $encoding);
|
||||
$end = mb_substr($string, $startIndex + $segmentLen);
|
||||
|
||||
return $start.str_repeat(mb_substr($character, 0, 1, $encoding), $segmentLen).$end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string matching the given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $subject
|
||||
* @return string
|
||||
*/
|
||||
public static function match($pattern, $subject)
|
||||
{
|
||||
preg_match($pattern, $subject, $matches);
|
||||
|
||||
if (! $matches) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $matches[1] ?? $matches[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string matching the given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $subject
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public static function matchAll($pattern, $subject)
|
||||
{
|
||||
preg_match_all($pattern, $subject, $matches);
|
||||
|
||||
if (empty($matches[0])) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return collect($matches[1] ?? $matches[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pad both sides of a string with another.
|
||||
*
|
||||
@@ -380,7 +497,7 @@ class Str
|
||||
*/
|
||||
public static function padBoth($value, $length, $pad = ' ')
|
||||
{
|
||||
return str_pad($value, $length, $pad, STR_PAD_BOTH);
|
||||
return str_pad($value, strlen($value) - mb_strlen($value) + $length, $pad, STR_PAD_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,7 +510,7 @@ class Str
|
||||
*/
|
||||
public static function padLeft($value, $length, $pad = ' ')
|
||||
{
|
||||
return str_pad($value, $length, $pad, STR_PAD_LEFT);
|
||||
return str_pad($value, strlen($value) - mb_strlen($value) + $length, $pad, STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,7 +523,7 @@ class Str
|
||||
*/
|
||||
public static function padRight($value, $length, $pad = ' ')
|
||||
{
|
||||
return str_pad($value, $length, $pad, STR_PAD_RIGHT);
|
||||
return str_pad($value, strlen($value) - mb_strlen($value) + $length, $pad, STR_PAD_RIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,7 +542,7 @@ class Str
|
||||
* Get the plural form of an English word.
|
||||
*
|
||||
* @param string $value
|
||||
* @param int $count
|
||||
* @param int|array|\Countable $count
|
||||
* @return string
|
||||
*/
|
||||
public static function plural($value, $count = 2)
|
||||
@@ -437,7 +554,7 @@ class Str
|
||||
* Pluralize the last word of an English, studly caps case string.
|
||||
*
|
||||
* @param string $value
|
||||
* @param int $count
|
||||
* @param int|array|\Countable $count
|
||||
* @return string
|
||||
*/
|
||||
public static function pluralStudly($value, $count = 2)
|
||||
@@ -470,6 +587,18 @@ class Str
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeat the given string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $times
|
||||
* @return string
|
||||
*/
|
||||
public static function repeat(string $string, int $times)
|
||||
{
|
||||
return str_repeat($string, $times);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace a given value in the string sequentially with an array.
|
||||
*
|
||||
@@ -491,6 +620,19 @@ class Str
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the given value in the given string.
|
||||
*
|
||||
* @param string|string[] $search
|
||||
* @param string|string[] $replace
|
||||
* @param string|string[] $subject
|
||||
* @return string
|
||||
*/
|
||||
public static function replace($search, $replace, $subject)
|
||||
{
|
||||
return str_replace($search, $replace, $subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the first occurrence of a given value in the string.
|
||||
*
|
||||
@@ -501,7 +643,7 @@ class Str
|
||||
*/
|
||||
public static function replaceFirst($search, $replace, $subject)
|
||||
{
|
||||
if ($search == '') {
|
||||
if ($search === '') {
|
||||
return $subject;
|
||||
}
|
||||
|
||||
@@ -537,6 +679,34 @@ class Str
|
||||
return $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any occurrence of the given string in the subject.
|
||||
*
|
||||
* @param string|array<string> $search
|
||||
* @param string $subject
|
||||
* @param bool $caseSensitive
|
||||
* @return string
|
||||
*/
|
||||
public static function remove($search, $subject, $caseSensitive = true)
|
||||
{
|
||||
$subject = $caseSensitive
|
||||
? str_replace($search, '', $subject)
|
||||
: str_ireplace($search, '', $subject);
|
||||
|
||||
return $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the given string.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public static function reverse(string $value)
|
||||
{
|
||||
return implode(array_reverse(mb_str_split($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a string with a single instance of a given value.
|
||||
*
|
||||
@@ -573,6 +743,25 @@ class Str
|
||||
return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given string to title case for each word.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public static function headline($value)
|
||||
{
|
||||
$parts = explode(' ', $value);
|
||||
|
||||
$parts = count($parts) > 1
|
||||
? $parts = array_map([static::class, 'title'], $parts)
|
||||
: $parts = array_map([static::class, 'title'], static::ucsplit(implode('_', $parts)));
|
||||
|
||||
$collapsed = static::replace(['-', '_', ' '], '_', implode('_', $parts));
|
||||
|
||||
return implode(' ', array_filter(explode('_', $collapsed)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singular form of an English word.
|
||||
*
|
||||
@@ -669,13 +858,17 @@ class Str
|
||||
return static::$studlyCache[$key];
|
||||
}
|
||||
|
||||
$value = ucwords(str_replace(['-', '_'], ' ', $value));
|
||||
$words = explode(' ', static::replace(['-', '_'], ' ', $value));
|
||||
|
||||
return static::$studlyCache[$key] = str_replace(' ', '', $value);
|
||||
$studlyWords = array_map(function ($word) {
|
||||
return static::ucfirst($word);
|
||||
}, $words);
|
||||
|
||||
return static::$studlyCache[$key] = implode($studlyWords);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the portion of string specified by the start and length parameters.
|
||||
* Returns the portion of the string specified by the start and length parameters.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $start
|
||||
@@ -705,6 +898,36 @@ class Str
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace text within a portion of a string.
|
||||
*
|
||||
* @param string|array $string
|
||||
* @param string|array $replace
|
||||
* @param array|int $offset
|
||||
* @param array|int|null $length
|
||||
* @return string|array
|
||||
*/
|
||||
public static function substrReplace($string, $replace, $offset = 0, $length = null)
|
||||
{
|
||||
if ($length === null) {
|
||||
$length = strlen($string);
|
||||
}
|
||||
|
||||
return substr_replace($string, $replace, $offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap multiple keywords in a string with other keywords.
|
||||
*
|
||||
* @param array $map
|
||||
* @param string $subject
|
||||
* @return string
|
||||
*/
|
||||
public static function swap(array $map, $subject)
|
||||
{
|
||||
return strtr($subject, $map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string's first character uppercase.
|
||||
*
|
||||
@@ -716,6 +939,28 @@ class Str
|
||||
return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a string into pieces by uppercase characters.
|
||||
*
|
||||
* @param string $string
|
||||
* @return array
|
||||
*/
|
||||
public static function ucsplit($string)
|
||||
{
|
||||
return preg_split('/(?=\p{Lu})/u', $string, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of words a string contains.
|
||||
*
|
||||
* @param string $string
|
||||
* @return int
|
||||
*/
|
||||
public static function wordCount($string)
|
||||
{
|
||||
return str_word_count($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a UUID (version 4).
|
||||
*
|
||||
@@ -739,7 +984,7 @@ class Str
|
||||
return call_user_func(static::$uuidFactory);
|
||||
}
|
||||
|
||||
$factory = new UuidFactory();
|
||||
$factory = new UuidFactory;
|
||||
|
||||
$factory->setRandomGenerator(new CombGenerator(
|
||||
$factory->getRandomGenerator(),
|
||||
@@ -773,4 +1018,16 @@ class Str
|
||||
{
|
||||
static::$uuidFactory = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all strings from the casing caches.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function flushCache()
|
||||
{
|
||||
static::$snakeCache = [];
|
||||
static::$camelCache = [];
|
||||
static::$studlyCache = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Traits\Conditionable;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Support\Traits\Tappable;
|
||||
use JsonSerializable;
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
|
||||
class Stringable
|
||||
class Stringable implements JsonSerializable
|
||||
{
|
||||
use Macroable;
|
||||
use Conditionable, Macroable, Tappable;
|
||||
|
||||
/**
|
||||
* The underlying string value.
|
||||
@@ -83,6 +86,16 @@ class Stringable
|
||||
return new static(basename($this->value, $suffix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the basename of the class path.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function classBasename()
|
||||
{
|
||||
return new static(class_basename($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the portion of a string before the first occurrence of a given value.
|
||||
*
|
||||
@@ -195,15 +208,19 @@ class Stringable
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a string using a regular expression.
|
||||
* Split a string using a regular expression or by length.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string|int $pattern
|
||||
* @param int $limit
|
||||
* @param int $flags
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function split($pattern, $limit = -1, $flags = 0)
|
||||
{
|
||||
if (filter_var($pattern, FILTER_VALIDATE_INT) !== false) {
|
||||
return collect(mb_str_split($this->value, $pattern));
|
||||
}
|
||||
|
||||
$segments = preg_split($pattern, $this->value, $limit, $flags);
|
||||
|
||||
return ! empty($segments) ? collect($segments) : collect();
|
||||
@@ -241,6 +258,16 @@ class Stringable
|
||||
return Str::isAscii($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given string is a valid UUID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isUuid()
|
||||
{
|
||||
return Str::isUuid($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given string is empty.
|
||||
*
|
||||
@@ -304,21 +331,40 @@ class Stringable
|
||||
return new static(Str::lower($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert GitHub flavored Markdown into HTML.
|
||||
*
|
||||
* @param array $options
|
||||
* @return static
|
||||
*/
|
||||
public function markdown(array $options = [])
|
||||
{
|
||||
return new static(Str::markdown($this->value, $options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Masks a portion of a string with a repeated character.
|
||||
*
|
||||
* @param string $character
|
||||
* @param int $index
|
||||
* @param int|null $length
|
||||
* @param string $encoding
|
||||
* @return static
|
||||
*/
|
||||
public function mask($character, $index, $length = null, $encoding = 'UTF-8')
|
||||
{
|
||||
return new static(Str::mask($this->value, $character, $index, $length, $encoding));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string matching the given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @return static|null
|
||||
* @return static
|
||||
*/
|
||||
public function match($pattern)
|
||||
{
|
||||
preg_match($pattern, $this->value, $matches);
|
||||
|
||||
if (! $matches) {
|
||||
return new static;
|
||||
}
|
||||
|
||||
return new static($matches[1] ?? $matches[0]);
|
||||
return new static(Str::match($pattern, $this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,13 +375,18 @@ class Stringable
|
||||
*/
|
||||
public function matchAll($pattern)
|
||||
{
|
||||
preg_match_all($pattern, $this->value, $matches);
|
||||
return Str::matchAll($pattern, $this->value);
|
||||
}
|
||||
|
||||
if (empty($matches[0])) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return collect($matches[1] ?? $matches[0]);
|
||||
/**
|
||||
* Determine if the string matches the given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @return bool
|
||||
*/
|
||||
public function test($pattern)
|
||||
{
|
||||
return $this->match($pattern)->isNotEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,6 +436,17 @@ class Stringable
|
||||
return Str::parseCallback($this->value, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the given callback and return a new string.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function pipe(callable $callback)
|
||||
{
|
||||
return new static(call_user_func($callback, $this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plural form of an English word.
|
||||
*
|
||||
@@ -418,6 +480,39 @@ class Stringable
|
||||
return new static(implode('', $values).$this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any occurrence of the given string in the subject.
|
||||
*
|
||||
* @param string|array<string> $search
|
||||
* @param bool $caseSensitive
|
||||
* @return static
|
||||
*/
|
||||
public function remove($search, $caseSensitive = true)
|
||||
{
|
||||
return new static(Str::remove($search, $this->value, $caseSensitive));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the string.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function reverse()
|
||||
{
|
||||
return new static(Str::reverse($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeat the string.
|
||||
*
|
||||
* @param int $times
|
||||
* @return static
|
||||
*/
|
||||
public function repeat(int $times)
|
||||
{
|
||||
return new static(Str::repeat($this->value, $times));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the given value in the given string.
|
||||
*
|
||||
@@ -427,7 +522,7 @@ class Stringable
|
||||
*/
|
||||
public function replace($search, $replace)
|
||||
{
|
||||
return new static(str_replace($search, $replace, $this->value));
|
||||
return new static(Str::replace($search, $replace, $this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,6 +578,17 @@ class Stringable
|
||||
return new static(preg_replace($pattern, $replace, $this->value, $limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse input from a string to a collection, according to a format.
|
||||
*
|
||||
* @param string $format
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function scan($format)
|
||||
{
|
||||
return collect(sscanf($this->value, $format));
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a string with a single instance of a given value.
|
||||
*
|
||||
@@ -494,6 +600,17 @@ class Stringable
|
||||
return new static(Str::start($this->value, $prefix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip HTML and PHP tags from the given string.
|
||||
*
|
||||
* @param string $allowedTags
|
||||
* @return static
|
||||
*/
|
||||
public function stripTags($allowedTags = null)
|
||||
{
|
||||
return new static(strip_tags($this->value, $allowedTags));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given string to upper-case.
|
||||
*
|
||||
@@ -514,6 +631,16 @@ class Stringable
|
||||
return new static(Str::title($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given string to title case for each word.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function headline()
|
||||
{
|
||||
return new static(Str::headline($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singular form of an English word.
|
||||
*
|
||||
@@ -569,7 +696,7 @@ class Stringable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the portion of string specified by the start and length parameters.
|
||||
* Returns the portion of the string specified by the start and length parameters.
|
||||
*
|
||||
* @param int $start
|
||||
* @param int|null $length
|
||||
@@ -590,7 +717,31 @@ class Stringable
|
||||
*/
|
||||
public function substrCount($needle, $offset = null, $length = null)
|
||||
{
|
||||
return Str::substrCount($this->value, $needle, $offset, $length);
|
||||
return Str::substrCount($this->value, $needle, $offset ?? 0, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace text within a portion of a string.
|
||||
*
|
||||
* @param string|array $replace
|
||||
* @param array|int $offset
|
||||
* @param array|int|null $length
|
||||
* @return static
|
||||
*/
|
||||
public function substrReplace($replace, $offset = 0, $length = null)
|
||||
{
|
||||
return new static(Str::substrReplace($this->value, $replace, $offset, $length));
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap multiple keywords in a string with other keywords.
|
||||
*
|
||||
* @param array $map
|
||||
* @return static
|
||||
*/
|
||||
public function swap(array $map)
|
||||
{
|
||||
return new static(strtr($this->value, $map));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -637,39 +788,152 @@ class Stringable
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the callback's string changes if the given "value" is true.
|
||||
* Split a string by uppercase characters.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function ucsplit()
|
||||
{
|
||||
return collect(Str::ucsplit($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string contains a given substring.
|
||||
*
|
||||
* @param string|array $needles
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return mixed|$this
|
||||
* @return static
|
||||
*/
|
||||
public function when($value, $callback, $default = null)
|
||||
public function whenContains($needles, $callback, $default = null)
|
||||
{
|
||||
if ($value) {
|
||||
return $callback($this, $value) ?: $this;
|
||||
} elseif ($default) {
|
||||
return $default($this, $value) ?: $this;
|
||||
}
|
||||
return $this->when($this->contains($needles), $callback, $default);
|
||||
}
|
||||
|
||||
return $this;
|
||||
/**
|
||||
* Execute the given callback if the string contains all array values.
|
||||
*
|
||||
* @param array $needles
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenContainsAll(array $needles, $callback, $default = null)
|
||||
{
|
||||
return $this->when($this->containsAll($needles), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string is empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenEmpty($callback)
|
||||
public function whenEmpty($callback, $default = null)
|
||||
{
|
||||
if ($this->isEmpty()) {
|
||||
$result = $callback($this);
|
||||
return $this->when($this->isEmpty(), $callback, $default);
|
||||
}
|
||||
|
||||
return is_null($result) ? $this : $result;
|
||||
}
|
||||
/**
|
||||
* Execute the given callback if the string is not empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenNotEmpty($callback, $default = null)
|
||||
{
|
||||
return $this->when($this->isNotEmpty(), $callback, $default);
|
||||
}
|
||||
|
||||
return $this;
|
||||
/**
|
||||
* Execute the given callback if the string ends with a given substring.
|
||||
*
|
||||
* @param string|array $needles
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenEndsWith($needles, $callback, $default = null)
|
||||
{
|
||||
return $this->when($this->endsWith($needles), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string is an exact match with the given value.
|
||||
*
|
||||
* @param string $value
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenExactly($value, $callback, $default = null)
|
||||
{
|
||||
return $this->when($this->exactly($value), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string matches a given pattern.
|
||||
*
|
||||
* @param string|array $pattern
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenIs($pattern, $callback, $default = null)
|
||||
{
|
||||
return $this->when($this->is($pattern), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string is 7 bit ASCII.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenIsAscii($callback, $default = null)
|
||||
{
|
||||
return $this->when($this->isAscii(), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string is a valid UUID.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenIsUuid($callback, $default = null)
|
||||
{
|
||||
return $this->when($this->isUuid(), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string starts with a given substring.
|
||||
*
|
||||
* @param string|array $needles
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenStartsWith($needles, $callback, $default = null)
|
||||
{
|
||||
return $this->when($this->startsWith($needles), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given callback if the string matches the given pattern.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static
|
||||
*/
|
||||
public function whenTest($pattern, $callback, $default = null)
|
||||
{
|
||||
return $this->when($this->test($pattern), $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -684,6 +948,26 @@ class Stringable
|
||||
return new static(Str::words($this->value, $words, $end));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of words a string contains.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function wordCount()
|
||||
{
|
||||
return str_word_count($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the string into a `HtmlString` instance.
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function toHtmlString()
|
||||
{
|
||||
return new HtmlString($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the string.
|
||||
*
|
||||
@@ -699,7 +983,7 @@ class Stringable
|
||||
/**
|
||||
* Dump the string and end the script.
|
||||
*
|
||||
* @return void
|
||||
* @return never
|
||||
*/
|
||||
public function dd()
|
||||
{
|
||||
@@ -708,6 +992,17 @@ class Stringable
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the object to a string when JSON encoded.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy dynamic properties onto methods.
|
||||
*
|
||||
|
||||
142
vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php
vendored
Normal file
142
vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Testing\Fakes;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Closure;
|
||||
use Illuminate\Bus\Batch;
|
||||
use Illuminate\Bus\BatchRepository;
|
||||
use Illuminate\Bus\PendingBatch;
|
||||
use Illuminate\Bus\UpdatedBatchJobCounts;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BatchRepositoryFake implements BatchRepository
|
||||
{
|
||||
/**
|
||||
* Retrieve a list of batches.
|
||||
*
|
||||
* @param int $limit
|
||||
* @param mixed $before
|
||||
* @return \Illuminate\Bus\Batch[]
|
||||
*/
|
||||
public function get($limit, $before)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve information about an existing batch.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return \Illuminate\Bus\Batch|null
|
||||
*/
|
||||
public function find(string $batchId)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new pending batch.
|
||||
*
|
||||
* @param \Illuminate\Bus\PendingBatch $batch
|
||||
* @return \Illuminate\Bus\Batch
|
||||
*/
|
||||
public function store(PendingBatch $batch)
|
||||
{
|
||||
return new Batch(
|
||||
new QueueFake(Facade::getFacadeApplication()),
|
||||
$this,
|
||||
(string) Str::orderedUuid(),
|
||||
$batch->name,
|
||||
count($batch->jobs),
|
||||
count($batch->jobs),
|
||||
0,
|
||||
[],
|
||||
$batch->options,
|
||||
CarbonImmutable::now(),
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the total number of jobs within the batch.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @param int $amount
|
||||
* @return void
|
||||
*/
|
||||
public function incrementTotalJobs(string $batchId, int $amount)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the total number of pending jobs for the batch.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @param string $jobId
|
||||
* @return \Illuminate\Bus\UpdatedBatchJobCounts
|
||||
*/
|
||||
public function decrementPendingJobs(string $batchId, string $jobId)
|
||||
{
|
||||
return new UpdatedBatchJobCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the total number of failed jobs for the batch.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @param string $jobId
|
||||
* @return \Illuminate\Bus\UpdatedBatchJobCounts
|
||||
*/
|
||||
public function incrementFailedJobs(string $batchId, string $jobId)
|
||||
{
|
||||
return new UpdatedBatchJobCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the batch that has the given ID as finished.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return void
|
||||
*/
|
||||
public function markAsFinished(string $batchId)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the batch that has the given ID.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return void
|
||||
*/
|
||||
public function cancel(string $batchId)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the batch that has the given ID.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return void
|
||||
*/
|
||||
public function delete(string $batchId)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given Closure within a storage specific transaction.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function transaction(Closure $callback)
|
||||
{
|
||||
return $callback();
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
namespace Illuminate\Support\Testing\Fakes;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Bus\PendingBatch;
|
||||
use Illuminate\Contracts\Bus\QueueingDispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Traits\ReflectsClosures;
|
||||
use PHPUnit\Framework\Assert as PHPUnit;
|
||||
|
||||
@@ -33,6 +35,13 @@ class BusFake implements QueueingDispatcher
|
||||
*/
|
||||
protected $commands = [];
|
||||
|
||||
/**
|
||||
* The commands that have been dispatched synchronously.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commandsSync = [];
|
||||
|
||||
/**
|
||||
* The commands that have been dispatched after the response has been sent.
|
||||
*
|
||||
@@ -40,6 +49,13 @@ class BusFake implements QueueingDispatcher
|
||||
*/
|
||||
protected $commandsAfterResponse = [];
|
||||
|
||||
/**
|
||||
* The batches that have been dispatched.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $batches = [];
|
||||
|
||||
/**
|
||||
* Create a new bus fake instance.
|
||||
*
|
||||
@@ -73,7 +89,8 @@ class BusFake implements QueueingDispatcher
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatched($command, $callback)->count() > 0 ||
|
||||
$this->dispatchedAfterResponse($command, $callback)->count() > 0,
|
||||
$this->dispatchedAfterResponse($command, $callback)->count() > 0 ||
|
||||
$this->dispatchedSync($command, $callback)->count() > 0,
|
||||
"The expected [{$command}] job was not dispatched."
|
||||
);
|
||||
}
|
||||
@@ -88,7 +105,8 @@ class BusFake implements QueueingDispatcher
|
||||
public function assertDispatchedTimes($command, $times = 1)
|
||||
{
|
||||
$count = $this->dispatched($command)->count() +
|
||||
$this->dispatchedAfterResponse($command)->count();
|
||||
$this->dispatchedAfterResponse($command)->count() +
|
||||
$this->dispatchedSync($command)->count();
|
||||
|
||||
PHPUnit::assertSame(
|
||||
$times, $count,
|
||||
@@ -111,11 +129,81 @@ class BusFake implements QueueingDispatcher
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatched($command, $callback)->count() === 0 &&
|
||||
$this->dispatchedAfterResponse($command, $callback)->count() === 0,
|
||||
$this->dispatchedAfterResponse($command, $callback)->count() === 0 &&
|
||||
$this->dispatchedSync($command, $callback)->count() === 0,
|
||||
"The unexpected [{$command}] job was dispatched."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that no jobs were dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertNothingDispatched()
|
||||
{
|
||||
PHPUnit::assertEmpty($this->commands, 'Jobs were dispatched unexpectedly.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
|
||||
*
|
||||
* @param string|\Closure $command
|
||||
* @param callable|int|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertDispatchedSync($command, $callback = null)
|
||||
{
|
||||
if ($command instanceof Closure) {
|
||||
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
|
||||
}
|
||||
|
||||
if (is_numeric($callback)) {
|
||||
return $this->assertDispatchedSyncTimes($command, $callback);
|
||||
}
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatchedSync($command, $callback)->count() > 0,
|
||||
"The expected [{$command}] job was not dispatched synchronously."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a job was pushed synchronously a number of times.
|
||||
*
|
||||
* @param string $command
|
||||
* @param int $times
|
||||
* @return void
|
||||
*/
|
||||
public function assertDispatchedSyncTimes($command, $times = 1)
|
||||
{
|
||||
$count = $this->dispatchedSync($command)->count();
|
||||
|
||||
PHPUnit::assertSame(
|
||||
$times, $count,
|
||||
"The expected [{$command}] job was synchronously pushed {$count} times instead of {$times} times."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a job was dispatched based on a truth-test callback.
|
||||
*
|
||||
* @param string|\Closure $command
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertNotDispatchedSync($command, $callback = null)
|
||||
{
|
||||
if ($command instanceof Closure) {
|
||||
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
|
||||
}
|
||||
|
||||
PHPUnit::assertCount(
|
||||
0, $this->dispatchedSync($command, $callback),
|
||||
"The unexpected [{$command}] job was dispatched synchronously."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a job was dispatched after the response was sent based on a truth-test callback.
|
||||
*
|
||||
@@ -135,7 +223,7 @@ class BusFake implements QueueingDispatcher
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatchedAfterResponse($command, $callback)->count() > 0,
|
||||
"The expected [{$command}] job was not dispatched for after sending the response."
|
||||
"The expected [{$command}] job was not dispatched after sending the response."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -171,7 +259,170 @@ class BusFake implements QueueingDispatcher
|
||||
|
||||
PHPUnit::assertCount(
|
||||
0, $this->dispatchedAfterResponse($command, $callback),
|
||||
"The unexpected [{$command}] job was dispatched for after sending the response."
|
||||
"The unexpected [{$command}] job was dispatched after sending the response."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a chain of jobs was dispatched.
|
||||
*
|
||||
* @param array $expectedChain
|
||||
* @return void
|
||||
*/
|
||||
public function assertChained(array $expectedChain)
|
||||
{
|
||||
$command = $expectedChain[0];
|
||||
|
||||
$expectedChain = array_slice($expectedChain, 1);
|
||||
|
||||
$callback = null;
|
||||
|
||||
if ($command instanceof Closure) {
|
||||
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
|
||||
} elseif (! is_string($command)) {
|
||||
$instance = $command;
|
||||
|
||||
$command = get_class($instance);
|
||||
|
||||
$callback = function ($job) use ($instance) {
|
||||
return serialize($this->resetChainPropertiesToDefaults($job)) === serialize($instance);
|
||||
};
|
||||
}
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatched($command, $callback)->isNotEmpty(),
|
||||
"The expected [{$command}] job was not dispatched."
|
||||
);
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
collect($expectedChain)->isNotEmpty(),
|
||||
'The expected chain can not be empty.'
|
||||
);
|
||||
|
||||
$this->isChainOfObjects($expectedChain)
|
||||
? $this->assertDispatchedWithChainOfObjects($command, $expectedChain, $callback)
|
||||
: $this->assertDispatchedWithChainOfClasses($command, $expectedChain, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the chain properties to their default values on the job.
|
||||
*
|
||||
* @param mixed $job
|
||||
* @return mixed
|
||||
*/
|
||||
protected function resetChainPropertiesToDefaults($job)
|
||||
{
|
||||
return tap(clone $job, function ($job) {
|
||||
$job->chainConnection = null;
|
||||
$job->chainQueue = null;
|
||||
$job->chainCatchCallbacks = null;
|
||||
$job->chained = [];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a job was dispatched with an empty chain based on a truth-test callback.
|
||||
*
|
||||
* @param string|\Closure $command
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertDispatchedWithoutChain($command, $callback = null)
|
||||
{
|
||||
if ($command instanceof Closure) {
|
||||
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
|
||||
}
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatched($command, $callback)->isNotEmpty(),
|
||||
"The expected [{$command}] job was not dispatched."
|
||||
);
|
||||
|
||||
$this->assertDispatchedWithChainOfClasses($command, [], $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a job was dispatched with chained jobs based on a truth-test callback.
|
||||
*
|
||||
* @param string $command
|
||||
* @param array $expectedChain
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
protected function assertDispatchedWithChainOfObjects($command, $expectedChain, $callback)
|
||||
{
|
||||
$chain = collect($expectedChain)->map(function ($job) {
|
||||
return serialize($job);
|
||||
})->all();
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$this->dispatched($command, $callback)->filter(function ($job) use ($chain) {
|
||||
return $job->chained == $chain;
|
||||
})->isNotEmpty(),
|
||||
'The expected chain was not dispatched.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a job was dispatched with chained jobs based on a truth-test callback.
|
||||
*
|
||||
* @param string $command
|
||||
* @param array $expectedChain
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
protected function assertDispatchedWithChainOfClasses($command, $expectedChain, $callback)
|
||||
{
|
||||
$matching = $this->dispatched($command, $callback)->map->chained->map(function ($chain) {
|
||||
return collect($chain)->map(function ($job) {
|
||||
return get_class(unserialize($job));
|
||||
});
|
||||
})->filter(function ($chain) use ($expectedChain) {
|
||||
return $chain->all() === $expectedChain;
|
||||
});
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
$matching->isNotEmpty(), 'The expected chain was not dispatched.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given chain is entirely composed of objects.
|
||||
*
|
||||
* @param array $chain
|
||||
* @return bool
|
||||
*/
|
||||
protected function isChainOfObjects($chain)
|
||||
{
|
||||
return ! collect($chain)->contains(function ($job) {
|
||||
return ! is_object($job);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a batch was dispatched based on a truth-test callback.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertBatched(callable $callback)
|
||||
{
|
||||
PHPUnit::assertTrue(
|
||||
$this->batched($callback)->count() > 0,
|
||||
'The expected batch was not dispatched.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the number of batches that have been dispatched.
|
||||
*
|
||||
* @param int $count
|
||||
* @return void
|
||||
*/
|
||||
public function assertBatchCount($count)
|
||||
{
|
||||
PHPUnit::assertCount(
|
||||
$count, $this->batches,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -197,6 +448,28 @@ class BusFake implements QueueingDispatcher
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the jobs dispatched synchronously matching a truth-test callback.
|
||||
*
|
||||
* @param string $command
|
||||
* @param callable|null $callback
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function dispatchedSync(string $command, $callback = null)
|
||||
{
|
||||
if (! $this->hasDispatchedSync($command)) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$callback = $callback ?: function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
return collect($this->commandsSync[$command])->filter(function ($command) use ($callback) {
|
||||
return $callback($command);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the jobs dispatched after the response was sent matching a truth-test callback.
|
||||
*
|
||||
@@ -219,6 +492,23 @@ class BusFake implements QueueingDispatcher
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the pending batches matching a truth-test callback.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function batched(callable $callback)
|
||||
{
|
||||
if (empty($this->batches)) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return collect($this->batches)->filter(function ($batch) use ($callback) {
|
||||
return $callback($batch);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if there are any stored commands for a given class.
|
||||
*
|
||||
@@ -230,6 +520,17 @@ class BusFake implements QueueingDispatcher
|
||||
return isset($this->commands[$command]) && ! empty($this->commands[$command]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if there are any stored commands for a given class.
|
||||
*
|
||||
* @param string $command
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDispatchedSync($command)
|
||||
{
|
||||
return isset($this->commandsSync[$command]) && ! empty($this->commandsSync[$command]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if there are any stored commands for a given class.
|
||||
*
|
||||
@@ -256,6 +557,24 @@ class BusFake implements QueueingDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process.
|
||||
*
|
||||
* Queueable jobs will be dispatched to the "sync" queue.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @param mixed $handler
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatchSync($command, $handler = null)
|
||||
{
|
||||
if ($this->shouldFakeJob($command)) {
|
||||
$this->commandsSync[get_class($command)][] = $command;
|
||||
} else {
|
||||
return $this->dispatcher->dispatchSync($command, $handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process.
|
||||
*
|
||||
@@ -303,7 +622,55 @@ class BusFake implements QueueingDispatcher
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an command should be faked or actually dispatched.
|
||||
* Create a new chain of queueable jobs.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array $jobs
|
||||
* @return \Illuminate\Foundation\Bus\PendingChain
|
||||
*/
|
||||
public function chain($jobs)
|
||||
{
|
||||
$jobs = Collection::wrap($jobs);
|
||||
|
||||
return new PendingChainFake($this, $jobs->shift(), $jobs->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to find the batch with the given ID.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return \Illuminate\Bus\Batch|null
|
||||
*/
|
||||
public function findBatch(string $batchId)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new batch of queueable jobs.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array $jobs
|
||||
* @return \Illuminate\Bus\PendingBatch
|
||||
*/
|
||||
public function batch($jobs)
|
||||
{
|
||||
return new PendingBatchFake($this, Collection::wrap($jobs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Record the fake pending batch dispatch.
|
||||
*
|
||||
* @param \Illuminate\Bus\PendingBatch $pendingBatch
|
||||
* @return \Illuminate\Bus\Batch
|
||||
*/
|
||||
public function recordPendingBatch(PendingBatch $pendingBatch)
|
||||
{
|
||||
$this->batches[] = $pendingBatch;
|
||||
|
||||
return (new BatchRepositoryFake)->store($pendingBatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a command should be faked or actually dispatched.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return bool
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace Illuminate\Support\Testing\Fakes;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Traits\ReflectsClosures;
|
||||
use PHPUnit\Framework\Assert as PHPUnit;
|
||||
use ReflectionFunction;
|
||||
|
||||
class EventFake implements Dispatcher
|
||||
{
|
||||
@@ -47,6 +49,42 @@ class EventFake implements Dispatcher
|
||||
$this->eventsToFake = Arr::wrap($eventsToFake);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if an event has a listener attached to it.
|
||||
*
|
||||
* @param string $expectedEvent
|
||||
* @param string $expectedListener
|
||||
* @return void
|
||||
*/
|
||||
public function assertListening($expectedEvent, $expectedListener)
|
||||
{
|
||||
foreach ($this->dispatcher->getListeners($expectedEvent) as $listenerClosure) {
|
||||
$actualListener = (new ReflectionFunction($listenerClosure))
|
||||
->getStaticVariables()['listener'];
|
||||
|
||||
if (is_string($actualListener) && Str::endsWith($actualListener, '@handle')) {
|
||||
$actualListener = Str::parseCallback($actualListener)[0];
|
||||
}
|
||||
|
||||
if ($actualListener === $expectedListener ||
|
||||
($actualListener instanceof Closure &&
|
||||
$expectedListener === Closure::class)) {
|
||||
PHPUnit::assertTrue(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PHPUnit::assertTrue(
|
||||
false,
|
||||
sprintf(
|
||||
'Event [%s] does not have the [%s] listener attached to it',
|
||||
$expectedEvent,
|
||||
print_r($expectedListener, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if an event was dispatched based on a truth-test callback.
|
||||
*
|
||||
@@ -106,6 +144,21 @@ class EventFake implements Dispatcher
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that no events were dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertNothingDispatched()
|
||||
{
|
||||
$count = count(Arr::flatten($this->events));
|
||||
|
||||
PHPUnit::assertSame(
|
||||
0, $count,
|
||||
"{$count} unexpected events were dispatched."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the events matching a truth-test callback.
|
||||
*
|
||||
@@ -142,11 +195,11 @@ class EventFake implements Dispatcher
|
||||
/**
|
||||
* Register an event listener with the dispatcher.
|
||||
*
|
||||
* @param string|array $events
|
||||
* @param \Closure|string|array $events
|
||||
* @param mixed $listener
|
||||
* @return void
|
||||
*/
|
||||
public function listen($events, $listener)
|
||||
public function listen($events, $listener = null)
|
||||
{
|
||||
$this->dispatcher->listen($events, $listener);
|
||||
}
|
||||
@@ -263,7 +316,7 @@ class EventFake implements Dispatcher
|
||||
*
|
||||
* @param string|object $event
|
||||
* @param mixed $payload
|
||||
* @return void
|
||||
* @return array|null
|
||||
*/
|
||||
public function until($event, $payload = [])
|
||||
{
|
||||
|
||||
@@ -45,9 +45,7 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
*/
|
||||
public function assertSent($mailable, $callback = null)
|
||||
{
|
||||
if ($mailable instanceof Closure) {
|
||||
[$mailable, $callback] = [$this->firstClosureParameterType($mailable), $mailable];
|
||||
}
|
||||
[$mailable, $callback] = $this->prepareMailableAndCallback($mailable, $callback);
|
||||
|
||||
if (is_numeric($callback)) {
|
||||
return $this->assertSentTimes($mailable, $callback);
|
||||
@@ -82,21 +80,47 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a mailable was not sent or queued to be sent based on a truth-test callback.
|
||||
*
|
||||
* @param string|\Closure $mailable
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertNotOutgoing($mailable, $callback = null)
|
||||
{
|
||||
$this->assertNotSent($mailable, $callback);
|
||||
$this->assertNotQueued($mailable, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a mailable was not sent based on a truth-test callback.
|
||||
*
|
||||
* @param string $mailable
|
||||
* @param string|\Closure $mailable
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertNotSent($mailable, $callback = null)
|
||||
{
|
||||
[$mailable, $callback] = $this->prepareMailableAndCallback($mailable, $callback);
|
||||
|
||||
PHPUnit::assertCount(
|
||||
0, $this->sent($mailable, $callback),
|
||||
"The unexpected [{$mailable}] mailable was sent."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that no mailables were sent or queued to be sent.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertNothingOutgoing()
|
||||
{
|
||||
$this->assertNothingSent();
|
||||
$this->assertNothingQueued();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that no mailables were sent.
|
||||
*
|
||||
@@ -120,9 +144,7 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
*/
|
||||
public function assertQueued($mailable, $callback = null)
|
||||
{
|
||||
if ($mailable instanceof Closure) {
|
||||
[$mailable, $callback] = [$this->firstClosureParameterType($mailable), $mailable];
|
||||
}
|
||||
[$mailable, $callback] = $this->prepareMailableAndCallback($mailable, $callback);
|
||||
|
||||
if (is_numeric($callback)) {
|
||||
return $this->assertQueuedTimes($mailable, $callback);
|
||||
@@ -154,12 +176,14 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
/**
|
||||
* Determine if a mailable was not queued based on a truth-test callback.
|
||||
*
|
||||
* @param string $mailable
|
||||
* @param string|\Closure $mailable
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function assertNotQueued($mailable, $callback = null)
|
||||
{
|
||||
[$mailable, $callback] = $this->prepareMailableAndCallback($mailable, $callback);
|
||||
|
||||
PHPUnit::assertCount(
|
||||
0, $this->queued($mailable, $callback),
|
||||
"The unexpected [{$mailable}] mailable was queued."
|
||||
@@ -183,12 +207,14 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
/**
|
||||
* Get all of the mailables matching a truth-test callback.
|
||||
*
|
||||
* @param string $mailable
|
||||
* @param string|\Closure $mailable
|
||||
* @param callable|null $callback
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function sent($mailable, $callback = null)
|
||||
{
|
||||
[$mailable, $callback] = $this->prepareMailableAndCallback($mailable, $callback);
|
||||
|
||||
if (! $this->hasSent($mailable)) {
|
||||
return collect();
|
||||
}
|
||||
@@ -216,12 +242,14 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
/**
|
||||
* Get all of the queued mailables matching a truth-test callback.
|
||||
*
|
||||
* @param string $mailable
|
||||
* @param string|\Closure $mailable
|
||||
* @param callable|null $callback
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function queued($mailable, $callback = null)
|
||||
{
|
||||
[$mailable, $callback] = $this->prepareMailableAndCallback($mailable, $callback);
|
||||
|
||||
if (! $this->hasQueued($mailable)) {
|
||||
return collect();
|
||||
}
|
||||
@@ -276,7 +304,7 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
* Get a mailer instance by name.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return \Illuminate\Mail\Mailer
|
||||
* @return \Illuminate\Contracts\Mail\Mailer
|
||||
*/
|
||||
public function mailer($name = null)
|
||||
{
|
||||
@@ -322,7 +350,7 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
/**
|
||||
* Send a new message using a view.
|
||||
*
|
||||
* @param string|array $view
|
||||
* @param \Illuminate\Contracts\Mail\Mailable|string|array $view
|
||||
* @param array $data
|
||||
* @param \Closure|string|null $callback
|
||||
* @return void
|
||||
@@ -335,12 +363,12 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
|
||||
$view->mailer($this->currentMailer);
|
||||
|
||||
$this->currentMailer = null;
|
||||
|
||||
if ($view instanceof ShouldQueue) {
|
||||
return $this->queue($view, $data);
|
||||
}
|
||||
|
||||
$this->currentMailer = null;
|
||||
|
||||
$this->mailables[] = $view;
|
||||
}
|
||||
|
||||
@@ -386,4 +414,32 @@ class MailFake implements Factory, Mailer, MailQueue
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Infer mailable class using reflection if a typehinted closure is passed to assertion.
|
||||
*
|
||||
* @param string|\Closure $mailable
|
||||
* @param callable|null $callback
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareMailableAndCallback($mailable, $callback)
|
||||
{
|
||||
if ($mailable instanceof Closure) {
|
||||
return [$this->firstClosureParameterType($mailable), $mailable];
|
||||
}
|
||||
|
||||
return [$mailable, $callback];
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget all of the resolved mailer instances.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forgetMailers()
|
||||
{
|
||||
$this->currentMailer = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Exception;
|
||||
use Illuminate\Contracts\Notifications\Dispatcher as NotificationDispatcher;
|
||||
use Illuminate\Contracts\Notifications\Factory as NotificationFactory;
|
||||
use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
use Illuminate\Notifications\AnonymousNotifiable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
@@ -31,6 +32,20 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory
|
||||
*/
|
||||
public $locale;
|
||||
|
||||
/**
|
||||
* Assert if a notification was sent on-demand based on a truth-test callback.
|
||||
*
|
||||
* @param string|\Closure $notification
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function assertSentOnDemand($notification, $callback = null)
|
||||
{
|
||||
$this->assertSentTo(new AnonymousNotifiable, $notification, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a notification was sent based on a truth-test callback.
|
||||
*
|
||||
@@ -69,6 +84,18 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a notification was sent on-demand a number of times.
|
||||
*
|
||||
* @param string $notification
|
||||
* @param int $times
|
||||
* @return void
|
||||
*/
|
||||
public function assertSentOnDemandTimes($notification, $times = 1)
|
||||
{
|
||||
return $this->assertSentToTimes(new AnonymousNotifiable, $notification, $times);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert if a notification was sent a number of times.
|
||||
*
|
||||
@@ -134,11 +161,11 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory
|
||||
/**
|
||||
* Assert the total amount of times a notification was sent.
|
||||
*
|
||||
* @param int $expectedCount
|
||||
* @param string $notification
|
||||
* @param int $expectedCount
|
||||
* @return void
|
||||
*/
|
||||
public function assertTimesSent($expectedCount, $notification)
|
||||
public function assertSentTimes($notification, $expectedCount)
|
||||
{
|
||||
$actualCount = collect($this->notifications)
|
||||
->flatten(1)
|
||||
@@ -152,6 +179,20 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the total amount of times a notification was sent.
|
||||
*
|
||||
* @param int $expectedCount
|
||||
* @param string $notification
|
||||
* @return void
|
||||
*
|
||||
* @deprecated Use the assertSentTimes method instead
|
||||
*/
|
||||
public function assertTimesSent($expectedCount, $notification)
|
||||
{
|
||||
$this->assertSentTimes($notification, $expectedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the notifications matching a truth-test callback.
|
||||
*
|
||||
@@ -210,7 +251,7 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory
|
||||
*/
|
||||
public function send($notifiables, $notification)
|
||||
{
|
||||
return $this->sendNow($notifiables, $notification);
|
||||
$this->sendNow($notifiables, $notification);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,9 +273,24 @@ class NotificationFake implements NotificationDispatcher, NotificationFactory
|
||||
$notification->id = Str::uuid()->toString();
|
||||
}
|
||||
|
||||
$notifiableChannels = $channels ?: $notification->via($notifiable);
|
||||
|
||||
if (method_exists($notification, 'shouldSend')) {
|
||||
$notifiableChannels = array_filter(
|
||||
$notifiableChannels,
|
||||
function ($channel) use ($notification, $notifiable) {
|
||||
return $notification->shouldSend($notifiable, $channel) !== false;
|
||||
}
|
||||
);
|
||||
|
||||
if (empty($notifiableChannels)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->notifications[get_class($notifiable)][$notifiable->getKey()][get_class($notification)][] = [
|
||||
'notification' => $notification,
|
||||
'channels' => $channels ?: $notification->via($notifiable),
|
||||
'channels' => $notifiableChannels,
|
||||
'notifiable' => $notifiable,
|
||||
'locale' => $notification->locale ?? $this->locale ?? value(function () use ($notifiable) {
|
||||
if ($notifiable instanceof HasLocalePreference) {
|
||||
|
||||
39
vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/PendingBatchFake.php
vendored
Normal file
39
vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/PendingBatchFake.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Testing\Fakes;
|
||||
|
||||
use Illuminate\Bus\PendingBatch;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class PendingBatchFake extends PendingBatch
|
||||
{
|
||||
/**
|
||||
* The fake bus instance.
|
||||
*
|
||||
* @var \Illuminate\Support\Testing\Fakes\BusFake
|
||||
*/
|
||||
protected $bus;
|
||||
|
||||
/**
|
||||
* Create a new pending batch instance.
|
||||
*
|
||||
* @param \Illuminate\Support\Testing\Fakes\BusFake $bus
|
||||
* @param \Illuminate\Support\Collection $jobs
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(BusFake $bus, Collection $jobs)
|
||||
{
|
||||
$this->bus = $bus;
|
||||
$this->jobs = $jobs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the batch.
|
||||
*
|
||||
* @return \Illuminate\Bus\Batch
|
||||
*/
|
||||
public function dispatch()
|
||||
{
|
||||
return $this->bus->recordPendingBatch($this);
|
||||
}
|
||||
}
|
||||
56
vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/PendingChainFake.php
vendored
Normal file
56
vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/PendingChainFake.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Testing\Fakes;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Bus\PendingChain;
|
||||
use Illuminate\Queue\CallQueuedClosure;
|
||||
|
||||
class PendingChainFake extends PendingChain
|
||||
{
|
||||
/**
|
||||
* The fake bus instance.
|
||||
*
|
||||
* @var \Illuminate\Support\Testing\Fakes\BusFake
|
||||
*/
|
||||
protected $bus;
|
||||
|
||||
/**
|
||||
* Create a new pending chain instance.
|
||||
*
|
||||
* @param \Illuminate\Support\Testing\Fakes\BusFake $bus
|
||||
* @param mixed $job
|
||||
* @param array $chain
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(BusFake $bus, $job, $chain)
|
||||
{
|
||||
$this->bus = $bus;
|
||||
$this->job = $job;
|
||||
$this->chain = $chain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the job with the given arguments.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Bus\PendingDispatch
|
||||
*/
|
||||
public function dispatch()
|
||||
{
|
||||
if (is_string($this->job)) {
|
||||
$firstJob = new $this->job(...func_get_args());
|
||||
} elseif ($this->job instanceof Closure) {
|
||||
$firstJob = CallQueuedClosure::create($this->job);
|
||||
} else {
|
||||
$firstJob = $this->job;
|
||||
}
|
||||
|
||||
$firstJob->allOnConnection($this->connection);
|
||||
$firstJob->allOnQueue($this->queue);
|
||||
$firstJob->chain($this->chain);
|
||||
$firstJob->delay($this->delay);
|
||||
$firstJob->chainCatchCallbacks = $this->catchCallbacks();
|
||||
|
||||
return $this->bus->dispatch($firstJob);
|
||||
}
|
||||
}
|
||||
@@ -22,24 +22,11 @@ class PendingMailFake extends PendingMail
|
||||
* Send a new mailable message instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailable $mailable
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function send(Mailable $mailable)
|
||||
{
|
||||
return $this->mailer->send($this->fill($mailable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a mailable message immediately.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailable $mailable
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated Use send() instead.
|
||||
*/
|
||||
public function sendNow(Mailable $mailable)
|
||||
{
|
||||
return $this->send($mailable);
|
||||
$this->mailer->send($this->fill($mailable));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,7 +74,7 @@ class QueueFake extends QueueManager implements Queue
|
||||
[$job, $callback] = [$this->firstClosureParameterType($job), $job];
|
||||
}
|
||||
|
||||
return $this->assertPushed($job, function ($job, $pushedQueue) use ($callback, $queue) {
|
||||
$this->assertPushed($job, function ($job, $pushedQueue) use ($callback, $queue) {
|
||||
if ($pushedQueue !== $queue) {
|
||||
return false;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ class QueueFake extends QueueManager implements Queue
|
||||
/**
|
||||
* Push a new job onto the queue.
|
||||
*
|
||||
* @param string $job
|
||||
* @param string|object $job
|
||||
* @param mixed $data
|
||||
* @param string|null $queue
|
||||
* @return mixed
|
||||
@@ -302,7 +302,7 @@ class QueueFake extends QueueManager implements Queue
|
||||
* Push a new job onto the queue after a delay.
|
||||
*
|
||||
* @param \DateTimeInterface|\DateInterval|int $delay
|
||||
* @param string $job
|
||||
* @param string|object $job
|
||||
* @param mixed $data
|
||||
* @param string|null $queue
|
||||
* @return mixed
|
||||
@@ -316,7 +316,7 @@ class QueueFake extends QueueManager implements Queue
|
||||
* Push a new job onto the queue.
|
||||
*
|
||||
* @param string $queue
|
||||
* @param string $job
|
||||
* @param string|object $job
|
||||
* @param mixed $data
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -330,7 +330,7 @@ class QueueFake extends QueueManager implements Queue
|
||||
*
|
||||
* @param string $queue
|
||||
* @param \DateTimeInterface|\DateInterval|int $delay
|
||||
* @param string $job
|
||||
* @param string|object $job
|
||||
* @param mixed $data
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
70
vendor/laravel/framework/src/Illuminate/Support/Timebox.php
vendored
Normal file
70
vendor/laravel/framework/src/Illuminate/Support/Timebox.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
class Timebox
|
||||
{
|
||||
/**
|
||||
* Indicates if the timebox is allowed to return early.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $earlyReturn = false;
|
||||
|
||||
/**
|
||||
* Invoke the given callback within the specified timebox minimum.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param int $microseconds
|
||||
* @return mixed
|
||||
*/
|
||||
public function call(callable $callback, int $microseconds)
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
$result = $callback($this);
|
||||
|
||||
$remainder = $microseconds - ((microtime(true) - $start) * 1000000);
|
||||
|
||||
if (! $this->earlyReturn && $remainder > 0) {
|
||||
$this->usleep($remainder);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the timebox can return early.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function returnEarly()
|
||||
{
|
||||
$this->earlyReturn = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the timebox cannot return early.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dontReturnEarly()
|
||||
{
|
||||
$this->earlyReturn = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sleep for the specified number of microseconds.
|
||||
*
|
||||
* @param $microseconds
|
||||
* @return void
|
||||
*/
|
||||
protected function usleep($microseconds)
|
||||
{
|
||||
usleep($microseconds);
|
||||
}
|
||||
}
|
||||
44
vendor/laravel/framework/src/Illuminate/Support/Traits/Conditionable.php
vendored
Normal file
44
vendor/laravel/framework/src/Illuminate/Support/Traits/Conditionable.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Traits;
|
||||
|
||||
trait Conditionable
|
||||
{
|
||||
/**
|
||||
* Apply the callback if the given "value" is truthy.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return $this|mixed
|
||||
*/
|
||||
public function when($value, $callback, $default = null)
|
||||
{
|
||||
if ($value) {
|
||||
return $callback($this, $value) ?: $this;
|
||||
} elseif ($default) {
|
||||
return $default($this, $value) ?: $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the callback if the given "value" is falsy.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return $this|mixed
|
||||
*/
|
||||
public function unless($value, $callback, $default = null)
|
||||
{
|
||||
if (! $value) {
|
||||
return $callback($this, $value) ?: $this;
|
||||
} elseif ($default) {
|
||||
return $default($this, $value) ?: $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,982 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Traits;
|
||||
|
||||
use CachingIterator;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Support\Jsonable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Enumerable;
|
||||
use Illuminate\Support\HigherOrderCollectionProxy;
|
||||
use Illuminate\Support\HigherOrderWhenProxy;
|
||||
use JsonSerializable;
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* @property-read HigherOrderCollectionProxy $average
|
||||
* @property-read HigherOrderCollectionProxy $avg
|
||||
* @property-read HigherOrderCollectionProxy $contains
|
||||
* @property-read HigherOrderCollectionProxy $each
|
||||
* @property-read HigherOrderCollectionProxy $every
|
||||
* @property-read HigherOrderCollectionProxy $filter
|
||||
* @property-read HigherOrderCollectionProxy $first
|
||||
* @property-read HigherOrderCollectionProxy $flatMap
|
||||
* @property-read HigherOrderCollectionProxy $groupBy
|
||||
* @property-read HigherOrderCollectionProxy $keyBy
|
||||
* @property-read HigherOrderCollectionProxy $map
|
||||
* @property-read HigherOrderCollectionProxy $max
|
||||
* @property-read HigherOrderCollectionProxy $min
|
||||
* @property-read HigherOrderCollectionProxy $partition
|
||||
* @property-read HigherOrderCollectionProxy $reject
|
||||
* @property-read HigherOrderCollectionProxy $some
|
||||
* @property-read HigherOrderCollectionProxy $sortBy
|
||||
* @property-read HigherOrderCollectionProxy $sortByDesc
|
||||
* @property-read HigherOrderCollectionProxy $sum
|
||||
* @property-read HigherOrderCollectionProxy $unique
|
||||
* @property-read HigherOrderCollectionProxy $until
|
||||
*/
|
||||
trait EnumeratesValues
|
||||
{
|
||||
/**
|
||||
* The methods that can be proxied.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $proxies = [
|
||||
'average',
|
||||
'avg',
|
||||
'contains',
|
||||
'each',
|
||||
'every',
|
||||
'filter',
|
||||
'first',
|
||||
'flatMap',
|
||||
'groupBy',
|
||||
'keyBy',
|
||||
'map',
|
||||
'max',
|
||||
'min',
|
||||
'partition',
|
||||
'reject',
|
||||
'skipUntil',
|
||||
'skipWhile',
|
||||
'some',
|
||||
'sortBy',
|
||||
'sortByDesc',
|
||||
'sum',
|
||||
'takeUntil',
|
||||
'takeWhile',
|
||||
'unique',
|
||||
'until',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new collection instance if the value isn't one already.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return static
|
||||
*/
|
||||
public static function make($items = [])
|
||||
{
|
||||
return new static($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the given value in a collection if applicable.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public static function wrap($value)
|
||||
{
|
||||
return $value instanceof Enumerable
|
||||
? new static($value)
|
||||
: new static(Arr::wrap($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying items from the given collection if applicable.
|
||||
*
|
||||
* @param array|static $value
|
||||
* @return array
|
||||
*/
|
||||
public static function unwrap($value)
|
||||
{
|
||||
return $value instanceof Enumerable ? $value->all() : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for the "avg" method.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function average($callback = null)
|
||||
{
|
||||
return $this->avg($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, using strict comparison.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function containsStrict($key, $value = null)
|
||||
{
|
||||
if (func_num_args() === 2) {
|
||||
return $this->contains(function ($item) use ($key, $value) {
|
||||
return data_get($item, $key) === $value;
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->useAsCallable($key)) {
|
||||
return ! is_null($this->first($key));
|
||||
}
|
||||
|
||||
foreach ($this as $item) {
|
||||
if ($item === $key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the items and end the script.
|
||||
*
|
||||
* @param mixed ...$args
|
||||
* @return void
|
||||
*/
|
||||
public function dd(...$args)
|
||||
{
|
||||
$this->dump(...$args);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the items.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dump()
|
||||
{
|
||||
(new Collection(func_get_args()))
|
||||
->push($this->all())
|
||||
->each(function ($item) {
|
||||
VarDumper::dump($item);
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a callback over each item.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function each(callable $callback)
|
||||
{
|
||||
foreach ($this as $key => $item) {
|
||||
if ($callback($item, $key) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a callback over each nested chunk of items.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function eachSpread(callable $callback)
|
||||
{
|
||||
return $this->each(function ($chunk, $key) use ($callback) {
|
||||
$chunk[] = $key;
|
||||
|
||||
return $callback(...$chunk);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if all items pass the given truth test.
|
||||
*
|
||||
* @param string|callable $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function every($key, $operator = null, $value = null)
|
||||
{
|
||||
if (func_num_args() === 1) {
|
||||
$callback = $this->valueRetriever($key);
|
||||
|
||||
foreach ($this as $k => $v) {
|
||||
if (! $callback($v, $k)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->every($this->operatorForWhere(...func_get_args()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first item by the given key value pair.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function firstWhere($key, $operator = null, $value = null)
|
||||
{
|
||||
return $this->first($this->operatorForWhere(...func_get_args()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the collection is not empty.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty()
|
||||
{
|
||||
return ! $this->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a map over each nested chunk of items.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function mapSpread(callable $callback)
|
||||
{
|
||||
return $this->map(function ($chunk, $key) use ($callback) {
|
||||
$chunk[] = $key;
|
||||
|
||||
return $callback(...$chunk);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a grouping map over the items.
|
||||
*
|
||||
* The callback should return an associative array with a single key/value pair.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function mapToGroups(callable $callback)
|
||||
{
|
||||
$groups = $this->mapToDictionary($callback);
|
||||
|
||||
return $groups->map([$this, 'make']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a collection and flatten the result by a single level.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return static
|
||||
*/
|
||||
public function flatMap(callable $callback)
|
||||
{
|
||||
return $this->map($callback)->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the values into a new class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return static
|
||||
*/
|
||||
public function mapInto($class)
|
||||
{
|
||||
return $this->map(function ($value, $key) use ($class) {
|
||||
return new $class($value, $key);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the min value of a given key.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function min($callback = null)
|
||||
{
|
||||
$callback = $this->valueRetriever($callback);
|
||||
|
||||
return $this->map(function ($value) use ($callback) {
|
||||
return $callback($value);
|
||||
})->filter(function ($value) {
|
||||
return ! is_null($value);
|
||||
})->reduce(function ($result, $value) {
|
||||
return is_null($result) || $value < $result ? $value : $result;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value of a given key.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function max($callback = null)
|
||||
{
|
||||
$callback = $this->valueRetriever($callback);
|
||||
|
||||
return $this->filter(function ($value) {
|
||||
return ! is_null($value);
|
||||
})->reduce(function ($result, $item) use ($callback) {
|
||||
$value = $callback($item);
|
||||
|
||||
return is_null($result) || $value > $result ? $value : $result;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* "Paginate" the collection by slicing it into a smaller collection.
|
||||
*
|
||||
* @param int $page
|
||||
* @param int $perPage
|
||||
* @return static
|
||||
*/
|
||||
public function forPage($page, $perPage)
|
||||
{
|
||||
$offset = max(0, ($page - 1) * $perPage);
|
||||
|
||||
return $this->slice($offset, $perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Partition the collection into two arrays using the given callback or key.
|
||||
*
|
||||
* @param callable|string $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function partition($key, $operator = null, $value = null)
|
||||
{
|
||||
$passed = [];
|
||||
$failed = [];
|
||||
|
||||
$callback = func_num_args() === 1
|
||||
? $this->valueRetriever($key)
|
||||
: $this->operatorForWhere(...func_get_args());
|
||||
|
||||
foreach ($this as $key => $item) {
|
||||
if ($callback($item, $key)) {
|
||||
$passed[$key] = $item;
|
||||
} else {
|
||||
$failed[$key] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return new static([new static($passed), new static($failed)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sum of the given values.
|
||||
*
|
||||
* @param callable|string|null $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function sum($callback = null)
|
||||
{
|
||||
$callback = is_null($callback)
|
||||
? $this->identity()
|
||||
: $this->valueRetriever($callback);
|
||||
|
||||
return $this->reduce(function ($result, $item) use ($callback) {
|
||||
return $result + $callback($item);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the callback if the value is truthy.
|
||||
*
|
||||
* @param bool|mixed $value
|
||||
* @param callable|null $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function when($value, callable $callback = null, callable $default = null)
|
||||
{
|
||||
if (! $callback) {
|
||||
return new HigherOrderWhenProxy($this, $value);
|
||||
}
|
||||
|
||||
if ($value) {
|
||||
return $callback($this, $value);
|
||||
} elseif ($default) {
|
||||
return $default($this, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the callback if the collection is empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $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|null $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.
|
||||
*
|
||||
* @param bool $value
|
||||
* @param callable $callback
|
||||
* @param callable|null $default
|
||||
* @return static|mixed
|
||||
*/
|
||||
public function unless($value, callable $callback, callable $default = null)
|
||||
{
|
||||
return $this->when(! $value, $callback, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the callback unless the collection is empty.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param callable|null $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|null $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.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $operator
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function where($key, $operator = null, $value = null)
|
||||
{
|
||||
return $this->filter($this->operatorForWhere(...func_get_args()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter items where the given key is not null.
|
||||
*
|
||||
* @param string|null $key
|
||||
* @return static
|
||||
*/
|
||||
public function whereNull($key = null)
|
||||
{
|
||||
return $this->whereStrict($key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter items where the given key is null.
|
||||
*
|
||||
* @param string|null $key
|
||||
* @return static
|
||||
*/
|
||||
public function whereNotNull($key = null)
|
||||
{
|
||||
return $this->where($key, '!==', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair using strict comparison.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public function whereStrict($key, $value)
|
||||
{
|
||||
return $this->where($key, '===', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function whereIn($key, $values, $strict = false)
|
||||
{
|
||||
$values = $this->getArrayableItems($values);
|
||||
|
||||
return $this->filter(function ($item) use ($key, $values, $strict) {
|
||||
return in_array(data_get($item, $key), $values, $strict);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair using strict comparison.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @return static
|
||||
*/
|
||||
public function whereInStrict($key, $values)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function whereNotIn($key, $values, $strict = false)
|
||||
{
|
||||
$values = $this->getArrayableItems($values);
|
||||
|
||||
return $this->reject(function ($item) use ($key, $values, $strict) {
|
||||
return in_array(data_get($item, $key), $values, $strict);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter items by the given key value pair using strict comparison.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $values
|
||||
* @return static
|
||||
*/
|
||||
public function whereNotInStrict($key, $values)
|
||||
{
|
||||
return $this->whereNotIn($key, $values, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the items, removing any items that don't match the given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return static
|
||||
*/
|
||||
public function whereInstanceOf($type)
|
||||
{
|
||||
return $this->filter(function ($value) use ($type) {
|
||||
return $value instanceof $type;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the collection to the given callback and return the result.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function pipe(callable $callback)
|
||||
{
|
||||
return $callback($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the collection to the given callback and then return it.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function tap(callable $callback)
|
||||
{
|
||||
$callback(clone $this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a collection of all elements that do not pass a given truth test.
|
||||
*
|
||||
* @param callable|mixed $callback
|
||||
* @return static
|
||||
*/
|
||||
public function reject($callback = true)
|
||||
{
|
||||
$useAsCallable = $this->useAsCallable($callback);
|
||||
|
||||
return $this->filter(function ($value, $key) use ($callback, $useAsCallable) {
|
||||
return $useAsCallable
|
||||
? ! $callback($value, $key)
|
||||
: $value != $callback;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return only unique items from the collection array.
|
||||
*
|
||||
* @param string|callable|null $key
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function unique($key = null, $strict = false)
|
||||
{
|
||||
$callback = $this->valueRetriever($key);
|
||||
|
||||
$exists = [];
|
||||
|
||||
return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) {
|
||||
if (in_array($id = $callback($item, $key), $exists, $strict)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$exists[] = $id;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return only unique items from the collection array using strict comparison.
|
||||
*
|
||||
* @param string|callable|null $key
|
||||
* @return static
|
||||
*/
|
||||
public function uniqueStrict($key = null)
|
||||
{
|
||||
return $this->unique($key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take items in the collection until the given condition is met.
|
||||
*
|
||||
* This is an alias to the "takeUntil" method.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*
|
||||
* @deprecated Use the "takeUntil" method directly.
|
||||
*/
|
||||
public function until($value)
|
||||
{
|
||||
return $this->takeUntil($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect the values into a collection.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
return new Collection($this->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of items as a plain array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->map(function ($value) {
|
||||
return $value instanceof Arrayable ? $value->toArray() : $value;
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the object into something JSON serializable.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return array_map(function ($value) {
|
||||
if ($value instanceof JsonSerializable) {
|
||||
return $value->jsonSerialize();
|
||||
} elseif ($value instanceof Jsonable) {
|
||||
return json_decode($value->toJson(), true);
|
||||
} elseif ($value instanceof Arrayable) {
|
||||
return $value->toArray();
|
||||
}
|
||||
|
||||
return $value;
|
||||
}, $this->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of items as JSON.
|
||||
*
|
||||
* @param int $options
|
||||
* @return string
|
||||
*/
|
||||
public function toJson($options = 0)
|
||||
{
|
||||
return json_encode($this->jsonSerialize(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a CachingIterator instance.
|
||||
*
|
||||
* @param int $flags
|
||||
* @return \CachingIterator
|
||||
*/
|
||||
public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING)
|
||||
{
|
||||
return new CachingIterator($this->getIterator(), $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the collection to its string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a method to the list of proxied methods.
|
||||
*
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public static function proxy($method)
|
||||
{
|
||||
static::$proxies[] = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically access collection proxies.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if (! in_array($key, static::$proxies)) {
|
||||
throw new Exception("Property [{$key}] does not exist on this collection instance.");
|
||||
}
|
||||
|
||||
return new HigherOrderCollectionProxy($this, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Results array of items from Collection or Arrayable.
|
||||
*
|
||||
* @param mixed $items
|
||||
* @return array
|
||||
*/
|
||||
protected function getArrayableItems($items)
|
||||
{
|
||||
if (is_array($items)) {
|
||||
return $items;
|
||||
} elseif ($items instanceof Enumerable) {
|
||||
return $items->all();
|
||||
} elseif ($items instanceof Arrayable) {
|
||||
return $items->toArray();
|
||||
} elseif ($items instanceof Jsonable) {
|
||||
return json_decode($items->toJson(), true);
|
||||
} elseif ($items instanceof JsonSerializable) {
|
||||
return (array) $items->jsonSerialize();
|
||||
} elseif ($items instanceof Traversable) {
|
||||
return iterator_to_array($items);
|
||||
}
|
||||
|
||||
return (array) $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an operator checker callback.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $operator
|
||||
* @param mixed $value
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function operatorForWhere($key, $operator = null, $value = null)
|
||||
{
|
||||
if (func_num_args() === 1) {
|
||||
$value = true;
|
||||
|
||||
$operator = '=';
|
||||
}
|
||||
|
||||
if (func_num_args() === 2) {
|
||||
$value = $operator;
|
||||
|
||||
$operator = '=';
|
||||
}
|
||||
|
||||
return function ($item) use ($key, $operator, $value) {
|
||||
$retrieved = data_get($item, $key);
|
||||
|
||||
$strings = array_filter([$retrieved, $value], function ($value) {
|
||||
return is_string($value) || (is_object($value) && method_exists($value, '__toString'));
|
||||
});
|
||||
|
||||
if (count($strings) < 2 && count(array_filter([$retrieved, $value], 'is_object')) == 1) {
|
||||
return in_array($operator, ['!=', '<>', '!==']);
|
||||
}
|
||||
|
||||
switch ($operator) {
|
||||
default:
|
||||
case '=':
|
||||
case '==': return $retrieved == $value;
|
||||
case '!=':
|
||||
case '<>': return $retrieved != $value;
|
||||
case '<': return $retrieved < $value;
|
||||
case '>': return $retrieved > $value;
|
||||
case '<=': return $retrieved <= $value;
|
||||
case '>=': return $retrieved >= $value;
|
||||
case '===': return $retrieved === $value;
|
||||
case '!==': return $retrieved !== $value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given value is callable, but not a string.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function useAsCallable($value)
|
||||
{
|
||||
return ! is_string($value) && is_callable($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value retrieving callback.
|
||||
*
|
||||
* @param callable|string|null $value
|
||||
* @return callable
|
||||
*/
|
||||
protected function valueRetriever($value)
|
||||
{
|
||||
if ($this->useAsCallable($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return function ($item) use ($value) {
|
||||
return data_get($item, $value);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a function to check an item's equality.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function equality($value)
|
||||
{
|
||||
return function ($item) use ($value) {
|
||||
return $item === $value;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a function using another function, by negating its result.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function negate(Closure $callback)
|
||||
{
|
||||
return function (...$params) use ($callback) {
|
||||
return ! $callback(...$params);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a function that returns what's passed to it.
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function identity()
|
||||
{
|
||||
return function ($value) {
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,27 @@ trait ForwardsCalls
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward a method call to the given object, returning $this if the forwarded call returned itself.
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
protected function forwardDecoratedCallTo($object, $method, $parameters)
|
||||
{
|
||||
$result = $this->forwardCallTo($object, $method, $parameters);
|
||||
|
||||
if ($result === $object) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw a bad method call exception for the given method.
|
||||
*
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support\Traits;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Closure;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
|
||||
trait Macroable
|
||||
{
|
||||
/**
|
||||
* The registered string macros.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $macros = [];
|
||||
|
||||
/**
|
||||
* Register a custom macro.
|
||||
*
|
||||
* @param string $name
|
||||
* @param object|callable $macro
|
||||
* @return void
|
||||
*/
|
||||
public static function macro($name, $macro)
|
||||
{
|
||||
static::$macros[$name] = $macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix another object into the class.
|
||||
*
|
||||
* @param object $mixin
|
||||
* @param bool $replace
|
||||
* @return void
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function mixin($mixin, $replace = true)
|
||||
{
|
||||
$methods = (new ReflectionClass($mixin))->getMethods(
|
||||
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
|
||||
);
|
||||
|
||||
foreach ($methods as $method) {
|
||||
if ($replace || ! static::hasMacro($method->name)) {
|
||||
$method->setAccessible(true);
|
||||
static::macro($method->name, $method->invoke($mixin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if macro is registered.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasMacro($name)
|
||||
{
|
||||
return isset(static::$macros[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically handle calls to the class.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public static function __callStatic($method, $parameters)
|
||||
{
|
||||
if (! static::hasMacro($method)) {
|
||||
throw new BadMethodCallException(sprintf(
|
||||
'Method %s::%s does not exist.', static::class, $method
|
||||
));
|
||||
}
|
||||
|
||||
$macro = static::$macros[$method];
|
||||
|
||||
if ($macro instanceof Closure) {
|
||||
$macro = $macro->bindTo(null, static::class);
|
||||
}
|
||||
|
||||
return $macro(...$parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically handle calls to the class.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (! static::hasMacro($method)) {
|
||||
throw new BadMethodCallException(sprintf(
|
||||
'Method %s::%s does not exist.', static::class, $method
|
||||
));
|
||||
}
|
||||
|
||||
$macro = static::$macros[$method];
|
||||
|
||||
if ($macro instanceof Closure) {
|
||||
$macro = $macro->bindTo($this, static::class);
|
||||
}
|
||||
|
||||
return $macro(...$parameters);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,62 @@ use RuntimeException;
|
||||
|
||||
trait ReflectsClosures
|
||||
{
|
||||
/**
|
||||
* Get the class name of the first parameter of the given Closure.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
* @return string
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function firstClosureParameterType(Closure $closure)
|
||||
{
|
||||
$types = array_values($this->closureParameterTypes($closure));
|
||||
|
||||
if (! $types) {
|
||||
throw new RuntimeException('The given Closure has no parameters.');
|
||||
}
|
||||
|
||||
if ($types[0] === null) {
|
||||
throw new RuntimeException('The first parameter of the given Closure is missing a type hint.');
|
||||
}
|
||||
|
||||
return $types[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class names of the first parameter of the given Closure, including union types.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
* @return array
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function firstClosureParameterTypes(Closure $closure)
|
||||
{
|
||||
$reflection = new ReflectionFunction($closure);
|
||||
|
||||
$types = collect($reflection->getParameters())->mapWithKeys(function ($parameter) {
|
||||
if ($parameter->isVariadic()) {
|
||||
return [$parameter->getName() => null];
|
||||
}
|
||||
|
||||
return [$parameter->getName() => Reflector::getParameterClassNames($parameter)];
|
||||
})->filter()->values()->all();
|
||||
|
||||
if (empty($types)) {
|
||||
throw new RuntimeException('The given Closure has no parameters.');
|
||||
}
|
||||
|
||||
if (isset($types[0]) && empty($types[0])) {
|
||||
throw new RuntimeException('The first parameter of the given Closure is missing a type hint.');
|
||||
}
|
||||
|
||||
return $types[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class names / types of the parameters of the given Closure.
|
||||
*
|
||||
@@ -29,27 +85,4 @@ trait ReflectsClosures
|
||||
return [$parameter->getName() => Reflector::getParameterClassName($parameter)];
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name of the first parameter of the given Closure.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
* @return string
|
||||
*
|
||||
* @throws \ReflectionException|\RuntimeException
|
||||
*/
|
||||
protected function firstClosureParameterType(Closure $closure)
|
||||
{
|
||||
$types = array_values($this->closureParameterTypes($closure));
|
||||
|
||||
if (! $types) {
|
||||
throw new RuntimeException('The given Closure has no parameters.');
|
||||
}
|
||||
|
||||
if ($types[0] === null) {
|
||||
throw new RuntimeException('The first parameter of the given Closure is missing a type hint.');
|
||||
}
|
||||
|
||||
return $types[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ trait Tappable
|
||||
* Call the given Closure with this instance then return the instance.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return mixed
|
||||
* @return $this|\Illuminate\Support\HigherOrderTapProxy
|
||||
*/
|
||||
public function tap($callback = null)
|
||||
{
|
||||
|
||||
219
vendor/laravel/framework/src/Illuminate/Support/ValidatedInput.php
vendored
Normal file
219
vendor/laravel/framework/src/Illuminate/Support/ValidatedInput.php
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Support;
|
||||
|
||||
use ArrayIterator;
|
||||
use Illuminate\Contracts\Support\ValidatedData;
|
||||
use stdClass;
|
||||
|
||||
class ValidatedInput implements ValidatedData
|
||||
{
|
||||
/**
|
||||
* The underlying input.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $input;
|
||||
|
||||
/**
|
||||
* Create a new validated input container.
|
||||
*
|
||||
* @param array $input
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a subset containing the provided keys with values from the input data.
|
||||
*
|
||||
* @param array|mixed $keys
|
||||
* @return array
|
||||
*/
|
||||
public function only($keys)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
$input = $this->input;
|
||||
|
||||
$placeholder = new stdClass;
|
||||
|
||||
foreach (is_array($keys) ? $keys : func_get_args() as $key) {
|
||||
$value = data_get($input, $key, $placeholder);
|
||||
|
||||
if ($value !== $placeholder) {
|
||||
Arr::set($results, $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the input except for a specified array of items.
|
||||
*
|
||||
* @param array|mixed $keys
|
||||
* @return array
|
||||
*/
|
||||
public function except($keys)
|
||||
{
|
||||
$keys = is_array($keys) ? $keys : func_get_args();
|
||||
|
||||
$results = $this->input;
|
||||
|
||||
Arr::forget($results, $keys);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the validated input with the given array of additional data.
|
||||
*
|
||||
* @param array $items
|
||||
* @return static
|
||||
*/
|
||||
public function merge(array $items)
|
||||
{
|
||||
return new static(array_merge($this->input, $items));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input as a collection.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
return new Collection($this->input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw, underlying input array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instance as an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically access input data.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->input[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically set input data.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->input[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an input key is set.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this->input[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an input key.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
unset($this->input[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an item exists at an offset.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return isset($this->input[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item at a given offset.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->input[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item at a given offset.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
$this->input[] = $value;
|
||||
} else {
|
||||
$this->input[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the item at a given offset.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
unset($this->input[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator for the input.
|
||||
*
|
||||
* @return \ArrayIterator
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->input);
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,7 @@ class ViewErrorBag implements Countable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return $this->getBag('default')->count();
|
||||
|
||||
@@ -14,13 +14,15 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"php": "^7.3|^8.0",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"doctrine/inflector": "^1.4|^2.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"nesbot/carbon": "^2.31",
|
||||
"voku/portable-ascii": "^1.4.8"
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/macroable": "^8.0",
|
||||
"nesbot/carbon": "^2.53.1",
|
||||
"voku/portable-ascii": "^1.6.1"
|
||||
},
|
||||
"conflict": {
|
||||
"tightenco/collect": "<5.5.33"
|
||||
@@ -35,16 +37,16 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/filesystem": "Required to use the composer class (^7.0).",
|
||||
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
|
||||
"ramsey/uuid": "Required to use Str::uuid() (^3.7|^4.0).",
|
||||
"symfony/process": "Required to use the composer class (^5.0).",
|
||||
"symfony/var-dumper": "Required to use the dd function (^5.0).",
|
||||
"vlucas/phpdotenv": "Required to use the Env class and env helper (^4.0)."
|
||||
"illuminate/filesystem": "Required to use the composer class (^8.0).",
|
||||
"league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^1.3|^2.0.2).",
|
||||
"ramsey/uuid": "Required to use Str::uuid() (^4.2.2).",
|
||||
"symfony/process": "Required to use the composer class (^5.4).",
|
||||
"symfony/var-dumper": "Required to use the dd function (^5.4).",
|
||||
"vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
use Illuminate\Contracts\Support\DeferringDisplayableValue;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Env;
|
||||
use Illuminate\Support\HigherOrderTapProxy;
|
||||
use Illuminate\Support\Optional;
|
||||
@@ -98,154 +97,11 @@ if (! function_exists('class_uses_recursive')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('collect')) {
|
||||
/**
|
||||
* Create a collection from the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
function collect($value = null)
|
||||
{
|
||||
return new Collection($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('data_fill')) {
|
||||
/**
|
||||
* Fill in data where it's missing.
|
||||
*
|
||||
* @param mixed $target
|
||||
* @param string|array $key
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
function data_fill(&$target, $key, $value)
|
||||
{
|
||||
return data_set($target, $key, $value, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('data_get')) {
|
||||
/**
|
||||
* Get an item from an array or object using "dot" notation.
|
||||
*
|
||||
* @param mixed $target
|
||||
* @param string|array|int|null $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
function data_get($target, $key, $default = null)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
return $target;
|
||||
}
|
||||
|
||||
$key = is_array($key) ? $key : explode('.', $key);
|
||||
|
||||
foreach ($key as $i => $segment) {
|
||||
unset($key[$i]);
|
||||
|
||||
if (is_null($segment)) {
|
||||
return $target;
|
||||
}
|
||||
|
||||
if ($segment === '*') {
|
||||
if ($target instanceof Collection) {
|
||||
$target = $target->all();
|
||||
} elseif (! is_array($target)) {
|
||||
return value($default);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($target as $item) {
|
||||
$result[] = data_get($item, $key);
|
||||
}
|
||||
|
||||
return in_array('*', $key) ? Arr::collapse($result) : $result;
|
||||
}
|
||||
|
||||
if (Arr::accessible($target) && Arr::exists($target, $segment)) {
|
||||
$target = $target[$segment];
|
||||
} elseif (is_object($target) && isset($target->{$segment})) {
|
||||
$target = $target->{$segment};
|
||||
} else {
|
||||
return value($default);
|
||||
}
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('data_set')) {
|
||||
/**
|
||||
* Set an item on an array or object using dot notation.
|
||||
*
|
||||
* @param mixed $target
|
||||
* @param string|array $key
|
||||
* @param mixed $value
|
||||
* @param bool $overwrite
|
||||
* @return mixed
|
||||
*/
|
||||
function data_set(&$target, $key, $value, $overwrite = true)
|
||||
{
|
||||
$segments = is_array($key) ? $key : explode('.', $key);
|
||||
|
||||
if (($segment = array_shift($segments)) === '*') {
|
||||
if (! Arr::accessible($target)) {
|
||||
$target = [];
|
||||
}
|
||||
|
||||
if ($segments) {
|
||||
foreach ($target as &$inner) {
|
||||
data_set($inner, $segments, $value, $overwrite);
|
||||
}
|
||||
} elseif ($overwrite) {
|
||||
foreach ($target as &$inner) {
|
||||
$inner = $value;
|
||||
}
|
||||
}
|
||||
} elseif (Arr::accessible($target)) {
|
||||
if ($segments) {
|
||||
if (! Arr::exists($target, $segment)) {
|
||||
$target[$segment] = [];
|
||||
}
|
||||
|
||||
data_set($target[$segment], $segments, $value, $overwrite);
|
||||
} elseif ($overwrite || ! Arr::exists($target, $segment)) {
|
||||
$target[$segment] = $value;
|
||||
}
|
||||
} elseif (is_object($target)) {
|
||||
if ($segments) {
|
||||
if (! isset($target->{$segment})) {
|
||||
$target->{$segment} = [];
|
||||
}
|
||||
|
||||
data_set($target->{$segment}, $segments, $value, $overwrite);
|
||||
} elseif ($overwrite || ! isset($target->{$segment})) {
|
||||
$target->{$segment} = $value;
|
||||
}
|
||||
} else {
|
||||
$target = [];
|
||||
|
||||
if ($segments) {
|
||||
data_set($target[$segment], $segments, $value, $overwrite);
|
||||
} elseif ($overwrite) {
|
||||
$target[$segment] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('e')) {
|
||||
/**
|
||||
* Encode HTML special characters in a string.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Support\DeferringDisplayableValue|\Illuminate\Contracts\Support\Htmlable|string $value
|
||||
* @param \Illuminate\Contracts\Support\DeferringDisplayableValue|\Illuminate\Contracts\Support\Htmlable|string|null $value
|
||||
* @param bool $doubleEncode
|
||||
* @return string
|
||||
*/
|
||||
@@ -259,7 +115,7 @@ if (! function_exists('e')) {
|
||||
return $value->toHtml();
|
||||
}
|
||||
|
||||
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', $doubleEncode);
|
||||
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,32 +146,6 @@ if (! function_exists('filled')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('head')) {
|
||||
/**
|
||||
* Get the first element of an array. Useful for method chaining.
|
||||
*
|
||||
* @param array $array
|
||||
* @return mixed
|
||||
*/
|
||||
function head($array)
|
||||
{
|
||||
return reset($array);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('last')) {
|
||||
/**
|
||||
* Get the last element from an array.
|
||||
*
|
||||
* @param array $array
|
||||
* @return mixed
|
||||
*/
|
||||
function last($array)
|
||||
{
|
||||
return end($array);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('object_get')) {
|
||||
/**
|
||||
* Get an item from an object using "dot" notation.
|
||||
@@ -327,7 +157,7 @@ if (! function_exists('object_get')) {
|
||||
*/
|
||||
function object_get($object, $key, $default = null)
|
||||
{
|
||||
if (is_null($key) || trim($key) == '') {
|
||||
if (is_null($key) || trim($key) === '') {
|
||||
return $object;
|
||||
}
|
||||
|
||||
@@ -386,13 +216,13 @@ if (! function_exists('retry')) {
|
||||
*
|
||||
* @param int $times
|
||||
* @param callable $callback
|
||||
* @param int $sleep
|
||||
* @param int|\Closure $sleepMilliseconds
|
||||
* @param callable|null $when
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
function retry($times, callable $callback, $sleep = 0, $when = null)
|
||||
function retry($times, callable $callback, $sleepMilliseconds = 0, $when = null)
|
||||
{
|
||||
$attempts = 0;
|
||||
|
||||
@@ -407,8 +237,8 @@ if (! function_exists('retry')) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($sleep) {
|
||||
usleep($sleep * 1000);
|
||||
if ($sleepMilliseconds) {
|
||||
usleep(value($sleepMilliseconds, $attempts) * 1000);
|
||||
}
|
||||
|
||||
goto beginning;
|
||||
@@ -442,15 +272,19 @@ if (! function_exists('throw_if')) {
|
||||
*
|
||||
* @param mixed $condition
|
||||
* @param \Throwable|string $exception
|
||||
* @param array ...$parameters
|
||||
* @param mixed ...$parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
function throw_if($condition, $exception, ...$parameters)
|
||||
function throw_if($condition, $exception = 'RuntimeException', ...$parameters)
|
||||
{
|
||||
if ($condition) {
|
||||
throw (is_string($exception) ? new $exception(...$parameters) : $exception);
|
||||
if (is_string($exception) && class_exists($exception)) {
|
||||
$exception = new $exception(...$parameters);
|
||||
}
|
||||
|
||||
throw is_string($exception) ? new RuntimeException($exception) : $exception;
|
||||
}
|
||||
|
||||
return $condition;
|
||||
@@ -463,16 +297,14 @@ if (! function_exists('throw_unless')) {
|
||||
*
|
||||
* @param mixed $condition
|
||||
* @param \Throwable|string $exception
|
||||
* @param array ...$parameters
|
||||
* @param mixed ...$parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
function throw_unless($condition, $exception, ...$parameters)
|
||||
function throw_unless($condition, $exception = 'RuntimeException', ...$parameters)
|
||||
{
|
||||
if (! $condition) {
|
||||
throw (is_string($exception) ? new $exception(...$parameters) : $exception);
|
||||
}
|
||||
throw_if(! $condition, $exception, ...$parameters);
|
||||
|
||||
return $condition;
|
||||
}
|
||||
@@ -487,7 +319,7 @@ if (! function_exists('trait_uses_recursive')) {
|
||||
*/
|
||||
function trait_uses_recursive($trait)
|
||||
{
|
||||
$traits = class_uses($trait);
|
||||
$traits = class_uses($trait) ?: [];
|
||||
|
||||
foreach ($traits as $trait) {
|
||||
$traits += trait_uses_recursive($trait);
|
||||
@@ -520,19 +352,6 @@ if (! function_exists('transform')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('value')) {
|
||||
/**
|
||||
* Return the default value of the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
function value($value)
|
||||
{
|
||||
return $value instanceof Closure ? $value() : $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('windows_os')) {
|
||||
/**
|
||||
* Determine whether the current environment is Windows based.
|
||||
|
||||
Reference in New Issue
Block a user