You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If autowire is enabled, you can also use annotations; with the previous exemple it would be::
147
+
.. tip::
148
148
149
-
/**
150
-
* @required
151
-
* @return static
152
-
*/
153
-
public function withLogger(LoggerInterface $logger)
154
-
{
155
-
$new = clone $this;
156
-
$new->logger = $logger;
149
+
If autowire is enabled, you can also use annotations; with the previous
150
+
example it would be::
157
151
158
-
return $new;
159
-
}
152
+
/**
153
+
* @required
154
+
* @return static
155
+
*/
156
+
public function withLogger(LoggerInterface $logger)
157
+
{
158
+
$new = clone $this;
159
+
$new->logger = $logger;
160
+
161
+
return $new;
162
+
}
163
+
164
+
You can also leverage the PHP 8 ``static`` return type instead of the
165
+
``@return static`` annotation. If you don't want a method with a
166
+
PHP 8 ``static`` return type and a ``@required`` annotation to behave as
167
+
a wither, you can add a ``@return $this`` annotation to disable the
168
+
*returns clone* feature.
169
+
170
+
.. versionadded:: 5.1
160
171
161
-
You can also leverage the PHP8 ``static`` return type instead of the ``@return static`` annotation. Note if you don't want a method with a PHP8 ``static`` return type and a ``@required`` annotation to behave as a wither, you can add a ``@return $this`` annotation to disable the *returns clone* feature.
172
+
Support for the PHP 8 ``static`` return type was introduced in
0 commit comments