jenkins-bot has submitted this change and it was merged. Change subject: Use static::class instead of get_called_class() ......................................................................
Use static::class instead of get_called_class() Available as of PHP 5.5 and more idomatic. Foo::class (explicit), self::class (defined), and static::class (late bound). Change-Id: I66937f32095a4e4ecde94ca20a935a3c3efc9cee --- M includes/libs/GenericArrayObject.php M tests/phpunit/MediaWikiTestCase.php M tests/phpunit/includes/actions/ActionTest.php M tests/phpunit/languages/LanguageClassesTestCase.php 4 files changed, 7 insertions(+), 7 deletions(-) Approvals: Jforrester: Looks good to me, but someone else must approve Addshore: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/libs/GenericArrayObject.php b/includes/libs/GenericArrayObject.php index dec55c9..76e23cf 100644 --- a/includes/libs/GenericArrayObject.php +++ b/includes/libs/GenericArrayObject.php @@ -144,7 +144,7 @@ if ( !$this->hasValidType( $value ) ) { throw new InvalidArgumentException( 'Can only add ' . $this->getObjectType() . ' implementing objects to ' - . get_called_class() . '.' + . static::class . '.' ); } diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index da9c03a..d5192ac 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -102,7 +102,7 @@ // Complain if self::setUp() was called, but not self::tearDown() // $this->called['setUp'] will be checked by self::testMediaWikiTestCaseParentSetupCalled() if ( isset( $this->called['setUp'] ) && !isset( $this->called['tearDown'] ) ) { - throw new MWException( get_called_class() . "::tearDown() must call parent::tearDown()" ); + throw new MWException( static::class . "::tearDown() must call parent::tearDown()" ); } } @@ -294,7 +294,7 @@ */ final public function testMediaWikiTestCaseParentSetupCalled() { $this->assertArrayHasKey( 'setUp', $this->called, - get_called_class() . "::setUp() must call parent::setUp()" + static::class . '::setUp() must call parent::setUp()' ); } diff --git a/tests/phpunit/includes/actions/ActionTest.php b/tests/phpunit/includes/actions/ActionTest.php index 462c715..4a30292 100644 --- a/tests/phpunit/includes/actions/ActionTest.php +++ b/tests/phpunit/includes/actions/ActionTest.php @@ -187,7 +187,7 @@ class DummyAction extends Action { public function getName() { - return get_called_class(); + return static::class; } public function show() { diff --git a/tests/phpunit/languages/LanguageClassesTestCase.php b/tests/phpunit/languages/LanguageClassesTestCase.php index f93ff7d..2216ba4 100644 --- a/tests/phpunit/languages/LanguageClassesTestCase.php +++ b/tests/phpunit/languages/LanguageClassesTestCase.php @@ -47,7 +47,7 @@ */ protected function setUp() { parent::setUp(); - $found = preg_match( '/Language(.+)Test/', get_called_class(), $m ); + $found = preg_match( '/Language(.+)Test/', static::class, $m ); if ( $found ) { # Normalize language code since classes uses underscores $m[1] = strtolower( str_replace( '_', '-', $m[1] ) ); @@ -55,8 +55,8 @@ # Fallback to english language $m[1] = 'en'; wfDebug( - __METHOD__ . " could not extract a language name " - . "out of " . get_called_class() . " failling back to 'en'\n" + __METHOD__ . ' could not extract a language name ' + . 'out of ' . static::class . " failling back to 'en'\n" ); } // @todo validate $m[1] which should be a valid language code -- To view, visit https://gerrit.wikimedia.org/r/273302 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I66937f32095a4e4ecde94ca20a935a3c3efc9cee Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits