php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
spl_functions.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Marcus Boerger <helly@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17#ifdef HAVE_CONFIG_H
18 #include <config.h>
19#endif
20
21#include "php.h"
22
23/* {{{ spl_add_class_name */
24void spl_add_class_name(zval *list, zend_class_entry *pce, int allow, int ce_flags)
25{
26 if (!allow || (allow > 0 && (pce->ce_flags & ce_flags)) || (allow < 0 && !(pce->ce_flags & ce_flags))) {
27 zval *tmp;
28
29 if ((tmp = zend_hash_find(Z_ARRVAL_P(list), pce->name)) == NULL) {
30 zval t;
31 ZVAL_STR_COPY(&t, pce->name);
32 zend_hash_add(Z_ARRVAL_P(list), pce->name, &t);
33 }
34 }
35}
36/* }}} */
37
38/* {{{ spl_add_interfaces */
39void spl_add_interfaces(zval *list, zend_class_entry * pce, int allow, int ce_flags)
40{
41 if (pce->num_interfaces) {
43 for (uint32_t num_interfaces = 0; num_interfaces < pce->num_interfaces; num_interfaces++) {
44 spl_add_class_name(list, pce->interfaces[num_interfaces], allow, ce_flags);
45 }
46 }
47}
48/* }}} */
49
50/* {{{ spl_add_traits */
51void spl_add_traits(zval *list, zend_class_entry * pce, int allow, int ce_flags)
52{
53 zend_class_entry *trait;
54
55 for (uint32_t num_traits = 0; num_traits < pce->num_traits; num_traits++) {
56 trait = zend_fetch_class_by_name(pce->trait_names[num_traits].name,
58 ZEND_ASSERT(trait);
59 spl_add_class_name(list, trait, allow, ce_flags);
60 }
61}
62/* }}} */
63
64
65/* {{{ spl_add_classes */
66void spl_add_classes(zend_class_entry *pce, zval *list, bool sub, int allow, int ce_flags)
67{
68 ZEND_ASSERT(pce);
69 spl_add_class_name(list, pce, allow, ce_flags);
70 if (sub) {
71 spl_add_interfaces(list, pce, allow, ce_flags);
72 while (pce->parent) {
73 pce = pce->parent;
74 spl_add_classes(pce, list, sub, allow, ce_flags);
75 }
76 }
77}
78/* }}} */
79
81 const zend_class_entry *ce,
82 const char *property,
83 size_t property_len,
84 HashTable *debug_info,
85 zval *value
86)
87{
89 ZSTR_VAL(ce->name),
90 ZSTR_LEN(ce->name),
92 property_len,
93 /* persistent */ false
94 );
95 zend_hash_update(debug_info, mangled_named, value);
96 zend_string_release_ex(mangled_named, /* persistent */ false);
97}
#define NULL
Definition gdcache.h:45
void spl_add_class_name(zval *list, zend_class_entry *pce, int allow, int ce_flags)
void spl_set_private_debug_info_property(const zend_class_entry *ce, const char *property, size_t property_len, HashTable *debug_info, zval *value)
void spl_add_interfaces(zval *list, zend_class_entry *pce, int allow, int ce_flags)
void spl_add_classes(zend_class_entry *pce, zval *list, bool sub, int allow, int ce_flags)
void spl_add_traits(zval *list, zend_class_entry *pce, int allow, int ce_flags)
zend_class_name * trait_names
Definition zend.h:216
zend_string * name
Definition zend.h:149
uint32_t num_traits
Definition zend.h:206
uint32_t num_interfaces
Definition zend.h:205
uint32_t ce_flags
Definition zend.h:156
zend_class_entry ** interfaces
Definition zend.h:212
zend_class_entry * parent
Definition zend.h:152
zend_string * lc_name
Definition zend.h:87
zend_string * name
Definition zend.h:86
struct _zval_struct zval
zend_string_release_ex(func->internal_function.function_name, 0)
ZEND_API zend_string * zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal)
#define ZEND_ACC_LINKED
#define ZEND_FETCH_CLASS_TRAIT
ZEND_API zend_class_entry * zend_fetch_class_by_name(zend_string *class_name, zend_string *lcname, uint32_t fetch_type)
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:997
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
Definition zend_hash.c:2668
ZEND_API zval *ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:992
struct _zend_string zend_string
#define ZEND_ASSERT(c)
struct _zend_class_entry zend_class_entry
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define Z_ARRVAL_P(zval_p)
Definition zend_types.h:987
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
Definition zend_types.h:386
value
property