]> granicus.if.org Git - php/commitdiff
- Fixed ReflectionClass::isTrait() checking (to not identify abstract class as Trait)
authorFelipe Pena <felipe@php.net>
Sat, 29 May 2010 22:08:51 +0000 (22:08 +0000)
committerFelipe Pena <felipe@php.net>
Sat, 29 May 2010 22:08:51 +0000 (22:08 +0000)
ext/reflection/php_reflection.c
ext/reflection/tests/traits003.phpt [new file with mode: 0644]

index 2d8ba6e0c22e5737dcbc35fd80102ca8618a8e56..a590bf541d841e72036737f9722814e6c2692855 100644 (file)
@@ -3999,7 +3999,7 @@ ZEND_METHOD(reflection_class, isInterface)
    Returns whether this is a trait */
 ZEND_METHOD(reflection_class, isTrait)
 {
-       _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT);
+       _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
 }
 /* }}} */
 
diff --git a/ext/reflection/tests/traits003.phpt b/ext/reflection/tests/traits003.phpt
new file mode 100644 (file)
index 0000000..c569a8e
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Reflection and Traits
+--FILE--
+<?php
+
+abstract class foo {
+}
+
+trait bar {
+       
+}
+
+final class baz {
+       
+}
+
+$x = new ReflectionClass('foo');
+var_dump($x->isTrait());
+
+$x = new ReflectionClass('bar');
+var_dump($x->isTrait());
+
+$x = new ReflectionClass('baz');
+var_dump($x->isTrait());
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
+bool(false)