From 98cb70f5d2e42dafa48413713cc60ddd881c54c6 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 23 Jun 2015 14:31:18 +0200 Subject: [ticket/13961] Move service_collection to di/service_collection namespace PHPBB3-13961 --- phpBB/phpbb/di/service_collection.php | 79 ---------------------- .../di/service_collection/service_collection.php | 79 ++++++++++++++++++++++ .../service_collection_iterator.php | 46 +++++++++++++ phpBB/phpbb/di/service_collection_iterator.php | 46 ------------- 4 files changed, 125 insertions(+), 125 deletions(-) delete mode 100644 phpBB/phpbb/di/service_collection.php create mode 100644 phpBB/phpbb/di/service_collection/service_collection.php create mode 100644 phpBB/phpbb/di/service_collection/service_collection_iterator.php delete mode 100644 phpBB/phpbb/di/service_collection_iterator.php (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/service_collection.php b/phpBB/phpbb/di/service_collection.php deleted file mode 100644 index 82ca9bf679..0000000000 --- a/phpBB/phpbb/di/service_collection.php +++ /dev/null @@ -1,79 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* Collection of services to be configured at container compile time. -*/ -class service_collection extends \ArrayObject -{ - /** - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $container; - - /** - * Constructor - * - * @param ContainerInterface $container Container object - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new service_collection_iterator($this); - } - - // Because of a PHP issue we have to redefine offsetExists - // (even with a call to the parent): - // https://bugs.php.net/bug.php?id=66834 - // https://bugs.php.net/bug.php?id=67067 - // But it triggers a sniffer issue that we have to skip - // @codingStandardsIgnoreStart - /** - * {@inheritdoc} - */ - public function offsetExists($index) - { - return parent::offsetExists($index); - } - // @codingStandardsIgnoreEnd - - /** - * {@inheritdoc} - */ - public function offsetGet($index) - { - return $this->container->get($index); - } - - /** - * Add a service to the collection - * - * @param string $name The service name - * @return null - */ - public function add($name) - { - $this->offsetSet($name, null); - } -} diff --git a/phpBB/phpbb/di/service_collection/service_collection.php b/phpBB/phpbb/di/service_collection/service_collection.php new file mode 100644 index 0000000000..8085128fed --- /dev/null +++ b/phpBB/phpbb/di/service_collection/service_collection.php @@ -0,0 +1,79 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\di\service_collection; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** +* Collection of services to be configured at container compile time. +*/ +class service_collection extends \ArrayObject +{ + /** + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * Constructor + * + * @param ContainerInterface $container Container object + */ + public function __construct(ContainerInterface $container) + { + $this->container = $container; + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + return new service_collection_iterator($this); + } + + // Because of a PHP issue we have to redefine offsetExists + // (even with a call to the parent): + // https://bugs.php.net/bug.php?id=66834 + // https://bugs.php.net/bug.php?id=67067 + // But it triggers a sniffer issue that we have to skip + // @codingStandardsIgnoreStart + /** + * {@inheritdoc} + */ + public function offsetExists($index) + { + return parent::offsetExists($index); + } + // @codingStandardsIgnoreEnd + + /** + * {@inheritdoc} + */ + public function offsetGet($index) + { + return $this->container->get($index); + } + + /** + * Add a service to the collection + * + * @param string $name The service name + * @return null + */ + public function add($name) + { + $this->offsetSet($name, null); + } +} diff --git a/phpBB/phpbb/di/service_collection/service_collection_iterator.php b/phpBB/phpbb/di/service_collection/service_collection_iterator.php new file mode 100644 index 0000000000..76e22b048e --- /dev/null +++ b/phpBB/phpbb/di/service_collection/service_collection_iterator.php @@ -0,0 +1,46 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\di\service_collection; + +/** +* Iterator which loads the services when they are requested +*/ +class service_collection_iterator extends \ArrayIterator +{ + /** + * @var \phpbb\di\service_collection\service_collection + */ + protected $collection; + + /** + * Construct an ArrayIterator for service_collection + * + * @param \phpbb\di\service_collection\service_collection $collection The collection to iterate over + * @param int $flags Flags to control the behaviour of the ArrayObject object. + * @see ArrayObject::setFlags() + */ + public function __construct(service_collection $collection, $flags = 0) + { + parent::__construct($collection, $flags); + $this->collection = $collection; + } + + /** + * {@inheritdoc} + */ + public function current() + { + return $this->collection->offsetGet($this->key()); + } +} diff --git a/phpBB/phpbb/di/service_collection_iterator.php b/phpBB/phpbb/di/service_collection_iterator.php deleted file mode 100644 index 0d031ab52d..0000000000 --- a/phpBB/phpbb/di/service_collection_iterator.php +++ /dev/null @@ -1,46 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di; - -/** -* Iterator which loads the services when they are requested -*/ -class service_collection_iterator extends \ArrayIterator -{ - /** - * @var \phpbb\di\service_collection - */ - protected $collection; - - /** - * Construct an ArrayIterator for service_collection - * - * @param \phpbb\di\service_collection $collection The collection to iterate over - * @param int $flags Flags to control the behaviour of the ArrayObject object. - * @see ArrayObject::setFlags() - */ - public function __construct(service_collection $collection, $flags = 0) - { - parent::__construct($collection, $flags); - $this->collection = $collection; - } - - /** - * {@inheritdoc} - */ - public function current() - { - return $this->collection->offsetGet($this->key()); - } -} -- cgit v1.2.1