Skip to content

Commit 1753236

Browse files
authored
Added full callable support to schedule:list (#42400)
* Added full callable support to `schedule:list` * Formatting * Formatting
1 parent 252d81b commit 1753236

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/Illuminate/Console/Scheduling/ScheduleListCommand.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Console\Scheduling;
44

5+
use Closure;
56
use Cron\CronExpression;
67
use DateTimeZone;
78
use Illuminate\Console\Application;
@@ -173,15 +174,25 @@ private function formatCronExpression($expression, $spacing)
173174
*/
174175
private function getClosureLocation(CallbackEvent $event)
175176
{
176-
$function = new ReflectionFunction(tap((new ReflectionClass($event))->getProperty('callback'))
177+
$callback = tap((new ReflectionClass($event))->getProperty('callback'))
177178
->setAccessible(true)
178-
->getValue($event));
179+
->getValue($event);
179180

180-
return sprintf(
181-
'%s:%s',
182-
str_replace($this->laravel->basePath().DIRECTORY_SEPARATOR, '', $function->getFileName() ?: ''),
183-
$function->getStartLine()
184-
);
181+
if ($callback instanceof Closure) {
182+
$function = new ReflectionFunction($callback);
183+
184+
return sprintf(
185+
'%s:%s',
186+
str_replace($this->laravel->basePath().DIRECTORY_SEPARATOR, '', $function->getFileName() ?: ''),
187+
$function->getStartLine()
188+
);
189+
}
190+
191+
if (is_array($callback)) {
192+
return sprintf('%s::%s', $callback[0]::class, $callback[1]);
193+
}
194+
195+
return sprintf('%s::__invoke', $callback::class);
185196
}
186197

187198
/**

0 commit comments

Comments
 (0)