Skip to content

Commit 1d86654

Browse files
committed
Add test
1 parent 8cc850b commit 1d86654

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Lazy objects: resetAsLazy*() accept a sub-class of the reflected class
3+
--FILE--
4+
<?php
5+
6+
class A {
7+
public $a;
8+
}
9+
class B extends A {}
10+
11+
class C {}
12+
13+
$reflector = new ReflectionClass(A::class);
14+
15+
$reflector->resetAsLazyGhost(new A(), function () {});
16+
$reflector->resetAsLazyGhost(new B(), function () {});
17+
18+
try {
19+
$reflector->resetAsLazyGhost(new C(), function () {});
20+
} catch (TypeError $e) {
21+
printf("%s: %s\n", $e::class, $e->getMessage());
22+
}
23+
24+
?>
25+
==DONE==
26+
--EXPECT--
27+
TypeError: ReflectionClass::resetAsLazyGhost(): Argument #1 ($object) must be of type A, C given
28+
==DONE==

ext/reflection/php_reflection.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5197,7 +5197,6 @@ void reflection_class_new_lazy(INTERNAL_FUNCTION_PARAMETERS,
51975197

51985198
if (is_reset) {
51995199
ZEND_PARSE_PARAMETERS_START(2, 3)
5200-
// TODO: check that obj->ce matches ce
52015200
Z_PARAM_OBJ_OF_CLASS(obj, ce)
52025201
Z_PARAM_FUNC(fci, fcc)
52035202
Z_PARAM_OPTIONAL

0 commit comments

Comments
 (0)