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 example it would be:
146
+
147
+
.. code-block:: php
148
+
149
+
/**
150
+
* @required
151
+
* @return static
152
+
*/
153
+
public function withLogger(LoggerInterface $logger)
154
+
{
155
+
$new = clone $this;
156
+
$new->logger = $logger;
157
+
158
+
return $new;
159
+
}
160
+
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.
0 commit comments