- Scalar type declarations:
function f(int ...$args)
(bool, int, float and string, in addition to array, callable, self, parent and interface/class name). - Return type declarations:
function f(): bool
. - Constant arrays using define():
define('MY_CONSTANT', [ ... ])
. - Integer division with intdiv():
var_dump(intdiv(8, 3)); // int(3)
. - Spaceship operator:
$a <=> $b
→ {-1, 0, 1} (less, equal, bigger). - Null coalescing operator:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: wp-includes/js/api-request.js | |
// Returns a jqXHR object. See: https://api.jquery.com/jQuery.ajax/#jqXHR | |
wp.apiRequest({path: '/namespace/vendor/v1/config'}) | |
.then(configOptions => console.log(configOptions)); | |
// jqXHR object has method then(), but does not have methods catch() or | |
// finally(). Use fail() or always() instead | |
wp.apiRequest({path: '/namespace/vendor/v1/config'}) | |
.done(configOptions => console.log(configOptions)) |
NOTE: This gist is a translation from an article by Marcos Douglas. Here is the original version, in Brazilian Portuguese: http://objectpascalprogramming.com/posts/menos-e-mais/.
Have you ever wondered what would be the ideal quantity of arguments in a method? And how about the number of methods on an interface or class? And how many classes would you put inside a single unity?