Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Config/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function load($group, $namespace, $collection)
// If we've already loaded this collection, we will just bail out since we do
// not want to load it again. Once items are loaded a first time they will
// stay kept in memory within this class and not loaded from disk again.
if (isset($this->afterLoad[$namespace]))
if ( ! is_null($namespace) && isset($this->afterLoad[$namespace]))
{
$items = $this->callAfterLoad($namespace, $group, $items);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Eloquent/Collection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Illuminate\Database\Eloquent;

use Illuminate\Support\Arr;
use Illuminate\Support\Collection as BaseCollection;

class Collection extends BaseCollection {
Expand All @@ -18,7 +19,7 @@ public function find($key, $default = null)
$key = $key->getKey();
}

return array_first($this->items, function($model, $itemKey) use ($key)
return Arr::first($this->items, function($model, $itemKey) use ($key)
{
return $model->getKey() == $key;

Expand Down
5 changes: 3 additions & 2 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Carbon\Carbon;
use Exception;
use Illuminate\Database\Connection;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use LogicException;
use JsonSerializable;
Expand Down Expand Up @@ -294,7 +295,7 @@ public static function hasGlobalScope($scope): bool
*/
public static function getGlobalScope($scope): ?ScopeInterface
{
return array_first(static::$globalScopes[get_called_class()], function($value, $key) use ($scope)
return Arr::first(static::$globalScopes[get_called_class()], function($value, $key) use ($scope)
{
return $scope instanceof $value;
});
Expand Down Expand Up @@ -991,7 +992,7 @@ protected function getBelongsToManyCaller():?string
{
$self = __FUNCTION__;

$caller = array_first(debug_backtrace(false), function($trace, $key) use ($self)
$caller = Arr::first(debug_backtrace(false), function($trace, $key) use ($self)
{
$caller = $trace['function'];

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace Illuminate\Foundation;

use Closure;
use Illuminate\Support\Arr;
use Illuminate\Container\BindingResolutionException;
use Illuminate\Foundation\Http\MiddlewareBuilder;
use ReflectionException;
Expand Down Expand Up @@ -350,7 +351,7 @@ public function getRegistered($provider)

if (array_key_exists($name, $this->loadedProviders))
{
return array_first($this->serviceProviders, function($value, $key) use ($name)
return Arr::first($this->serviceProviders, function($value, $key) use ($name)
{
return get_class($value) == $name;
});
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/EnvironmentDetector.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Illuminate\Foundation;

use Illuminate\Support\Arr;
use Closure;

class EnvironmentDetector {
Expand Down Expand Up @@ -79,7 +80,7 @@ protected function detectConsoleEnvironment($environments, array $args): string
*/
protected function getEnvironmentArgument(array $args): ?string
{
return array_first($args, function($value, $key)
return Arr::first($args, function($value, $key)
{
return starts_with($value, '--env');
});
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Routing\Matching\HostValidator;
use Illuminate\Routing\Matching\MethodValidator;
use Illuminate\Routing\Matching\SchemeValidator;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Symfony\Component\Routing\CompiledRoute;
use Symfony\Component\Routing\Route as SymfonyRoute;
Expand Down Expand Up @@ -503,7 +504,7 @@ protected function parseAction($action)
*/
protected function findClosure(array $action)
{
return array_first($action, function($value, $key)
return Arr::first($action, function($value, $key)
{
return is_callable($value);
});
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Routing/RouteCollection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Illuminate\Routing;

use Illuminate\Support\Arr;
use Countable;
use ArrayIterator;
use IteratorAggregate;
Expand Down Expand Up @@ -221,7 +222,7 @@ protected function methodNotAllowed(array $others)
*/
protected function check(array $routes, $request, $includingMethod = true)
{
return array_first($routes, function($value, $key) use ($request, $includingMethod)
return Arr::first($routes, function($value, $key) use ($request, $includingMethod)
{
return $value->matches($request, $includingMethod);
});
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function first(?Closure $callback = null, $default = null)
return count($this->items) > 0 ? reset($this->items) : null;
}

return array_first($this->items, $callback, $default);
return Arr::first($this->items, $callback, $default);
}

/**
Expand Down Expand Up @@ -212,7 +212,7 @@ public function groupBy($groupBy)

foreach ($this->items as $key => $value)
{
$results[$this->getGroupByKey($groupBy, $key, $value)][] = $value;
$results[$this->getGroupByKey($groupBy, $key, $value) ?? ''][] = $value;
}

return new static($results);
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ function array_fetch($array, $key)
* @param \Closure $callback
* @param mixed $default
* @return mixed
*
* @deprecated Use \Illuminate\Support\Arr::first() instead.
*/
function array_first($array, $callback, $default = null)
{
Expand All @@ -193,6 +195,8 @@ function array_first($array, $callback, $default = null)
* @param \Closure $callback
* @param mixed $default
* @return mixed
*
* @deprecated Use \Illuminate\Support\Arr::last() instead.
*/
function array_last($array, $callback, $default = null)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/View/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Closure;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\View\Engines\EngineResolver;
use Illuminate\Support\Contracts\ArrayableInterface as Arrayable;
Expand Down Expand Up @@ -272,7 +273,7 @@ protected function getExtension($path)
{
$extensions = array_keys($this->extensions);

return array_first($extensions, function($value, $key) use ($path)
return Arr::first($extensions, function($value, $key) use ($path)
{
return ends_with($path, $value);
});
Expand Down
Loading