/** * Constructor. * * @param string $key The requested parameter key * @param string $sourceId The service id that references the non-existent parameter * @param string $sourceKey The parameter key that references the non-existent parameter * @param \Exception $previous The previous exception * @param string[] $alternatives Some parameter name alternatives */ public function __construct($key, $sourceId = null, $sourceKey = null, Exception $previous = null, array $alternatives = array()) { $this->key = $key; $this->sourceId = $sourceId; $this->sourceKey = $sourceKey; $this->alternatives = $alternatives; if (version_compare(PHP_VERSION, '5.3') < 0) { parent::__construct('', 0); } else { parent::__construct('', 0, $previous); } $this->updateRepr(); }
public function __construct($id, $sourceId = null, Exception $previous = null, array $alternatives = array()) { if (null === $sourceId) { $msg = sprintf('You have requested a non-existent service "%s".', $id); } else { $msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id); } if ($alternatives) { if (1 == count($alternatives)) { $msg .= ' Did you mean this: "'; } else { $msg .= ' Did you mean one of these: "'; } $msg .= implode('", "', $alternatives) . '"?'; } if (version_compare(PHP_VERSION, '5.3') < 0) { parent::__construct($msg, 0); } else { parent::__construct($msg, 0, $previous); } $this->id = $id; $this->sourceId = $sourceId; }