From 755ac5f3e91511ade53c8dd692fdcece60c35498 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Tue, 8 Oct 2019 11:23:08 -0700 Subject: [PATCH] Services: Convert PermissionManager's static to a const now HHVM is gone Change-Id: Ib75b6f5d6b3e793ddbce42951693d8c99e6b7e57 (cherry picked from commit 9cba9f8567ade9a142a49a75b834d1b938c18336) --- includes/Permissions/PermissionManager.php | 6 ++---- includes/ServiceWiring.php | 2 +- includes/config/ServiceOptions.php | 12 ++++++------ .../includes/Permissions/PermissionManagerTest.php | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/includes/Permissions/PermissionManager.php b/includes/Permissions/PermissionManager.php index ef6b8ac5a9..a361639082 100644 --- a/includes/Permissions/PermissionManager.php +++ b/includes/Permissions/PermissionManager.php @@ -56,12 +56,10 @@ class PermissionManager { const RIGOR_SECURE = 'secure'; /** - * TODO Make this const when HHVM support is dropped (T192166) - * * @since 1.34 * @var array */ - public static $constructorOptions = [ + public const CONSTRUCTOR_OPTIONS = [ 'WhitelistRead', 'WhitelistReadRegexp', 'EmailConfirmToEdit', @@ -201,7 +199,7 @@ class PermissionManager { RevisionLookup $revisionLookup, NamespaceInfo $nsInfo ) { - $options->assertRequiredOptions( self::$constructorOptions ); + $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS ); $this->options = $options; $this->specialPageFactory = $specialPageFactory; $this->revisionLookup = $revisionLookup; diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 2c1725ed75..4692d05ca9 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -545,7 +545,7 @@ return [ 'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager { return new PermissionManager( new ServiceOptions( - PermissionManager::$constructorOptions, $services->getMainConfig() + PermissionManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ), $services->getSpecialPageFactory(), $services->getRevisionLookup(), diff --git a/includes/config/ServiceOptions.php b/includes/config/ServiceOptions.php index 6ae059ebff..46f6689b8e 100644 --- a/includes/config/ServiceOptions.php +++ b/includes/config/ServiceOptions.php @@ -13,12 +13,12 @@ use Wikimedia\Assert\Assert; * objects). * * Services that take this type as a parameter to their constructor should specify a list of the - * keys they expect to receive in an array. The convention is to make it a public static variable - * called $constructorOptions. (When we drop HHVM support -- see T192166 -- it should become a - * const.) In the constructor, they should call assertRequiredOptions() to make sure that they - * weren't passed too few or too many options. This way it's clear what each class depends on, and - * that it's getting passed the correct set of options. (This means there are no optional options. - * This makes sense for services, since they shouldn't be constructed by outside code.) + * keys they expect to receive in an array. The convention is to make it a public const called + * CONSTRUCTOR_OPTIONS. In the constructor, they should call assertRequiredOptions() to make sure + * that they weren't passed too few or too many options. This way it's clear what each class + * depends on, and that it's getting passed the correct set of options. (This means there are no + * optional options. This makes sense for services, since they shouldn't be constructed by + * outside code.) * * @since 1.34 */ diff --git a/tests/phpunit/includes/Permissions/PermissionManagerTest.php b/tests/phpunit/includes/Permissions/PermissionManagerTest.php index 0e788e7455..683e89dddf 100644 --- a/tests/phpunit/includes/Permissions/PermissionManagerTest.php +++ b/tests/phpunit/includes/Permissions/PermissionManagerTest.php @@ -722,7 +722,7 @@ class PermissionManagerTest extends MediaWikiLangTestCase { $permissionManager = new PermissionManager( new LoggedServiceOptions( self::$serviceOptionsAccessLog, - PermissionManager::$constructorOptions, + PermissionManager::CONSTRUCTOR_OPTIONS, [ 'WhitelistRead' => [], 'WhitelistReadRegexp' => [], -- 2.20.1