mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Fixed Bug #60173 (Wrong error message on reflective trait instantiation)
This commit is contained in:
parent
0c6861ac5e
commit
ada5cda0ec
12
Zend/tests/traits/bug60173.phpt
Normal file
12
Zend/tests/traits/bug60173.phpt
Normal file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Bug #60173 (Wrong error message on reflective trait instantiation)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait foo { }
|
||||
|
||||
$rc = new ReflectionClass('foo');
|
||||
$rc->newInstance();
|
||||
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot instantiate trait foo in %s on line %d
|
@ -1107,7 +1107,9 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type
|
||||
zend_object *object;
|
||||
|
||||
if (class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
|
||||
char *what = class_type->ce_flags & ZEND_ACC_INTERFACE ? "interface" : "abstract class";
|
||||
char *what = (class_type->ce_flags & ZEND_ACC_INTERFACE) ? "interface"
|
||||
:((class_type->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) ? "trait"
|
||||
: "abstract class";
|
||||
zend_error(E_ERROR, "Cannot instantiate %s %s", what, class_type->name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user