ConnectionManager: Require ILoadBalancer instead of LoadBalancer
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 14 May 2018 11:27:23 +0000 (13:27 +0200)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 14 May 2018 11:27:23 +0000 (13:27 +0200)
Since I4fdf7f7 more code stops returning the implementation, but only
returns the interface. This is a good, very welcome change. However,
ConnectionManager still requires the LoadBalancer implementation, for
no obvious reason. All code in this class works fine with the interface.

This is currently reported by Phan as a violation (and it actually is
one), e.g.:
https://integration.wikimedia.org/ci/job/mwext-php70-phan-docker/6433/console

Change-Id: I63cbb98fd277b0c64ab8b303888b9354c4be29e2

includes/libs/rdbms/connectionmanager/ConnectionManager.php

index 4a497b0..27e6138 100644 (file)
@@ -35,7 +35,7 @@ use InvalidArgumentException;
 class ConnectionManager {
 
        /**
-        * @var LoadBalancer
+        * @var ILoadBalancer
         */
        private $loadBalancer;
 
@@ -52,14 +52,14 @@ class ConnectionManager {
        private $groups = [];
 
        /**
-        * @param LoadBalancer $loadBalancer
+        * @param ILoadBalancer $loadBalancer
         * @param string|bool $domain Optional logical DB name, defaults to current wiki.
         *        This follows the convention for database names used by $loadBalancer.
         * @param string[] $groups see LoadBalancer::getConnection
         *
         * @throws InvalidArgumentException
         */
-       public function __construct( LoadBalancer $loadBalancer, $domain = false, array $groups = [] ) {
+       public function __construct( ILoadBalancer $loadBalancer, $domain = false, array $groups = [] ) {
                if ( !is_string( $domain ) && $domain !== false ) {
                        throw new InvalidArgumentException( '$dbName must be a string, or false.' );
                }