| 1 | <?php declare(strict_types = 1); |
||
| 14 | abstract class ContainerException extends RuntimeException implements ContainerExceptionInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * List of entries referred to cause a circular reference. |
||
| 18 | * |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $referenceChain; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Container entry identifier. |
||
| 25 | * |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $serviceId; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * CircularReferenceException constructor. |
||
| 32 | * |
||
| 33 | * @param string $entryId |
||
| 34 | * @param array $referenceChain |
||
| 35 | * @param Exception|null $previous |
||
| 36 | * @internal param string $message |
||
| 37 | */ |
||
| 38 | 7 | public function __construct(string $entryId, array $referenceChain = [], Exception $previous = null) |
|
| 39 | { |
||
| 40 | 7 | $referenceChain[] = $this->serviceId = $entryId; |
|
|
1 ignored issue
–
show
|
|||
| 41 | 7 | $this->referenceChain = $referenceChain; |
|
| 42 | 7 | parent::__construct($this->createMessage($previous), 0, $previous); |
|
| 43 | 7 | } |
|
| 44 | |||
| 45 | /** |
||
| 46 | * Get reference chain. |
||
| 47 | * |
||
| 48 | * @return array |
||
| 49 | */ |
||
| 50 | public function getReferenceChain(): array |
||
| 51 | { |
||
| 52 | return $this->referenceChain; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Get container entry identifier which caused a circular reference error. |
||
| 57 | * |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | public function getServiceId(): string |
||
| 61 | { |
||
| 62 | return $this->serviceId; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Returns exception message |
||
| 67 | * |
||
| 68 | * @param Exception $previous |
||
|
1 ignored issue
–
show
|
|||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | abstract protected function createMessage(Exception $previous = null): string; |
||
| 72 | |||
| 73 | } |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.