Skip to content

Commit ab86ac4

Browse files
author
Rastusik
committed
compatibility with PHP 8.2
1 parent 0ca1ca6 commit ab86ac4

5 files changed

Lines changed: 71 additions & 43 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Library that provides direct access to native PHP structures",
44
"type": "library",
55
"require": {
6-
"php": "8.1.*",
6+
"php": "8.2.*",
77
"ext-ffi": "*"
88
},
99
"license": [

include/engine_x64_nts.h

Lines changed: 67 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ struct _zend_array {
129129
uint32_t flags;
130130
} u;
131131
uint32_t nTableMask;
132-
Bucket *arData;
132+
union {
133+
uint32_t *arHash; /* hash table (allocated above this pointer) */
134+
Bucket *arData; /* array of hash buckets */
135+
zval *arPacked; /* packed array of zvals */
136+
};
133137
uint32_t nNumUsed;
134138
uint32_t nNumOfElements;
135139
uint32_t nTableSize;
@@ -406,16 +410,16 @@ struct _zend_op_array {
406410
uint32_t required_num_args;
407411
zend_arg_info *arg_info;
408412
HashTable *attributes;
413+
uint32_t T; /* number of temporary variables */
414+
void ** * run_time_cache;
409415
/* END of common elements */
410416

411417
int cache_size; /* number of run_time_cache_slots * sizeof(void*) */
412418
int last_var; /* number of CV variables */
413-
uint32_t T; /* number of temporary variables */
414419
uint32_t last; /* number of opcodes */
415420

416421
zend_op *opcodes;
417-
void ** * run_time_cache; ## __run_time_cache
418-
HashTable * * static_variables_ptr; ## __static_variables_ptr
422+
HashTable * * static_variables_ptr;
419423
HashTable *static_variables;
420424
zend_string **vars; /* names of CV variables */
421425

@@ -457,6 +461,8 @@ typedef struct _zend_internal_function {
457461
uint32_t required_num_args;
458462
zend_internal_arg_info *arg_info;
459463
HashTable *attributes;
464+
uint32_t T; /* number of temporary variables */
465+
void ** * run_time_cache;
460466
/* END of common elements */
461467

462468
zif_handler handler;
@@ -477,8 +483,10 @@ union _zend_function {
477483
zend_function *prototype;
478484
uint32_t num_args;
479485
uint32_t required_num_args;
480-
zend_arg_info *arg_info;
481-
HashTable *attributes;
486+
zend_arg_info *arg_info; /* index -1 represents the return value info, if any */
487+
HashTable *attributes;
488+
uint32_t T; /* number of temporary variables */
489+
void ** * run_time_cache;
482490
} common;
483491

484492
zend_op_array op_array;
@@ -512,24 +520,16 @@ typedef struct _zend_closure {
512520

513521
extern const ZEND_API zend_object_handlers std_object_handlers;
514522

515-
/* The following rule applies to read_property() and read_dimension() implementations:
516-
If you return a zval which is not otherwise referenced by the extension or the engine's
517-
symbol table, its reference count should be 0.
518-
*/
519523
/* Used to fetch property from the object, read-only */
520524
typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
521525

522526
/* Used to fetch dimension from the object, read-only */
523527
typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv);
524528

525529

526-
/* The following rule applies to write_property() and write_dimension() implementations:
527-
If you receive a value zval in write_property/write_dimension, you may only modify it if
528-
its reference count is 1. Otherwise, you must create a copy of that zval before making
529-
any changes. You should NOT modify the reference count of the value passed to you.
530+
/* Used to set property of the object
530531
You must return the final value of the assigned property.
531532
*/
532-
/* Used to set property of the object */
533533
typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot);
534534

535535
/* Used to set dimension of the object */
@@ -608,46 +608,46 @@ typedef int (*zend_object_compare_t)(zval *object1, zval *object2);
608608
/* Cast an object to some other type.
609609
* readobj and retval must point to distinct zvals.
610610
*/
611-
typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type);
611+
typedef zend_result (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type);
612612

613613
/* updates *count to hold the number of elements present and returns SUCCESS.
614614
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
615-
typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count);
615+
typedef zend_result (*zend_object_count_elements_t)(zend_object *object, zend_long *count);
616616

617-
typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
617+
typedef zend_result (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
618618

619619
typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n);
620620

621-
typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2);
621+
typedef zend_result (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2);
622622

623623
struct _zend_object_handlers {
624624
/* offset of real object header (usually zero) */
625-
int offset;
625+
int offset;
626626
/* object handlers */
627-
zend_object_free_obj_t free_obj; /* required */
628-
zend_object_dtor_obj_t dtor_obj; /* required */
629-
zend_object_clone_obj_t clone_obj; /* optional */
630-
zend_object_read_property_t read_property; /* required */
627+
zend_object_free_obj_t free_obj; /* required */
628+
zend_object_dtor_obj_t dtor_obj; /* required */
629+
zend_object_clone_obj_t clone_obj; /* optional */
630+
zend_object_read_property_t read_property; /* required */
631631
zend_object_write_property_t write_property; /* required */
632632
zend_object_read_dimension_t read_dimension; /* required */
633-
zend_object_write_dimension_t write_dimension; /* required */
634-
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */
635-
zend_object_has_property_t has_property; /* required */
633+
zend_object_write_dimension_t write_dimension; /* required */
634+
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr; /* required */
635+
zend_object_has_property_t has_property; /* required */
636636
zend_object_unset_property_t unset_property; /* required */
637-
zend_object_has_dimension_t has_dimension; /* required */
638-
zend_object_unset_dimension_t unset_dimension; /* required */
637+
zend_object_has_dimension_t has_dimension; /* required */
638+
zend_object_unset_dimension_t unset_dimension; /* required */
639639
zend_object_get_properties_t get_properties; /* required */
640640
zend_object_get_method_t get_method; /* required */
641-
zend_object_get_constructor_t get_constructor; /* required */
641+
zend_object_get_constructor_t get_constructor; /* required */
642642
zend_object_get_class_name_t get_class_name; /* required */
643-
zend_object_cast_t cast_object; /* required */
643+
zend_object_cast_t cast_object; /* required */
644644
zend_object_count_elements_t count_elements; /* optional */
645645
zend_object_get_debug_info_t get_debug_info; /* optional */
646-
zend_object_get_closure_t get_closure; /* optional */
646+
zend_object_get_closure_t get_closure; /* optional */
647647
zend_object_get_gc_t get_gc; /* required */
648-
zend_object_do_operation_t do_operation; /* optional */
649-
zend_object_compare_t compare; /* required */
650-
zend_object_get_properties_for_t get_properties_for; /* optional */
648+
zend_object_do_operation_t do_operation; /* optional */
649+
zend_object_compare_t compare; /* required */
650+
zend_object_get_properties_for_t get_properties_for; /* optional */
651651
};
652652

653653
/* zend_llist.h*/
@@ -782,6 +782,13 @@ typedef struct _zend_class_iterator_funcs {
782782
zend_function *zf_rewind;
783783
} zend_class_iterator_funcs;
784784

785+
typedef struct _zend_class_arrayaccess_funcs {
786+
zend_function *zf_offsetget;
787+
zend_function *zf_offsetexists;
788+
zend_function *zf_offsetset;
789+
zend_function *zf_offsetunset;
790+
} zend_class_arrayaccess_funcs;
791+
785792
/* zend.h */
786793
struct _zend_serialize_data;
787794
struct _zend_unserialize_data;
@@ -823,6 +830,7 @@ typedef struct _zend_class_mutable_data {
823830
zval *default_properties_table;
824831
HashTable *constants_table;
825832
uint32_t ce_flags;
833+
HashTable *backed_enum_table;
826834
} zend_class_mutable_data;
827835

828836
typedef struct _zend_class_dependency {
@@ -891,6 +899,8 @@ struct _zend_class_entry {
891899

892900
/* allocated only if class implements Iterator or IteratorAggregate interface */
893901
zend_class_iterator_funcs *iterator_funcs_ptr;
902+
/* allocated only if class implements ArrayAccess interface */
903+
zend_class_arrayaccess_funcs *arrayaccess_funcs_ptr;
894904

895905
/* handlers */
896906
union {
@@ -1028,6 +1038,7 @@ typedef struct _zend_fiber_transfer {
10281038
/* Coroutine functions must populate the given transfer with a new context
10291039
* and (optional) data before they return. */
10301040
typedef void (*zend_fiber_coroutine)(zend_fiber_transfer *transfer);
1041+
typedef void (*zend_fiber_clean)(zend_fiber_context *context);
10311042
typedef struct _zend_fiber_stack zend_fiber_stack;
10321043

10331044
struct _zend_fiber_stack {
@@ -1068,12 +1079,18 @@ struct _zend_fiber_context {
10681079
/* Entrypoint function of the fiber. */
10691080
zend_fiber_coroutine function;
10701081

1082+
/* Cleanup function for fiber. */
1083+
zend_fiber_clean cleanup;
1084+
10711085
/* Assigned C stack. */
10721086
zend_fiber_stack *stack;
10731087

10741088
/* Fiber status. */
10751089
zend_fiber_status status;
10761090

1091+
/* Observer state */
1092+
zend_execute_data *top_observed_frame;
1093+
10771094
/* Reserved for extensions */
10781095
void *reserved[6];
10791096
};
@@ -1104,6 +1121,9 @@ struct _zend_fiber {
11041121
/* Frame on the bottom of the fiber vm stack. */
11051122
zend_execute_data *stack_bottom;
11061123

1124+
/* Active fiber vm stack. */
1125+
zend_vm_stack vm_stack;
1126+
11071127
/* Storage for fiber return value. */
11081128
zval result;
11091129
};
@@ -1201,6 +1221,10 @@ typedef struct _OSVERSIONINFOEXA {
12011221
} OSVERSIONINFOEX;
12021222
#endif
12031223

1224+
typedef struct zend_atomic_bool_s {
1225+
volatile bool value;
1226+
} zend_atomic_bool;
1227+
12041228
struct _zend_executor_globals {
12051229
zval uninitialized_zval;
12061230
zval error_zval;
@@ -1249,8 +1273,8 @@ struct _zend_executor_globals {
12491273
/* for extended information support */
12501274
bool no_extensions;
12511275

1252-
bool vm_interrupt;
1253-
bool timed_out;
1276+
zend_atomic_bool vm_interrupt;
1277+
zend_atomic_bool timed_out;
12541278
zend_long hard_timeout;
12551279

12561280
#ifdef ZEND_WIN32
@@ -1327,6 +1351,10 @@ struct _zend_executor_globals {
13271351
uint32_t num_errors;
13281352
zend_error_info **errors;
13291353

1354+
/* Override filename or line number of thrown errors and exceptions */
1355+
zend_string *filename_override;
1356+
zend_long lineno_override;
1357+
13301358
void *reserved[6];
13311359
};
13321360
typedef struct _zend_executor_globals zend_executor_globals;
@@ -1489,8 +1517,8 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(zend_ast_kind kind, zend_ast
14891517
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3);
14901518
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4);
14911519
ZEND_API zend_ast *zend_ast_create_decl(
1492-
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
1493-
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4
1520+
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
1521+
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4
14941522
);
14951523

14961524
/**

src/Reflection/ReflectionClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function fromCData(CData $classEntry): ReflectionClass
110110
$reflectionClass->initLowLevelStructures($classEntry);
111111
$classNameValue = StringEntry::fromCData($classEntry->name);
112112
try {
113-
call_user_func([$reflectionClass, 'parent::__construct'], $classNameValue->getStringValue());
113+
call_user_func($reflectionClass->__construct(...), $classNameValue->getStringValue());
114114
} catch (\ReflectionException $e) {
115115
// This can happen during the class-loading. But we still can work with it.
116116
}

src/Reflection/ReflectionClassConstant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function fromCData(CData $constantEntry, string $constantName): Re
6565
$reflectionConstant = (new ReflectionClass(static::class))->newInstanceWithoutConstructor();
6666
$className = StringEntry::fromCData($constantEntry->ce->name);
6767
call_user_func(
68-
[$reflectionConstant, 'parent::__construct'],
68+
$reflectionConstant->__construct(...),
6969
$className->getStringValue(),
7070
$constantName
7171
);

src/Reflection/ReflectionMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function fromCData(CData $functionEntry): ReflectionMethod
6464
$scopeName = StringEntry::fromCData($scopeNamePtr);
6565
$functionName = StringEntry::fromCData($functionNamePtr);
6666
call_user_func(
67-
[$reflectionMethod, 'parent::__construct'],
67+
$reflectionMethod->__construct(...),
6868
$scopeName->getStringValue(),
6969
$functionName->getStringValue()
7070
);

0 commit comments

Comments
 (0)