Comments (2)
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.
from compiler.
Casting could be made obsolete if something like the as
-assertions were to be added to PHP: https://externals.io/message/122687
from compiler.
Related Issues (20)
- Use php:X.Y instead of PHP.X.Y HOT 1
- Regex syntax exploration HOT 1
- Logical Operators and Assignment Expressions: HOT 1
- For with ranges HOT 3
- Line number inconsistent after multi-line doc comments HOT 2
- Produce errors for trojan source HOT 1
- Support Disjunctive Normal Form Types
- Nullable type unions don't work as expected HOT 5
- do expression HOT 3
- #Override annotation HOT 6
- Interface Default Methods HOT 4
- Typed local variables HOT 1
- Typed class constants support HOT 3
- Fatal error: Label 'c1107822099' already defined HOT 1
- Arbitrary static variable initializers HOT 4
- Reusable property hooks HOT 2
- Lambda parameters bleeding into locals
- ::namespace HOT 3
- Not-Null pipe operator HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler.