]> git.mxchange.org Git - friendica.git/commitdiff
Improve argument handling in Core\Worker::add
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 16 Oct 2021 23:06:43 +0000 (19:06 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 16 Oct 2021 23:19:56 +0000 (19:19 -0400)
- The argument name made it unclear the first argument is supposed to be a priority number

src/Core/Worker.php

index 3519ce3e519f8e71c805c1eeba406b94e639f026..0431c79521507e646bc4b0b990e2fe892ccd4d8e 100644 (file)
@@ -1199,10 +1199,8 @@ class Worker
         *    array $arr
         *
         */
-       public static function add($cmd)
+       public static function add(...$args)
        {
-               $args = func_get_args();
-
                if (!count($args)) {
                        return 0;
                }
@@ -1241,6 +1239,8 @@ class Worker
                        if (isset($run_parameter['force_priority'])) {
                                $force_priority = $run_parameter['force_priority'];
                        }
+               } else {
+                       throw new \InvalidArgumentException('Priority number or task parameter array expected as first argument');
                }
 
                $command = array_shift($args);