com php-src: Add test to ensure ReflectionClass works correctly with traits: ext/reflection/php_reflection.c ext/reflection/re
flectionclass_for_traits.phpt

From: Date: Thu, 12 Feb 2015 22:25:09 +0000
Subject: com php-src: Add test to ensure ReflectionClass works correctly with traits: ext/reflection/php_reflection.c ext/reflection/re
flectionclass_for_traits.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84839@lists.php.net to get a copy of this message
Commit: 240fbd36f18efcec817b0b8ecd85763ec6abf007 Author: Nikita Popov <nikic@php.net> Thu, 12 Feb 2015 23:25:09 +0100 Parents: 8c81d80e10e0f189307fc8ff4a8fb34bd0cb1fcb Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=240fbd36f18efcec817b0b8ecd85763ec6abf007 Log: Add test to ensure ReflectionClass works correctly with traits Some of these were not working correctly before Guilherme's patch. Another was broken by it and is fixed in this commit as well. Changed paths: M ext/reflection/php_reflection.c A ext/reflection/reflectionclass_for_traits.phpt Diff: diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 309b10c..1f16c4d 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4084,7 +4084,7 @@ ZEND_METHOD(reflection_class, isInstantiable) return; } GET_REFLECTION_OBJECT_PTR(ce); - if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) { + if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) { RETURN_FALSE; } diff --git a/ext/reflection/reflectionclass_for_traits.phpt b/ext/reflection/reflectionclass_for_traits.phpt new file mode 100644 index 0000000...526310a --- /dev/null +++ b/ext/reflection/reflectionclass_for_traits..phpt @@ -0,0 +1,20 @@ +--TEST-- +Tests some parts of ReflectionClass behavior for traits +--FILE-- +<?php + +trait T {} + +$r = new ReflectionClass('T'); +var_dump(Reflection::getModifierNames($r->getModifiers())); +var_dump($r->isAbstract()); +var_dump($r->isInstantiable()); +var_dump($r->isCloneable()); + +?> +--EXPECT-- +array(0) { +} +bool(false) +bool(false) +bool(false)

« previous php.cvs (#84839) next »