Skip to content

Commit ea96289

Browse files
committed
Move zend_verify_abstract_class() into zend_inheritance.c
1 parent 02eded8 commit ea96289

File tree

4 files changed

+60
-60
lines changed

4 files changed

+60
-60
lines changed

Zend/zend_execute.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ ZEND_API void zend_unset_timeout(void);
304304
ZEND_API ZEND_NORETURN void zend_timeout(int dummy);
305305
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
306306
ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *lcname, int fetch_type);
307-
void zend_verify_abstract_class(zend_class_entry *ce);
308307

309308
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name);
310309
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len);

Zend/zend_execute_API.c

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,65 +1374,6 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string
13741374
}
13751375
/* }}} */
13761376

1377-
#define MAX_ABSTRACT_INFO_CNT 3
1378-
#define MAX_ABSTRACT_INFO_FMT "%s%s%s%s"
1379-
#define DISPLAY_ABSTRACT_FN(idx) \
1380-
ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : "", \
1381-
ai.afn[idx] ? "::" : "", \
1382-
ai.afn[idx] ? ZSTR_VAL(ai.afn[idx]->common.function_name) : "", \
1383-
ai.afn[idx] && ai.afn[idx + 1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
1384-
1385-
typedef struct _zend_abstract_info {
1386-
zend_function *afn[MAX_ABSTRACT_INFO_CNT + 1];
1387-
int cnt;
1388-
int ctor;
1389-
} zend_abstract_info;
1390-
1391-
static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai) /* {{{ */
1392-
{
1393-
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
1394-
if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
1395-
ai->afn[ai->cnt] = fn;
1396-
}
1397-
if (fn->common.fn_flags & ZEND_ACC_CTOR) {
1398-
if (!ai->ctor) {
1399-
ai->cnt++;
1400-
ai->ctor = 1;
1401-
} else {
1402-
ai->afn[ai->cnt] = NULL;
1403-
}
1404-
} else {
1405-
ai->cnt++;
1406-
}
1407-
}
1408-
}
1409-
/* }}} */
1410-
1411-
void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
1412-
{
1413-
zend_function *func;
1414-
zend_abstract_info ai;
1415-
1416-
if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & (ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) {
1417-
memset(&ai, 0, sizeof(ai));
1418-
1419-
ZEND_HASH_FOREACH_PTR(&ce->function_table, func) {
1420-
zend_verify_abstract_class_function(func, &ai);
1421-
} ZEND_HASH_FOREACH_END();
1422-
1423-
if (ai.cnt) {
1424-
zend_error_noreturn(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
1425-
ZSTR_VAL(ce->name), ai.cnt,
1426-
ai.cnt > 1 ? "s" : "",
1427-
DISPLAY_ABSTRACT_FN(0),
1428-
DISPLAY_ABSTRACT_FN(1),
1429-
DISPLAY_ABSTRACT_FN(2)
1430-
);
1431-
}
1432-
}
1433-
}
1434-
/* }}} */
1435-
14361377
ZEND_API int zend_delete_global_variable(zend_string *name) /* {{{ */
14371378
{
14381379
return zend_hash_del_ind(&EG(symbol_table), name);

Zend/zend_inheritance.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,65 @@ void zend_check_deprecated_constructor(const zend_class_entry *ce) /* {{{ */
18911891
}
18921892
/* }}} */
18931893

1894+
#define MAX_ABSTRACT_INFO_CNT 3
1895+
#define MAX_ABSTRACT_INFO_FMT "%s%s%s%s"
1896+
#define DISPLAY_ABSTRACT_FN(idx) \
1897+
ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : "", \
1898+
ai.afn[idx] ? "::" : "", \
1899+
ai.afn[idx] ? ZSTR_VAL(ai.afn[idx]->common.function_name) : "", \
1900+
ai.afn[idx] && ai.afn[idx + 1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
1901+
1902+
typedef struct _zend_abstract_info {
1903+
zend_function *afn[MAX_ABSTRACT_INFO_CNT + 1];
1904+
int cnt;
1905+
int ctor;
1906+
} zend_abstract_info;
1907+
1908+
static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai) /* {{{ */
1909+
{
1910+
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
1911+
if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
1912+
ai->afn[ai->cnt] = fn;
1913+
}
1914+
if (fn->common.fn_flags & ZEND_ACC_CTOR) {
1915+
if (!ai->ctor) {
1916+
ai->cnt++;
1917+
ai->ctor = 1;
1918+
} else {
1919+
ai->afn[ai->cnt] = NULL;
1920+
}
1921+
} else {
1922+
ai->cnt++;
1923+
}
1924+
}
1925+
}
1926+
/* }}} */
1927+
1928+
void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
1929+
{
1930+
zend_function *func;
1931+
zend_abstract_info ai;
1932+
1933+
if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & (ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) {
1934+
memset(&ai, 0, sizeof(ai));
1935+
1936+
ZEND_HASH_FOREACH_PTR(&ce->function_table, func) {
1937+
zend_verify_abstract_class_function(func, &ai);
1938+
} ZEND_HASH_FOREACH_END();
1939+
1940+
if (ai.cnt) {
1941+
zend_error_noreturn(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
1942+
ZSTR_VAL(ce->name), ai.cnt,
1943+
ai.cnt > 1 ? "s" : "",
1944+
DISPLAY_ABSTRACT_FN(0),
1945+
DISPLAY_ABSTRACT_FN(1),
1946+
DISPLAY_ABSTRACT_FN(2)
1947+
);
1948+
}
1949+
}
1950+
}
1951+
/* }}} */
1952+
18941953
/*
18951954
* Local variables:
18961955
* tab-width: 4

Zend/zend_inheritance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ZEND_API void zend_do_implement_interfaces(zend_class_entry *ce);
3131

3232
ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
3333

34+
void zend_verify_abstract_class(zend_class_entry *ce);
3435
void zend_check_deprecated_constructor(const zend_class_entry *ce);
3536

3637
END_EXTERN_C()

0 commit comments

Comments
 (0)