Coverage Report

Created: 2026-06-02 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/php-src/Zend/zend_constants.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: Andi Gutmans <andi@php.net>                                 |
15
   |          Zeev Suraski <zeev@php.net>                                 |
16
   +----------------------------------------------------------------------+
17
*/
18
19
#ifndef ZEND_CONSTANTS_H
20
#define ZEND_CONSTANTS_H
21
22
#include "zend_globals.h"
23
24
#define CONST_CS        0         /* No longer used -- always case sensitive */
25
2.18k
#define CONST_PERSISTENT    (1<<0)        /* Persistent */
26
0
#define CONST_NO_FILE_CACHE   (1<<1)        /* Can't be saved in file cache */
27
0
#define CONST_DEPRECATED    (1<<2)        /* Deprecated */
28
0
#define CONST_OWNED       (1<<3)        /* constant should be destroyed together with class */
29
0
#define CONST_RECURSIVE     (1<<4)        /* Recursion protection for constant evaluation */
30
31
0
#define CONST_IS_RECURSIVE(c) (Z_CONSTANT_FLAGS((c)->value) & CONST_RECURSIVE)
32
#define CONST_PROTECT_RECURSION(c) \
33
0
  do { \
34
0
    Z_CONSTANT_FLAGS((c)->value) |= CONST_RECURSIVE; \
35
0
  } while (0)
36
#define CONST_UNPROTECT_RECURSION(c) \
37
0
  do { \
38
0
    Z_CONSTANT_FLAGS((c)->value) &= ~CONST_RECURSIVE; \
39
0
  } while (0)
40
41
1.11k
#define PHP_USER_CONSTANT   0x7fffff /* a constant defined in user space */
42
43
typedef struct _zend_constant {
44
  zval value;
45
  zend_string *name;
46
  zend_string *filename;
47
  HashTable *attributes;
48
} zend_constant;
49
50
#define ZEND_CONSTANT_FLAGS(c) \
51
1.09k
  (Z_CONSTANT_FLAGS((c)->value) & 0xff)
52
53
#define ZEND_CONSTANT_MODULE_NUMBER(c) \
54
1.11k
  (Z_CONSTANT_FLAGS((c)->value) >> 8)
55
56
1.09k
#define ZEND_CONSTANT_SET_FLAGS(c, _flags, _module_number) do { \
57
1.09k
    Z_CONSTANT_FLAGS((c)->value) = \
58
1.09k
      ((_flags) & 0xff) | ((_module_number) << 8); \
59
1.09k
  } while (0)
60
61
2
#define REGISTER_NULL_CONSTANT(name, flags)  zend_register_null_constant((name), sizeof(name)-1, (flags), module_number)
62
14
#define REGISTER_BOOL_CONSTANT(name, bval, flags)  zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number)
63
946
#define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
64
44
#define REGISTER_DOUBLE_CONSTANT(name, dval, flags)  zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number)
65
86
#define REGISTER_STRING_CONSTANT(name, str, flags)  zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number)
66
#define REGISTER_STRINGL_CONSTANT(name, str, len, flags)  zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number)
67
68
#define REGISTER_NS_NULL_CONSTANT(ns, name, flags)  zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number)
69
#define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags)  zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number)
70
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
71
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags)  zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number)
72
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags)  zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number)
73
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags)  zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number)
74
75
#define REGISTER_MAIN_NULL_CONSTANT(name, flags)  zend_register_null_constant((name), sizeof(name)-1, (flags), 0)
76
#define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags)  zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0)
77
#define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0)
78
#define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags)  zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0)
79
#define REGISTER_MAIN_STRING_CONSTANT(name, str, flags)  zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0)
80
#define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags)  zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0)
81
82
BEGIN_EXTERN_C()
83
void clean_module_constants(int module_number);
84
void free_zend_constant(zval *zv);
85
void zend_startup_constants(void);
86
void zend_register_standard_constants(void);
87
ZEND_API bool zend_verify_const_access(const zend_class_constant *c, const zend_class_entry *ce);
88
ZEND_API zval *zend_get_constant(zend_string *name);
89
ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name);
90
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
91
ZEND_API zval *zend_get_constant_ex(zend_string *name, const zend_class_entry *scope, uint32_t flags);
92
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, const zend_class_entry *scope, uint32_t flags);
93
ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
94
ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
95
ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
96
ZEND_API zend_constant *zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
97
ZEND_API zend_constant *zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number);
98
ZEND_API zend_constant *zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number);
99
ZEND_API zend_constant *zend_register_constant(zend_constant *c);
100
void zend_constant_add_attributes(zend_constant *c, HashTable *attributes);
101
#ifdef ZTS
102
void zend_copy_constants(HashTable *target, HashTable *source);
103
#endif
104
105
ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t name_len);
106
107
static zend_always_inline zend_constant *zend_get_special_const(
108
0
    const char *name, size_t name_len) {
109
0
  if (name_len == 4 || name_len == 5) {
110
0
    return _zend_get_special_const(name, name_len);
111
0
  }
112
0
  return NULL;
113
0
}
Unexecuted instantiation: php_date.c:zend_get_special_const
Unexecuted instantiation: php_pcre.c:zend_get_special_const
Unexecuted instantiation: exif.c:zend_get_special_const
Unexecuted instantiation: hash_adler32.c:zend_get_special_const
Unexecuted instantiation: hash_crc32.c:zend_get_special_const
Unexecuted instantiation: hash_fnv.c:zend_get_special_const
Unexecuted instantiation: hash_gost.c:zend_get_special_const
Unexecuted instantiation: hash_haval.c:zend_get_special_const
Unexecuted instantiation: hash_joaat.c:zend_get_special_const
Unexecuted instantiation: hash_md.c:zend_get_special_const
Unexecuted instantiation: hash_murmur.c:zend_get_special_const
Unexecuted instantiation: hash_ripemd.c:zend_get_special_const
Unexecuted instantiation: hash_sha_ni.c:zend_get_special_const
Unexecuted instantiation: hash_sha_sse2.c:zend_get_special_const
Unexecuted instantiation: hash_sha.c:zend_get_special_const
Unexecuted instantiation: hash_sha3.c:zend_get_special_const
Unexecuted instantiation: hash_snefru.c:zend_get_special_const
Unexecuted instantiation: hash_tiger.c:zend_get_special_const
Unexecuted instantiation: hash_whirlpool.c:zend_get_special_const
Unexecuted instantiation: hash_xxhash.c:zend_get_special_const
Unexecuted instantiation: hash.c:zend_get_special_const
Unexecuted instantiation: json_encoder.c:zend_get_special_const
Unexecuted instantiation: json_parser.tab.c:zend_get_special_const
Unexecuted instantiation: json_scanner.c:zend_get_special_const
Unexecuted instantiation: json.c:zend_get_special_const
Unexecuted instantiation: php_lexbor.c:zend_get_special_const
Unexecuted instantiation: shared_alloc_mmap.c:zend_get_special_const
Unexecuted instantiation: shared_alloc_posix.c:zend_get_special_const
Unexecuted instantiation: shared_alloc_shm.c:zend_get_special_const
Unexecuted instantiation: zend_accelerator_api.c:zend_get_special_const
Unexecuted instantiation: zend_accelerator_blacklist.c:zend_get_special_const
Unexecuted instantiation: zend_accelerator_debug.c:zend_get_special_const
Unexecuted instantiation: zend_accelerator_hash.c:zend_get_special_const
Unexecuted instantiation: zend_accelerator_module.c:zend_get_special_const
Unexecuted instantiation: zend_accelerator_util_funcs.c:zend_get_special_const
Unexecuted instantiation: zend_file_cache.c:zend_get_special_const
Unexecuted instantiation: zend_persist_calc.c:zend_get_special_const
Unexecuted instantiation: zend_persist.c:zend_get_special_const
Unexecuted instantiation: zend_shared_alloc.c:zend_get_special_const
Unexecuted instantiation: ZendAccelerator.c:zend_get_special_const
Unexecuted instantiation: zend_jit_vm_helpers.c:zend_get_special_const
Unexecuted instantiation: zend_jit.c:zend_get_special_const
Unexecuted instantiation: csprng.c:zend_get_special_const
Unexecuted instantiation: engine_mt19937.c:zend_get_special_const
Unexecuted instantiation: engine_pcgoneseq128xslrr64.c:zend_get_special_const
Unexecuted instantiation: engine_secure.c:zend_get_special_const
Unexecuted instantiation: engine_user.c:zend_get_special_const
Unexecuted instantiation: engine_xoshiro256starstar.c:zend_get_special_const
Unexecuted instantiation: gammasection.c:zend_get_special_const
Unexecuted instantiation: random.c:zend_get_special_const
Unexecuted instantiation: randomizer.c:zend_get_special_const
Unexecuted instantiation: zend_utils.c:zend_get_special_const
Unexecuted instantiation: php_reflection.c:zend_get_special_const
Unexecuted instantiation: php_spl.c:zend_get_special_const
Unexecuted instantiation: spl_array.c:zend_get_special_const
Unexecuted instantiation: spl_directory.c:zend_get_special_const
Unexecuted instantiation: spl_dllist.c:zend_get_special_const
Unexecuted instantiation: spl_exceptions.c:zend_get_special_const
Unexecuted instantiation: spl_fixedarray.c:zend_get_special_const
Unexecuted instantiation: spl_functions.c:zend_get_special_const
Unexecuted instantiation: spl_heap.c:zend_get_special_const
Unexecuted instantiation: spl_iterators.c:zend_get_special_const
Unexecuted instantiation: spl_observer.c:zend_get_special_const
Unexecuted instantiation: array.c:zend_get_special_const
Unexecuted instantiation: assert.c:zend_get_special_const
Unexecuted instantiation: base64.c:zend_get_special_const
Unexecuted instantiation: basic_functions.c:zend_get_special_const
Unexecuted instantiation: browscap.c:zend_get_special_const
Unexecuted instantiation: crc32_x86.c:zend_get_special_const
Unexecuted instantiation: crc32.c:zend_get_special_const
Unexecuted instantiation: credits.c:zend_get_special_const
Unexecuted instantiation: crypt.c:zend_get_special_const
Unexecuted instantiation: css.c:zend_get_special_const
Unexecuted instantiation: datetime.c:zend_get_special_const
Unexecuted instantiation: dir.c:zend_get_special_const
Unexecuted instantiation: dl.c:zend_get_special_const
Unexecuted instantiation: dns.c:zend_get_special_const
Unexecuted instantiation: exec.c:zend_get_special_const
Unexecuted instantiation: file.c:zend_get_special_const
Unexecuted instantiation: filestat.c:zend_get_special_const
Unexecuted instantiation: filters.c:zend_get_special_const
Unexecuted instantiation: flock_compat.c:zend_get_special_const
Unexecuted instantiation: formatted_print.c:zend_get_special_const
Unexecuted instantiation: fsock.c:zend_get_special_const
Unexecuted instantiation: ftok.c:zend_get_special_const
Unexecuted instantiation: ftp_fopen_wrapper.c:zend_get_special_const
Unexecuted instantiation: head.c:zend_get_special_const
Unexecuted instantiation: hrtime.c:zend_get_special_const
Unexecuted instantiation: html.c:zend_get_special_const
Unexecuted instantiation: http_fopen_wrapper.c:zend_get_special_const
Unexecuted instantiation: http.c:zend_get_special_const
Unexecuted instantiation: image.c:zend_get_special_const
Unexecuted instantiation: incomplete_class.c:zend_get_special_const
Unexecuted instantiation: info.c:zend_get_special_const
Unexecuted instantiation: iptc.c:zend_get_special_const
Unexecuted instantiation: levenshtein.c:zend_get_special_const
Unexecuted instantiation: link.c:zend_get_special_const
Unexecuted instantiation: mail.c:zend_get_special_const
Unexecuted instantiation: math.c:zend_get_special_const
Unexecuted instantiation: md5.c:zend_get_special_const
Unexecuted instantiation: metaphone.c:zend_get_special_const
Unexecuted instantiation: microtime.c:zend_get_special_const
Unexecuted instantiation: net.c:zend_get_special_const
Unexecuted instantiation: pack.c:zend_get_special_const
Unexecuted instantiation: pageinfo.c:zend_get_special_const
Unexecuted instantiation: password.c:zend_get_special_const
Unexecuted instantiation: php_fopen_wrapper.c:zend_get_special_const
Unexecuted instantiation: proc_open.c:zend_get_special_const
Unexecuted instantiation: quot_print.c:zend_get_special_const
Unexecuted instantiation: scanf.c:zend_get_special_const
Unexecuted instantiation: sha1.c:zend_get_special_const
Unexecuted instantiation: soundex.c:zend_get_special_const
Unexecuted instantiation: streamsfuncs.c:zend_get_special_const
Unexecuted instantiation: string.c:zend_get_special_const
Unexecuted instantiation: strnatcmp.c:zend_get_special_const
Unexecuted instantiation: syslog.c:zend_get_special_const
Unexecuted instantiation: type.c:zend_get_special_const
Unexecuted instantiation: uniqid.c:zend_get_special_const
Unexecuted instantiation: url_scanner_ex.c:zend_get_special_const
Unexecuted instantiation: url.c:zend_get_special_const
Unexecuted instantiation: user_filters.c:zend_get_special_const
Unexecuted instantiation: uuencode.c:zend_get_special_const
Unexecuted instantiation: var_unserializer.c:zend_get_special_const
Unexecuted instantiation: var.c:zend_get_special_const
Unexecuted instantiation: versioning.c:zend_get_special_const
Unexecuted instantiation: crypt_sha256.c:zend_get_special_const
Unexecuted instantiation: crypt_sha512.c:zend_get_special_const
Unexecuted instantiation: php_crypt_r.c:zend_get_special_const
Unexecuted instantiation: php_uri.c:zend_get_special_const
Unexecuted instantiation: php_uri_common.c:zend_get_special_const
Unexecuted instantiation: uri_parser_rfc3986.c:zend_get_special_const
Unexecuted instantiation: uri_parser_whatwg.c:zend_get_special_const
Unexecuted instantiation: uri_parser_php_parse_url.c:zend_get_special_const
Unexecuted instantiation: explicit_bzero.c:zend_get_special_const
Unexecuted instantiation: fopen_wrappers.c:zend_get_special_const
Unexecuted instantiation: getopt.c:zend_get_special_const
Unexecuted instantiation: main.c:zend_get_special_const
Unexecuted instantiation: network.c:zend_get_special_const
Unexecuted instantiation: output.c:zend_get_special_const
Unexecuted instantiation: php_content_types.c:zend_get_special_const
Unexecuted instantiation: php_ini_builder.c:zend_get_special_const
Unexecuted instantiation: php_ini.c:zend_get_special_const
Unexecuted instantiation: php_glob.c:zend_get_special_const
Unexecuted instantiation: php_odbc_utils.c:zend_get_special_const
Unexecuted instantiation: php_open_temporary_file.c:zend_get_special_const
Unexecuted instantiation: php_scandir.c:zend_get_special_const
Unexecuted instantiation: php_syslog.c:zend_get_special_const
Unexecuted instantiation: php_ticks.c:zend_get_special_const
Unexecuted instantiation: php_variables.c:zend_get_special_const
Unexecuted instantiation: reentrancy.c:zend_get_special_const
Unexecuted instantiation: rfc1867.c:zend_get_special_const
Unexecuted instantiation: safe_bcmp.c:zend_get_special_const
Unexecuted instantiation: SAPI.c:zend_get_special_const
Unexecuted instantiation: snprintf.c:zend_get_special_const
Unexecuted instantiation: spprintf.c:zend_get_special_const
Unexecuted instantiation: strlcat.c:zend_get_special_const
Unexecuted instantiation: strlcpy.c:zend_get_special_const
Unexecuted instantiation: cast.c:zend_get_special_const
Unexecuted instantiation: filter.c:zend_get_special_const
Unexecuted instantiation: glob_wrapper.c:zend_get_special_const
Unexecuted instantiation: memory.c:zend_get_special_const
Unexecuted instantiation: mmap.c:zend_get_special_const
Unexecuted instantiation: plain_wrapper.c:zend_get_special_const
Unexecuted instantiation: stream_errors.c:zend_get_special_const
Unexecuted instantiation: streams.c:zend_get_special_const
Unexecuted instantiation: transports.c:zend_get_special_const
Unexecuted instantiation: userspace.c:zend_get_special_const
Unexecuted instantiation: xp_socket.c:zend_get_special_const
Unexecuted instantiation: block_pass.c:zend_get_special_const
Unexecuted instantiation: compact_literals.c:zend_get_special_const
Unexecuted instantiation: compact_vars.c:zend_get_special_const
Unexecuted instantiation: dfa_pass.c:zend_get_special_const
Unexecuted instantiation: nop_removal.c:zend_get_special_const
Unexecuted instantiation: optimize_func_calls.c:zend_get_special_const
Unexecuted instantiation: optimize_temp_vars_5.c:zend_get_special_const
Unexecuted instantiation: pass1.c:zend_get_special_const
Unexecuted instantiation: pass3.c:zend_get_special_const
Unexecuted instantiation: sccp.c:zend_get_special_const
Unexecuted instantiation: zend_optimizer.c:zend_get_special_const
Unexecuted instantiation: zend_API.c:zend_get_special_const
Unexecuted instantiation: zend_ast.c:zend_get_special_const
Unexecuted instantiation: zend_attributes.c:zend_get_special_const
Unexecuted instantiation: zend_autoload.c:zend_get_special_const
Unexecuted instantiation: zend_builtin_functions.c:zend_get_special_const
Unexecuted instantiation: zend_closures.c:zend_get_special_const
Unexecuted instantiation: zend_compile.c:zend_get_special_const
Unexecuted instantiation: zend_constants.c:zend_get_special_const
Unexecuted instantiation: zend_default_classes.c:zend_get_special_const
Unexecuted instantiation: zend_dtrace.c:zend_get_special_const
Unexecuted instantiation: zend_enum.c:zend_get_special_const
Unexecuted instantiation: zend_exceptions.c:zend_get_special_const
Unexecuted instantiation: zend_execute_API.c:zend_get_special_const
Unexecuted instantiation: zend_execute.c:zend_get_special_const
Unexecuted instantiation: zend_fibers.c:zend_get_special_const
Unexecuted instantiation: zend_gc.c:zend_get_special_const
Unexecuted instantiation: zend_generators.c:zend_get_special_const
Unexecuted instantiation: zend_inheritance.c:zend_get_special_const
Unexecuted instantiation: zend_ini_parser.c:zend_get_special_const
Unexecuted instantiation: zend_ini_scanner.c:zend_get_special_const
Unexecuted instantiation: zend_ini.c:zend_get_special_const
Unexecuted instantiation: zend_interfaces.c:zend_get_special_const
Unexecuted instantiation: zend_iterators.c:zend_get_special_const
Unexecuted instantiation: zend_language_parser.c:zend_get_special_const
Unexecuted instantiation: zend_language_scanner.c:zend_get_special_const
Unexecuted instantiation: zend_lazy_objects.c:zend_get_special_const
Unexecuted instantiation: zend_list.c:zend_get_special_const
Unexecuted instantiation: zend_object_handlers.c:zend_get_special_const
Unexecuted instantiation: zend_objects_API.c:zend_get_special_const
Unexecuted instantiation: zend_objects.c:zend_get_special_const
Unexecuted instantiation: zend_observer.c:zend_get_special_const
Unexecuted instantiation: zend_opcode.c:zend_get_special_const
Unexecuted instantiation: zend_operators.c:zend_get_special_const
Unexecuted instantiation: zend_property_hooks.c:zend_get_special_const
Unexecuted instantiation: zend_smart_str.c:zend_get_special_const
Unexecuted instantiation: zend_system_id.c:zend_get_special_const
Unexecuted instantiation: zend_variables.c:zend_get_special_const
Unexecuted instantiation: zend_weakrefs.c:zend_get_special_const
Unexecuted instantiation: zend.c:zend_get_special_const
Unexecuted instantiation: internal_functions_cli.c:zend_get_special_const
Unexecuted instantiation: fuzzer-unserialize.c:zend_get_special_const
Unexecuted instantiation: fuzzer-sapi.c:zend_get_special_const
114
115
END_EXTERN_C()
116
117
#define ZEND_CONSTANT_DTOR free_zend_constant
118
119
#endif