<p dir="auto"><strong>Symfony version(s) affected</strong>: 3.4.15</p>
<p dir="auto"><strong>Description</strong><br>
When following the symfony-cmf installation guide with SF 3.4.15 I get the following error:</p>
<p dir="auto"><code class="notranslate">Cannot dump definitions which have method calls.</code></p>
<p dir="auto">This is not the case with 3.4.14, so downgrading solves.</p>
<p dir="auto"><strong>How to reproduce</strong><br>
I created a test project for this.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone git@github.com:wuestkamp/my_project_name.git
cd my_project_name
composer install"><pre class="notranslate"><code class="notranslate">git clone git@github.com:wuestkamp/my_project_name.git
cd my_project_name
composer install
</code></pre></div>
<p dir="auto">This will show the error.</p>
<p dir="auto"><strong>Additional context</strong><br>
Here is the verbose output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In PhpDumper.php line 1761:
                                                                      
  [Symfony\Component\DependencyInjection\Exception\RuntimeException]  
  Cannot dump definitions which have method calls.                    
                                                                      

Exception trace:
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;dumpValue() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:642
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServiceMethodCalls() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:521
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServiceInlinedDefinitions() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:834
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;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-&gt;dump() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:859
 Symfony\Component\HttpKernel\Kernel-&gt;dumpContainer() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:663
 Symfony\Component\HttpKernel\Kernel-&gt;initializeContainer() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:135
 Symfony\Component\HttpKernel\Kernel-&gt;boot() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:64
 Symfony\Bundle\FrameworkBundle\Console\Application-&gt;doRun() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:148
 Symfony\Component\Console\Application-&gt;run() at /Users/kim/tmp/my_project_name/bin/console:27"><pre class="notranslate"><code class="notranslate">In PhpDumper.php line 1761:
                                                                      
  [Symfony\Component\DependencyInjection\Exception\RuntimeException]  
  Cannot dump definitions which have method calls.                    
                                                                      

Exception trace:
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;dumpValue() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:642
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServiceMethodCalls() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:521
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServiceInlinedDefinitions() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:834
 Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;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-&gt;dump() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:859
 Symfony\Component\HttpKernel\Kernel-&gt;dumpContainer() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:663
 Symfony\Component\HttpKernel\Kernel-&gt;initializeContainer() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:135
 Symfony\Component\HttpKernel\Kernel-&gt;boot() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:64
 Symfony\Bundle\FrameworkBundle\Console\Application-&gt;doRun() at /Users/kim/tmp/my_project_name/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:148
 Symfony\Component\Console\Application-&gt;run() at /Users/kim/tmp/my_project_name/bin/console:27
</code></pre></div>
<p dir="auto">When I debug, then in PhpDumper::dumpValue the $value is of class <code class="notranslate">Symfony\Component\DependencyInjection\Definition</code></p>
<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.1.4</p>
<p dir="auto"><strong>Description</strong></p>
<p dir="auto">After upgrading to v4.1.4 the following error shown when container tries to build.</p>
<p dir="auto">RuntimeException Cannot dump definitions which have method calls.</p>
<details>
<summary>Tace</summary>
RuntimeException Cannot dump definitions which have method calls.  
 [Symfony\Component\DependencyInjection\Exception\RuntimeException]  
  Cannot dump definitions which have method calls.                    
<p dir="auto">Exception trace:<br>
Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;dumpValue() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:614<br>
Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServiceMethodCalls() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:516<br>
Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServiceInlinedDefinitions() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:792<br>
Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addService() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:827<br>
Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;addServices() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:194<br>
Symfony\Component\DependencyInjection\Dumper\PhpDumper-&gt;dump() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:704<br>
Symfony\Component\HttpKernel\Kernel-&gt;dumpContainer() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:541<br>
Symfony\Component\HttpKernel\Kernel-&gt;initializeContainer() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:123<br>
Symfony\Component\HttpKernel\Kernel-&gt;boot() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:65<br>
Symfony\Bundle\FrameworkBundle\Console\Application-&gt;doRun() at /var/www/html/vendor/symfony/console/Application.php:145<br>
Symfony\Component\Console\Application-&gt;run() at /var/www/html/bin/console:39</p>
</details>
<p dir="auto">possibly BC break<br>
possibly caused by: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="344454837" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/28060" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/28060/hovercard" href="https://github.com/symfony/symfony/pull/28060">#28060</a><br>
(or maybe i missed something and used it wrong)</p>
<p dir="auto"><strong>How to reproduce</strong><br>
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</p>
<p dir="auto">Files that requre to reproduce:</p>
<details>
<summary>src/Monolog/DoctrineDBHandler.php</summary>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
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-&gt;entityManager = $em;
    }

    protected function write(array $record): void
    {
        // write log to db
    }
}"><pre class="notranslate"><span class="pl-k">namespace</span> <span class="pl-v">App</span>\<span class="pl-v">Monolog</span>;

<span class="pl-k">use</span> <span class="pl-v">Doctrine</span>\<span class="pl-c1">ORM</span>\<span class="pl-v">EntityManagerInterface</span>;
<span class="pl-k">use</span> <span class="pl-v">Monolog</span>\<span class="pl-v">Handler</span>\<span class="pl-v">AbstractProcessingHandler</span>;

<span class="pl-k">class</span> <span class="pl-v">DoctrineDBHandler</span> <span class="pl-k">extends</span> <span class="pl-v">AbstractProcessingHandler</span>
{
    <span class="pl-k">private</span> <span class="pl-c1"><span class="pl-c1">$</span>entityManager</span>;

    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">__construct</span>(<span class="pl-smi"><span class="pl-smi">EntityManagerInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>em</span>)
    {
        <span class="pl-smi">parent</span>::<span class="pl-en">__construct</span>();
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">entityManager</span> = <span class="pl-s1"><span class="pl-c1">$</span>em</span>;
    }

    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">write</span>(<span class="pl-smi">array</span> <span class="pl-s1"><span class="pl-c1">$</span>record</span>): <span class="pl-smi">void</span>
    {
        <span class="pl-c">// write log to db</span>
    }
}</pre></div>
</details>
<details>
<summary>src/EventSubscriber/DoctrineLogSubscriber.php</summary>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
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-&gt;logger = $logger;
    }

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

    public function postPersist(LifecycleEventArgs $args): void
    {
        $this-&gt;logger-&gt;addInfo('create');
    }
}"><pre class="notranslate"><span class="pl-k">namespace</span> <span class="pl-v">App</span>\<span class="pl-v">EventSubscriber</span>;

<span class="pl-k">use</span> <span class="pl-v">Doctrine</span>\<span class="pl-v">Common</span>\<span class="pl-v">EventSubscriber</span>;
<span class="pl-k">use</span> <span class="pl-v">Doctrine</span>\<span class="pl-c1">ORM</span>\<span class="pl-v">Event</span>\<span class="pl-v">LifecycleEventArgs</span>;
<span class="pl-k">use</span> <span class="pl-v">Monolog</span>\<span class="pl-v">Logger</span>;

<span class="pl-k">class</span> <span class="pl-v">DoctrineLogSubscriber</span> <span class="pl-k">implements</span> <span class="pl-v">EventSubscriber</span>
{
    <span class="pl-k">private</span> <span class="pl-c1"><span class="pl-c1">$</span>logger</span>;

    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">__construct</span>(<span class="pl-smi"><span class="pl-smi">Logger</span></span> <span class="pl-s1"><span class="pl-c1">$</span>logger</span>)
    {
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">logger</span> = <span class="pl-s1"><span class="pl-c1">$</span>logger</span>;
    }

    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">getSubscribedEvents</span>(): <span class="pl-smi">array</span>
    {
        <span class="pl-k">return</span> [<span class="pl-s">'postPersist'</span>];
    }

    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">postPersist</span>(<span class="pl-smi"><span class="pl-smi">LifecycleEventArgs</span></span> <span class="pl-s1"><span class="pl-c1">$</span>args</span>): <span class="pl-smi">void</span>
    {
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">logger</span>-&gt;<span class="pl-en">addInfo</span>(<span class="pl-s">'create'</span>);
    }
}</pre></div>
</details>
<details>
<summary>config/services.yaml</summary>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
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 }
"><pre class="notranslate"><span class="pl-ent">parameters</span>:
    <span class="pl-ent">locale</span>: <span class="pl-s"><span class="pl-pds">'</span>en<span class="pl-pds">'</span></span>

<span class="pl-ent">services</span>:
    <span class="pl-ent">_defaults</span>:
        <span class="pl-ent">autowire</span>: <span class="pl-c1">true</span>
        <span class="pl-ent">autoconfigure</span>: <span class="pl-c1">true</span>
        <span class="pl-ent">public</span>: <span class="pl-c1">false</span>

    <span class="pl-ent">App\</span>:
        <span class="pl-ent">resource</span>: <span class="pl-s"><span class="pl-pds">'</span>../src/*<span class="pl-pds">'</span></span>
        <span class="pl-ent">exclude</span>: <span class="pl-s"><span class="pl-pds">'</span>../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}<span class="pl-pds">'</span></span>

    <span class="pl-ent">App\DoctrineLogSubscriber</span>:
        <span class="pl-ent">arguments</span>: <span class="pl-s">['@monolog.logger.demo']</span>
        <span class="pl-ent">tags</span>:
            - <span class="pl-s">{ name: doctrine.event_subscriber }</span>
</pre></div>
</details>
<details>
<summary>config/packages/dev/monolog.yaml</summary>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
...
monolog:
    channels: ['demo']
    handlers:
        main:
            type: stream
            path: &quot;%kernel.logs_dir%/%kernel.environment%.log&quot;
            level: debug
            channels: [&quot;!event&quot;]
        console:
            type: console
            process_psr_3_messages: false
            channels: [&quot;!event&quot;, &quot;!doctrine&quot;, &quot;!console&quot;]
        demo:
            channels: ['demo']
            level: INFO
            type: service
            id: App\Monolog\DoctrineDBHandler
"><pre class="notranslate">...
<span class="pl-ent">monolog</span>:
    <span class="pl-ent">channels</span>: <span class="pl-s">['demo']</span>
    <span class="pl-ent">handlers</span>:
        <span class="pl-ent">main</span>:
            <span class="pl-ent">type</span>: <span class="pl-s">stream</span>
            <span class="pl-ent">path</span>: <span class="pl-s"><span class="pl-pds">"</span>%kernel.logs_dir%/%kernel.environment%.log<span class="pl-pds">"</span></span>
            <span class="pl-ent">level</span>: <span class="pl-s">debug</span>
            <span class="pl-ent">channels</span>: <span class="pl-s">["!event"]</span>
        <span class="pl-ent">console</span>:
            <span class="pl-ent">type</span>: <span class="pl-s">console</span>
            <span class="pl-ent">process_psr_3_messages</span>: <span class="pl-c1">false</span>
            <span class="pl-ent">channels</span>: <span class="pl-s">["!event", "!doctrine", "!console"]</span>
        <span class="pl-ent">demo</span>:
            <span class="pl-ent">channels</span>: <span class="pl-s">['demo']</span>
            <span class="pl-ent">level</span>: <span class="pl-s">INFO</span>
            <span class="pl-ent">type</span>: <span class="pl-s">service</span>
            <span class="pl-ent">id</span>: <span class="pl-s">App\Monolog\DoctrineDBHandler</span>
</pre></div>
</details>