From a94c300c0a1bbb9eece351eac2a44ea464da195d Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 5 Apr 2019 01:09:30 +0100 Subject: [PATCH] jobqueue: Change internal $params logic to teach Phan (3) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- includes/jobqueue/Job.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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(); } -- 2.20.1