comparison vendor/symfony/dependency-injection/ContainerBuilder.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents 129ea1e6d783
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
121 121
122 private $autoconfiguredInstanceof = []; 122 private $autoconfiguredInstanceof = [];
123 123
124 private $removedIds = []; 124 private $removedIds = [];
125 125
126 private $removedBindingIds = [];
127
126 private static $internalTypes = [ 128 private static $internalTypes = [
127 'int' => true, 129 'int' => true,
128 'float' => true, 130 'float' => true,
129 'string' => true, 131 'string' => true,
130 'bool' => true, 132 'bool' => true,
864 */ 866 */
865 public function setAlias($alias, $id) 867 public function setAlias($alias, $id)
866 { 868 {
867 $alias = $this->normalizeId($alias); 869 $alias = $this->normalizeId($alias);
868 870
871 if ('' === $alias || '\\' === substr($alias, -1) || \strlen($alias) !== strcspn($alias, "\0\r\n'")) {
872 throw new InvalidArgumentException(sprintf('Invalid alias id: "%s"', $alias));
873 }
874
869 if (\is_string($id)) { 875 if (\is_string($id)) {
870 $id = new Alias($this->normalizeId($id)); 876 $id = new Alias($this->normalizeId($id));
871 } elseif (!$id instanceof Alias) { 877 } elseif (!$id instanceof Alias) {
872 throw new InvalidArgumentException('$id must be a string, or an Alias object.'); 878 throw new InvalidArgumentException('$id must be a string, or an Alias object.');
873 } 879 }
1016 if ($this->isCompiled()) { 1022 if ($this->isCompiled()) {
1017 throw new BadMethodCallException('Adding definition to a compiled container is not allowed'); 1023 throw new BadMethodCallException('Adding definition to a compiled container is not allowed');
1018 } 1024 }
1019 1025
1020 $id = $this->normalizeId($id); 1026 $id = $this->normalizeId($id);
1027
1028 if ('' === $id || '\\' === substr($id, -1) || \strlen($id) !== strcspn($id, "\0\r\n'")) {
1029 throw new InvalidArgumentException(sprintf('Invalid service id: "%s"', $id));
1030 }
1021 1031
1022 unset($this->aliasDefinitions[$id], $this->removedIds[$id]); 1032 unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
1023 1033
1024 return $this->definitions[$id] = $definition; 1034 return $this->definitions[$id] = $definition;
1025 } 1035 }
1503 1513
1504 return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || isset($this->removedIds[$id]) ? $id : parent::normalizeId($id); 1514 return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || isset($this->removedIds[$id]) ? $id : parent::normalizeId($id);
1505 } 1515 }
1506 1516
1507 /** 1517 /**
1518 * Gets removed binding ids.
1519 *
1520 * @return array
1521 *
1522 * @internal
1523 */
1524 public function getRemovedBindingIds()
1525 {
1526 return $this->removedBindingIds;
1527 }
1528
1529 /**
1530 * Removes bindings for a service.
1531 *
1532 * @param string $id The service identifier
1533 *
1534 * @internal
1535 */
1536 public function removeBindings($id)
1537 {
1538 if ($this->hasDefinition($id)) {
1539 foreach ($this->getDefinition($id)->getBindings() as $key => $binding) {
1540 list(, $bindingId) = $binding->getValues();
1541 $this->removedBindingIds[(int) $bindingId] = true;
1542 }
1543 }
1544 }
1545
1546 /**
1508 * Returns the Service Conditionals. 1547 * Returns the Service Conditionals.
1509 * 1548 *
1510 * @param mixed $value An array of conditionals to return 1549 * @param mixed $value An array of conditionals to return
1511 * 1550 *
1512 * @return array An array of Service conditionals 1551 * @return array An array of Service conditionals