- iPhone (2)
- Learning (42)
- Linux (4)
- Debian (1)
- Mac Terminal / Linux (5)
- Other Stuff (1)
- Programming (67)
- Slim Framework (1)
- WordPress (5)
1. iteratable psuedo type
This is a new type that can be used to more generically indicate that what is being passed can be iterated over using something like foreach. Prior to this, you could not type hint an iterable custom object.
2. Closure from callable
Allows you to create a closure from any callable function. This new technique will help catch typos up front, and improves performance.
3 and 4. Square bracket syntax for list.
This one is a shorthand for list($a, $b, $c) = [‘a’,’b’,’c’]; We can now write [$a, $b, $c] = [‘a’, ‘b’, ‘c’]; It also now allows you to specify the keys, and supports multi-dimensional arrays.
5. Class constant visibility
Class constants can now explicitly be set to protected, private, or public to aid in information hiding.
6. Nullable types
Now you can type hint, and allow optional null. Just put a ? in front of the type hint. Applies to function params and return types.
7. Void functions
You can now specify that a function may only return void. function foo() : void
8. Catching multiple exception types
Catch can now have more than one exception type. Just separate them with a | like catch(FooException | BarException)
9. Too few arguments exception
This one just means that in PHP 7.1, calling a function without required parameters will trigger an Error exception. It was a warning previously, but now you have to deal with it. This is a potentially breaking change when upgrading.