Skip to content

Symbol exists #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static const func_info_t func_infos[] = {
F1("get_declared_classes", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_traits", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_interfaces", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_declared_symbols", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("get_defined_functions", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ARRAY),
F1("get_defined_vars", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
F1("get_resource_type", MAY_BE_STRING),
Expand Down
14 changes: 13 additions & 1 deletion Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,11 @@ ZEND_FUNCTION(enum_exists)
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_ENUM, 0);
}

ZEND_FUNCTION(symbol_exists)
{
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED, 0);
}

/* {{{ Checks if the function exists */
ZEND_FUNCTION(function_exists)
{
Expand Down Expand Up @@ -1382,7 +1387,7 @@ static inline void get_declared_class_impl(INTERNAL_FUNCTION_PARAMETERS, int fla
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(EG(class_table), key, zv) {
ce = Z_PTR_P(zv);
if ((ce->ce_flags & (ZEND_ACC_LINKED|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT)) == flags
if ((ce->ce_flags & (flags|ZEND_ACC_LINKED|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT)) == flags
&& key
&& ZSTR_VAL(key)[0] != 0) {
ZEND_HASH_FILL_GROW();
Expand Down Expand Up @@ -1420,6 +1425,13 @@ ZEND_FUNCTION(get_declared_interfaces)
}
/* }}} */

/* {{{ Returns an array of all declared symbols. */
ZEND_FUNCTION(get_declared_symbols)
{
get_declared_class_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT);
}
/* }}} */

/* {{{ Returns an array of all defined functions */
ZEND_FUNCTION(get_defined_functions)
{
Expand Down
8 changes: 8 additions & 0 deletions Zend/zend_builtin_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ function trait_exists(string $trait, bool $autoload = true): bool {}

function enum_exists(string $enum, bool $autoload = true): bool {}

function symbol_exists(string $symbol, bool $autoload = true): bool {}

function function_exists(string $function): bool {}

function class_alias(string $class, string $alias, bool $autoload = true): bool {}
Expand Down Expand Up @@ -140,6 +142,12 @@ function get_declared_traits(): array {}
*/
function get_declared_interfaces(): array {}

/**
* @return array<int, string>
* @refcount 1
*/
function get_declared_symbols(): array {}

/**
* @return array<string, array>
* @refcount 1
Expand Down
13 changes: 12 additions & 1 deletion Zend/zend_builtin_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading