-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvariables.c
executable file
·65 lines (55 loc) · 1.4 KB
/
variables.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* This file is part of the Zephir.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. If you did not receive
* a copy of the license it is available through the world-wide-web at the
* following url: https://docs.zephir-lang.com/en/latest/license
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ext.h"
#include "ext/standard/php_smart_string.h"
#include "ext/standard/php_var.h"
static zend_always_inline void zephir_smart_str_0(smart_str *str)
{
if (str->s) {
ZSTR_VAL(str->s)[ZSTR_LEN(str->s)] = '\0';
}
}
/**
* var_dump outputs php variables without using the PHP userland
*/
void zephir_var_dump(zval *var)
{
php_var_dump(var, 1);
}
/**
* var_export outputs php variables without using the PHP userland
*/
void zephir_var_export(zval *var)
{
php_var_export(var, 1);
}
/**
* var_export returns php variables without using the PHP userland
*/
void zephir_var_export_ex(zval *return_value, zval *var)
{
smart_str buf = { 0 };
php_var_export_ex(var, 1, &buf);
zephir_smart_str_0(&buf);
ZVAL_STR(return_value, buf.s);
}
void zephir_get_defined_vars(zval *return_value)
{
zend_array *symtable = zend_rebuild_symbol_table();
if (EXPECTED(symtable != NULL)) {
RETURN_ARR(zend_array_dup(symtable));
}
RETURN_NULL();
}