by itafroma · 11y ago · 0 comments
A more comprehensive list:
- Dual-mode scalar type hints (weak by default, toggleable to strict via a per-file syntax) (https://wiki.php.net/rfc/scalar_type_hints_v5)
- Return type declarations (https://wiki.php.net/rfc/return_types)
- <=> operator (https://wiki.php.net/rfc/combined-comparison-operator)
- Null coalesce operator (??) (https://wiki.php.net/rfc/isset_ternary)
- Closure::call (https://wiki.php.net/rfc/closure_apply)
- Abstract syntax tree (https://wiki.php.net/rfc/abstract_syntax_tree)
- Context sensitive lexer, allowing the use of reserved words in more places (https://wiki.php.net/rfc/context_sensitive_lexer)
- Unicode escape syntax in strings (https://wiki.php.net/rfc/unicode_escape)
- A uniform variable syntax (https://wiki.php.net/rfc/uniform_variable_syntax)
- Expectations (https://wiki.php.net/rfc/expectations)
- Use declaration grouping (https://wiki.php.net/rfc/group_use_declarations)
- Removal of a ton of long-deprecated features
- Massive speed improvements
You can see everything that's been added to PHP 7 on https://wiki.php.net/rfc (look under Accepted and Implemented - PHP 7.0)
Because, you know, this is PHP.
All of those would result in the variable being assigned those values: the null check uses the same semantics as is_null(), and the truth table for those values is:
$v is_null($v)
------------------
'' FALSE
false FALSE
' ' FALSE
0 FALSE
[] FALSE
If you want to all falsy values to use the fallback value, use the shorthand ternary operator (?:) instead.This is not meant to be an endorsement of this method, but PHP <7.0 uses a single-pass compilation where the parser itself does the opcode compilation. A lot of the buggy and quirky behavior PHP exhibits (at least when that behavior is unintentional) is the result of this process.
Like a lot of extant PHP, there's no real reason it was done this way: it's just the method Rasmus et al happened to program the original engine, and it's grown organically since then. With the AST, phpng, and the uniform variable syntax, I'd argue PHP7's main feature is finally getting around to correcting the sins of the past.
A lot? Please stop spreading wrong info. In the words of an internal developer,
> It does fix a few minor points with regard to variables vs. expressions, but those aren't particularly important.
>"So, really, the whole thing has no direct effect on userland devs. It's an internal rewrite."
https://www.reddit.com/r/PHP/comments/2cc9xp/rfc_abstract_sy...
You may disagree with me saying "a lot", and that's fair, but I don't think it's fair to say it's "wrong info" and NikiC's characterization that it has "no direct effect on userland devs" is disingenuous, given the RFC lists several changes to syntax and behavior: https://wiki.php.net/rfc/abstract_syntax_tree#changes_to_syn...