<p dir="auto">When we create a lazy load service , It is supposed to pass initializer to  staticProxyConstructor of a proxy  instead of  its constructor.  I have no idea why this happened, please check this <a href="https://github.com/Sylius/Sylius/issues/4335" data-hovercard-type="issue" data-hovercard-url="/Sylius/Sylius/issues/4335/hovercard">link.</a></p>
<p dir="auto">Symfony 2.8.1<br>
PHP 7.0.2.1 (debian)</p>
<p dir="auto">I've enabled the Symonfy serializer.</p>
<p dir="auto">I'm using the <code class="notranslate">"friendsofsymfony/rest-bundle": "^1.7"</code> with the following config:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fos_rest:
    param_fetcher_listener: force
    routing_loader:
        include_format:       false
    view:
        mime_types:
            json: ['application/json', 'application/json;version=1.0', 'application/json;version=1.1', 'application/json;version=1.2']
        view_response_listener: 'force'
        formats:
            xml:  true
            json: true
        templating_formats:
            html: true
    format_listener:
        rules:
            - { path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true }
        media_type:
            version_regex: '/(v|version)=(?P&lt;version&gt;[0-9\.]+)/'
    exception:
        codes:
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
            'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
        messages:
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
    allowed_methods_listener: true
    access_denied_listener:
        json: true
    body_listener: true"><pre class="notranslate"><span class="pl-ent">fos_rest</span>:
    <span class="pl-ent">param_fetcher_listener</span>: <span class="pl-s">force</span>
    <span class="pl-ent">routing_loader</span>:
        <span class="pl-ent">include_format</span>:       <span class="pl-c1">false</span>
    <span class="pl-ent">view</span>:
        <span class="pl-ent">mime_types</span>:
            <span class="pl-ent">json</span>: <span class="pl-s">['application/json', 'application/json;version=1.0', 'application/json;version=1.1', 'application/json;version=1.2']</span>
        <span class="pl-ent">view_response_listener</span>: <span class="pl-s"><span class="pl-pds">'</span>force<span class="pl-pds">'</span></span>
        <span class="pl-ent">formats</span>:
            <span class="pl-ent">xml</span>:  <span class="pl-c1">true</span>
            <span class="pl-ent">json</span>: <span class="pl-c1">true</span>
        <span class="pl-ent">templating_formats</span>:
            <span class="pl-ent">html</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">format_listener</span>:
        <span class="pl-ent">rules</span>:
            - <span class="pl-s">{ path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true }</span>
        <span class="pl-ent">media_type</span>:
            <span class="pl-ent">version_regex</span>: <span class="pl-s"><span class="pl-pds">'</span>/(v|version)=(?P&lt;version&gt;[0-9\.]+)/<span class="pl-pds">'</span></span>
    <span class="pl-ent">exception</span>:
        <span class="pl-ent">codes</span>:
            <span class="pl-s"><span class="pl-pds">'</span><span class="pl-ent">Symfony\Component\Routing\Exception\ResourceNotFoundException</span><span class="pl-pds">'</span></span>: <span class="pl-c1">404</span>
            <span class="pl-s"><span class="pl-pds">'</span><span class="pl-ent">Doctrine\ORM\OptimisticLockException</span><span class="pl-pds">'</span></span>: <span class="pl-s">HTTP_CONFLICT</span>
        <span class="pl-ent">messages</span>:
            <span class="pl-s"><span class="pl-pds">'</span><span class="pl-ent">Symfony\Component\Routing\Exception\ResourceNotFoundException</span><span class="pl-pds">'</span></span>: <span class="pl-c1">true</span>
    <span class="pl-ent">allowed_methods_listener</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">access_denied_listener</span>:
        <span class="pl-ent">json</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">body_listener</span>: <span class="pl-c1">true</span></pre></div>
<p dir="auto">And this is a part of my controller action:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public function getNewsAction(Request $request)
    {
       ...
        $news = [generator news]..
       ...

        $view = $this-&gt;view($news);
        return $this-&gt;handleView($view, 200);
    }"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">getNewsAction</span>(<span class="pl-smi"><span class="pl-smi">Request</span></span> <span class="pl-s1"><span class="pl-c1">$</span>request</span>)
    {
       <span class="pl-c1">.</span>.<span class="pl-c1">.</span>
        <span class="pl-s1"><span class="pl-c1">$</span>news</span> = [generator news].<span class="pl-c1">.</span>
       .<span class="pl-c1">.</span>.

        <span class="pl-s1"><span class="pl-c1">$</span>view</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">view</span>(<span class="pl-s1"><span class="pl-c1">$</span>news</span>);
        <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">handleView</span>(<span class="pl-s1"><span class="pl-c1">$</span>view</span>, <span class="pl-c1">200</span>);
    }</pre></div>
<p dir="auto">I'm trying to debug the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="An Exception was thrown while handling: Type error: Argument 1 passed to 
FOSRestBundleSerializerSymfonySerializerAdapter_0000000052c9fc6b000000005a32441d7f491784
a700368952f1ec7813de5f79::__construct() must implement interface 
Symfony\Component\Serializer\SerializerInterface, instance of Closure given, called in 
/tmpfs/dev/cache/appDevDebugProjectContainer.php on line 2766"><pre class="notranslate"><code class="notranslate">An Exception was thrown while handling: Type error: Argument 1 passed to 
FOSRestBundleSerializerSymfonySerializerAdapter_0000000052c9fc6b000000005a32441d7f491784
a700368952f1ec7813de5f79::__construct() must implement interface 
Symfony\Component\Serializer\SerializerInterface, instance of Closure given, called in 
/tmpfs/dev/cache/appDevDebugProjectContainer.php on line 2766
</code></pre></div>
<p dir="auto">Even when using the JMSSerializer I get:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="An Exception was thrown while handling: Type error: Argument 1 passed to 
FOSRestBundleSerializerJMSSerializerAdapter_000000003e79141b0000000013a926a47f491784a70
0368952f1ec7813de5f79::__construct() must implement interface JMS\Serializer\SerializerInterface, 
instance of Closure given, called in /tmpfs/dev/cache/appDevDebugProjectContainer.php on line 2789"><pre class="notranslate"><code class="notranslate">An Exception was thrown while handling: Type error: Argument 1 passed to 
FOSRestBundleSerializerJMSSerializerAdapter_000000003e79141b0000000013a926a47f491784a70
0368952f1ec7813de5f79::__construct() must implement interface JMS\Serializer\SerializerInterface, 
instance of Closure given, called in /tmpfs/dev/cache/appDevDebugProjectContainer.php on line 2789
</code></pre></div>
<p dir="auto">This is the generated code:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/**
     * Gets the 'fos_rest.serializer' service.
     *
     * This service is shared.
     * This method always returns the same instance of the service.
     *
     * @param bool    $lazyLoad whether to try lazy-loading the service with a proxy
     *
     * @return \FOS\RestBundle\Serializer\JMSSerializerAdapter A FOS\RestBundle\Serializer\JMSSerializerAdapter instance.
     */
    public function getFosRest_SerializerService($lazyLoad = true)
    {
        if ($lazyLoad) {
            $container = $this;

            return $this-&gt;services['fos_rest.serializer'] = new FOSRestBundleSerializerJMSSerializerAdapter_000000003e79141b0000000013a926a47f491784a
700368952f1ec7813de5f79(
                function (&amp;$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {
                    $wrappedInstance = $container-&gt;getFosRest_SerializerService(false);

                    $proxy-&gt;setProxyInitializer(null);

                    return true;
                }
            );
        }

        return new \FOS\RestBundle\Serializer\JMSSerializerAdapter($this-&gt;get('jms_serializer'));
    }"><pre class="notranslate"><span class="pl-c">/**</span>
<span class="pl-c">     * Gets the 'fos_rest.serializer' service.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * This service is shared.</span>
<span class="pl-c">     * This method always returns the same instance of the service.</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * @param bool    $lazyLoad whether to try lazy-loading the service with a proxy</span>
<span class="pl-c">     *</span>
<span class="pl-c">     * @return \FOS\RestBundle\Serializer\JMSSerializerAdapter A FOS\RestBundle\Serializer\JMSSerializerAdapter instance.</span>
<span class="pl-c">     */</span>
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">getFosRest_SerializerService</span>(<span class="pl-s1"><span class="pl-c1">$</span>lazyLoad</span> = <span class="pl-c1">true</span>)
    {
        <span class="pl-k">if</span> (<span class="pl-s1"><span class="pl-c1">$</span>lazyLoad</span>) {
            <span class="pl-s1"><span class="pl-c1">$</span>container</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>;

            <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">services</span>[<span class="pl-s">'fos_rest.serializer'</span>] = <span class="pl-k">new</span> <span class="pl-v">FOSRestBundleSerializerJMSSerializerAdapter_000000003e79141b0000000013a926a47f491784a</span>
<span class="pl-c1">700368952</span>f1ec7813de5f79(
                <span class="pl-k">function</span> (&amp;<span class="pl-s1"><span class="pl-c1">$</span>wrappedInstance</span>, <span class="pl-smi"><span class="pl-smi">\<span class="pl-v">ProxyManager</span>\<span class="pl-v">Proxy</span>\<span class="pl-v">LazyLoadingInterface</span></span></span> <span class="pl-s1"><span class="pl-c1">$</span>proxy</span>) <span class="pl-k">use</span> (<span class="pl-s1"><span class="pl-c1">$</span>container</span>) {
                    <span class="pl-s1"><span class="pl-c1">$</span>wrappedInstance</span> = <span class="pl-s1"><span class="pl-c1">$</span>container</span>-&gt;<span class="pl-en">getFosRest_SerializerService</span>(<span class="pl-c1">false</span>);

                    <span class="pl-s1"><span class="pl-c1">$</span>proxy</span>-&gt;<span class="pl-en">setProxyInitializer</span>(<span class="pl-c1">null</span>);

                    <span class="pl-k">return</span> <span class="pl-c1">true</span>;
                }
            );
        }

        <span class="pl-k">return</span> <span class="pl-k">new</span> \<span class="pl-c1">FOS</span>\<span class="pl-v">RestBundle</span>\<span class="pl-v">Serializer</span>\<span class="pl-v">JMSSerializerAdapter</span>(<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">get</span>(<span class="pl-s">'jms_serializer'</span>));
    }</pre></div>
<p dir="auto">Any idea where I should start looking for this problem?<br>
I've also seen it in another project (unsolved).</p>