"pear/mail_mime": "1.10.2",
"pear/net_smtp": "1.8.1",
"php": ">=5.6.99",
+ "psr/container": "1.0.0",
"psr/log": "1.0.2",
"wikimedia/assert": "0.2.2",
"wikimedia/at-ease": "2.0.0",
namespace Wikimedia\Services;
use Exception;
+use Psr\Container\ContainerExceptionInterface;
use RuntimeException;
/**
/**
* Exception thrown when trying to replace an already active service.
*/
-class CannotReplaceActiveServiceException extends RuntimeException {
+class CannotReplaceActiveServiceException extends RuntimeException
+ implements ContainerExceptionInterface {
/**
* @param string $serviceName
namespace Wikimedia\Services;
use Exception;
+use Psr\Container\ContainerExceptionInterface;
use RuntimeException;
/**
/**
* Exception thrown when trying to access a service on a disabled container or factory.
*/
-class ContainerDisabledException extends RuntimeException {
+class ContainerDisabledException extends RuntimeException
+ implements ContainerExceptionInterface {
/**
* @param Exception|null $previous
namespace Wikimedia\Services;
use Exception;
+use Psr\Container\NotFoundExceptionInterface;
use RuntimeException;
/**
/**
* Exception thrown when the requested service is not known.
*/
-class NoSuchServiceException extends RuntimeException {
+class NoSuchServiceException extends RuntimeException
+ implements NotFoundExceptionInterface {
/**
* @param string $serviceName
namespace Wikimedia\Services;
use Exception;
+use Psr\Container\ContainerExceptionInterface;
use RuntimeException;
/**
* Exception thrown when a service was already defined, but the
* caller expected it to not exist.
*/
-class ServiceAlreadyDefinedException extends RuntimeException {
+class ServiceAlreadyDefinedException extends RuntimeException
+ implements ContainerExceptionInterface {
/**
* @param string $serviceName
namespace Wikimedia\Services;
use InvalidArgumentException;
+use Psr\Container\ContainerInterface;
use RuntimeException;
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[]
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
return $this->services[$name];
}
+ /** @inheritDoc */
+ public function get( $name ) {
+ return $this->getService( $name );
+ }
+
/**
* @param string $name
*
namespace Wikimedia\Services;
use Exception;
+use Psr\Container\ContainerExceptionInterface;
use RuntimeException;
/**
/**
* Exception thrown when trying to access a disabled service.
*/
-class ServiceDisabledException extends RuntimeException {
+class ServiceDisabledException extends RuntimeException
+ implements ContainerExceptionInterface {
/**
* @param string $serviceName