ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate, 0, 0, 1)
ZEND_ARG_INFO(0, file)
ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(1, errcnt)
ZEND_END_ARG_INFO();
static PHP_FUNCTION(psi_validate)
{
struct psi_data D = {0};
struct psi_validate_scope S = {0};
zend_long flags = 0;
+ zval *errcnt = NULL;
#if PHP_DEBUG
if (psi_check_env("PSI_DEBUG")) {
}
#endif
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "P|l", &file, &flags)) {
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "P|lz", &file, &flags, &errcnt)) {
return;
}
psi_data_ctor(&D, P.error, P.flags);
psi_validate_scope_ctor(&S);
S.defs = &P.preproc->defs;
- RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)) && !P.errors);
+
+ RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
+
+ if (errcnt) {
+ ZVAL_DEREF(errcnt);
+ convert_to_long(errcnt);
+ ZVAL_LONG(errcnt, P.errors);
+ }
+
psi_validate_scope_dtor(&S);
psi_data_dtor(&D);
psi_parser_dtor(&P);
ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate_string, 0, 0, 1)
ZEND_ARG_INFO(0, string)
+ ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(1, errcnt)
ZEND_END_ARG_INFO();
static PHP_FUNCTION(psi_validate_string)
{
struct psi_data D = {0};
struct psi_validate_scope S = {0};
zend_long flags = 0;
+ zval *errcnt = NULL;
#if PHP_DEBUG
if (psi_check_env("PSI_DEBUG")) {
}
#endif
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &string, &flags)) {
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &string, &flags, &errcnt)) {
return;
}
psi_data_ctor(&D, P.error, P.flags);
psi_validate_scope_ctor(&S);
S.defs = &P.preproc->defs;
- RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)) && !P.errors);
+
+ RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
+
+ if (errcnt) {
+ ZVAL_DEREF(errcnt);
+ convert_to_long(errcnt);
+ ZVAL_LONG(errcnt, P.errors);
+ }
+
psi_validate_scope_dtor(&S);
psi_data_dtor(&D);
psi_parser_dtor(&P);
PHP_FE_END
};
+static const zend_module_dep psi_deps[] = {
+ ZEND_MOD_REQUIRED("standard")
+ {0}
+};
+
zend_module_entry psi_module_entry = {
- STANDARD_MODULE_HEADER,
+ STANDARD_MODULE_HEADER_EX,
+ NULL,
+ psi_deps,
"psi",
psi_functions,
PHP_MINIT(psi),