gron                                     Mon, 31 Oct 2011 22:59:00 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=318621

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

Bug: https://bugs.php.net/60173 (Assigned) Wrong message on trait instantiation
      
Changed paths:
    A   php/php-src/branches/PHP_5_4/Zend/tests/traits/bug60173.phpt
    U   php/php-src/branches/PHP_5_4/Zend/zend_API.c
    A   php/php-src/trunk/Zend/tests/traits/bug60173.phpt
    U   php/php-src/trunk/Zend/zend_API.c

Added: php/php-src/branches/PHP_5_4/Zend/tests/traits/bug60173.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/traits/bug60173.phpt                
                (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/traits/bug60173.phpt        
2011-10-31 22:59:00 UTC (rev 318621)
@@ -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

Modified: php/php-src/branches/PHP_5_4/Zend/zend_API.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_API.c        2011-10-31 21:49:35 UTC 
(rev 318620)
+++ php/php-src/branches/PHP_5_4/Zend/zend_API.c        2011-10-31 22:59:00 UTC 
(rev 318621)
@@ -1107,7 +1107,9 @@
        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);
        }


Added: php/php-src/trunk/Zend/tests/traits/bug60173.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/bug60173.phpt                           
(rev 0)
+++ php/php-src/trunk/Zend/tests/traits/bug60173.phpt   2011-10-31 22:59:00 UTC 
(rev 318621)
@@ -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

Modified: php/php-src/trunk/Zend/zend_API.c
===================================================================
--- php/php-src/trunk/Zend/zend_API.c   2011-10-31 21:49:35 UTC (rev 318620)
+++ php/php-src/trunk/Zend/zend_API.c   2011-10-31 22:59:00 UTC (rev 318621)
@@ -1107,7 +1107,9 @@
        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);
        }


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to