Coverage Report

Created: 2025-12-14 06:05

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