1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00

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 c4eb5f2387
commit 2e5d5e5ac6
2 changed files with 15 additions and 1 deletions
+12
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
+3 -1
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);
}