Timm Friebe
Timm Friebe
The vote for the Property Hooks RFC is now open, see https://externals.io/message/123139
✅ Now works with *both* current PHP 8.4 and PHP 8.4 with https://github.com/php/php-src/pull/13455 in place
AST syntax is released: https://github.com/xp-framework/ast/releases/tag/v11.1.0
Released in https://github.com/xp-framework/compiler/releases/tag/v9.1.0
### Casting XP Compiler supports casting to any type, including value types and those not present in the PHP type system (but supported by tools like PHPDoc, PHPStan and others),...
Casting could be made obsolete if something like the `as`-assertions were to be added to PHP: https://externals.io/message/122687
In Kotlin, [scope functions](https://kotlinlang.org/docs/scope-functions.html) solve this: ```kotlin Person("Tom", age = 12) |> findFriends(it) |> storeFriendsList(it) // Equivalent Person("tom", age = 12) .let { findFriends(it) } .let { storeFriendsList(it) } ```...
> In Kotlin, [scope functions](https://kotlinlang.org/docs/scope-functions.html) solve this: The `let` function can be implemented relatively easily, even as an optional extension: ```diff diff --git a/src/main/php/lang/ast/emit/PHP.class.php b/src/main/php/lang/ast/emit/PHP.class.php index ac3d93a..adbe64b 100755 --- a/src/main/php/lang/ast/emit/PHP.class.php...
Here's a real-world example from https://github.com/thekid/dialog: ```php if ($prop= $env->properties($config, optional: true)) { $this->sources['config']= $prop->readString(...); } ``` This could be rewritten as follows: ```php // Scope function $env->properties($config, optional: true)?->let(fn($prop)...
This would break class constants named *namespace*: ```bash $ xp -w 'class T { const namespace = "ns"; } return T::namespace' ns ```