Merge branch '4.4' into 5.1

* 4.4:
  [DependencyInjection] Fixed incorrect report for private services if required service does not exist
  Remove Xdebug from php-extra runs.
This commit is contained in:
Alexander M. Turek 2020-12-03 10:18:36 +01:00
commit 2d062df845
3 changed files with 44 additions and 2 deletions

View File

@ -58,7 +58,6 @@ before_install:
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data" export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
export COMPOSER_UP='composer update --no-progress --ansi' export COMPOSER_UP='composer update --no-progress --ansi'
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort) export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort)
find ~/.phpenv -name xdebug.ini -delete
nanoseconds () { nanoseconds () {
local cmd="date" local cmd="date"
@ -137,6 +136,7 @@ before_install:
echo extension = memcached.so >> $INI echo extension = memcached.so >> $INI
fi fi
done done
find ~/.phpenv -name xdebug.ini -delete
- | - |
# Install extra PHP extensions # Install extra PHP extensions

View File

@ -85,13 +85,14 @@ class PassConfig
new ReplaceAliasByActualDefinitionPass(), new ReplaceAliasByActualDefinitionPass(),
new RemoveAbstractDefinitionsPass(), new RemoveAbstractDefinitionsPass(),
new RemoveUnusedDefinitionsPass(), new RemoveUnusedDefinitionsPass(),
new AnalyzeServiceReferencesPass(),
new CheckExceptionOnInvalidReferenceBehaviorPass(),
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()), new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
new AnalyzeServiceReferencesPass(), new AnalyzeServiceReferencesPass(),
new DefinitionErrorExceptionPass(), new DefinitionErrorExceptionPass(),
]]; ]];
$this->afterRemovingPasses = [[ $this->afterRemovingPasses = [[
new CheckExceptionOnInvalidReferenceBehaviorPass(),
new ResolveHotPathPass(), new ResolveHotPathPass(),
new ResolveNoPreloadPass(), new ResolveNoPreloadPass(),
new AliasDeprecatedPublicServicesPass(), new AliasDeprecatedPublicServicesPass(),

View File

@ -1339,6 +1339,47 @@ class ContainerBuilderTest extends TestCase
$container->compile(); $container->compile();
} }
public function testGetThrownServiceNotFoundExceptionWithCorrectServiceId()
{
$this->expectException(ServiceNotFoundException::class);
$this->expectExceptionMessage('The service "child_service" has a dependency on a non-existent service "non_existent_service".');
$container = new ContainerBuilder();
$container->register('child_service', \stdClass::class)
->setPublic(false)
->addArgument([
'non_existent' => new Reference('non_existent_service'),
])
;
$container->register('parent_service', \stdClass::class)
->setPublic(true)
->addArgument([
'child_service' => new Reference('child_service'),
])
;
$container->compile();
}
public function testUnusedServiceRemovedByPassAndServiceNotFoundExceptionWasNotThrown()
{
$container = new ContainerBuilder();
$container->register('service', \stdClass::class)
->setPublic(false)
->addArgument([
'non_existent_service' => new Reference('non_existent_service'),
])
;
try {
$container->compile();
} catch (ServiceNotFoundException $e) {
$this->fail('Should not be thrown');
}
$this->addToAssertionCount(1);
}
public function testServiceLocator() public function testServiceLocator()
{ {
$container = new ContainerBuilder(); $container = new ContainerBuilder();