Commit Graph

31046 Commits

Author SHA1 Message Date
Fabien Potencier
a3f78608e8 feature #22665 [DI] Do not throw autowiring exceptions for a service that will be removed (weaverryan)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Do not throw autowiring exceptions for a service that will be removed

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no (arguable)
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Hi guys!

tl;dr Do no throw a "Cannot autowire service id foo_bar" if that service (`foo_bar`) is private and is ultimately removed from the container.

I ran into a problem with the new PSR-4 service loader: our existing projects often contains directories with a mixture of services and model classes. In reality, that's not a problem: since the services are private, if any "extra" classes are registered as service, they're removed from the container because they're not referenced. In other words, the system is great: model classes do *not* become services naturally... because nobody tries to inject them as services.

However, if your model classes have constructor args... then things blow up on compilation. This fixes that: it delays autowiring errors until after `RemoveUnusedDefinitionsPass` runs and then does *not* throw those exceptions if the service is gone.

Cheers!

Commits
-------

f4913feaa8 Fixing a bug where services that were eventually removed could cause autowire errors
2017-05-11 10:07:41 -07:00
Fabien Potencier
428b9bfa4f Merge branch '3.2'
* 3.2:
  [Console] Do not duplicate Helper::strlen() code
  [FrameworkBundle] Adding the extension XML
  [Form] Minor: Fix comment in ChoiceType
  [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice
  fixed CS
  fixed CS
  [DI] Fix PhpDumper blank lines around namespace
  fixed CS
  [Workflow] fix use directives
  [Workflow] Move twig extension registration to twig bundle
  Filesystem: annotate the one network test with a "network" group.
  [DependencyInjection] Don't store default deprecation template in every service definition instance
2017-05-11 09:47:52 -07:00
Fabien Potencier
329e96c583 Merge branch '2.8' into 3.2
* 2.8:
  [Console] Do not duplicate Helper::strlen() code
  [FrameworkBundle] Adding the extension XML
  [Form] Minor: Fix comment in ChoiceType
  [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice
2017-05-11 09:41:44 -07:00
Fabien Potencier
433dfd42a1 Merge branch '2.7' into 2.8
* 2.7:
  [Console] Do not duplicate Helper::strlen() code
  [FrameworkBundle] Adding the extension XML
  [Form] Minor: Fix comment in ChoiceType
  [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice
2017-05-11 09:41:12 -07:00
Fabien Potencier
0ad2f2ef9f bug #22669 [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice (ogizanagi)
This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/recipes/issues/46
| License       | MIT
| Doc PR        | N/A

As spotted in https://github.com/symfony/recipes/issues/46, there is no reason to call `registerBundles` on the kernel instance, as it's already booted. So we just have to use `getBundles` instead and `registerBundles` can be implemented in a non-rewindable way, as done with flex.

Commits
-------

040edfec4a [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice
2017-05-11 09:38:53 -07:00
Robin Chalas
75f098fcb8 Fix errors not rethrown even if not handled by console.error listeners 2017-05-11 16:06:19 +02:00
Ryan Weaver
5326bab10a Fixing a bug where abstract classes were wired 2017-05-11 05:42:51 -04:00
Ryan Weaver
22b905226d Making the RegisterControllerArgumentLocatorsPass throw an exception on a bad type-hint 2017-05-10 15:41:43 -04:00
Fabien Potencier
2f1c28bbbc minor #22683 [Console] Do not duplicate Helper::strlen() code (ogizanagi)
This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Do not duplicate Helper::strlen() code

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

Commits
-------

01c2c099a4 [Console] Do not duplicate Helper::strlen() code
2017-05-10 11:24:43 -07:00
Ryan Weaver
f4913feaa8 Fixing a bug where services that were eventually removed could cause autowire errors 2017-05-10 09:32:00 -04:00
Maxime Steinhausser
01c2c099a4 [Console] Do not duplicate Helper::strlen() code 2017-05-09 20:54:25 +02:00
Fabien Potencier
2d72b0b8ce minor #22673 [Form] Minor: Fix comment in ChoiceType (issei-m)
This PR was merged into the 2.7 branch.

Discussion
----------

[Form] Minor: Fix comment in ChoiceType

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | n/a
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Forgotten to be updated in: #21957

Commits
-------

a49d79c856 [Form] Minor: Fix comment in ChoiceType
2017-05-09 07:57:36 -07:00
Fabien Potencier
71efe3f3de bug #22676 [FrameworkBundle] Adding the extension XML (flug)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #22676).

Discussion
----------

[FrameworkBundle] Adding the extension XML

| Q             | A
| ------------- | ---
| Branch?       | <3.3
| Bug fix?      | yes
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->

![XmlUtils](https://cloud.githubusercontent.com/assets/1810304/25841740/9b655036-34a1-11e7-9d1e-a23928b8ed17.png)

This pull request is referenced on ![symfony/skeleton](https://github.com/symfony/skeleton/pull/7)
<!--
- Bug fixes must be submitted against the lowest branch where they apply
  (lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

Commits
-------

6fe2ad0558 [FrameworkBundle] Adding the extension XML
2017-05-09 07:44:44 -07:00
Flug
6fe2ad0558 [FrameworkBundle] Adding the extension XML
required by XmlUtils and not installed by default
2017-05-09 07:43:21 -07:00
Fabien Potencier
ae9bda1ffc bug #22611 [FrameworkBundle] Fix "Locale class not found" in AboutCommand (rubenrua)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Fix "Locale class not found" in AboutCommand

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Found testing http://fabien.potencier.org/symfony4-demo.html with docker `php:7.1`

Commits
-------

0269f9d422 [FrameworkBundle] Fix "Locale class not found" in AboutCommand
2017-05-09 07:36:16 -07:00
Fabien Potencier
ca509ea6fe bug #22677 [DI] Fixed index args bug with ResolveNamedArgumentsPass (weaverryan)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Fixed index args bug with ResolveNamedArgumentsPass

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | n/a

While upgrading a project, this code suddenly broke:

```yml
services:
    ice_cream_service:
        class: AppBundle\Service\IceCreamService
        autowire: true
        arguments:
            1: 'http://api.example.com'
```

```php
class IceCreamService
{
    public function __construct(EntityManager $em, $apiUrl)
    {
    }
}
```

Suddenly, the index `1` was not being mapped to `$apiUrl`. This was valid in 3.2, but broke when `ResolveNamedArgumentsPass` accidentally re-set the index. Simple fix :). Ping @dunglas

Cheers!

Commits
-------

7cc7c85919 Fixing bug where indexed args were set wrong in pass in some situations
2017-05-09 07:31:58 -07:00
Ryan Weaver
7cc7c85919 Fixing bug where indexed args were set wrong in pass in some situations 2017-05-09 05:53:08 -04:00
Issei.M
a49d79c856 [Form] Minor: Fix comment in ChoiceType 2017-05-09 13:05:50 +09:00
Fabien Potencier
f389fa3a56 bug #22652 [Workflow] Move twig extension registration to twig bundle (ogizanagi)
This PR was merged into the 3.2 branch.

Discussion
----------

[Workflow] Move twig extension registration to twig bundle

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | not really
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

It's probably very late, but I think the twig extension registration is supposed to be done from the `TwigBundle` rather than the `FrameworkBundle`. Fortunately, it doesn't cause any issue currently when using the framework bundle and the workflow component without twig, because it only creates a `workflow.twig_extension` service you'll probably never call, and the `twig.extension` tag is never processed. But still, creates a useless service that cannot be called (and is not removed because it's public).

So this PR aims for consistency over other twig extensions registration, and removing this service when not using twig.
It isn't a BC break to me, as you usually already use the `TwigBundle` for other extensions.

Commits
-------

3fc80d10ef [Workflow] Move twig extension registration to twig bundle
2017-05-08 09:35:15 -07:00
Fabien Potencier
3646d08735 feature #22668 [FrameworkBundle] KernelTestCase: allow to provide the kernel class with a var (ogizanagi)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] KernelTestCase: allow to provide the kernel class with a var

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | no
| New feature?  | yes, but must-have for the new project structure when using flex
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22661
| License       | MIT
| Doc PR        | todo in https://symfony.com/doc/current/testing.html#your-first-functional-test

So, when using flex, the new `phpunit.xml.dist` will be:

```diff
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="vendor/autoload.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
-        <server name="KERNEL_DIR" value="etc/" />
+        <server name="KERNEL_CLASS" value="App\Kernel" />
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests/</directory>
        </testsuite>
    </testsuites>
</phpunit>
```

As it may cause issues when refactoring, I added a `class_exists` check with an appropriate exception to indicate the class is either not found or not autoloadable.

Commits
-------

4f68912552 [FrameworkBundle] KernelTestCase: allow to provide the kernel class with a var
2017-05-08 06:59:10 -07:00
Maxime Steinhausser
040edfec4a [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice 2017-05-08 10:50:08 +02:00
Maxime Steinhausser
4f68912552 [FrameworkBundle] KernelTestCase: allow to provide the kernel class with a var 2017-05-08 10:36:21 +02:00
Fabien Potencier
ec92b68bad minor #22653 [Workflow] fix use directives (ogizanagi)
This PR was merged into the 3.2 branch.

Discussion
----------

[Workflow] fix use directives

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

Spotted while creating https://github.com/symfony/symfony/pull/22652

Commits
-------

08f4ad2275 [Workflow] fix use directives
2017-05-07 20:43:20 -07:00
Fabien Potencier
f832a4c7eb minor #22666 CS fixes (fabpot)
This PR was merged into the 3.2 branch.

Discussion
----------

CS fixes

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

33d6f5c327 fixed CS
2017-05-07 20:42:20 -07:00
Fabien Potencier
33d6f5c327 fixed CS 2017-05-07 19:28:57 -07:00
Fabien Potencier
b81a6629ee Merge branch '2.8' into 3.2
* 2.8:
  fixed CS
  [DI] Fix PhpDumper blank lines around namespace
  fixed CS
  Filesystem: annotate the one network test with a "network" group.
  [DependencyInjection] Don't store default deprecation template in every service definition instance
2017-05-07 18:51:21 -07:00
Fabien Potencier
5e8412b65f minor #22660 fixed CS (fabpot)
This PR was merged into the 2.8 branch.

Discussion
----------

fixed CS

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

a23330bf1e fixed CS
2017-05-07 18:49:14 -07:00
Fabien Potencier
e7da63a51f minor #22662 Tweaked the tabs of the logger profiler panel (javiereguiluz)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Tweaked the tabs of the logger profiler panel

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Another tweak that was on my TODO list for the profiler. With the addition of the "Container compilation" tab, the current tab menu looks too wide:

![logs_before](https://cloud.githubusercontent.com/assets/73419/25783180/07ed745e-3358-11e7-97b2-246f08d7da32.png)

I propose to rename some tabs to make it narrower:

![logs_after](https://cloud.githubusercontent.com/assets/73419/25783188/14b89b00-3358-11e7-8d87-ff2161945711.png)

---

Besides, I propose to add some help notes about the type of logs included in each tab. Examples:

![logs_after_message_1](https://cloud.githubusercontent.com/assets/73419/25783191/26d50e04-3358-11e7-983c-2e50f891247e.png)

![logs_after_message_2](https://cloud.githubusercontent.com/assets/73419/25783192/289af780-3358-11e7-8bec-d6572a5ae761.png)

Commits
-------

c21782dcae Tweaked the tabs of the logger profiler panel
2017-05-07 18:29:08 -07:00
Fabien Potencier
a23330bf1e fixed CS 2017-05-07 18:19:21 -07:00
Fabien Potencier
ae3d88c215 Merge branch '2.7' into 2.8
* 2.7:
  [DI] Fix PhpDumper blank lines around namespace
2017-05-07 18:18:23 -07:00
Fabien Potencier
62cb443770 minor #22663 [DI] Fix PhpDumper blank lines around namespace (ogizanagi)
This PR was merged into the 2.7 branch.

Discussion
----------

[DI] Fix PhpDumper blank lines around namespace

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

219bce9916 tries to fix CS in an expected PhpDumper output, which actually shows the PhpDumper does not create proper blank lines around the namespace.
That's why tests are failing on https://github.com/symfony/symfony/pull/22660.

Commits
-------

c9f6c1680f [DI] Fix PhpDumper blank lines around namespace
2017-05-07 18:18:06 -07:00
Maxime Steinhausser
5b123b9674 [Security] Fix TraceableAccessDecisionManager / DebugAccessDecisionManager BC layer 2017-05-07 21:52:37 +02:00
Maxime Steinhausser
c9f6c1680f [DI] Fix PhpDumper blank lines around namespace 2017-05-07 19:29:35 +02:00
Javier Eguiluz
c21782dcae Tweaked the tabs of the logger profiler panel 2017-05-07 19:02:29 +02:00
Fabien Potencier
57129de78c Merge branch '2.7' into 2.8
* 2.7:
  fixed CS
  Filesystem: annotate the one network test with a "network" group.
2017-05-07 09:04:05 -07:00
Fabien Potencier
219bce9916 fixed CS 2017-05-07 09:03:57 -07:00
Fabien Potencier
f56245594c minor #22659 Improved the stack traces that don't contain a function (javiereguiluz)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Improved the stack traces that don't contain a function

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

When a trace doesn't have a method/function associated, we display `n/a` and the file path below it. This usually happens in the first line of the stack traces. I don't think this looks OK, so I'm proposing to change it as follows:

### Before

![before-exception](https://cloud.githubusercontent.com/assets/73419/25782450/ae521cc6-334b-11e7-9e22-b31342667f6c.png)

### After

![after-exception](https://cloud.githubusercontent.com/assets/73419/25782451/b1b9957e-334b-11e7-812f-8c24ab8872df.png)

Commits
-------

9457558457 Improved the stack traces that don't contain a function
2017-05-07 08:55:12 -07:00
Javier Eguiluz
9457558457 Improved the stack traces that don't contain a function 2017-05-07 17:32:13 +02:00
Fabien Potencier
66c4c35396 bug #22639 [WebLink][TwigBundle] Fix registration of the twig extension (ogizanagi)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[WebLink][TwigBundle] Fix registration of the twig extension

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | See http://symfony.com/blog/new-in-symfony-3-3-weblink-component comments
| License       | MIT
| Doc PR        | N/A

BTW it is the only extension not using a classic service definition and adding the tag using the `Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass` class.

(Fabbot failure fixed in https://github.com/symfony/symfony/pull/22640)

Commits
-------

3d8a5646e7 [WebLink][TwigBundle] Fix registration of the twig extension
2017-05-07 08:24:22 -07:00
Fabien Potencier
56feeec7dc bug #22658 Make the exception pages work when the WebProfilerBundle is not installed (javiereguiluz)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Make the exception pages work when the WebProfilerBundle is not installed

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22631
| License       | MIT
| Doc PR        | -

Commits
-------

98353b0032 Make the exception pages work when the WebProfilerBundle is not installed
2017-05-07 08:23:41 -07:00
Fabien Potencier
b0236cef9b minor #22656 [DI][DX] Fix missing autoconfigure in container debug (Christopher Hertel)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI][DX] Fix missing autoconfigure in container debug

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Added missing autoconfigure flag for `debug:container` with service id.

Commits
-------

f50afad839 fixed missing autoconfigure in container debug
2017-05-07 08:22:37 -07:00
Fabien Potencier
5b6928dbe9 bug #22657 [DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use (ogizanagi)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21369
| License       | MIT
| Doc PR        | N/A

The `return` trick doesn't seem to work, and php is still trying to declare the `DefinitionDecorator` class, which causes the "Cannot declare class ...\DefinitionDecorator, because the name is already in use" error because of the `class_alias` previously declared in `ChildDefinition.php`.

This never happens as soon as the `ChildDefinition` class is used first, as the alias will take hand, but their are some situations, like in some unit test cases it can happen apparently, because `DefinitionDecorator` is used first.

Commits
-------

530849e4b5 [DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use
2017-05-07 08:20:56 -07:00
Javier Eguiluz
98353b0032 Make the exception pages work when the WebProfilerBundle is not installed 2017-05-07 17:01:53 +02:00
Maxime Steinhausser
530849e4b5 [DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use 2017-05-07 11:42:51 +02:00
Christopher Hertel
f50afad839 fixed missing autoconfigure in container debug 2017-05-07 00:45:28 +02:00
Maxime Steinhausser
08f4ad2275 [Workflow] fix use directives 2017-05-06 11:04:08 +02:00
Maxime Steinhausser
3fc80d10ef [Workflow] Move twig extension registration to twig bundle 2017-05-06 10:33:49 +02:00
Fabien Potencier
e5bb8fad3f minor #22648 Improving autowire exception when you type-hint a class & alias is available (weaverryan)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Improving autowire exception when you type-hint a class & alias is available

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | n/a

Suppose you type-hint a class instead of the correct interface (which is aliased):

```php
public function __construct(Logger $logger)
```

Current error:

> Cannot autowire service "AppBundle\Security\PostVoter": argument "$logger" of method "__construct()" references class "Symfony\Bridge\Monolog\Logger" but no such service exists. You should maybe alias this class to one of these existing services: "monolog.logger", "monolog.logger.request", "monolog.logger.console", "monolog.logger.cache", "monolog.logger.templating", "monolog.logger.translation", "monolog.logger.profiler", "monolog.logger.php", "monolog.logger.event", "monolog.logger.router", "monolog.logger.security", "monolog.logger.doctrine"; or type-hint against interface "Psr\Log\LoggerInterface" instead.

New error:

> Cannot autowire service "AppBundle\Security\PostVoter": argument "$logger" of method "__construct()" references class "Symfony\Bridge\Monolog\Logger" but no such service exists. Try changing the type-hint to "Psr\Log\LoggerInterface" instead.

The correct "suggestion" was always  there (at the end). I think if there is already a definitive alias available for your type-hint, we can say that they are simply using the wrong type-hint and suggest *only* that.

Commits
-------

5a3c156798 Improving autowire exception when you type-hint a class and there is an interface alias available
2017-05-05 08:45:54 -07:00
Ryan Weaver
5a3c156798 Improving autowire exception when you type-hint a class and there is an interface alias available 2017-05-05 11:28:37 -04:00
Fabien Potencier
fb021404ba minor #22646 [FrameworkBundle] Add type hint for ContainerInterface on ControllerTrait (maff)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Add type hint for ContainerInterface on ControllerTrait

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

When inspecting code using the `ControllerTrait`, IDE autocompletion and automatic type resolving of services does not work as the IDE (e.g. PHPStorm with the Symfony plugin) does not know what `$this->container` refers to:

![image](https://cloud.githubusercontent.com/assets/27403/25742248/eee5f280-318e-11e7-83df-c417bc7edb84.png)

This adds a type hint for the container property, making the IDE aware what `container` is.

![image](https://cloud.githubusercontent.com/assets/27403/25742238/dceda64a-318e-11e7-9f63-c92a82e75744.png)

Commits
-------

7f416ede17 [FrameworkBundle] Add type hint for ContainerInterface to ControllerTrait
2017-05-05 06:58:44 -07:00