com php-src: Fix bug #78697: inaccurate error message: NEWS ext/reflection/php_reflection.c ext/reflection/tests/Refl
ectionClass_implementsInterface_001.phpt ext/refl ection/tests/bug78697.phpt
| From: | Joe Watkins | Date: | Mon, 21 Oct 2019 07:22:09 +0000 |
| Subject: | com php-src: Fix bug #78697: inaccurate error message: NEWS ext/reflection/php_reflection.c ext/reflection/tests/Refl ectionClass_implementsInterface_001.phpt ext/refl ection/tests/bug78697.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108977@lists.php.net to get a copy of this message | ||
Commit: bea2ff88c9536ffd157c5fa304bd29a9cee85524
Author: Fabien Villepinte <fabien.villepinte@gmail.com> Sat, 19 Oct 2019 21:27:37
+0200
Committer: Joe Watkins <krakjoe@php.net> Mon, 21 Oct 2019 09:22:09 +0200
Parents: 45a7723267741be4867306d18b15a4a27d67b0f7
Branches: PHP-7.2 PHP-7.3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bea2ff88c9536ffd157c5fa304bd29a9cee85524
Log:
Fix bug #78697: inaccurate error message
Bugs:
https://bugs.php.net/78697
Changed paths:
M NEWS
M ext/reflection/php_reflection.c
M ext/reflection/tests/ReflectionClass_implementsInterface_001..phpt
A ext/reflection/tests/bug78697.phpt
Diff:
diff --git a/NEWS b/NEWS
index d63dd99d6ed..f2a811b6061 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,10 @@ PHP NEWS
. Fixed bug #78654 (Incorrectly computed opcache checksum on files with
non-ascii characters). (mhagstrand)
+- Reflection:
+ . Fixed bug #78697 (ReflectionClass::ImplementsInterface - inaccurate error
+ message with traits). (villfa)
+
- Sockets:
. Fixed bug #78665 (Multicasting may leak memory). (cmb)
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 012f23982d9..fe5f2178c6e 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -5140,7 +5140,7 @@ ZEND_METHOD(reflection_class, implementsInterface)
if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Interface %s is a Class", ZSTR_VAL(interface_ce->name));
+ "%s is not an interface", ZSTR_VAL(interface_ce->name));
return;
}
RETURN_BOOL(instanceof_function(ce, interface_ce));
diff --git a/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
index 91398867ecd..d1cbc8ae477 100644
--- a/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
@@ -67,14 +67,14 @@ try {
?>
--EXPECTF--
Does A implement A?
- - Using object argument: Interface A is a Class
- - Using string argument: Interface A is a Class
+ - Using object argument: A is not an interface
+ - Using string argument: A is not an interface
Does A implement B?
- - Using object argument: Interface B is a Class
- - Using string argument: Interface B is a Class
+ - Using object argument: B is not an interface
+ - Using string argument: B is not an interface
Does A implement C?
- - Using object argument: Interface C is a Class
- - Using string argument: Interface C is a Class
+ - Using object argument: C is not an interface
+ - Using string argument: C is not an interface
Does A implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
@@ -82,14 +82,14 @@ Does A implement I2?
- Using object argument: bool(false)
- Using string argument: bool(false)
Does B implement A?
- - Using object argument: Interface A is a Class
- - Using string argument: Interface A is a Class
+ - Using object argument: A is not an interface
+ - Using string argument: A is not an interface
Does B implement B?
- - Using object argument: Interface B is a Class
- - Using string argument: Interface B is a Class
+ - Using object argument: B is not an interface
+ - Using string argument: B is not an interface
Does B implement C?
- - Using object argument: Interface C is a Class
- - Using string argument: Interface C is a Class
+ - Using object argument: C is not an interface
+ - Using string argument: C is not an interface
Does B implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
@@ -97,14 +97,14 @@ Does B implement I2?
- Using object argument: bool(false)
- Using string argument: bool(false)
Does C implement A?
- - Using object argument: Interface A is a Class
- - Using string argument: Interface A is a Class
+ - Using object argument: A is not an interface
+ - Using string argument: A is not an interface
Does C implement B?
- - Using object argument: Interface B is a Class
- - Using string argument: Interface B is a Class
+ - Using object argument: B is not an interface
+ - Using string argument: B is not an interface
Does C implement C?
- - Using object argument: Interface C is a Class
- - Using string argument: Interface C is a Class
+ - Using object argument: C is not an interface
+ - Using string argument: C is not an interface
Does C implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
@@ -112,14 +112,14 @@ Does C implement I2?
- Using object argument: bool(true)
- Using string argument: bool(true)
Does I1 implement A?
- - Using object argument: Interface A is a Class
- - Using string argument: Interface A is a Class
+ - Using object argument: A is not an interface
+ - Using string argument: A is not an interface
Does I1 implement B?
- - Using object argument: Interface B is a Class
- - Using string argument: Interface B is a Class
+ - Using object argument: B is not an interface
+ - Using string argument: B is not an interface
Does I1 implement C?
- - Using object argument: Interface C is a Class
- - Using string argument: Interface C is a Class
+ - Using object argument: C is not an interface
+ - Using string argument: C is not an interface
Does I1 implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
@@ -127,14 +127,14 @@ Does I1 implement I2?
- Using object argument: bool(false)
- Using string argument: bool(false)
Does I2 implement A?
- - Using object argument: Interface A is a Class
- - Using string argument: Interface A is a Class
+ - Using object argument: A is not an interface
+ - Using string argument: A is not an interface
Does I2 implement B?
- - Using object argument: Interface B is a Class
- - Using string argument: Interface B is a Class
+ - Using object argument: B is not an interface
+ - Using string argument: B is not an interface
Does I2 implement C?
- - Using object argument: Interface C is a Class
- - Using string argument: Interface C is a Class
+ - Using object argument: C is not an interface
+ - Using string argument: C is not an interface
Does I2 implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
diff --git a/ext/reflection/tests/bug78697.phpt b/ext/reflection/tests/bug78697.phpt
new file mode 100644
index 00000000000..b35d0f4d4ef
--- /dev/null
+++ b/ext/reflection/tests/bug78697.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #78697: ReflectionClass::implementsInterface - inaccurate error message with traits
+--FILE--
+<?php
+trait T {}
+
+try {
+ (new ReflectionClass(new stdClass))->implementsInterface(T::class);
+} catch (ReflectionException $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECT--
+T is not an interface