Skip to content

Commit

Permalink
Merge "Replace new stdClass with more compact array syntax"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Nov 2, 2021
2 parents b6a4acb ee0f973 commit 7e1cd81
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/includes/filerepo/file/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 477,7 @@ public function testNormalizeTitleFails( $title ) {
* @covers File::getHandlerState
*/
public function testSetHandlerState() {
$obj = new stdClass;
$obj = (object)[];
$file = new class extends File {
public function __construct() {
}
Expand Down
19 changes: 10 additions & 9 deletions tests/phpunit/integration/includes/user/UserRightsProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,6 @@
use MediaWiki\User\UserGroupManager;
use MediaWiki\User\UserGroupManagerFactory;
use MediaWikiIntegrationTestCase;
use stdClass;
use UserRightsProxy;
use Wikimedia\Rdbms\ILoadBalancer;
use Wikimedia\Rdbms\LBFactory;
Expand All @@ -27,9 26,10 @@ protected function setUp(): void {

$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 );
Expand Down Expand Up @@ -138,7 138,7 @@ public function testGroupMethods() {
$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' )
Expand All @@ -161,7 161,7 @@ public function testGroupMethods() {
$userGroupManagerMock2
->expects( $this->exactly( 2 ) )
->method( 'getUserGroupMemberships' )
->willReturn( [ 'bot' => new stdClass ] );
->willReturn( [ 'bot' => (object)[] ] );
$userGroupManagerFactoryMock2 = $this->createMock( UserGroupManagerFactory::class );
$userGroupManagerFactoryMock2
->method( 'getUserGroupManager' )
Expand All @@ -184,9 184,10 @@ public function testOptions() {
$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' );
Expand Down
3 changes: 1 addition & 2 deletions tests/phpunit/unit/includes/json/JsonCodecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 8,6 @@
use MediaWiki\Json\JsonCodec;
use MediaWiki\Json\JsonConstants;
use MediaWikiUnitTestCase;
use stdClass;
use Title;
use Wikimedia\Assert\PreconditionException;

Expand Down Expand Up @@ -136,7 135,7 @@ public function jsonSerialize() {
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 ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/unit/includes/skins/SkinFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 90,7 @@ public function testMakeSkinWithValidCallback() {
* @covers SkinFactory::makeSkin
*/
public function testMakeSkinWithValidSpec() {
$serviceInstance = new stdClass();
$serviceInstance = (object)[];

$serviceContainer = $this->createMock( ContainerInterface::class );
$serviceContainer->method( 'has' )->willReturn( true );
Expand Down

0 comments on commit 7e1cd81

Please sign in to comment.