Coverage Report

Created: 2025-09-27 06:26

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
3.31k
#define ZEND_ATTRIBUTE_TARGET_CLASS     (1<<0)
27
606k
#define ZEND_ATTRIBUTE_TARGET_FUNCTION    (1<<1)
28
1.64k
#define ZEND_ATTRIBUTE_TARGET_METHOD    (1<<2)
29
1.28k
#define ZEND_ATTRIBUTE_TARGET_PROPERTY    (1<<3)
30
387
#define ZEND_ATTRIBUTE_TARGET_CLASS_CONST (1<<4)
31
721k
#define ZEND_ATTRIBUTE_TARGET_PARAMETER   (1<<5)
32
1.51k
#define ZEND_ATTRIBUTE_TARGET_CONST     (1<<6)
33
9.01k
#define ZEND_ATTRIBUTE_TARGET_ALL     ((1<<7) - 1)
34
4.15k
#define ZEND_ATTRIBUTE_IS_REPEATABLE    (1<<7)
35
300
#define ZEND_ATTRIBUTE_FLAGS        ((1<<8) - 1)
36
37
/* Flags for zend_attribute.flags */
38
2.39M
#define ZEND_ATTRIBUTE_PERSISTENT   (1<<0)
39
233
#define ZEND_ATTRIBUTE_STRICT_TYPES (1<<1)
40
41
#define ZEND_ATTRIBUTE_SIZE(argc) \
42
3.32k
  (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(HashTable *attributes, zend_string *lcname);
81
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len);
82
83
ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset);
84
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset);
85
86
ZEND_API zend_result zend_get_attribute_value(zval *ret, 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(HashTable *attributes, 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(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
160
{
106
160
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
107
160
  return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
108
160
}
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
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
}
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
128
{
106
128
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
107
128
  return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
108
128
}
zend_builtin_functions.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
}
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
576
{
112
576
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
576
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
576
}
php_date.c:zend_add_function_attribute
Line
Count
Source
111
304
{
112
304
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
304
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
304
}
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
16
{
112
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
16
}
php_reflection.c:zend_add_function_attribute
Line
Count
Source
111
96
{
112
96
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
96
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
96
}
spl_directory.c:zend_add_function_attribute
Line
Count
Source
111
16
{
112
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
16
}
spl_fixedarray.c:zend_add_function_attribute
Line
Count
Source
111
16
{
112
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
16
}
spl_observer.c:zend_add_function_attribute
Line
Count
Source
111
48
{
112
48
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
48
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
48
}
basic_functions.c:zend_add_function_attribute
Line
Count
Source
111
80
{
112
80
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
113
80
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
114
80
}
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
192
{
118
192
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
119
192
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
120
192
}
Unexecuted instantiation: php_date.c:zend_add_parameter_attribute
hash.c:zend_add_parameter_attribute
Line
Count
Source
117
112
{
118
112
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
119
112
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
120
112
}
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
48
{
118
48
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
119
48
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
120
48
}
Unexecuted instantiation: file.c:zend_add_parameter_attribute
php_uri.c:zend_add_parameter_attribute
Line
Count
Source
117
32
{
118
32
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
119
32
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
120
32
}
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(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(zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
129
16
{
130
16
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
131
16
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
132
16
}
php_date.c:zend_add_class_constant_attribute
Line
Count
Source
129
16
{
130
16
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
131
16
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
132
16
}
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
208
{
136
208
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
137
208
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
138
208
}
php_date.c:zend_add_global_constant_attribute
Line
Count
Source
135
64
{
136
64
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
137
64
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
138
64
}
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
16
{
136
16
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
137
16
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
138
16
}
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
80
{
136
80
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
137
80
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
138
80
}
file.c:zend_add_global_constant_attribute
Line
Count
Source
135
32
{
136
32
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
137
32
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
138
32
}
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
16
{
136
16
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
137
16
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
138
16
}
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