Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit ba7e6f9

Browse files
committed
#83 - a specific exception should be thrown when a cycle is detected
1 parent b195a48 commit ba7e6f9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ServiceManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
1717
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
1818
use Zend\ServiceManager\Exception\ContainerModificationsNotAllowedException;
19+
use Zend\ServiceManager\Exception\CyclicAliasException;
1920
use Zend\ServiceManager\Exception\InvalidArgumentException;
2021
use Zend\ServiceManager\Exception\InvalidServiceException;
2122
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
@@ -575,7 +576,7 @@ private function resolveAliases(array $aliases)
575576

576577
while (isset($this->aliases[$name])) {
577578
if (isset($visited[$name])) {
578-
throw new InvalidServiceException('YADDA');
579+
throw CyclicAliasException::fromAliasesMap($aliases);
579580
}
580581

581582
$visited[$name] = true;

test/CommonServiceLocatorBehaviorsTrait.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use ReflectionProperty;
1616
use stdClass;
1717
use Zend\ServiceManager\Exception\ContainerModificationsNotAllowedException;
18+
use Zend\ServiceManager\Exception\CyclicAliasException;
1819
use Zend\ServiceManager\Exception\InvalidArgumentException;
1920
use Zend\ServiceManager\Exception\InvalidServiceException;
2021
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
@@ -791,15 +792,13 @@ public function testCanRetrieveParentContainerViaGetServiceLocatorWithDeprecatio
791792
*/
792793
public function testCrashesOnCyclicAliases()
793794
{
794-
$this->setExpectedException(InvalidServiceException::class);
795+
$this->setExpectedException(CyclicAliasException::class);
795796

796-
$serviceManager = $this->createContainer([
797+
$this->createContainer([
797798
'aliases' => [
798799
'a' => 'b',
799800
'b' => 'a',
800801
],
801802
]);
802-
803-
$serviceManager->get('b');
804803
}
805804
}

0 commit comments

Comments
 (0)