mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Make missing trait error recoverable
We were already handling NULL as a case, but seem to have forgotten to pass the ZEND_FETCH_CLASS_EXCEPTION flag. Also make "is not a trait" error recoverable, there's no reason why it can't be. Fixes GH-17959 Closes GH-17960
This commit is contained in:
parent
0a811cea4f
commit
8731c95b35
9 changed files with 46 additions and 8 deletions
|
@ -3546,13 +3546,13 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
|
|||
|
||||
for (i = 0; i < ce->num_traits; i++) {
|
||||
zend_class_entry *trait = zend_fetch_class_by_name(ce->trait_names[i].name,
|
||||
ce->trait_names[i].lc_name, ZEND_FETCH_CLASS_TRAIT);
|
||||
ce->trait_names[i].lc_name, ZEND_FETCH_CLASS_TRAIT | ZEND_FETCH_CLASS_EXCEPTION);
|
||||
if (UNEXPECTED(trait == NULL)) {
|
||||
free_alloca(traits_and_interfaces, use_heap);
|
||||
return NULL;
|
||||
}
|
||||
if (UNEXPECTED(!(trait->ce_flags & ZEND_ACC_TRAIT))) {
|
||||
zend_error_noreturn(E_ERROR, "%s cannot use %s - it is not a trait", ZSTR_VAL(ce->name), ZSTR_VAL(trait->name));
|
||||
zend_throw_error(NULL, "%s cannot use %s - it is not a trait", ZSTR_VAL(ce->name), ZSTR_VAL(trait->name));
|
||||
free_alloca(traits_and_interfaces, use_heap);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue