Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 680f319

Browse filesBrowse files
feature #28412 [PhpUnitBridge] enable DebugClassLoader by default (nicolas-grekas)
This PR was merged into the 4.2-dev branch. Discussion ---------- [PhpUnitBridge] enable DebugClassLoader by default | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#10360 With this PR, the phpunit-bridge will enable `DebugClassLoader` by default, making it do its job: throw deprecation notices at autoloading time. On top of #28329, this made me spot some glitches in the code base, fixed here also. This can be disabled by configuring the listener in `phpunit.xml.dist` files, adding `<element key="debug-class-loader"><integer>0</integer></element>` next to `<element key="time-sensitive">...`. Commits ------- 2fb11fc [PhpUnitBridge] enable DebugClassLoader by default
2 parents 3caa9d4 + 2fb11fc commit 680f319
Copy full SHA for 680f319

File tree

Expand file treeCollapse file tree

3 files changed

+25
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-3
lines changed

‎src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Util\Blacklist;
1919
use Symfony\Bridge\PhpUnit\ClockMock;
2020
use Symfony\Bridge\PhpUnit\DnsMock;
21+
use Symfony\Component\Debug\DebugClassLoader;
2122

2223
/**
2324
* PHP 5.3 compatible trait-like shared implementation.
@@ -52,6 +53,8 @@ public function __construct(array $mockedNamespaces = array())
5253
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
5354
}
5455

56+
$enableDebugClassLoader = \class_exists('Symfony\Component\Debug\DebugClassLoader');
57+
5558
foreach ($mockedNamespaces as $type => $namespaces) {
5659
if (!\is_array($namespaces)) {
5760
$namespaces = array($namespaces);
@@ -66,6 +69,12 @@ public function __construct(array $mockedNamespaces = array())
6669
DnsMock::register($ns.'\DummyClass');
6770
}
6871
}
72+
if ('debug-class-loader' === $type) {
73+
$enableDebugClassLoader = $namespaces && $namespaces[0];
74+
}
75+
}
76+
if ($enableDebugClassLoader) {
77+
DebugClassLoader::enable();
6978
}
7079
if (self::$globallyEnabled) {
7180
$this->state = -2;

‎src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
3232

3333
private $processExpressions = false;
3434
private $expressionLanguage;
35+
private $inExpression = false;
3536

3637
/**
3738
* {@inheritdoc}
@@ -52,12 +53,21 @@ protected function enableExpressionProcessing()
5253
$this->processExpressions = true;
5354
}
5455

56+
protected function inExpression(bool $reset = true): bool
57+
{
58+
$inExpression = $this->inExpression;
59+
if ($reset) {
60+
$this->inExpression = false;
61+
}
62+
63+
return $inExpression;
64+
}
65+
5566
/**
5667
* Processes a value found in a definition tree.
5768
*
5869
* @param mixed $value
5970
* @param bool $isRoot
60-
* @param bool $inExpression
6171
*
6272
* @return mixed The processed value
6373
*/
@@ -194,7 +204,9 @@ private function getExpressionLanguage()
194204
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
195205
if ('""' === substr_replace($arg, '', 1, -1)) {
196206
$id = stripcslashes(substr($arg, 1, -1));
197-
$arg = $this->processValue(new Reference($id), false, true);
207+
$this->inExpression = true;
208+
$arg = $this->processValue(new Reference($id));
209+
$this->inExpression = false;
198210
if (!$arg instanceof Reference) {
199211
throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, %s returned for service("%s").', \get_class($this), \is_object($arg) ? \get_class($arg) : \gettype($arg)));
200212
}

‎src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public function process(ContainerBuilder $container)
7979
}
8080
}
8181

82-
protected function processValue($value, $isRoot = false, bool $inExpression = false)
82+
protected function processValue($value, $isRoot = false)
8383
{
8484
$lazy = $this->lazy;
85+
$inExpression = $this->inExpression();
8586

8687
if ($value instanceof ArgumentInterface) {
8788
$this->lazy = true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.