knuspermagier.de
Der privateste Blog von Philipp.

PHP ES6

Seitdem ich ziemlich viel JavaScript schreibe, würde ich es mir ja wünschen, wenn es die ein oder andere moderne Sprachfunktion auch in PHP gäbe. Zum Beispiel Arrow Functions.

Witzigerweise gibt es dazu sogar zwei RFCs, leider beide ohne Fortschritte in den letzten Jahre. Schade.

PHP RFC: Arrow Functions
Anonymous functions and closures can be verbose even though sometimes they are quite simple and contain only a single expression. Additionally, importing variables into the closure's scope is manual and is painful overhead for single-expression closures. In practice these single-expression closures are common. This RFC proposes a more concise syntax for this pattern.

PHP: rfc:arrow_functions

“Status: Under Discussion”, seit 2016, kein Voting.

PHP RFC: Short Closures
Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses.

PHP: rfc:short_closures

Ich finde den hier vorgeschlagenen ~>-Syntax nicht so schön, aber besser als nix. Beim Voting gab es 30 Nein-Stimmen gegen 22 Ja-Stimmen, und der Herr Lerdorf persönlich war leider dagegen. Dafür ist der Pull-Request noch offen und hat immerhin ab und zu in den letzten Monaten mal noch einen Kommentar bekommen.

Ich hab auf jeden Fall mal einen Daumen nach oben hinterlassen.