Add static return type for ParserOutput::getExternalLinks
PHPUnit tests that mock the ParserOutput object are unable to correctly infer that the mock should return an empty array rather than null for `getExternalLinks`. This is currently causing test failures in SpamBlacklist in CI. Add the return type definition to the function field definition so that PHPUnit has a better chance at doing the right thing. Note that `getExternalLinks` returns `$this->mExternalLinks` by reference; if there’s some existing code which reassigns a non-array value to that reference (and, consequently, to `$this->mExternalLinks`, such code will start to throw TypeErrors during the assignment. Bug: T376633 Change-Id: I246d5541200c9d0c405f30ea9de091ff9c0e759c
This commit is contained in:
parent
bca1a4932c
commit
9ae964fde7
1 changed files with 2 additions and 2 deletions
|
|
@ -195,7 +195,7 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
|
|||
/**
|
||||
* @var array<string,int> External link URLs, in the key only.
|
||||
*/
|
||||
private $mExternalLinks = [];
|
||||
private array $mExternalLinks = [];
|
||||
|
||||
/**
|
||||
* @var array<string,array<string,int>> 2-D map of prefix/DBK (in keys only)
|
||||
|
|
@ -799,7 +799,7 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
|
|||
return $this->mFileSearchOptions;
|
||||
}
|
||||
|
||||
public function &getExternalLinks() {
|
||||
public function &getExternalLinks(): array {
|
||||
return $this->mExternalLinks;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue