xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

XP Core dependencies #132

Open thekid opened 2 years ago

thekid commented 2 years ago

This ticket tracks the dependencies on XP core:

thekid commented 2 years ago

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), like array<string>:

// Syntax
$input= (array<string>)$parameters->named('list');

// Rewritten to use the cast function from XP Core
$input= cast($parameters->named('list'), 'string[]');

Extracting this functionality would create quite some overhead in the compiler and result in lots of duplicated code being generated.

thekid commented 7 months ago

Casting could be made obsolete if something like the as-assertions were to be added to PHP: https://externals.io/message/122687