Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint:container fails on prod with event name from parameter #37166

Closed
alexander-schranz opened this issue Jun 9, 2020 · 0 comments
Closed

Lint:container fails on prod with event name from parameter #37166

alexander-schranz opened this issue Jun 9, 2020 · 0 comments

Comments

@alexander-schranz
Copy link
Contributor

Symfony version(s) affected: 5.1.0 (not sure if also appear on 5.0)

Description

Lint:container fails on prod with event name from parameter.

How to reproduce

# config/services.yaml
parameters:
    test_event: 'test_event'

services:
    App\EventListener\MyListener:
        tags:
            - { name: kernel.event_listener, event: '%test_event%' }
<?php

namespace App\EventListener;

use Symfony\Contracts\EventDispatcher\Event;

class MyListener
{
    public function onEvent(Event $test)
    {
        return $test;
    }
}

bin/console lint:container --env prod
[ERROR] Invalid definition for service "event_dispatcher": argument 1 of
"Symfony\Component\EventDispatcher\EventDispatcher::addListener" accepts "string", "array" passed.

Possible Solution

Not sure why it fails with this and why it only fails on prod and not on dev

@fabpot fabpot closed this as completed Jun 11, 2020
fabpot added a commit that referenced this issue Jun 11, 2020
…solve parameters (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection][CheckTypeDeclarationsPass] Always resolve parameters

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37166
| License       | MIT
| Doc PR        | -

> Only array parameters are not inlined when dumped.

This is true only when the XML debug container is used, not on a live container that can contain unresolved parameters in the `%my_param%` form. That was my mistake. We have to resolve to get the parameter type.

`$value = [];` was just an improvement to avoid useless parameter resolve btw.

Commits
-------

da0e2c3 [DependencyInjection][CheckTypeDeclarationsPass] Always resolve parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants