Fixed Bug #60173 (Wrong error message on reflective trait instantiation)

This commit is contained in:
Stefan Marr 2011-10-31 22:59:00 +00:00
parent 0c6861ac5e
commit ada5cda0ec
2 changed files with 15 additions and 1 deletions

View 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

View File

@ -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);
}