Skip to content

Commit 2f1285e

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Add a note about constructor promotion and IDEs errors about attributes
2 parents 5423044 + 05c7614 commit 2f1285e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

service_container/autowiring.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,13 @@ attribute like this::
573573
}
574574
}
575575

576+
.. note::
577+
578+
Some IDEs will show an error when using ``#[Target]`` as in the previous example:
579+
*"Attribute cannot be applied to a property because it does not contain the 'Attribute::TARGET_PROPERTY' flag"*.
580+
The reason is that thanks to `PHP constructor promotion`_ this constructor
581+
argument is both a parameter and a class property. You can safely ignore this error message.
582+
576583
.. _autowire-attribute:
577584

578585
Fixing Non-Autowireable Arguments
@@ -833,3 +840,4 @@ over all code.
833840

834841
.. _ROT13: https://en.wikipedia.org/wiki/ROT13
835842
.. _service definition prototype: https://symfony.com/blog/new-in-symfony-3-3-psr-4-based-service-discovery
843+
.. _`PHP constructor promotion`: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion

service_container/tags.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,14 @@ directly via PHP attributes:
699699
;
700700
};
701701
702+
.. note::
703+
704+
Some IDEs will show an error when using ``#[TaggedIterator]`` together
705+
with the `PHP constructor promotion`_:
706+
*"Attribute cannot be applied to a property because it does not contain the 'Attribute::TARGET_PROPERTY' flag"*.
707+
The reason is that those constructor arguments are both parameters and class
708+
properties. You can safely ignore this error message.
709+
702710
If for some reason you need to exclude one or more services when using a tagged
703711
iterator, add the ``exclude`` option:
704712

@@ -1162,3 +1170,5 @@ be used directly on the class of the service you want to configure::
11621170
{
11631171
// ...
11641172
}
1173+
1174+
.. _`PHP constructor promotion`: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion

0 commit comments

Comments
 (0)