Permalink
Browse files

feature #22811 [DI] Remove deprecated case insensitive service ids (r…

…o0NL)

This PR was squashed before being merged into the 4.0-dev branch (closes #22811).

Discussion
----------

[DI] Remove deprecated case insensitive service ids

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

See #21223

Commits
-------

63e26fc [DI] Remove deprecated case insensitive service ids
  • Loading branch information...
nicolas-grekas committed Jul 11, 2017
2 parents 6db73d3 + 63e26fc commit a55cbf83c03057565c05ed745abf85bac618c96a
Showing with 261 additions and 229 deletions.
  1. +0 −3 src/Symfony/Bridge/Doctrine/ManagerRegistry.php
  2. +1 −0 src/Symfony/Component/DependencyInjection/CHANGELOG.md
  3. +58 −128 src/Symfony/Component/DependencyInjection/Container.php
  4. +6 −38 src/Symfony/Component/DependencyInjection/ContainerBuilder.php
  5. +1 −1 src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php
  6. +0 −20 src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
  7. +15 −0 src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
  8. +7 −18 src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
  9. +0 −6 src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php
  10. +6 −0 src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
  11. +4 −0 src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot
  12. +0 −3 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php
  13. +48 −6 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
  14. +48 −2 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
  15. +0 −4 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php
  16. +5 −0 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
  17. +15 −0 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_case.xml
  18. +7 −0 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
  19. +10 −0 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_case.yml
  20. +15 −0 src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
  21. +15 −0 src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -49,9 +49,6 @@ protected function resetService($name)
}
$manager->setProxyInitializer(\Closure::bind(
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
if (isset($this->normalizedIds[$normalizedId = strtolower($name)])) {
$name = $this->normalizedIds[$normalizedId];
}
if (isset($this->aliases[$name])) {
$name = $this->aliases[$name];
}
@@ -10,6 +10,7 @@ CHANGELOG
* removed `Container::isFrozen`
* removed support for dumping an ucompiled container in `PhpDumper`
* removed support for generating a dumped `Container` without populating the method map
* removed support for case insensitive service identifiers
3.4.0
-----
@@ -26,26 +26,7 @@
*
* Services and parameters are simple key/pair stores.
*
* Parameter and service keys are case insensitive.
*
* A service id can contain lowercased letters, digits, underscores, and dots.
* Underscores are used to separate words, and dots to group services
* under namespaces:
*
* <ul>
* <li>request</li>
* <li>mysql_session_storage</li>
* <li>symfony.mysql_session_storage</li>
* </ul>
*
* A service can also be defined by creating a method named
* getXXXService(), where XXX is the camelized version of the id:
*
* <ul>
* <li>request -> getRequestService()</li>
* <li>mysql_session_storage -> getMysqlSessionStorageService()</li>
* <li>symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()</li>
* </ul>
* Parameter keys are case insensitive.
*
* The container can have three possible behaviors when a service does not exist:
*
@@ -70,11 +51,6 @@ class Container implements ResettableContainerInterface
protected $aliases = array();
protected $loading = array();
/**
* @internal
*/
protected $normalizedIds = array();
private $envCache = array();
private $compiled = false;
@@ -171,8 +147,6 @@ public function setParameter($name, $value)
*/
public function set($id, $service)
{
$id = $this->normalizeId($id);
if ('service_container' === $id) {
throw new InvalidArgumentException('You cannot set service "service_container".');
}
@@ -212,31 +186,24 @@ public function set($id, $service)
*/
public function has($id)
{
for ($i = 2;;) {
if (isset($this->privates[$id])) {
@trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
}
if ('service_container' === $id) {
return true;
}
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
if (isset($this->services[$id])) {
return true;
}
if (isset($this->methodMap[$id])) {
return true;
}
if (--$i && $id !== $normalizedId = $this->normalizeId($id)) {
$id = $normalizedId;
continue;
}
if (isset($this->privates[$id])) {
@trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
}
if ('service_container' === $id) {
return true;
}
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
if (isset($this->services[$id])) {
return true;
}
return false;
if (isset($this->methodMap[$id])) {
return true;
}
return false;
}
/**
@@ -258,69 +225,60 @@ public function has($id)
*/
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
{
// Attempt to retrieve the service by checking first aliases then
// available services. Service IDs are case insensitive, however since
// this method can be called thousands of times during a request, avoid
// calling $this->normalizeId($id) unless necessary.
for ($i = 2;;) {
if (isset($this->privates[$id])) {
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
}
if ('service_container' === $id) {
return $this;
}
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
if (isset($this->privates[$id])) {
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
}
if ('service_container' === $id) {
return $this;
}
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
// Re-use shared service instance if it exists.
if (isset($this->services[$id])) {
return $this->services[$id];
}
// Re-use shared service instance if it exists.
if (isset($this->services[$id])) {
return $this->services[$id];
}
if (isset($this->loading[$id])) {
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
}
if (isset($this->loading[$id])) {
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
}
if (isset($this->methodMap[$id])) {
$method = $this->methodMap[$id];
} elseif (--$i && $id !== $normalizedId = $this->normalizeId($id)) {
$id = $normalizedId;
continue;
} else {
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
if (!$id) {
throw new ServiceNotFoundException($id);
}
if (isset($this->methodMap[$id])) {
$method = $this->methodMap[$id];
} else {
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
if (!$id) {
throw new ServiceNotFoundException($id);
}
$alternatives = array();
foreach ($this->getServiceIds() as $knownId) {
$lev = levenshtein($id, $knownId);
if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) {
$alternatives[] = $knownId;
}
$alternatives = array();
foreach ($this->getServiceIds() as $knownId) {
$lev = levenshtein($id, $knownId);
if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) {
$alternatives[] = $knownId;
}
throw new ServiceNotFoundException($id, null, null, $alternatives);
}
return;
throw new ServiceNotFoundException($id, null, null, $alternatives);
}
$this->loading[$id] = true;
return;
}
try {
$service = $this->$method();
} catch (\Exception $e) {
unset($this->services[$id]);
$this->loading[$id] = true;
throw $e;
} finally {
unset($this->loading[$id]);
}
try {
$service = $this->$method();
} catch (\Exception $e) {
unset($this->services[$id]);
return $service;
throw $e;
} finally {
unset($this->loading[$id]);
}
return $service;
}
/**
@@ -332,8 +290,6 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
*/
public function initialized($id)
{
$id = $this->normalizeId($id);
if ('service_container' === $id) {
return false;
}
@@ -418,32 +374,6 @@ protected function getEnv($name)
return $this->envCache[$name] = $this->getParameter("env($name)");
}
/**
* Returns the case sensitive id used at registration time.
*
* @param string $id
*
* @return string
*
* @internal
*/
public function normalizeId($id)
{
if (!is_string($id)) {
$id = (string) $id;
}
if (isset($this->normalizedIds[$normalizedId = strtolower($id)])) {
$normalizedId = $this->normalizedIds[$normalizedId];
if ($id !== $normalizedId) {
@trigger_error(sprintf('Service identifiers will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.3.', $id, $normalizedId), E_USER_DEPRECATED);
}
} else {
$normalizedId = $this->normalizedIds[$normalizedId] = $id;
}
return $normalizedId;
}
private function __clone()
{
}
Oops, something went wrong.

0 comments on commit a55cbf8

Please sign in to comment.