jobqueue: Change internal $params logic to teach Phan (3)
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 5 Apr 2019 00:09:30 +0000 (01:09 +0100)
committerKrinkle <krinklemail@gmail.com>
Fri, 5 Apr 2019 18:01:12 +0000 (18:01 +0000)
Follows-up 9b4938c40d02c4bff6f1558, and 766549999c.

It seems despite being optional and documented as 'array|Title',
Phan still thinks it is wrong to pass Title.

Try removing the explicit default of empty array,
the lower code already does this anyway.

This should fix build failures that are preventing merges
in repos where Phan is finding Job::__construct(string, Title)
where it currently fails as follows:

 CompileArticleMetadataJob.php:11
 PhanTypeMismatchArgument Argument 2 (params) is …\Title|string but
 \Job::__construct() takes array

Change-Id: I1c3aee273e0917e30b9c18b49b24fc7f966ff57c

includes/jobqueue/Job.php

index 55cb942..060003b 100644 (file)
@@ -106,13 +106,13 @@ abstract class Job implements IJobSpecification {
 
        /**
         * @param string $command
-        * @param array|Title $params
+        * @param array|Title|null $params
         */
-       public function __construct( $command, $params = [] ) {
+       public function __construct( $command, $params = null ) {
                if ( $params instanceof Title ) {
                        // Backwards compatibility for old signature ($command, $title, $params)
                        $title = $params;
-                       $params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
+                       $params = func_get_arg( 2 );
                } else {
                        // Subclasses can override getTitle() to return something more meaningful
                        $title = Title::makeTitle( NS_SPECIAL, 'Blankpage' );
@@ -120,7 +120,7 @@ abstract class Job implements IJobSpecification {
 
                $this->command = $command;
                $this->title = $title;
-               $this->params = is_array( $params ) ? $params : []; // sanity
+               $this->params = is_array( $params ) ? $params : [];
                if ( !isset( $this->params['requestId'] ) ) {
                        $this->params['requestId'] = WebRequest::getRequestId();
                }