Static Arrow Function

../_images/static_arrow_function.png

It is possible to add the static option to an arrow function. In that case, PHP doesn’t allow usage of the local object context, via $this.

On the other hand, it is still possible to access all the local variables of the context, and, if ever, $this was assigned to a local variable, it may be imported in the arrow function context.

Also, note that PHP accepts the presence of $this in the static arrow function, as long as… it is not executed! Since there is no way to modify the static status of the arrow function, it is a zombie function: it may be passed around, but not executed.

See Also

PHP Error Messages

PHP Features