1PHP 8.0 INTERNALS UPGRADE NOTES 2 31. Internal API changes 4 a. Object Handlers API 5 b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler 6 c. TSRM changes 7 d. get() and set() object handlers 8 e. zend_parse_parameters 'L' specifier 9 f. Arginfo argument types 10 g. zend_free_op type and should_free argument of zend_get_zval_ptr() 11 h. zend_value_error() 12 i. get_closure() object handler 13 j. compare_objects() and compare() object handlers 14 k. The 'I' length modifier 15 l. Some VM instructions switched to IS_TMP_VAR result instead of IS_VAR 16 m. All internal functions must have arginfo 17 n. zend_hash_sort compare function and zend_hash_sort signature change 18 o. cast_object() object handler is now required 19 p. ARG_COUNT() macro removed 20 q. GC_COLLECTABLE flag 21 r. Cannot implement Traversable only 22 s. zend_fcall_info no_separation flag removed 23 t. Signature changes 24 u. Error Notification callbacks to replace zend_error_cb overwrite use-cases 25 v. Removed Zend APIs 26 w. Renamed Zend APIs 27 x. ZEND_EXT_NOP no longer emitted 28 292. Build system changes 30 a. Abstract 31 b. Unix build system changes 32 c. Windows build system changes 33 343. Module changes 35 36======================== 371. Internal API changes 38======================== 39 40 a. The Object Handlers API was changed to receive zend_object* instead of 41 zval* and zend_string* instead of zval* for property names. See also 42 section t for other similar changes. 43 44 b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler 45 were removed. ZEND_INTERNAL_FUNCTION with ZEND_ACC_CALL_VIA_HANDLER and 46 defined "handler" callback should be used instead. This "handler" callback 47 should also take care about function cleanup. See ext/zend_test/test.c 48 for example. 49 50 c. The following things have been removed from TSRM: 51 - TSRMLS_DC 52 - TSRMLS_D 53 - TSRMLS_CC 54 - TSRMLS_C 55 - TSRMLS_FETCH 56 - TSRMLS_FETCH_FROM_CTX 57 - TSRMLS_SET_CTX 58 - tsrm_new_interpreter_context 59 - tsrm_set_interpreter_context 60 - tsrm_free_interpreter_context 61 - support for GNUPTH, SGI ST, and BETHREADS 62 63 d. The get() and set() object handlers have been removed. The get() handler 64 can generally be replaced with cast_object(). Some uses of set() may be 65 replaced by do_operation(). If set() was used to overload direct 66 assignments using "=", then this is no longer supported and the 67 functionality should be provided in some other way (for example, as 68 modification of an object property). 69 70 e. The zend_parse_parameters 'L' specifier and the Z_PARAM_STRICT_LONG() 71 family of macros have been removed. Use 'l' and Z_PARAM_LONG() instead, 72 which, despite the confusing name, actually have stricter input validation. 73 74 f. Arginfo argument types for internal functions are no longer checked. 75 Instead type checks should be performed using the zend_parse_parameters() 76 or ZEND_PARSE_PARAMETERS_*() APIs. 77 78 g. The zend_free_op type and the "should_free" and "type" arguments of 79 zend_get_zval_ptr() were removed. It's possible to get the old 80 "should_free" value using the following code: 81 82 zval *ret = zend_get_zval_ptr( 83 opline, opline->op1_type, &opline->op1, execute_data); 84 zval *should_free = (op_type & (IS_TMP_VAR|IS_VAR)) ? ret : NULL; 85 86 h. Added the zend_value_error() function, which is intended to be used 87 to raise ValueError when inappropriate argument values are passed 88 to functions. 89 90 i. get_closure() object handlers now accept an additional zend_bool parameter 91 `check_only`. If it is true, the handler is called to check whether the 92 object is callable; in this case the handler should not throw an exception. 93 94 j. compare_objects() handler was removed. Extensions should use compare() object 95 handler instead and check if both arguments are objects and have the same 96 compare handler, using ZEND_COMPARE_OBJECTS_FALLBACK() macro. 97 98 k. The 'I' length modifier, used to denote 32 and 64bit integer from the custom 99 snprintf and spprintf implementations has been removed. 100 Use the ZEND_LONG_FMT, ZEND_ULONG_FMT and ZEND_XLONG_FMT macros defined in 101 php-src/Zend/zend_long.h 102 103 The 'v' format from the custom snprintf and spprintf implementations has 104 been removed. Use the standard 's' format instead. 105 106 l. Some VM instructions switched to IS_TMP_VAR result instead of IS_VAR. 107 Actually, all assignments (ZEND_ASSIGN, ZEND_ASSIGN_DIM, ZEND_ASSIGN_OBJ, 108 ZEND_ASSIGN_STATIC_PROP), all compound assignments (ZEND_ASSIGN_OP, 109 ZEND_ASSIGN_DIM_OP, ZEND_ASSIGN_OBJ_OP, ZEND_ASSIGN_STATIC_PROP_OP) and all 110 pre increments/decrements (ZEND_PRE_INC, ZEND_PRE_DEC, ZEND_PRE_INC_OBJ 111 ZEND_PRE_DEC_OBJ, ZEND_PRE_INC_STATIC_PROP ZEND_PRE_DEC_STATIC_PROP). 112 113 m. All internal functions and methods are now required to specify arginfo 114 information, otherwise warnings will be thrown on startup. 115 116 n. The zend_hash_sort and zend_hash_minmax APIs now accept a comparison 117 function with the following signature: 118 119 typedef int (*bucket_compare_func_t)(Bucket *a, Bucket *b); 120 121 Previously compare_func_t was used, which accepted void pointers. 122 Furthermore, the return type of zend_hash_sort and zend_ts_hash_sort has 123 been changed from int to void; these functions always succeed. 124 125 o. The cast_object() handler is now required, i.e. must be non-null. You can 126 indicate that casting is not supported by always returning FAILURE. 127 128 p. The ARG_COUNT() macro has been removed use ZEND_NUM_ARGS() instead. 129 130 q. GC_COLLECTABLE flag was inverted into GC_NOT_COLLECTABLE. 131 Assignments to GC_TYPE_INFO() might need to be changed to properly 132 set the value of the GC_NOT_COLLECTABLE flag. 133 134 r. Just for for userland classes, it is no longer allowed to implement only 135 the Traversable interface. Instead, it is necessary to implement either 136 Iterator or IteratorAggregate. You can do the latter by implementing 137 zend_ce_aggregate and providing the following method implementation: 138 139 ZEND_METHOD(MyClass, getIterator) { 140 ZEND_PARSE_PARAMETERS_NONE(); 141 zend_create_internal_iterator_zval(return_value, ZEND_THIS); 142 } 143 144 s. The zend_fcall_info no_separation flag has been removed, and separation is 145 never allowed. If you wish to pass (or allow passing) arguments by 146 reference, explicitly create those arguments as references using 147 ZEND_MAKE_REF. This removal also affects call_user_function_ex(), which 148 should be replaced by call_user_function(). 149 150 t. The following ZEND_API function have changed signature: 151 1. Void in Zend Engine 4.0: 152 - add_assoc_*() 153 - add_index_*() 154 - add_property_*() 155 - object_init() 156 - zend_declare_class_constant*() 157 - zend_declare_property*() 158 - zend_startup_modules() 159 - zend_wrong_parameters_none_error() 160 - zend_fcall_info_argp() 161 - zend_fcall_info_argv() 162 - zend_fcall_info_argn() 163 - zend_startup() 164 - zend_set_memory_limit() 165 - pass_two() 166 - zend_startup_constants() 167 - zend_shutdown_constants() 168 - zend_startup_extensions_mechanism() 169 - zend_startup_extensions() 170 - zend_register_extension() 171 - highlight_string() 172 - zend_ini_startup() 173 - zend_ini_shutdown() 174 - zend_ini_global_shutdown() 175 - zend_ini_deactivate() 176 - zend_copy_ini_directives() 177 - zend_prepare_string_for_scanning() 178 - zend_init_rsrc_list() 179 - zend_list_close() 180 - zend_signal() 181 - zend_sigaction() 182 - zend_stack_init() 183 - zend_stack_del_top() 184 - zend_stack_destroy() 185 2. Argument int to uint32_t in Zend Engine 4.0: 186 - _zend_get_parameters_array_ex() 187 - zend_copy_parameters_array() 188 - zend_fcall_info_args_save() 189 - zend_fcall_info_args_restore() 190 - zend_fcall_info_argp() 191 - zend_fcall_info_argv() 192 - zend_fcall_info_argn() 193 - zend_wrong_parameter*() 194 - zend_wrong_callback_error() 195 - zend_parse_arg_class() 196 3. Argument int to bool in Zend Engine 4.0: 197 - add_next_index_bool() 198 - zend_register_class_alias_ex() 199 - add_assoc_bool_ex() 200 - add_index_bool() 201 - zend_fcall_info_args_clear() 202 - zend_set_local_var() 203 - zend_set_local_var_str() 204 - zend_parse_arg_*() 205 - shutdown_memory_manager() 206 - zend_memory_usage() 207 - zend_memory_peak_usage() 208 - zend_mm_shutdown() 209 - zend_eval_string*() 210 - zend_set_timeout() 211 - _zend_hash_append_ex() 212 - _zend_hash_append_ptr_ex() 213 - zend_alter_ini_entry_ex() 214 - (*zend_encoding_list_parser) typedef 215 - zend_multibyte_parse_encoding_list() 216 - zend_safe_address() 217 - zend_string_tolower_ex() 218 - zend_string_alloc() 219 - zend_string_safe_alloc() 220 - zend_string_init() 221 - zend_string_dup() 222 - zend_string_realloc() 223 - zend_string_extend() 224 - zend_string_truncate() 225 - zend_string_safe_realloc() 226 - zend_string_release_ex() 227 - zend_ts_hash_merge() 228 - zend_ts_hash_sort() 229 4. Argument int to size_t in Zend Engine 4.0: 230 - zend_set_hash_symbol() 231 5. Argument zval* to zend_object* in Zend Engine 4.0: 232 - zend_read_property() 233 - zend_update_property() 234 - zend_unset_property() 235 - zend_call_method() 236 - zend_objects_clone_obj() 237 - zend_get_closure_method_def() 238 - zend_throw_exception_hook() 239 - zend_throw_exception_internal() 240 - zend_get_exception_base() 241 6. Argument zval* to zend_long in Zend Engine 4.0: 242 - _php_math_longtobase() 243 7. Return type from int to zend_result in Zend Engine 4.0: 244 - (*stream_open_function) in _zend_utility_functions 245 - (*zend_post_startup_cb) 246 - (*zend_preload_autoload) 247 - zend_execute_scripts() 248 - zend_post_startup() 249 - _zend_get_parameters_array_ex() 250 - zend_copy_parameters_array() 251 - zend_parse_parameters() 252 - zend_parse_parameters_ex() 253 - zend_parse_method_parameters() 254 - zend_parse_method_parameters_ex() 255 - zend_parse_method_parameters() 256 - zend_register_functions() 257 - zend_startup_module() 258 - zend_startup_module_ex() 259 - zend_register_class_alias_ex() 260 - zend_disable_function() 261 - zend_disable_class() 262 - zend_update_class_constants() 263 - zend_update_static_property*() 264 - object_init_ex() 265 - object_and_properties_init() 266 - add_index_zval() 267 - add_next_index_long_*() 268 - array_set_zval_key() 269 - _call_user_function_impl() 270 - zend_fcall_info_*() 271 - zend_call_function() 272 - zend_set_hash_symbol() 273 - zend_delete_global_variable() 274 - zend_set_local_var() 275 - zend_set_local_var_str() 276 - zend_forbid_dynamic_call() 277 - zend_get_default_from_internal_arg_info() 278 - zend_try_assign_typed_ref*() 279 - zend_ast_evaluate() 280 - zend_startup_builtin_functions() 281 - do_bind_function() 282 - do_bind_class() 283 - zend_unmangle_property_name_ex() 284 - zend_register_auto_global() 285 - zend_register_constant() 286 - zend_exception_error() 287 - zend_eval_string*() 288 - zend_undefined_offset_write() 289 - zend_undefined_index_write() 290 - zval_update_constant(_ex)() 291 - zend_load_extension() 292 - zend_load_extension_handle() 293 - zend_hash_del(_ind)() 294 - zend_hash_str_del(_ind)() 295 - zend_hash_index_del() 296 - zend_hash_move_forward_ex() 297 - zend_hash_move_backward_ex() 298 - zend_hash_get_current_key_ex() 299 - zend_hash_get_current_key_type_ex() 300 - zend_symtable_del(_ind)() 301 - zend_symtable_str_del(_ind)() 302 - highlight_file() 303 - zend_do_link_class() 304 - zend_alter_ini_entry*() 305 - zend_restore_ini_entry() 306 - zend_ini_register_displayer() 307 - zend_ini_open_file_for_scanning() 308 - zend_ini_prepare_string_for_scanning() 309 - zend_user_it_valid() 310 - zend_create_internal_iterator_zval() 311 - zend_multibyte_set_filter() 312 - zend_lex_tstring() 313 - _zend_module_entry module_startup_func, module_shutdown_func, 314 request_startup_func, request_shutdown_func, and post_deactivate_func function pointers 315 - (*zend_encoding_list_parser) typedef 316 - (*zend_encoding_internal_encoding_setter) typedef 317 - zend_multibyte_set_functions() 318 - zend_multibyte_set_script_encoding_by_string() 319 - add_function() 320 - sub_function() 321 - mul_function() 322 - pow_function() 323 - div_function() 324 - mod_function() 325 - boolean_xor_function() 326 - boolean_not_function() 327 - bitwise_not_function() 328 - bitwise_or_function() 329 - bitwise_and_function() 330 - bitwise_xor_function() 331 - shift_left_function() 332 - shift_right_function() 333 - concat_function() 334 - is_equal_function( 335 - is_identical_function() 336 - is_not_identical_function() 337 - is_not_equal_function() 338 - is_smaller_function() 339 - is_smaller_or_equal_function(zv 340 - increment_function() 341 - decrement_function() 342 - zend_stream_open() 343 - zend_stream_fixup() 344 - zend_ts_hash_del() 345 - zend_ts_hash_index_del() 346 8. Return type from int to bool in Zend Engine 4.0: 347 - zend_make_printable_zval() 348 - zend_parse_arg_*() 349 - is_zend_mm() 350 - is_zend_ptr() 351 - zend_mm_is_custom_heap() 352 - (*zend_mm_chunk_truncate_t) 353 - (*zend_mm_chunk_extend_t) 354 - zend_bitset_empty() 355 - zend_is_smart_branch() 356 - zend_check_arg_send_type() 357 - zend_verify_const_access() 358 - zend_gdb_register_code() 359 - zend_gdb_present() 360 - _zend_handle_numeric_str(_ex)() 361 - zend_hash_exists_ind() 362 - zend_hash_str_exists_ind() 363 - zend_symtable_exists(_ind)() 364 - zend_symtable_str_exists() 365 - (*zend_encoding_lexer_compatibility_checker) 366 - zend_object_is_true() 367 - i_zend_is_true() 368 - zendi_smart_streq() 369 - zend_stack_is_empty() 370 - zend_ts_hash_exists() 371 - zend_ts_hash_index_exists() 372 9. Argument void to const char* in Zend Engine 4.0: 373 - zend_get_op_array_extension_handle() 374 10. Argument zend_extension to const char* in Zend Engine 4.0: 375 - zend_get_resource_handle() 376 11. Argument const char * to HMODULE in Zend Engine 4.0: 377 - php_win32_image_compatible() 378 12. const char * argument dropped in Zend Engine 4.0: 379 - php_win32_crt_compatible() 380 381 u. Instead of overwriting zend_error_cb extensions with debugging, monitoring 382 use-cases catching Errors/Exceptions are strongly encouraged to use 383 the new error observer API instead. 384 385 Error observering callbacks are guaranteed to be called regardless of 386 the users error_reporting setting or userland error handler return values. 387 388 Register observer callbacks during MINIT of an extension: 389 390 void my_error_observer_cb(int type, 391 const char *error_filename, 392 uint32_t error_lineno, 393 zend_string *message) { 394 } 395 zend_observer_error_register(my_error_observer_cb); 396 397 v. The following APIs have been removed from the Zend Engine: 398 - zend_ts_hash_init_ex(), drop the last argument and use zend_ts_hash_init() instead 399 - zend_hash_init_ex(), drop the last argument and use zend_hash_init() instead 400 - zval_internal_dtor(), use zval_internal_ptr_dtor() instead 401 - zval_dtor_func(), use rc_dtor_func() instead 402 - zval_ptr_dtor_wrapper(), use zval_ptr_dtor() instead 403 - zval_internal_ptr_dtor_wrapper(), use zval_internal_ptr_dtor() instead 404 405 w. The following APIs have been renamed: 406 - _zend_ts_hash_init() to zend_ts_hash_init() 407 408 x. In COMPILE_EXTENDED_STMT mode, a ZEND_EXT_NOP opcode will no longer be 409 generated at the start of a function. Use the new observer APIs or hook 410 into zend_execute_ex instead. 411 412======================== 4132. Build system changes 414======================== 415 416 a. Abstract 417 1. Symbol HAVE_HASH_EXT is removed and is no longer defined. It should be 418 considered to have hash extension always available since PHP 7.4. 419 420 2. Symbol HAVE_PCRE is removed and is no longer defined. It should be 421 considered to have pcre extension always available since PHP 7.4. 422 423 3. Symbol HAVE_LOCALE_H has been removed and is no longer defined. 424 425 4. --disable-inline-optimization (which actually disabled all compiler 426 optimizations) has been removed. If you wish to build PHP on a host 427 with extremely constrained memory, and compilation fails with an "out 428 of memory" message, add "-O0" to CFLAGS. 429 430 5. build system and provider are displayed in phpinfo from environment: 431 - PHP_BUILD_SYSTEM (default is same as PHP_UNAME) 432 - PHP_BUILD_PROVIDER (no default) 433 434 b. Unix build system changes 435 436 1. --enable-maintainer-zts is renamed --enable-zts for parity with Windows 437 and as recognition that ZTS is not a "maintainer" or experimental 438 feature. 439 440 2. The PHP_CHECK_GCC_ARG() m4 macro has been removed in favor of 441 AX_CHECK_COMPILE_FLAG(). 442 443 3. The 6th argument of PHP_ADD_SOURCES_X has been removed. 444 445 4. The 'special-flags' (3rd) argument of PHP_ADD_SOURCES_X are 446 now appended instead of prepended to previous compiler flags. 447 This means compiler flags passed to PHP_NEW_EXTENSION and PHP_ADD_SOURCES 448 are now appended, this allows to disable compiler flags set by Zend/Zend.m4 449 (e.g. disable certain compiler flags enabled by -Wextra) 450 451 c. Windows build system changes 452 453 - The configuration option --enable-crt-debug has been removed. The VC 454 debug heap can now be enabled for debug builds by setting the environment 455 variable PHP_WIN32_DEBUG_HEAP to a non-negative number before PHP process 456 startup. 457 458======================== 4593. Module changes 460======================== 461 462