HHVM 4.44
HHVM 4.44 is released! HHVM 4.38–4.43 remain supported, as do the 4.8 and 4.32 LTS releases.
Breaking Changes
- the
__Deprecatedattribute is no longer permitted on any types, such as classes, enums, or type aliases; it had no effect in these positions. (int) NANis now consistently the minimum 64-bit signed integer, instead of- In previous releases, this behavior could differ at runtime compared to when constant-folding.
- square bracket literals for PHP arrays (e.g.
['foo', 'bar']) are now a parse error.array()is still supported, but will be removed in the near future. Ideally, usevec/dict/keysetinstead, butvarrayanddarrayremain supported.
Future Changes
- comparison operations (e.g.
<,<=,<=>etc) will be changed to throw when a PHP array is compared with a non-array. This operation currently raises a typechecker error, and raises a notice ifhhvm.hack_arr_compat_notices=trueandhhvm.hack_arr_compat_check_compare_non_any_array=trueINI options are set. The behavior of!==, and===will not change. array_key_exists()will change to throw an exception if the specified key is null. A notice is raised if thehhvm.hack_arr_compat_check_null_hack_array_key=trueandhhvm.hack_arr_compat_notices=trueINI options are set.- lambda type inference is being changed in the next release; the new behavior
can be enabled now with the
new_inference_lambda=true.hhconfigsetting; this can lead to the detection of additional type errors (example below) - string casts of
Stringishobjects will change to raise a runtime exception; thehhvm.notice_on_implicit_invoke_to_stringoption can be used to detect this.- this includes both explicit
(string)casts, and various forms of implicit casting (e.g. concatenation, comparisons, printfs, and interpolation); searching for(string)will not find all problematic code.
- this includes both explicit
- empty switch blocks (
switch ($foo) { /* empty */ }) will become a parse error. array()literals will be removed; usevec/dict/keysetinstead if possible, otherwisevarrayordarray.
New lambda inference
If the type can not be inferred in a usable way, the typechecker will now raise an error instead of assuming the behavior is safe.
1
2
3
4
5
6
7
8
9
10
function just_return_it<T>((function(T): void) $f):(function(T): void) {
return $f;
}
function break_it():void {
// No error here
$g = just_return_it($y ==> $y->this_method_does_not_exist());
// Can even try and invoke it on a string
$g('ohno');
}