Skip to content

Commit 1c9b62f

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix bug #78697: inaccurate error message
2 parents 4f50d58 + bea2ff8 commit 1c9b62f

File tree

4 files changed

+49
-31
lines changed

4 files changed

+49
-31
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ PHP NEWS
2121
. Fixed bug #78654 (Incorrectly computed opcache checksum on files with
2222
non-ascii characters). (mhagstrand)
2323

24+
- Reflection:
25+
. Fixed bug #78697 (ReflectionClass::ImplementsInterface - inaccurate error
26+
message with traits). (villfa)
27+
2428
- Sockets:
2529
. Fixed bug #78665 (Multicasting may leak memory). (cmb)
2630

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5087,7 +5087,7 @@ ZEND_METHOD(reflection_class, implementsInterface)
50875087

50885088
if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) {
50895089
zend_throw_exception_ex(reflection_exception_ptr, 0,
5090-
"Interface %s is a Class", ZSTR_VAL(interface_ce->name));
5090+
"%s is not an interface", ZSTR_VAL(interface_ce->name));
50915091
return;
50925092
}
50935093
RETURN_BOOL(instanceof_function(ce, interface_ce));

ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,74 +67,74 @@ try {
6767
?>
6868
--EXPECTF--
6969
Does A implement A?
70-
- Using object argument: Interface A is a Class
71-
- Using string argument: Interface A is a Class
70+
- Using object argument: A is not an interface
71+
- Using string argument: A is not an interface
7272
Does A implement B?
73-
- Using object argument: Interface B is a Class
74-
- Using string argument: Interface B is a Class
73+
- Using object argument: B is not an interface
74+
- Using string argument: B is not an interface
7575
Does A implement C?
76-
- Using object argument: Interface C is a Class
77-
- Using string argument: Interface C is a Class
76+
- Using object argument: C is not an interface
77+
- Using string argument: C is not an interface
7878
Does A implement I1?
7979
- Using object argument: bool(true)
8080
- Using string argument: bool(true)
8181
Does A implement I2?
8282
- Using object argument: bool(false)
8383
- Using string argument: bool(false)
8484
Does B implement A?
85-
- Using object argument: Interface A is a Class
86-
- Using string argument: Interface A is a Class
85+
- Using object argument: A is not an interface
86+
- Using string argument: A is not an interface
8787
Does B implement B?
88-
- Using object argument: Interface B is a Class
89-
- Using string argument: Interface B is a Class
88+
- Using object argument: B is not an interface
89+
- Using string argument: B is not an interface
9090
Does B implement C?
91-
- Using object argument: Interface C is a Class
92-
- Using string argument: Interface C is a Class
91+
- Using object argument: C is not an interface
92+
- Using string argument: C is not an interface
9393
Does B implement I1?
9494
- Using object argument: bool(true)
9595
- Using string argument: bool(true)
9696
Does B implement I2?
9797
- Using object argument: bool(false)
9898
- Using string argument: bool(false)
9999
Does C implement A?
100-
- Using object argument: Interface A is a Class
101-
- Using string argument: Interface A is a Class
100+
- Using object argument: A is not an interface
101+
- Using string argument: A is not an interface
102102
Does C implement B?
103-
- Using object argument: Interface B is a Class
104-
- Using string argument: Interface B is a Class
103+
- Using object argument: B is not an interface
104+
- Using string argument: B is not an interface
105105
Does C implement C?
106-
- Using object argument: Interface C is a Class
107-
- Using string argument: Interface C is a Class
106+
- Using object argument: C is not an interface
107+
- Using string argument: C is not an interface
108108
Does C implement I1?
109109
- Using object argument: bool(true)
110110
- Using string argument: bool(true)
111111
Does C implement I2?
112112
- Using object argument: bool(true)
113113
- Using string argument: bool(true)
114114
Does I1 implement A?
115-
- Using object argument: Interface A is a Class
116-
- Using string argument: Interface A is a Class
115+
- Using object argument: A is not an interface
116+
- Using string argument: A is not an interface
117117
Does I1 implement B?
118-
- Using object argument: Interface B is a Class
119-
- Using string argument: Interface B is a Class
118+
- Using object argument: B is not an interface
119+
- Using string argument: B is not an interface
120120
Does I1 implement C?
121-
- Using object argument: Interface C is a Class
122-
- Using string argument: Interface C is a Class
121+
- Using object argument: C is not an interface
122+
- Using string argument: C is not an interface
123123
Does I1 implement I1?
124124
- Using object argument: bool(true)
125125
- Using string argument: bool(true)
126126
Does I1 implement I2?
127127
- Using object argument: bool(false)
128128
- Using string argument: bool(false)
129129
Does I2 implement A?
130-
- Using object argument: Interface A is a Class
131-
- Using string argument: Interface A is a Class
130+
- Using object argument: A is not an interface
131+
- Using string argument: A is not an interface
132132
Does I2 implement B?
133-
- Using object argument: Interface B is a Class
134-
- Using string argument: Interface B is a Class
133+
- Using object argument: B is not an interface
134+
- Using string argument: B is not an interface
135135
Does I2 implement C?
136-
- Using object argument: Interface C is a Class
137-
- Using string argument: Interface C is a Class
136+
- Using object argument: C is not an interface
137+
- Using string argument: C is not an interface
138138
Does I2 implement I1?
139139
- Using object argument: bool(true)
140140
- Using string argument: bool(true)

ext/reflection/tests/bug78697.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #78697: ReflectionClass::implementsInterface - inaccurate error message with traits
3+
--FILE--
4+
<?php
5+
trait T {}
6+
7+
try {
8+
(new ReflectionClass(new stdClass))->implementsInterface(T::class);
9+
} catch (ReflectionException $e) {
10+
echo $e->getMessage();
11+
}
12+
?>
13+
--EXPECT--
14+
T is not an interface

0 commit comments

Comments
 (0)