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

Commit 8fc6304

Browse files
author
fhein
committed
Fixed introduced bc break by adding Named Constructor for CMNAException.
1 parent a7cb8c5 commit 8fc6304

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/Exception/ContainerModificationsNotAllowedException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
*/
1515
class ContainerModificationsNotAllowedException extends DomainException implements ExceptionInterface
1616
{
17-
18-
public function __construct($service)
17+
public static function fromExistingService($service)
1918
{
20-
parent::__construct(sprintf(
19+
return new self(sprintf(
2120
'The container does not allow to replace/update a service'
2221
. ' with existing instances; the following '
2322
. 'already exist in the container: %s',

src/ServiceManager.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public function setAlias($alias, $target)
413413
$this->mapAliasToTarget($alias, $target);
414414
return;
415415
}
416-
throw new ContainerModificationsNotAllowedException($alias);
416+
throw ContainerModificationsNotAllowedException::fromExistingService($alias);
417417
}
418418

419419
/**
@@ -429,7 +429,7 @@ public function setInvokableClass($name, $class = null)
429429
$this->createAliasesAndFactoriesForInvokables([$name => $class ?? $name]);
430430
return;
431431
}
432-
throw new ContainerModificationsNotAllowedException($name);
432+
throw ContainerModificationsNotAllowedException::fromExistingService($name);
433433
}
434434

435435
/**
@@ -445,7 +445,7 @@ public function setFactory($name, $factory)
445445
$this->factories[$name] = $factory;
446446
return;
447447
}
448-
throw new ContainerModificationsNotAllowedException($name);
448+
throw ContainerModificationsNotAllowedException::fromExistingService($name);
449449
}
450450

451451
/**
@@ -504,7 +504,7 @@ public function setService($name, $service)
504504
$this->services[$name] = $service;
505505
return;
506506
}
507-
throw new ContainerModificationsNotAllowedException($name);
507+
throw ContainerModificationsNotAllowedException::fromExistingService($name);
508508
}
509509

510510
/**
@@ -519,7 +519,7 @@ public function setShared($name, $flag)
519519
$this->shared[$name] = (bool) $flag;
520520
return;
521521
}
522-
throw new ContainerModificationsNotAllowedException($name);
522+
throw ContainerModificationsNotAllowedException::fromExistingService($name);
523523
}
524524

525525
/**
@@ -798,7 +798,7 @@ private function validateServiceNames(array $config)
798798
if (! isset($this->services[$service]) || $this->allowOverride) {
799799
continue;
800800
}
801-
throw new ContainerModificationsNotAllowedException($service);
801+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
802802
}
803803
}
804804

@@ -807,7 +807,7 @@ private function validateServiceNames(array $config)
807807
if (! isset($this->services[$service]) || $this->allowOverride) {
808808
continue;
809809
}
810-
throw new ContainerModificationsNotAllowedException($service);
810+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
811811
}
812812
}
813813

@@ -816,7 +816,7 @@ private function validateServiceNames(array $config)
816816
if (! isset($this->services[$service]) || $this->allowOverride) {
817817
continue;
818818
}
819-
throw new ContainerModificationsNotAllowedException($service);
819+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
820820
}
821821
}
822822

@@ -825,7 +825,7 @@ private function validateServiceNames(array $config)
825825
if (! isset($this->services[$service]) || $this->allowOverride) {
826826
continue;
827827
}
828-
throw new ContainerModificationsNotAllowedException($service);
828+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
829829
}
830830
}
831831

@@ -834,7 +834,7 @@ private function validateServiceNames(array $config)
834834
if (! isset($this->services[$service]) || $this->allowOverride) {
835835
continue;
836836
}
837-
throw new ContainerModificationsNotAllowedException($service);
837+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
838838
}
839839
}
840840

@@ -843,7 +843,7 @@ private function validateServiceNames(array $config)
843843
if (! isset($this->services[$service]) || $this->allowOverride) {
844844
continue;
845845
}
846-
throw new ContainerModificationsNotAllowedException($service);
846+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
847847
}
848848
}
849849

@@ -852,7 +852,7 @@ private function validateServiceNames(array $config)
852852
if (! isset($this->services[$service]) || $this->allowOverride) {
853853
continue;
854854
}
855-
throw new ContainerModificationsNotAllowedException($service);
855+
throw ContainerModificationsNotAllowedException::fromExistingService($service);
856856
}
857857
}
858858
}

0 commit comments

Comments
 (0)