Have ServiceContainer implement PSR-11
[lhc/web/wiklou.git] / includes / libs / services / ServiceContainer.php
index dd0d081..d1f1052 100644 (file)
@@ -3,6 +3,7 @@
 namespace Wikimedia\Services;
 
 use InvalidArgumentException;
+use Psr\Container\ContainerInterface;
 use RuntimeException;
 use Wikimedia\Assert\Assert;
 
@@ -44,7 +45,7 @@ use Wikimedia\Assert\Assert;
  * @see docs/injection.txt for an overview of using dependency injection in the
  *      MediaWiki code base.
  */
-class ServiceContainer implements DestructibleService {
+class ServiceContainer implements ContainerInterface, DestructibleService {
 
        /**
         * @var object[]
@@ -193,6 +194,11 @@ class ServiceContainer implements DestructibleService {
                return isset( $this->serviceInstantiators[$name] );
        }
 
+       /** @inheritDoc */
+       public function has( $name ) {
+               return $this->hasService( $name );
+       }
+
        /**
         * Returns the service instance for $name only if that service has already been instantiated.
         * This is intended for situations where services get destroyed/cleaned up, so we can
@@ -418,6 +424,11 @@ class ServiceContainer implements DestructibleService {
                return $this->services[$name];
        }
 
+       /** @inheritDoc */
+       public function get( $name ) {
+               return $this->getService( $name );
+       }
+
        /**
         * @param string $name
         *