[TASK] Deprecate usage of @inject with non-public properties
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / master / Deprecation-82975-DeprecateUsageOfInjectWithNonPublicProperties.rst
1 .. include:: ../../Includes.txt
2
3 ===========================================================================
4 Deprecation: #82975 - Deprecate usage of @inject with non-public properties
5 ===========================================================================
6
7 See :issue:`82975`
8
9 Description
10 ===========
11
12 When using private or protected properties for Dependency Injection via :php:`@inject`, Extbase needs to
13 use the object reflection API to make these properties settable from the outside,
14 which is quite slow and cannot be cached in any way. Therefore property injection should
15 only work for public properties.
16
17
18 Impact
19 ======
20
21 Using :php:`@inject` with a non-public property will trigger a deprecation warning and will
22 not work any longer in TYPO3 version 10.
23
24
25 Affected Installations
26 ======================
27
28 All installations, that use property injection via :php:`@inject` with non-public properties
29
30
31 Migration
32 =========
33
34 You have the following options to migrate:
35
36 - Introduce an explicit :php:`inject*()` method (e.g. :php:`injectMyProperty()`)
37 - Use constructor injection
38 - Make the property public (think about whether this is desired in terms of software design)
39
40
41 An inject method would look like this:
42
43 .. code-block:: php
44
45 /**
46 * @var MyFancyProperty $myFancyProperty
47 */
48 private $myFancyProperty;
49
50 /**
51 * @param MyFancyProperty $myFancyProperty
52 */
53 public function injectMyFancyProperty(MyFancyProperty $myFancyProperty): void
54 {
55 $this->myFancyProperty = $myFancyProperty;
56 }
57
58 .. index:: PHP-API, ext:extbase, NotScanned