Services: Convert PermissionManager's static to a const now HHVM is gone
authorJames D. Forrester <jforrester@wikimedia.org>
Tue, 8 Oct 2019 18:23:08 +0000 (11:23 -0700)
committerJforrester <jforrester@wikimedia.org>
Tue, 8 Oct 2019 20:05:40 +0000 (20:05 +0000)
Change-Id: Ib75b6f5d6b3e793ddbce42951693d8c99e6b7e57
(cherry picked from commit 9cba9f8567ade9a142a49a75b834d1b938c18336)

includes/Permissions/PermissionManager.php
includes/ServiceWiring.php
includes/config/ServiceOptions.php
tests/phpunit/includes/Permissions/PermissionManagerTest.php

index ef6b8ac..a361639 100644 (file)
@@ -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;
index 2c1725e..4692d05 100644 (file)
@@ -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(),
index 6ae059e..46f6689 100644 (file)
@@ -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
  */
index 0e788e7..683e89d 100644 (file)
@@ -722,7 +722,7 @@ class PermissionManagerTest extends MediaWikiLangTestCase {
                $permissionManager = new PermissionManager(
                        new LoggedServiceOptions(
                                self::$serviceOptionsAccessLog,
-                               PermissionManager::$constructorOptions,
+                               PermissionManager::CONSTRUCTOR_OPTIONS,
                                [
                                        'WhitelistRead' => [],
                                        'WhitelistReadRegexp' => [],