php-cron-scheduler
php-cron-scheduler copied to clipboard
Unexpected argument passed into Job->call()'s Closure
Environment
- PHP 5.6
-
composer require peppeocchi/php-cron-scheduler:^2.3
How to Reproduce
$scheduler = new \GO\Scheduler()
$scheduler->call(
function($args) {
echo $args["foo"];
},
["foo" => "bar"],
"ident"
)->everyMinute();
$scheduler->run();
Expected Behavior
Within the closure, and based on the docs, I expect $args
to be an array and for $args["foo"]
to equal "bar"
.
Observed Behavior
However, that actual value of $args
is a string that equals "bar"
.
Possible Solutions
- Change the docs
- Change
call_user_func_array($fn, $args)
tocall_user_func($fn, $args)
- https://github.com/peppeocchi/php-cron-scheduler/blob/master/src/GO/Job.php#L431
Hi @veloper thanks for pointing that out, I think the safest approach is just to update the docs what do you think? If the second solution is not causing any breaking change I'd be happy to go for n.2
Do you want to create a PR with your solution?
@peppeocchi - I'd go with the safest approach as well; update the docs. Normally I'd make a PR but I'm under a deadline right now.