Issue 1:
Symfony version(s) affected: 3.4.15

Description

When following the symfony-cmf installation guide with SF 3.4.15 I get the following error:

Cannot dump definitions which have method calls.

This is not the case with 3.4.14, so downgrading solves.

How to reproduce

I created a test project for this.

git clone git@github.com:wuestkamp/my_project_name.git
cd my_project_name
composer install

This will show the error.

Additional context

Here is the verbose output:

In PhpDumper.php line 1761:

[Symfony\Component\DependencyInjection\Exception\RuntimeException]
Cannot dump definitions which have method calls.

Exception trace:
Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:642
Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceMethodCalls() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:521
Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceInlinedDefinitions() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:834
Symfony\Component\DependencyInjection\Dumper\PhpDumper->addService() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:889
Symfony\Component\DependencyInjection\Dumper\PhpDumper::generateServiceFiles() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:218
Symfony\Component\DependencyInjection\Dumper\PhpDumper->dump() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:859
Symfony\Component\HttpKernel\Kernel->dumpContainer() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:663
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:135
Symfony\Component\HttpKernel\Kernel->boot() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:64
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:148
Symfony\Component\Console\Application->run() at /Users/kim/tmp/my_project_name/bin/console:27

When I debug, then in PhpDumper::dumpValue the $value is of class Symfony\Component\DependencyInjection\Definition

Issue 2:
Symfony version(s) affected: 4.1.4

Description

After upgrading to v4.1.4 the following error shown when container tries to build.

RuntimeException Cannot dump definitions which have method calls.

Tace

RuntimeException Cannot dump definitions which have method calls.
[Symfony\Component\DependencyInjection\Exception\RuntimeException]
Cannot dump definitions which have method calls.

Exception trace:

Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:614

Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceMethodCalls() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:516

Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceInlinedDefinitions() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:792

Symfony\Component\DependencyInjection\Dumper\PhpDumper->addService() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:827

Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServices() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:194

Symfony\Component\DependencyInjection\Dumper\PhpDumper->dump() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:704

Symfony\Component\HttpKernel\Kernel->dumpContainer() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:541

Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:123

Symfony\Component\HttpKernel\Kernel->boot() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:65

Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:145

Symfony\Component\Console\Application->run() at /var/www/html/bin/console:39

possibly BC break

possibly caused by: #28060

(or maybe i missed something and used it wrong)

How to reproduce

I have a monolog handler that requires EntityManagerInterface and a doctrine EventSubscriber that needs the monolog logger with the handler. It works fine when I downgrade to symfony/dependency-injection to v4.1.3

Files that requre to reproduce:

src/Monolog/DoctrineDBHandler.php

namespace App\Monolog;

use Doctrine\ORM\EntityManagerInterface;
use Monolog\Handler\AbstractProcessingHandler;

class DoctrineDBHandler extends AbstractProcessingHandler
{
private $entityManager;

public function __construct(EntityManagerInterface $em)
{
parent::__construct();
$this->entityManager = $em;
}

protected function write(array $record): void
{
// write log to db
}
}

src/EventSubscriber/DoctrineLogSubscriber.php

namespace App\EventSubscriber;

use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Monolog\Logger;

class DoctrineLogSubscriber implements EventSubscriber
{
private $logger;

public function __construct(Logger $logger)
{
$this->logger = $logger;
}

public function getSubscribedEvents(): array
{
return ['postPersist'];
}

public function postPersist(LifecycleEventArgs $args): void
{
$this->logger->addInfo('create');
}
}

config/services.yaml

parameters:
locale: 'en'

services:
_defaults:
autowire: true
autoconfigure: true
public: false

App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

App\DoctrineLogSubscriber:
arguments: ['@monolog.logger.demo']
tags:
- { name: doctrine.event_subscriber }

config/packages/dev/monolog.yaml

...
monolog:
channels: ['demo']
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
demo:
channels: ['demo']
level: INFO
type: service
id: App\Monolog\DoctrineDBHandler