Skip to content

Declare ext/standard constants in stubs - part 10 #9719

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
Oct 12, 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
24 changes: 5 additions & 19 deletions ext/standard/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ ZEND_DECLARE_MODULE_GLOBALS(assert)

#define SAFE_STRING(s) ((s)?(s):"")

enum {
ASSERT_ACTIVE=1,
ASSERT_CALLBACK,
ASSERT_BAIL,
ASSERT_WARNING,
ASSERT_EXCEPTION
};

PHPAPI zend_class_entry *assertion_error_ce;

static PHP_INI_MH(OnChangeCallback) /* {{{ */
Expand Down Expand Up @@ -93,12 +85,6 @@ PHP_MINIT_FUNCTION(assert) /* {{{ */

REGISTER_INI_ENTRIES();

REGISTER_LONG_CONSTANT("ASSERT_ACTIVE", ASSERT_ACTIVE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ASSERT_CALLBACK", ASSERT_CALLBACK, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ASSERT_BAIL", ASSERT_BAIL, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ASSERT_WARNING", ASSERT_WARNING, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ASSERT_EXCEPTION", ASSERT_EXCEPTION, CONST_CS|CONST_PERSISTENT);

return SUCCESS;
}
/* }}} */
Expand Down Expand Up @@ -219,7 +205,7 @@ PHP_FUNCTION(assert_options)
ZEND_PARSE_PARAMETERS_END();

switch (what) {
case ASSERT_ACTIVE:
case PHP_ASSERT_ACTIVE:
oldint = ASSERTG(active);
if (ac == 2) {
zend_string *value_str = zval_try_get_string(value);
Expand All @@ -235,7 +221,7 @@ PHP_FUNCTION(assert_options)
RETURN_LONG(oldint);
break;

case ASSERT_BAIL:
case PHP_ASSERT_BAIL:
oldint = ASSERTG(bail);
if (ac == 2) {
zend_string *value_str = zval_try_get_string(value);
Expand All @@ -251,7 +237,7 @@ PHP_FUNCTION(assert_options)
RETURN_LONG(oldint);
break;

case ASSERT_WARNING:
case PHP_ASSERT_WARNING:
oldint = ASSERTG(warning);
if (ac == 2) {
zend_string *value_str = zval_try_get_string(value);
Expand All @@ -267,7 +253,7 @@ PHP_FUNCTION(assert_options)
RETURN_LONG(oldint);
break;

case ASSERT_CALLBACK:
case PHP_ASSERT_CALLBACK:
if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) {
ZVAL_COPY(return_value, &ASSERTG(callback));
} else if (ASSERTG(cb)) {
Expand All @@ -286,7 +272,7 @@ PHP_FUNCTION(assert_options)
}
return;

case ASSERT_EXCEPTION:
case PHP_ASSERT_EXCEPTION:
oldint = ASSERTG(exception);
if (ac == 2) {
zend_string *val = zval_try_get_string(value);
Expand Down
1 change: 1 addition & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "php.h"
#include "php_assert.h"
#include "php_streams.h"
#include "php_main.h"
#include "php_globals.h"
Expand Down
28 changes: 28 additions & 0 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,34 @@
*/
const ARRAY_FILTER_USE_KEY = UNKNOWN;

/* assert.c */

/**
* @var int
* @cvalue PHP_ASSERT_ACTIVE
*/
const ASSERT_ACTIVE = UNKNOWN;
/**
* @var int
* @cvalue PHP_ASSERT_CALLBACK
*/
const ASSERT_CALLBACK = UNKNOWN;
/**
* @var int
* @cvalue PHP_ASSERT_BAIL
*/
const ASSERT_BAIL = UNKNOWN;
/**
* @var int
* @cvalue PHP_ASSERT_WARNING
*/
const ASSERT_WARNING = UNKNOWN;
/**
* @var int
* @cvalue PHP_ASSERT_EXCEPTION
*/
const ASSERT_EXCEPTION = UNKNOWN;

/* basic_functions.h */

/**
Expand Down
7 changes: 6 additions & 1 deletion ext/standard/basic_functions_arginfo.h

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

8 changes: 8 additions & 0 deletions ext/standard/php_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ PHP_RINIT_FUNCTION(assert);
PHP_RSHUTDOWN_FUNCTION(assert);
PHP_MINFO_FUNCTION(assert);

enum {
PHP_ASSERT_ACTIVE=1,
PHP_ASSERT_CALLBACK,
PHP_ASSERT_BAIL,
PHP_ASSERT_WARNING,
PHP_ASSERT_EXCEPTION
};

extern PHPAPI zend_class_entry *assertion_error_ce;

#endif /* PHP_ASSERT_H */