Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  updated VERSION for 3.4.40
  update CONTRIBUTORS for 3.4.40
  updated CHANGELOG for 3.4.40
  [WebProfilerBundle] changed label of peak memory usage in the time & memory panels (MB into MiB)
  add tests for the ConstraintViolationBuilder class
  Improve dirname usage
  [PhpUnitBridge] Use COMPOSER_BINARY env var if available
  Allow invalidateTags calls to be traced by data collector
  [YAML] escape DEL(\x7f)
  fix compatibility with phpunit 9
  [Cache] skip APCu in chains when the backend is disabled
  [Mailer] Add a comment to avoid more wrong PRs on this piece of code
  [Form] apply automatically step=1 for datetime-local input
  Fixing a bug where class_alias would cause incorrect items in debug:autowiring
  [DependencyInjection][ServiceSubscriber] Support late aliases
  • Loading branch information
nicolas-grekas committed Apr 28, 2020
2 parents be7811a + fdacdf1 commit 3fd5aec
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Command/DebugAutowiringCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$serviceIdsNb = 0;
foreach ($serviceIds as $serviceId) {
$text = [];
$resolvedServiceId = $serviceId;
if (0 !== strpos($serviceId, $previousId)) {
$text[] = '';
if ('' !== $description = Descriptor::getClassDescription($serviceId, $serviceId)) {
if ('' !== $description = Descriptor::getClassDescription($serviceId, $resolvedServiceId)) {
if (isset($hasAlias[$serviceId])) {
continue;
}
Expand Down
14 changes: 14 additions & 0 deletions Tests/Fixtures/ClassAliasExampleClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;

class_alias(
ClassAliasTargetClass::class,
__NAMESPACE__ . '\ClassAliasExampleClass'
);

if (false) {
class ClassAliasExampleClass
{
}
}
7 changes: 7 additions & 0 deletions Tests/Fixtures/ClassAliasTargetClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;

class ClassAliasTargetClass
{
}
12 changes: 12 additions & 0 deletions Tests/Functional/DebugAutowiringCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,16 @@ public function testSearchNotAliasedServiceWithAll()
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
$this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
}

public function testNotConfusedByClassAliases()
{
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);

$application = new Application(static::$kernel);
$application->setAutoExit(false);

$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'ClassAlias']);
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass (public)', $tester->getDisplay());
}
}
1 change: 1 addition & 0 deletions Tests/Functional/app/ContainerDebug/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
public: false
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass:
class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BackslashClass
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass: '@public'
env:
class: stdClass
arguments:
Expand Down

0 comments on commit 3fd5aec

Please sign in to comment.