8000 [HttpKernel] Strange controller argument behaviour · Issue #24729 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Strange controller argument behaviour #24729

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

Closed
vudaltsov opened this issue Oct 28, 2017 · 3 comments
Closed

[HttpKernel] Strange controller argument behaviour #24729

vudaltsov opened this issue Oct 28, 2017 · 3 comments

Comments

@vudaltsov
Copy link
Contributor
vudaltsov commented Oct 28, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4 (maybe earlier)

With default routing and services configuration create a simple controller with a non-service class like this:

<?php

namespace App\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

class IndexController extends AbstractController
{
    /**
     * @Route(name="index")
     */
    public function indexAction(A $a)
    {
        dump($a);

        return new Response();
    }
}

class A
{
}

Expected result: an exception about wrong argument. Actual result:

image

Which means that a new instance of a non-DI class is injected.

I investigated a little and found that Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver does this.

@mvrhov
Copy link
mvrhov commented Oct 29, 2017

AFAIR this is expected behavior since 3.4 and controller action injection.

@ogizanagi
Copy link
Contributor

@vudaltsov : Could you try v3.4.0-BETA2 and setting the container.autowiring.strict_mode to true? It should solve this issue.

Looks a duplicate of #24569

@vudaltsov
Copy link
Contributor Author

@ogizanagi , yes, thank you!

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

5 participants
0