From: Erik Bernhardson Date: Fri, 8 Jun 2018 20:51:44 +0000 (-0700) Subject: Remove PhanUndeclaredStaticMethod from blacklist X-Git-Tag: 1.34.0-rc.0~4279^2 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=08dba3de303a44ffae5e60eaec62cad562407f4b;p=lhc%2Fweb%2Fwiklou.git Remove PhanUndeclaredStaticMethod from blacklist There was a single instance of this issue which was reasonably simple to solve. The code that triggered the issue was not wrong, but calling the grandparent constructor directly is not the cleanest code so it seems right to fix it. Switch revision initialization into an overridable function to remove the need to even have a constructor in the class. Change-Id: Ic2af0d93e8d55e93061e3f4b5c7a4122509543f0 --- diff --git a/includes/revisiondelete/RevDelArchiveItem.php b/includes/revisiondelete/RevDelArchiveItem.php index 679acc6493..11f2d133b4 100644 --- a/includes/revisiondelete/RevDelArchiveItem.php +++ b/includes/revisiondelete/RevDelArchiveItem.php @@ -23,10 +23,9 @@ * Item class for a archive table row */ class RevDelArchiveItem extends RevDelRevisionItem { - public function __construct( $list, $row ) { - RevDelItem::__construct( $list, $row ); - $this->revision = Revision::newFromArchiveRow( $row, - [ 'page' => $this->list->title->getArticleID() ] ); + protected static function initRevision( $list, $row ) { + return Revision::newFromArchiveRow( $row, + [ 'page' => $list->title->getArticleID() ] ); } public function getIdField() { diff --git a/includes/revisiondelete/RevDelArchivedFileItem.php b/includes/revisiondelete/RevDelArchivedFileItem.php index d36fac9244..00e40a0b5e 100644 --- a/includes/revisiondelete/RevDelArchivedFileItem.php +++ b/includes/revisiondelete/RevDelArchivedFileItem.php @@ -29,11 +29,14 @@ class RevDelArchivedFileItem extends RevDelFileItem { protected $lockFile; public function __construct( $list, $row ) { - RevDelItem::__construct( $list, $row ); - $this->file = ArchivedFile::newFromRow( $row ); + parent::__construct( $list, $row ); $this->lockFile = RepoGroup::singleton()->getLocalRepo()->newFile( $row->fa_name ); } + protected static function initFile( $list, $row ) { + return ArchivedFile::newFromRow( $row ); + } + public function getIdField() { return 'fa_id'; } diff --git a/includes/revisiondelete/RevDelArchivedRevisionItem.php b/includes/revisiondelete/RevDelArchivedRevisionItem.php index d839fcfc5b..fd214e176e 100644 --- a/includes/revisiondelete/RevDelArchivedRevisionItem.php +++ b/includes/revisiondelete/RevDelArchivedRevisionItem.php @@ -24,13 +24,6 @@ * used via RevDelRevisionList. */ class RevDelArchivedRevisionItem extends RevDelArchiveItem { - public function __construct( $list, $row ) { - RevDelItem::__construct( $list, $row ); - - $this->revision = Revision::newFromArchiveRow( $row, - [ 'page' => $this->list->title->getArticleID() ] ); - } - public function getIdField() { return 'ar_rev_id'; } diff --git a/includes/revisiondelete/RevDelFileItem.php b/includes/revisiondelete/RevDelFileItem.php index 0ca84d7f51..c7941b7658 100644 --- a/includes/revisiondelete/RevDelFileItem.php +++ b/includes/revisiondelete/RevDelFileItem.php @@ -30,7 +30,18 @@ class RevDelFileItem extends RevDelItem { public function __construct( $list, $row ) { parent::__construct( $list, $row ); - $this->file = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row ); + $this->file = static::initFile( $list, $row ); + } + + /** + * Create file object from $row sourced from $list + * + * @param RevDelFileList $list + * @param mixed $row + * @return mixed + */ + protected static function initFile( $list, $row ) { + return RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row ); } public function getIdField() { diff --git a/includes/revisiondelete/RevDelRevisionItem.php b/includes/revisiondelete/RevDelRevisionItem.php index 7b5d130b24..2cfa2abe52 100644 --- a/includes/revisiondelete/RevDelRevisionItem.php +++ b/includes/revisiondelete/RevDelRevisionItem.php @@ -28,7 +28,18 @@ class RevDelRevisionItem extends RevDelItem { public function __construct( $list, $row ) { parent::__construct( $list, $row ); - $this->revision = new Revision( $row ); + $this->revision = static::initRevision( $list, $row ); + } + + /** + * Create revision object from $row sourced from $list + * + * @param RevisionListBase $list + * @param mixed $row + * @return Revision + */ + protected static function initRevision( $list, $row ) { + return new Revision( $row ); } public function getIdField() { diff --git a/tests/phan/config.php b/tests/phan/config.php index f76b1e370d..585ebb975b 100644 --- a/tests/phan/config.php +++ b/tests/phan/config.php @@ -346,8 +346,6 @@ return [ "PhanUndeclaredMethod", // approximate error count: 1224 "PhanUndeclaredProperty", - // approximate error count: 3 - "PhanUndeclaredStaticMethod", // approximate error count: 58 "PhanUndeclaredVariableDim", ],