diff --git a/tests/phpunit/includes/filerepo/file/FileTest.php b/tests/phpunit/includes/filerepo/file/FileTest.php index 6d8ac700c67..8e0da2ea592 100644 --- a/tests/phpunit/includes/filerepo/file/FileTest.php +++ b/tests/phpunit/includes/filerepo/file/FileTest.php @@ -477,7 +477,7 @@ class FileTest extends MediaWikiMediaTestCase { * @covers File::getHandlerState */ public function testSetHandlerState() { - $obj = new stdClass; + $obj = (object)[]; $file = new class extends File { public function __construct() { } diff --git a/tests/phpunit/integration/includes/user/UserRightsProxyTest.php b/tests/phpunit/integration/includes/user/UserRightsProxyTest.php index d3882a97670..b55cd818a75 100644 --- a/tests/phpunit/integration/includes/user/UserRightsProxyTest.php +++ b/tests/phpunit/integration/includes/user/UserRightsProxyTest.php @@ -5,7 +5,6 @@ namespace MediaWiki\Tests\User; use MediaWiki\User\UserGroupManager; use MediaWiki\User\UserGroupManagerFactory; use MediaWikiIntegrationTestCase; -use stdClass; use UserRightsProxy; use Wikimedia\Rdbms\ILoadBalancer; use Wikimedia\Rdbms\LBFactory; @@ -27,9 +26,10 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase { $dbMock = $this->createMock( MaintainableDBConnRef::class ); - $row = new stdClass; - $row->user_name = 'UserRightsProxyTest'; - $row->user_id = 12345; + $row = (object)[ + 'user_name' => 'UserRightsProxyTest', + 'user_id' => 12345, + ]; $dbMock->method( 'selectRow' )->willReturn( $row ); $lbMock = $this->createMock( ILoadBalancer::class ); @@ -138,7 +138,7 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase { $userGroupManagerMock ->expects( $this->once() ) ->method( 'getUserGroupMemberships' ) - ->willReturn( [ 'bot' => new stdClass, 'sysop' => new stdClass ] ); + ->willReturn( [ 'bot' => (object)[], 'sysop' => (object)[] ] ); $userGroupManagerFactoryMock = $this->createMock( UserGroupManagerFactory::class ); $userGroupManagerFactoryMock ->method( 'getUserGroupManager' ) @@ -161,7 +161,7 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase { $userGroupManagerMock2 ->expects( $this->exactly( 2 ) ) ->method( 'getUserGroupMemberships' ) - ->willReturn( [ 'bot' => new stdClass ] ); + ->willReturn( [ 'bot' => (object)[] ] ); $userGroupManagerFactoryMock2 = $this->createMock( UserGroupManagerFactory::class ); $userGroupManagerFactoryMock2 ->method( 'getUserGroupManager' ) @@ -184,9 +184,10 @@ class UserRightsProxyTest extends MediaWikiIntegrationTestCase { $value = 'bar'; $dbMock = $this->createMock( MaintainableDBConnRef::class ); - $row = new stdClass; - $row->user_name = 'UserRightsProxyTest'; - $row->user_id = 12345; + $row = (object)[ + 'user_name' => 'UserRightsProxyTest', + 'user_id' => 12345, + ]; $dbMock->method( 'selectRow' )->willReturn( $row ); $dbMock->method( 'timestamp' )->willReturn( 'timestamp' ); $dbMock->method( 'getDomainID' )->willReturn( 'foowiki' ); diff --git a/tests/phpunit/unit/includes/json/JsonCodecTest.php b/tests/phpunit/unit/includes/json/JsonCodecTest.php index 7d1849d1974..632c7e27ef5 100644 --- a/tests/phpunit/unit/includes/json/JsonCodecTest.php +++ b/tests/phpunit/unit/includes/json/JsonCodecTest.php @@ -8,7 +8,6 @@ use JsonSerializable; use MediaWiki\Json\JsonCodec; use MediaWiki\Json\JsonConstants; use MediaWikiUnitTestCase; -use stdClass; use Title; use Wikimedia\Assert\PreconditionException; @@ -136,7 +135,7 @@ class JsonCodecTest extends MediaWikiUnitTestCase { yield 'Null' => [ null, true, null ]; yield 'Class' => [ $classInstance, false, '$' ]; yield 'Empty array' => [ [], true, null ]; - yield 'Empty stdClass' => [ new stdClass(), true, null ]; + yield 'Empty stdClass' => [ (object)[], true, null ]; yield 'Non-empty array' => [ [ 1, 2, 3 ], true, null ]; yield 'Non-empty map' => [ [ 'a' => 'b' ], true, null ]; yield 'Nested, serializable' => [ [ 'a' => [ 'b' => [ 'c' => 'd' ] ] ], true, null ]; diff --git a/tests/phpunit/unit/includes/media/TrivialMediaHandlerStateTest.php b/tests/phpunit/unit/includes/media/TrivialMediaHandlerStateTest.php index 17e46d049f6..7acafbee0c5 100644 --- a/tests/phpunit/unit/includes/media/TrivialMediaHandlerStateTest.php +++ b/tests/phpunit/unit/includes/media/TrivialMediaHandlerStateTest.php @@ -5,7 +5,7 @@ */ class TrivialMediaHandlerStateTest extends MediaWikiUnitTestCase { public function testSetHandlerState() { - $obj = new stdClass; + $obj = (object)[]; $state = new TrivialMediaHandlerState; $this->assertNull( $state->getHandlerState( 'test' ) ); $state->setHandlerState( 'test', $obj ); diff --git a/tests/phpunit/unit/includes/skins/SkinFactoryTest.php b/tests/phpunit/unit/includes/skins/SkinFactoryTest.php index 327b66a6fd4..d25ea45784e 100644 --- a/tests/phpunit/unit/includes/skins/SkinFactoryTest.php +++ b/tests/phpunit/unit/includes/skins/SkinFactoryTest.php @@ -90,7 +90,7 @@ class SkinFactoryTest extends \MediaWikiUnitTestCase { * @covers SkinFactory::makeSkin */ public function testMakeSkinWithValidSpec() { - $serviceInstance = new stdClass(); + $serviceInstance = (object)[]; $serviceContainer = $this->createMock( ContainerInterface::class ); $serviceContainer->method( 'has' )->willReturn( true );