8000 [PhpUnitBridge] enable DebugClassLoader by default by nicolas-grekas · Pull Request #28412 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PhpUnitBridge] enable DebugClassLoader by default #28412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use PHPUnit\Util\Blacklist;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Bridge\PhpUnit\DnsMock;
use Symfony\Component\Debug\DebugClassLoader;

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

$enableDebugClassLoader = \class_exists('Symfony\Component\Debug\DebugClassLoader');
Copy link
Member Author
@nicolas-grekas nicolas-grekas Sep 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as a reminder, because we want to use it when testing branch 2.8, the bridge is still compatible with PHP 5.3, so we cannot use ::class here)


foreach ($mockedNamespaces as $type => $namespaces) {
if (!\is_array($namespaces)) {
$namespaces = array($namespaces);
Expand All @@ -66,6 +69,12 @@ public function __construct(array $mockedNamespaces = array())
DnsMock::register($ns.'\DummyClass');
}
}
if ('debug-class-loader' === $type) {
$enableDebugClassLoader = $namespaces && $namespaces[0];
}
}
if ($enableDebugClassLoader) {
DebugClassLoader::enable();
}
if (self::$globallyEnabled) {
$this->state = -2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface

private $processExpressions = false;
private $expressionLanguage;
private $inExpression = false;

/**
* {@inheritdoc}
Expand All @@ -52,12 +53,21 @@ protected function enableExpressionProcessing()
$this->processExpressions = true;
}

protected function inExpression(bool $reset = true): bool
{
$inExpression = $this->inExpression;
if ($reset) {
$this->inExpression = false;
}

return $inExpression;
}

/**
* Processes a value found in a definition tree.
*
* @param mixed $value
* @param bool $isRoot
* @param bool $inExpression
*
* @return mixed The processed value
*/
Expand Down Expand Up @@ -194,7 +204,9 @@ private function getExpressionLanguage()
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
if ('""' === substr_replace($arg, '', 1, -1)) {
$id = stripcslashes(substr($arg, 1, -1));
$arg = $this->processValue(new Reference($id), false, true);
$this->inExpression = true;
$arg = $this->processValue(new Reference($id));
$this->inExpression = false;
if (!$arg instanceof Reference) {
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)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ public function process(ContainerBuilder $container)
}
}

protected function processValue($value, $isRoot = false, bool $inExpression = false)
protected function processValue($value, $isRoot = false)
{
$lazy = $this->lazy;
$inExpression = $this->inExpression();

if ($value instanceof ArgumentInterface) {
$this->lazy = true;
Expand Down
0