Skip to content

Commit

Permalink
[6.x] Adjust is_callable usage where needed for PHP 8 (#34999)
Browse files Browse the repository at this point in the history
* adjust is_callable usage where needed for php8

* Apply fixes from StyleCI (#35000)
  • Loading branch information
taylorotwell authored Oct 27, 2020
1 parent 043768d commit 6611265
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Illuminate/Console/Scheduling/CallbackEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Console\Scheduling;

use Illuminate\Contracts\Container\Container;
use Illuminate\Support\Reflector;
use InvalidArgumentException;
use LogicException;

Expand Down Expand Up @@ -35,7 +36,7 @@ class CallbackEvent extends Event
*/
public function __construct(EventMutex $mutex, $callback, array $parameters = [], $timezone = null)
{
if (! is_string($callback) && ! is_callable($callback)) {
if (! is_string($callback) && ! Reflector::isCallable($callback)) {
throw new InvalidArgumentException(
'Invalid scheduled callback event. Must be a string or callable.'
);
Expand Down Expand Up @@ -163,6 +164,6 @@ public function getSummaryForDisplay()
return $this->description;
}

return is_string($this->callback) ? $this->callback : 'Closure';
return is_string($this->callback) ? $this->callback : 'Callback';
}
}
5 changes: 3 additions & 2 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Reflector;
use Illuminate\Support\Traits\Macroable;
use Psr\Http\Client\ClientExceptionInterface;
use Symfony\Component\Process\Process;
Expand Down Expand Up @@ -672,7 +673,7 @@ public function onOneServer()
*/
public function when($callback)
{
$this->filters[] = is_callable($callback) ? $callback : function () use ($callback) {
$this->filters[] = Reflector::isCallable($callback) ? $callback : function () use ($callback) {
return $callback;
};

Expand All @@ -687,7 +688,7 @@ public function when($callback)
*/
public function skip($callback)
{
$this->rejects[] = is_callable($callback) ? $callback : function () use ($callback) {
$this->rejects[] = Reflector::isCallable($callback) ? $callback : function () use ($callback) {
return $callback;
};

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Reflector;
use Illuminate\Support\ViewErrorBag;
use Illuminate\Validation\ValidationException;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -103,7 +104,7 @@ public function report(Exception $e)
return;
}

if (is_callable($reportCallable = [$e, 'report'])) {
if (Reflector::isCallable($reportCallable = [$e, 'report'])) {
return $this->container->call($reportCallable);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/RouteSignatureParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected static function fromClassMethodString($uses)
{
[$class, $method] = Str::parseCallback($uses);

if (! method_exists($class, $method) && is_callable($class, $method)) {
if (! method_exists($class, $method) && Reflector::isCallable($class, $method)) {
return [];
}

Expand Down

0 comments on commit 6611265

Please sign in to comment.