/src/php-src/Zend/zend_attributes.h
Line | Count | Source |
1 | | /* |
2 | | +----------------------------------------------------------------------+ |
3 | | | Zend Engine | |
4 | | +----------------------------------------------------------------------+ |
5 | | | Copyright © Zend Technologies Ltd., a subsidiary company of | |
6 | | | Perforce Software, Inc., and Contributors. | |
7 | | +----------------------------------------------------------------------+ |
8 | | | This source file is subject to the Modified BSD License that is | |
9 | | | bundled with this package in the file LICENSE, and is available | |
10 | | | through the World Wide Web at <https://www.php.net/license/>. | |
11 | | | | |
12 | | | SPDX-License-Identifier: BSD-3-Clause | |
13 | | +----------------------------------------------------------------------+ |
14 | | | Authors: Benjamin Eberlei <kontakt@beberlei.de> | |
15 | | | Martin Schröder <m.schroeder2007@gmail.com> | |
16 | | +----------------------------------------------------------------------+ |
17 | | */ |
18 | | |
19 | | #ifndef ZEND_ATTRIBUTES_H |
20 | | #define ZEND_ATTRIBUTES_H |
21 | | |
22 | | #include "zend_compile.h" |
23 | | #include "zend_constants.h" |
24 | | |
25 | 94 | #define ZEND_ATTRIBUTE_TARGET_CLASS (1<<0) |
26 | 44 | #define ZEND_ATTRIBUTE_TARGET_FUNCTION (1<<1) |
27 | 20 | #define ZEND_ATTRIBUTE_TARGET_METHOD (1<<2) |
28 | 12 | #define ZEND_ATTRIBUTE_TARGET_PROPERTY (1<<3) |
29 | 7 | #define ZEND_ATTRIBUTE_TARGET_CLASS_CONST (1<<4) |
30 | 137 | #define ZEND_ATTRIBUTE_TARGET_PARAMETER (1<<5) |
31 | 29 | #define ZEND_ATTRIBUTE_TARGET_CONST (1<<6) |
32 | 227 | #define ZEND_ATTRIBUTE_TARGET_ALL ((1<<7) - 1) |
33 | 103 | #define ZEND_ATTRIBUTE_IS_REPEATABLE (1<<7) |
34 | 2 | #define ZEND_ATTRIBUTE_FLAGS ((1<<8) - 1) |
35 | | |
36 | | /* Flags for zend_attribute.flags */ |
37 | 583 | #define ZEND_ATTRIBUTE_PERSISTENT (1<<0) |
38 | 6 | #define ZEND_ATTRIBUTE_STRICT_TYPES (1<<1) |
39 | | |
40 | | #define ZEND_ATTRIBUTE_SIZE(argc) \ |
41 | 0 | (sizeof(zend_attribute) + sizeof(zend_attribute_arg) * (argc) - sizeof(zend_attribute_arg)) |
42 | | |
43 | | BEGIN_EXTERN_C() |
44 | | |
45 | | extern ZEND_API zend_class_entry *zend_ce_attribute; |
46 | | extern ZEND_API zend_class_entry *zend_ce_allow_dynamic_properties; |
47 | | extern ZEND_API zend_class_entry *zend_ce_sensitive_parameter; |
48 | | extern ZEND_API zend_class_entry *zend_ce_sensitive_parameter_value; |
49 | | extern ZEND_API zend_class_entry *zend_ce_override; |
50 | | extern ZEND_API zend_class_entry *zend_ce_deprecated; |
51 | | extern ZEND_API zend_class_entry *zend_ce_nodiscard; |
52 | | extern ZEND_API zend_class_entry *zend_ce_delayed_target_validation; |
53 | | |
54 | | typedef struct { |
55 | | zend_string *name; |
56 | | zval value; |
57 | | } zend_attribute_arg; |
58 | | |
59 | | typedef struct _zend_attribute { |
60 | | zend_string *name; |
61 | | zend_string *lcname; |
62 | | /* Only non-null for internal attributes with validation errors that are |
63 | | * delayed until runtime via #[\DelayedTargetValidation] */ |
64 | | zend_string *validation_error; |
65 | | uint32_t flags; |
66 | | uint32_t lineno; |
67 | | /* Parameter offsets start at 1, everything else uses 0. */ |
68 | | uint32_t offset; |
69 | | uint32_t argc; |
70 | | zend_attribute_arg args[1]; |
71 | | } zend_attribute; |
72 | | |
73 | | typedef struct _zend_internal_attribute { |
74 | | zend_class_entry *ce; |
75 | | uint32_t flags; |
76 | | zend_string* (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope); |
77 | | } zend_internal_attribute; |
78 | | |
79 | | ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname); |
80 | | ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len); |
81 | | |
82 | | ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset); |
83 | | ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset); |
84 | | |
85 | | ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope); |
86 | | ZEND_API zend_result zend_get_attribute_object(zval *out, zend_class_entry *attribute_ce, zend_attribute *attribute_data, zend_class_entry *scope, zend_string *filename); |
87 | | |
88 | | ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets); |
89 | | ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr); |
90 | | |
91 | | ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce); |
92 | | ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags); |
93 | | ZEND_API zend_internal_attribute *zend_internal_attribute_get(zend_string *lcname); |
94 | | |
95 | | ZEND_API zend_attribute *zend_add_attribute( |
96 | | HashTable **attributes, zend_string *name, uint32_t argc, |
97 | | uint32_t flags, uint32_t offset, uint32_t lineno); |
98 | | |
99 | | uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope); |
100 | | |
101 | | END_EXTERN_C() |
102 | | |
103 | | static zend_always_inline zend_attribute *zend_add_class_attribute(zend_class_entry *ce, zend_string *name, uint32_t argc) |
104 | 20 | { |
105 | 20 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; |
106 | 20 | return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0); |
107 | 20 | } Unexecuted instantiation: php_date.c:zend_add_class_attribute Unexecuted instantiation: hash.c:zend_add_class_attribute Unexecuted instantiation: zend_file_cache.c:zend_add_class_attribute Unexecuted instantiation: zend_persist_calc.c:zend_add_class_attribute Unexecuted instantiation: zend_persist.c:zend_add_class_attribute Unexecuted instantiation: random.c:zend_add_class_attribute Unexecuted instantiation: php_reflection.c:zend_add_class_attribute Unexecuted instantiation: spl_directory.c:zend_add_class_attribute Unexecuted instantiation: spl_fixedarray.c:zend_add_class_attribute Unexecuted instantiation: spl_observer.c:zend_add_class_attribute basic_functions.c:zend_add_class_attribute Line | Count | Source | 104 | 2 | { | 105 | 2 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 106 | 2 | return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0); | 107 | 2 | } |
Unexecuted instantiation: file.c:zend_add_class_attribute Unexecuted instantiation: php_uri.c:zend_add_class_attribute zend_attributes.c:zend_add_class_attribute Line | Count | Source | 104 | 16 | { | 105 | 16 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 106 | 16 | return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0); | 107 | 16 | } |
zend_builtin_functions.c:zend_add_class_attribute Line | Count | Source | 104 | 2 | { | 105 | 2 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 106 | 2 | return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0); | 107 | 2 | } |
Unexecuted instantiation: zend_compile.c:zend_add_class_attribute Unexecuted instantiation: zend_constants.c:zend_add_class_attribute Unexecuted instantiation: zend_default_classes.c:zend_add_class_attribute Unexecuted instantiation: zend_execute.c:zend_add_class_attribute Unexecuted instantiation: zend_inheritance.c:zend_add_class_attribute Unexecuted instantiation: zend.c:zend_add_class_attribute |
108 | | |
109 | | static zend_always_inline zend_attribute *zend_add_function_attribute(zend_function *func, zend_string *name, uint32_t argc) |
110 | 72 | { |
111 | 72 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; |
112 | 72 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); |
113 | 72 | } php_date.c:zend_add_function_attribute Line | Count | Source | 110 | 38 | { | 111 | 38 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 38 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 38 | } |
Unexecuted instantiation: hash.c:zend_add_function_attribute Unexecuted instantiation: zend_file_cache.c:zend_add_function_attribute Unexecuted instantiation: zend_persist_calc.c:zend_add_function_attribute Unexecuted instantiation: zend_persist.c:zend_add_function_attribute random.c:zend_add_function_attribute Line | Count | Source | 110 | 2 | { | 111 | 2 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 2 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 2 | } |
php_reflection.c:zend_add_function_attribute Line | Count | Source | 110 | 12 | { | 111 | 12 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 12 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 12 | } |
spl_directory.c:zend_add_function_attribute Line | Count | Source | 110 | 2 | { | 111 | 2 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 2 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 2 | } |
spl_fixedarray.c:zend_add_function_attribute Line | Count | Source | 110 | 2 | { | 111 | 2 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 2 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 2 | } |
spl_observer.c:zend_add_function_attribute Line | Count | Source | 110 | 6 | { | 111 | 6 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 6 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 6 | } |
basic_functions.c:zend_add_function_attribute Line | Count | Source | 110 | 10 | { | 111 | 10 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 112 | 10 | return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0); | 113 | 10 | } |
Unexecuted instantiation: file.c:zend_add_function_attribute Unexecuted instantiation: php_uri.c:zend_add_function_attribute Unexecuted instantiation: zend_attributes.c:zend_add_function_attribute Unexecuted instantiation: zend_builtin_functions.c:zend_add_function_attribute Unexecuted instantiation: zend_compile.c:zend_add_function_attribute Unexecuted instantiation: zend_constants.c:zend_add_function_attribute Unexecuted instantiation: zend_default_classes.c:zend_add_function_attribute Unexecuted instantiation: zend_execute.c:zend_add_function_attribute Unexecuted instantiation: zend_inheritance.c:zend_add_function_attribute Unexecuted instantiation: zend.c:zend_add_function_attribute |
114 | | |
115 | | static zend_always_inline zend_attribute *zend_add_parameter_attribute(zend_function *func, uint32_t offset, zend_string *name, uint32_t argc) |
116 | 24 | { |
117 | 24 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; |
118 | 24 | return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0); |
119 | 24 | } Unexecuted instantiation: php_date.c:zend_add_parameter_attribute hash.c:zend_add_parameter_attribute Line | Count | Source | 116 | 14 | { | 117 | 14 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 118 | 14 | return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0); | 119 | 14 | } |
Unexecuted instantiation: zend_file_cache.c:zend_add_parameter_attribute Unexecuted instantiation: zend_persist_calc.c:zend_add_parameter_attribute Unexecuted instantiation: zend_persist.c:zend_add_parameter_attribute Unexecuted instantiation: random.c:zend_add_parameter_attribute Unexecuted instantiation: php_reflection.c:zend_add_parameter_attribute Unexecuted instantiation: spl_directory.c:zend_add_parameter_attribute Unexecuted instantiation: spl_fixedarray.c:zend_add_parameter_attribute Unexecuted instantiation: spl_observer.c:zend_add_parameter_attribute basic_functions.c:zend_add_parameter_attribute Line | Count | Source | 116 | 6 | { | 117 | 6 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 118 | 6 | return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0); | 119 | 6 | } |
Unexecuted instantiation: file.c:zend_add_parameter_attribute php_uri.c:zend_add_parameter_attribute Line | Count | Source | 116 | 4 | { | 117 | 4 | uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 118 | 4 | return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0); | 119 | 4 | } |
Unexecuted instantiation: zend_attributes.c:zend_add_parameter_attribute Unexecuted instantiation: zend_builtin_functions.c:zend_add_parameter_attribute Unexecuted instantiation: zend_compile.c:zend_add_parameter_attribute Unexecuted instantiation: zend_constants.c:zend_add_parameter_attribute Unexecuted instantiation: zend_default_classes.c:zend_add_parameter_attribute Unexecuted instantiation: zend_execute.c:zend_add_parameter_attribute Unexecuted instantiation: zend_inheritance.c:zend_add_parameter_attribute Unexecuted instantiation: zend.c:zend_add_parameter_attribute |
120 | | |
121 | | static zend_always_inline zend_attribute *zend_add_property_attribute(const zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc) |
122 | 0 | { |
123 | 0 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; |
124 | 0 | return zend_add_attribute(&info->attributes, name, argc, flags, 0, 0); |
125 | 0 | } Unexecuted instantiation: php_date.c:zend_add_property_attribute Unexecuted instantiation: hash.c:zend_add_property_attribute Unexecuted instantiation: zend_file_cache.c:zend_add_property_attribute Unexecuted instantiation: zend_persist_calc.c:zend_add_property_attribute Unexecuted instantiation: zend_persist.c:zend_add_property_attribute Unexecuted instantiation: random.c:zend_add_property_attribute Unexecuted instantiation: php_reflection.c:zend_add_property_attribute Unexecuted instantiation: spl_directory.c:zend_add_property_attribute Unexecuted instantiation: spl_fixedarray.c:zend_add_property_attribute Unexecuted instantiation: spl_observer.c:zend_add_property_attribute Unexecuted instantiation: basic_functions.c:zend_add_property_attribute Unexecuted instantiation: file.c:zend_add_property_attribute Unexecuted instantiation: php_uri.c:zend_add_property_attribute Unexecuted instantiation: zend_attributes.c:zend_add_property_attribute Unexecuted instantiation: zend_builtin_functions.c:zend_add_property_attribute Unexecuted instantiation: zend_compile.c:zend_add_property_attribute Unexecuted instantiation: zend_constants.c:zend_add_property_attribute Unexecuted instantiation: zend_default_classes.c:zend_add_property_attribute Unexecuted instantiation: zend_execute.c:zend_add_property_attribute Unexecuted instantiation: zend_inheritance.c:zend_add_property_attribute Unexecuted instantiation: zend.c:zend_add_property_attribute |
126 | | |
127 | | static zend_always_inline zend_attribute *zend_add_class_constant_attribute(const zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc) |
128 | 2 | { |
129 | 2 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; |
130 | 2 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); |
131 | 2 | } php_date.c:zend_add_class_constant_attribute Line | Count | Source | 128 | 2 | { | 129 | 2 | uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; | 130 | 2 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); | 131 | 2 | } |
Unexecuted instantiation: hash.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_file_cache.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_persist_calc.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_persist.c:zend_add_class_constant_attribute Unexecuted instantiation: random.c:zend_add_class_constant_attribute Unexecuted instantiation: php_reflection.c:zend_add_class_constant_attribute Unexecuted instantiation: spl_directory.c:zend_add_class_constant_attribute Unexecuted instantiation: spl_fixedarray.c:zend_add_class_constant_attribute Unexecuted instantiation: spl_observer.c:zend_add_class_constant_attribute Unexecuted instantiation: basic_functions.c:zend_add_class_constant_attribute Unexecuted instantiation: file.c:zend_add_class_constant_attribute Unexecuted instantiation: php_uri.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_attributes.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_builtin_functions.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_compile.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_constants.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_default_classes.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_execute.c:zend_add_class_constant_attribute Unexecuted instantiation: zend_inheritance.c:zend_add_class_constant_attribute Unexecuted instantiation: zend.c:zend_add_class_constant_attribute |
132 | | |
133 | | static zend_always_inline zend_attribute *zend_add_global_constant_attribute(zend_constant *c, zend_string *name, uint32_t argc) |
134 | 26 | { |
135 | 26 | uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT; |
136 | 26 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); |
137 | 26 | } php_date.c:zend_add_global_constant_attribute Line | Count | Source | 134 | 8 | { | 135 | 8 | uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT; | 136 | 8 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); | 137 | 8 | } |
Unexecuted instantiation: hash.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_file_cache.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_persist_calc.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_persist.c:zend_add_global_constant_attribute random.c:zend_add_global_constant_attribute Line | Count | Source | 134 | 2 | { | 135 | 2 | uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT; | 136 | 2 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); | 137 | 2 | } |
Unexecuted instantiation: php_reflection.c:zend_add_global_constant_attribute Unexecuted instantiation: spl_directory.c:zend_add_global_constant_attribute Unexecuted instantiation: spl_fixedarray.c:zend_add_global_constant_attribute Unexecuted instantiation: spl_observer.c:zend_add_global_constant_attribute basic_functions.c:zend_add_global_constant_attribute Line | Count | Source | 134 | 10 | { | 135 | 10 | uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT; | 136 | 10 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); | 137 | 10 | } |
file.c:zend_add_global_constant_attribute Line | Count | Source | 134 | 4 | { | 135 | 4 | uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT; | 136 | 4 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); | 137 | 4 | } |
Unexecuted instantiation: php_uri.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_attributes.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_builtin_functions.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_compile.c:zend_add_global_constant_attribute zend_constants.c:zend_add_global_constant_attribute Line | Count | Source | 134 | 2 | { | 135 | 2 | uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT; | 136 | 2 | return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); | 137 | 2 | } |
Unexecuted instantiation: zend_default_classes.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_execute.c:zend_add_global_constant_attribute Unexecuted instantiation: zend_inheritance.c:zend_add_global_constant_attribute Unexecuted instantiation: zend.c:zend_add_global_constant_attribute |
138 | | |
139 | | void zend_register_attribute_ce(void); |
140 | | void zend_attributes_shutdown(void); |
141 | | |
142 | | #endif |