In this new article Er Galvao Abbott talks about the struggle (and finally, inclusion) of type hinting in PHP, more specifically coming in PHP7, and how strict they can be.
It wasn't easy (we knew it wouldn't be) and certainly wasn't pretty (we sort of knew that as well), but it's finally official: PHP7 will come with Scalar Type Hints (STH) and an optional "strict mode". [...] This is basically a step towards a more strict way of coding in PHP. Will we see more steps in that direction in the future? We don't know and we're OK with that for now. What's brilliant about the body of work represented by these RFCs is that by implementing their concepts and specially making the "strict mode" optional the choice of being more strict remains with the programmer.
He talks some about the background of the want and need for strict typing in PHP and mentions three RFCs that will influence the type hints and handling in PHP7:
- Scalar Type Hints v5- (forked) RFC by Anthony Ferrara on Andrea Faulds' original
- Return Type Declarations -RFC by Levi Morrison
- Exceptions in the engine- RFC by Nikita Popov
He summarizes each RFC and what it contributes to the language. He ends the post by dispelling one thing about all of this new typing functionality - PHP will remain loosely typed, this new functionality is in a "strict mode" only used when specified.
Link: https://medium.com/@galvao/php7-more-strict-but-only-if-you-want-it-to-be-78d6690f2090
没有评论:
发表评论