Skip to content

Commit

Permalink
bug #29587 [Debug] ignore underscore vs backslash namespaces in Debug…
Browse files Browse the repository at this point in the history
…ClassLoader (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[Debug] ignore underscore vs backslash namespaces in DebugClassLoader

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29503
| License       | MIT
| Doc PR        | -

Commits
-------

d858dad [Debug] ignore underscore vs backslash namespaces in DebugClassLoader
  • Loading branch information
nicolas-grekas committed Dec 13, 2018
2 parents 7a34a78 + d858dad commit 3fff306
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Debug/DebugClassLoader.php
Expand Up @@ -219,7 +219,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
$len = 0;
$ns = '';
} else {
$ns = \substr($class, 0, $len);
$ns = \str_replace('_', '\\', \substr($class, 0, $len));
}

// Detect annotations on the class
Expand Down Expand Up @@ -250,13 +250,13 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
if (!isset(self::$checkedClasses[$use])) {
$this->checkClass($use);
}
if (isset(self::$deprecated[$use]) && \strncmp($ns, $use, $len)) {
if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) {
$type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait');
$verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses');

$deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]);
}
if (isset(self::$internal[$use]) && \strncmp($ns, $use, $len)) {
if (isset(self::$internal[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) {
$deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class);
}
}
Expand Down

0 comments on commit 3fff306

Please sign in to comment.