From: Timo Tijhof Date: Fri, 5 Apr 2019 00:09:30 +0000 (+0100) Subject: jobqueue: Change internal $params logic to teach Phan (3) X-Git-Tag: 1.34.0-rc.0~2142^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=a94c300c0a1bbb9eece351eac2a44ea464da195d;p=lhc%2Fweb%2Fwiklou.git jobqueue: Change internal $params logic to teach Phan (3) Follows-up 9b4938c40d02c, 4bff6f1558, 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 --- diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php index 55cb942a3f..060003b2ec 100644 --- a/includes/jobqueue/Job.php +++ b/includes/jobqueue/Job.php @@ -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(); }