Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XP Core dependencies #132

Open
thekid opened this issue Jan 29, 2022 · 2 comments
Open

XP Core dependencies #132

thekid opened this issue Jan 29, 2022 · 2 comments

Comments

@thekid
Copy link
Member

thekid commented Jan 29, 2022

This ticket tracks the dependencies on XP core:

  • cast() for casting anything other than string, int, float, bool, array and object (and nullable versions of these, see Inline nullable checks when casting #131)
  • typeof() in the VirtualPropertyTypes augmentation
  • XP meta information for extended types such as array<int>, as seen in this failing test if XpMeta is removed:
    Failing test
  • util.Objects::stringOf() inside RewriteEnums used in PHP < 8.1
  • lang.VirtualProperty for being able to set readonly properties via reflection
  • is() in the VirtualPropertyTypes augmentation
  • hard-wired .class.php file extension -see Implement command line option to set file extension for compiled files #159
@thekid
Copy link
Member Author

thekid commented Jan 29, 2022

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
Copy link
Member Author

thekid commented Mar 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant