Coverage Report

Created: 2025-06-13 06:43

/src/php-src/Zend/zend_attributes.h
Line
Count
Source (jump to first uncovered line)
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
2.80k
#define ZEND_ATTRIBUTE_TARGET_CLASS     (1<<0)
27
5.05k
#define ZEND_ATTRIBUTE_TARGET_FUNCTION    (1<<1)
28
639
#define ZEND_ATTRIBUTE_TARGET_METHOD    (1<<2)
29
404
#define ZEND_ATTRIBUTE_TARGET_PROPERTY    (1<<3)
30
455
#define ZEND_ATTRIBUTE_TARGET_CLASS_CONST (1<<4)
31
1.92k
#define ZEND_ATTRIBUTE_TARGET_PARAMETER   (1<<5)
32
493
#define ZEND_ATTRIBUTE_TARGET_CONST     (1<<6)
33
4.58k
#define ZEND_ATTRIBUTE_TARGET_ALL     ((1<<7) - 1)
34
2.02k
#define ZEND_ATTRIBUTE_IS_REPEATABLE    (1<<7)
35
180
#define ZEND_ATTRIBUTE_FLAGS        ((1<<8) - 1)
36
37
/* Flags for zend_attribute.flags */
38
59.2k
#define ZEND_ATTRIBUTE_PERSISTENT   (1<<0)
39
232
#define ZEND_ATTRIBUTE_STRICT_TYPES (1<<1)
40
41
#define ZEND_ATTRIBUTE_SIZE(argc) \
42
  (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
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
  uint32_t flags;
63
  uint32_t lineno;
64
  /* Parameter offsets start at 1, everything else uses 0. */
65
  uint32_t offset;
66
  uint32_t argc;
67
  zend_attribute_arg args[1];
68
} zend_attribute;
69
70
typedef struct _zend_internal_attribute {
71
  zend_class_entry *ce;
72
  uint32_t flags;
73
  void (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope);
74
} zend_internal_attribute;
75
76
ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname);
77
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len);
78
79
ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset);
80
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset);
81
82
ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope);
83
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);
84
85
ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets);
86
ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr);
87
88
ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce);
89
ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags);
90
ZEND_API zend_internal_attribute *zend_internal_attribute_get(zend_string *lcname);
91
92
ZEND_API zend_attribute *zend_add_attribute(
93
    HashTable **attributes, zend_string *name, uint32_t argc,
94
    uint32_t flags, uint32_t offset, uint32_t lineno);
95
96
uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope);
97
98
END_EXTERN_C()
99
100
static zend_always_inline zend_attribute *zend_add_class_attribute(zend_class_entry *ce, zend_string *name, uint32_t argc)
101
144
{
102
144
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
103
144
  return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
104
144
}
Unexecuted instantiation: php_date.c:zend_add_class_attribute
Unexecuted instantiation: hash.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
basic_functions.c:zend_add_class_attribute
Line
Count
Source
101
16
{
102
16
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
103
16
  return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
104
16
}
Unexecuted instantiation: php_uri.c:zend_add_class_attribute
zend_attributes.c:zend_add_class_attribute
Line
Count
Source
101
112
{
102
112
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
103
112
  return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
104
112
}
zend_builtin_functions.c:zend_add_class_attribute
Line
Count
Source
101
16
{
102
16
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
103
16
  return zend_add_attribute(&ce->attributes, name, argc, flags, 0, 0);
104
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
105
106
static zend_always_inline zend_attribute *zend_add_function_attribute(zend_function *func, zend_string *name, uint32_t argc)
107
384
{
108
384
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
384
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
384
}
php_date.c:zend_add_function_attribute
Line
Count
Source
107
208
{
108
208
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
208
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
208
}
Unexecuted instantiation: hash.c:zend_add_function_attribute
random.c:zend_add_function_attribute
Line
Count
Source
107
16
{
108
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
16
}
php_reflection.c:zend_add_function_attribute
Line
Count
Source
107
64
{
108
64
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
64
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
64
}
spl_directory.c:zend_add_function_attribute
Line
Count
Source
107
16
{
108
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
16
}
spl_fixedarray.c:zend_add_function_attribute
Line
Count
Source
107
16
{
108
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
16
}
basic_functions.c:zend_add_function_attribute
Line
Count
Source
107
64
{
108
64
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
109
64
  return zend_add_attribute(&func->common.attributes, name, argc, flags, 0, 0);
110
64
}
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
111
112
static zend_always_inline zend_attribute *zend_add_parameter_attribute(zend_function *func, uint32_t offset, zend_string *name, uint32_t argc)
113
176
{
114
176
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
115
176
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
116
176
}
Unexecuted instantiation: php_date.c:zend_add_parameter_attribute
hash.c:zend_add_parameter_attribute
Line
Count
Source
113
112
{
114
112
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
115
112
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
116
112
}
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
basic_functions.c:zend_add_parameter_attribute
Line
Count
Source
113
48
{
114
48
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
115
48
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
116
48
}
php_uri.c:zend_add_parameter_attribute
Line
Count
Source
113
16
{
114
16
  uint32_t flags = func->common.type != ZEND_USER_FUNCTION ? ZEND_ATTRIBUTE_PERSISTENT : 0;
115
16
  return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
116
16
}
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
117
118
static zend_always_inline zend_attribute *zend_add_property_attribute(zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc)
119
0
{
120
0
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
121
0
  return zend_add_attribute(&info->attributes, name, argc, flags, 0, 0);
122
0
}
Unexecuted instantiation: php_date.c:zend_add_property_attribute
Unexecuted instantiation: hash.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: basic_functions.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
123
124
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)
125
0
{
126
0
  uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
127
0
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
128
0
}
Unexecuted instantiation: php_date.c:zend_add_class_constant_attribute
Unexecuted instantiation: hash.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: basic_functions.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
129
130
static zend_always_inline zend_attribute *zend_add_global_constant_attribute(zend_constant *c, zend_string *name, uint32_t argc)
131
16
{
132
16
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
133
16
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
134
16
}
Unexecuted instantiation: php_date.c:zend_add_global_constant_attribute
Unexecuted instantiation: hash.c:zend_add_global_constant_attribute
Unexecuted instantiation: random.c:zend_add_global_constant_attribute
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: basic_functions.c:zend_add_global_constant_attribute
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
131
16
{
132
16
  uint32_t flags = ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT ? 0 : ZEND_ATTRIBUTE_PERSISTENT;
133
16
  return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
134
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
135
136
void zend_register_attribute_ce(void);
137
void zend_attributes_shutdown(void);
138
139
#endif