Skip to content

Commit

Permalink
Compatibility with newest arginfo gen_stub from PHP 8.4
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <[email protected]>
  • Loading branch information
bwoebi authored and estringana committed Nov 21, 2024
1 parent 599e8a1 commit 9917e7a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 43 deletions.
8 changes: 8 additions & 0 deletions ext/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ static inline zend_long zval_get_long(zval *op) {
#endif

enum {
ZEND_STR_NAME,
ZEND_STR_RESOURCE,
ZEND_STR_TRACE,
ZEND_STR_LINE,
ZEND_STR_FILE,
Expand Down Expand Up @@ -625,6 +627,12 @@ static zend_always_inline zend_result zend_call_function_with_return_value(zend_
#else
#define hasThis() (Z_TYPE_P(ZEND_THIS) == IS_OBJECT)
#endif

static inline zend_class_entry *zend_register_internal_class_with_flags(zend_class_entry *class_entry, zend_class_entry *parent_ce, uint32_t ce_flags) {
zend_class_entry *register_class = zend_register_internal_class_ex(class_entry, parent_ce);
register_class->ce_flags |= ce_flags;
return register_class;
}
#endif

#endif // DD_COMPATIBILITY_H
2 changes: 2 additions & 0 deletions ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,8 @@ static void dd_disable_if_incompatible_sapi_detected(void) {
#if PHP_VERSION_ID < 70100
zend_string *ddtrace_known_strings[ZEND_STR__LAST];
void ddtrace_init_known_strings(void) {
ddtrace_known_strings[ZEND_STR_NAME] = zend_string_init_interned(ZEND_STRL("name"), 1);
ddtrace_known_strings[ZEND_STR_RESOURCE] = zend_string_init_interned(ZEND_STRL("resource"), 1);
ddtrace_known_strings[ZEND_STR_TRACE] = zend_string_init_interned(ZEND_STRL("trace"), 1);
ddtrace_known_strings[ZEND_STR_LINE] = zend_string_init_interned(ZEND_STRL("line"), 1);
ddtrace_known_strings[ZEND_STR_FILE] = zend_string_init_interned(ZEND_STRL("file"), 1);
Expand Down
48 changes: 14 additions & 34 deletions ext/ddtrace_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,6 @@ static const zend_function_entry class_DDTrace_SpanLink_methods[] = {
ZEND_FE_END
};

static const zend_function_entry class_DDTrace_GitMetadata_methods[] = {
ZEND_FE_END
};

static const zend_function_entry class_DDTrace_SpanData_methods[] = {
ZEND_ME(DDTrace_SpanData, getDuration, arginfo_class_DDTrace_SpanData_getDuration, ZEND_ACC_PUBLIC)
ZEND_ME(DDTrace_SpanData, getStartTime, arginfo_class_DDTrace_SpanData_getStartTime, ZEND_ACC_PUBLIC)
Expand All @@ -489,14 +485,6 @@ static const zend_function_entry class_DDTrace_SpanData_methods[] = {
ZEND_FE_END
};

static const zend_function_entry class_DDTrace_RootSpanData_methods[] = {
ZEND_FE_END
};

static const zend_function_entry class_DDTrace_SpanStack_methods[] = {
ZEND_FE_END
};

static const zend_function_entry class_DDTrace_Integration_methods[] = {
ZEND_RAW_FENTRY("init", NULL, arginfo_class_DDTrace_Integration_init, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL)
ZEND_FE_END
Expand All @@ -523,14 +511,12 @@ static zend_class_entry *register_class_DDTrace_SpanEvent(zend_class_entry *clas
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanEvent", class_DDTrace_SpanEvent_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0);
zend_class_implements(class_entry, 1, class_entry_JsonSerializable);

zval property_name_default_value;
ZVAL_UNDEF(&property_name_default_value);
zend_string *property_name_name = zend_string_init("name", sizeof("name") - 1, 1);
zend_declare_typed_property(class_entry, property_name_name, &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
zend_string_release(property_name_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_NAME), &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));

zval property_attributes_default_value;
ZVAL_UNDEF(&property_attributes_default_value);
Expand All @@ -552,7 +538,7 @@ static zend_class_entry *register_class_DDTrace_ExceptionSpanEvent(zend_class_en
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "ExceptionSpanEvent", class_DDTrace_ExceptionSpanEvent_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_DDTrace_SpanEvent);
class_entry = zend_register_internal_class_with_flags(&ce, class_entry_DDTrace_SpanEvent, 0);

zval property_exception_default_value;
ZVAL_UNDEF(&property_exception_default_value);
Expand All @@ -569,7 +555,7 @@ static zend_class_entry *register_class_DDTrace_SpanLink(zend_class_entry *class
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanLink", class_DDTrace_SpanLink_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0);
zend_class_implements(class_entry, 1, class_entry_JsonSerializable);

zval property_traceId_default_value;
Expand Down Expand Up @@ -609,8 +595,8 @@ static zend_class_entry *register_class_DDTrace_GitMetadata(void)
{
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "GitMetadata", class_DDTrace_GitMetadata_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
INIT_NS_CLASS_ENTRY(ce, "DDTrace", "GitMetadata", NULL);
class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0);

zval property_commitSha_default_value;
ZVAL_EMPTY_STRING(&property_commitSha_default_value);
Expand All @@ -632,19 +618,15 @@ static zend_class_entry *register_class_DDTrace_SpanData(void)
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanData", class_DDTrace_SpanData_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0);

zval property_name_default_value;
ZVAL_EMPTY_STRING(&property_name_default_value);
zend_string *property_name_name = zend_string_init("name", sizeof("name") - 1, 1);
zend_declare_typed_property(class_entry, property_name_name, &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));
zend_string_release(property_name_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_NAME), &property_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));

zval property_resource_default_value;
ZVAL_EMPTY_STRING(&property_resource_default_value);
zend_string *property_resource_name = zend_string_init("resource", sizeof("resource") - 1, 1);
zend_declare_typed_property(class_entry, property_resource_name, &property_resource_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));
zend_string_release(property_resource_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_RESOURCE), &property_resource_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));

zval property_service_default_value;
ZVAL_EMPTY_STRING(&property_service_default_value);
Expand Down Expand Up @@ -672,9 +654,7 @@ static zend_class_entry *register_class_DDTrace_SpanData(void)

zval property_type_default_value;
ZVAL_EMPTY_STRING(&property_type_default_value);
zend_string *property_type_name = zend_string_init("type", sizeof("type") - 1, 1);
zend_declare_typed_property(class_entry, property_type_name, &property_type_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));
zend_string_release(property_type_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_TYPE), &property_type_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));

zval property_meta_default_value;
ZVAL_EMPTY_ARRAY(&property_meta_default_value);
Expand Down Expand Up @@ -740,8 +720,8 @@ static zend_class_entry *register_class_DDTrace_RootSpanData(zend_class_entry *c
{
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "RootSpanData", class_DDTrace_RootSpanData_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_DDTrace_SpanData);
INIT_NS_CLASS_ENTRY(ce, "DDTrace", "RootSpanData", NULL);
class_entry = zend_register_internal_class_with_flags(&ce, class_entry_DDTrace_SpanData, 0);

zval property_origin_default_value;
ZVAL_UNDEF(&property_origin_default_value);
Expand Down Expand Up @@ -805,8 +785,8 @@ static zend_class_entry *register_class_DDTrace_SpanStack(void)
{
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanStack", class_DDTrace_SpanStack_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
INIT_NS_CLASS_ENTRY(ce, "DDTrace", "SpanStack", NULL);
class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0);

zval property_parent_default_value;
ZVAL_UNDEF(&property_parent_default_value);
Expand Down
8 changes: 3 additions & 5 deletions ext/hook/uhook_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 4b2f667462bc9e7bed94b2c9a479b85f3086b521 */
* Stub hash: 74ab08e7f09c564fabb646706cb9ba0371026875 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_install_hook, 0, 1, IS_LONG, 0)
ZEND_ARG_OBJ_TYPE_MASK(0, target, Closure|Generator, MAY_BE_STRING|MAY_BE_CALLABLE, NULL)
Expand Down Expand Up @@ -83,7 +83,7 @@ static zend_class_entry *register_class_DDTrace_HookData(void)
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "HookData", class_DDTrace_HookData_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0);

zval property_data_default_value;
ZVAL_UNDEF(&property_data_default_value);
Expand All @@ -99,9 +99,7 @@ static zend_class_entry *register_class_DDTrace_HookData(void)

zval property_args_default_value;
ZVAL_UNDEF(&property_args_default_value);
zend_string *property_args_name = zend_string_init("args", sizeof("args") - 1, 1);
zend_declare_typed_property(class_entry, property_args_name, &property_args_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));
zend_string_release(property_args_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_ARGS), &property_args_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));

zval property_returned_default_value;
ZVAL_UNDEF(&property_returned_default_value);
Expand Down
2 changes: 1 addition & 1 deletion ext/hook/uhook_attributes.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <php.h>
#include <Zend/zend_attributes.h>
#include <Zend/zend_smart_str.h>
#include "uhook_attributes_arginfo.h"
#include "../ddtrace.h"
#include "../configuration.h"
#include "uhook_attributes_arginfo.h"
#include "uhook.h"

#include <hook/hook.h>
Expand Down
5 changes: 2 additions & 3 deletions ext/hook/uhook_attributes_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 90919c9c350e86acd6fe3c8d06753918d5e0572b */
* Stub hash: 39cf4bf2cf4b4ec1c18f3ff8643b3ba7b4ad69a1 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DDTrace_Trace___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 0, "\"\"")
Expand All @@ -23,8 +23,7 @@ static zend_class_entry *register_class_DDTrace_Trace(void)
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "DDTrace", "Trace", class_DDTrace_Trace_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL);

zend_string *attribute_name_Attribute_class_DDTrace_Trace_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1);
zend_attribute *attribute_Attribute_class_DDTrace_Trace_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_DDTrace_Trace_0, 1);
Expand Down

0 comments on commit 9917e7a

Please sign in to comment.