Skip to content

Add support for constants in stubs #7434

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

Merged
merged 1 commit into from
May 22, 2022
Merged
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
19 changes: 2 additions & 17 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "zend_operators.h"
#include "zend_globals.h"
#include "zend_API.h"
#include "zend_constants_arginfo.h"

/* Protection from recursive self-referencing class constants */
#define IS_CONSTANT_VISITED_MARK 0x80
Expand Down Expand Up @@ -108,23 +109,7 @@ void zend_startup_constants(void)

void zend_register_standard_constants(void)
{
REGISTER_MAIN_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_WARNING", E_WARNING, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_PARSE", E_PARSE, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_NOTICE", E_NOTICE, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_CORE_ERROR", E_CORE_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_PERSISTENT | CONST_CS);

REGISTER_MAIN_LONG_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT | CONST_CS);
register_zend_constants_consts(0);

REGISTER_MAIN_LONG_CONSTANT("DEBUG_BACKTRACE_PROVIDE_OBJECT", DEBUG_BACKTRACE_PROVIDE_OBJECT, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT | CONST_CS);
Expand Down
99 changes: 99 additions & 0 deletions Zend/zend_constants.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

/** @generate-class-entries */

/**
* @var int
* @cname E_ERROR
*/
const E_ERROR = UNKNOWN;

/**
* @var int
* @cname E_WARNING
*/
const E_WARNING = UNKNOWN;

/**
* @var int
* @cname E_PARSE
*/
const E_PARSE = UNKNOWN;

/**
* @var int
* @cname E_NOTICE
*/
const E_NOTICE = UNKNOWN;

/**
* @var int
* @cname E_CORE_ERROR
*/
const E_CORE_ERROR = UNKNOWN;

/**
* @var int
* @cname E_CORE_WARNING
*/
const E_CORE_WARNING = UNKNOWN;

/**
* @var int
* @cname E_COMPILE_ERROR
*/
const E_COMPILE_ERROR = UNKNOWN;

/**
* @var int
* @cname E_COMPILE_WARNING
*/
const E_COMPILE_WARNING = UNKNOWN;

/**
* @var int
* @cname E_USER_ERROR
*/
const E_USER_ERROR = UNKNOWN;

/**
* @var int
* @cname E_USER_WARNING
*/
const E_USER_WARNING = UNKNOWN;

/**
* @var int
* @cname E_USER_NOTICE
*/
const E_USER_NOTICE = UNKNOWN;

/**
* @var int
* @cname E_STRICT
*/
const E_STRICT = UNKNOWN;

/**
* @var int
* @cname E_RECOVERABLE_ERROR
*/
const E_RECOVERABLE_ERROR = UNKNOWN;

/**
* @var int
* @cname E_DEPRECATED
*/
const E_DEPRECATED = UNKNOWN;

/**
* @var int
* @cname E_USER_DEPRECATED
*/
const E_USER_DEPRECATED = UNKNOWN;

/**
* @var int
* @cname E_ALL
*/
const E_ALL = UNKNOWN;
24 changes: 24 additions & 0 deletions Zend/zend_constants_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: f417ea0f3a43036f0abc87856c83f4c93395405a */



static void register_zend_constants_consts(int module_number)
{
REGISTER_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_WARNING", E_WARNING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_PARSE", E_PARSE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_NOTICE", E_NOTICE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_CORE_ERROR", E_CORE_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_ALL", E_ALL, CONST_CS | CONST_PERSISTENT);
}
5 changes: 0 additions & 5 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,6 @@ void zend_register_default_exception(void) /* {{{ */
zend_ce_error_exception = register_class_ErrorException(zend_ce_exception);
zend_ce_error_exception->create_object = zend_error_exception_new;

/* Declared manually because it uses constant E_ERROR. */
zval severity_default_value;
ZVAL_LONG(&severity_default_value, E_ERROR);
zend_declare_typed_property(zend_ce_error_exception, ZSTR_KNOWN(ZEND_STR_SEVERITY), &severity_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));

zend_ce_error = register_class_Error(zend_ce_throwable);
zend_ce_error->create_object = zend_default_exception_new;

Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_exceptions_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ static zend_class_entry *register_class_ErrorException(zend_class_entry *class_e
INIT_CLASS_ENTRY(ce, "ErrorException", class_ErrorException_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);

zval property_severity_default_value;
ZVAL_LONG(&property_severity_default_value, E_ERROR);
zend_string *property_severity_name = zend_string_init("severity", sizeof("severity") - 1, 1);
zend_declare_typed_property(class_entry, property_severity_name, &property_severity_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(property_severity_name);

return class_entry;
}

Expand Down
Loading