Skip to content

Commit

Permalink
Fix bug #78697: inaccurate error message
Browse files Browse the repository at this point in the history
  • Loading branch information
villfa authored and krakjoe committed Oct 21, 2019
1 parent 45a7723 commit bea2ff8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 31 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
60 changes: 30 additions & 30 deletions ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -67,74 +67,74 @@ 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)
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)
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)
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)
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)
Expand Down
14 changes: 14 additions & 0 deletions ext/reflection/tests/bug78697.phpt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bea2ff8

Please sign in to comment.