Skip to content

Commit 277f0f4

Browse files
committed
ext/reflection: only warn instead of throwing exceptions on bad __isset
1 parent 132446f commit 277f0f4

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

ext/reflection/php_reflection.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6725,8 +6725,9 @@ ZEND_METHOD(ReflectionProperty, isReadable)
67256725
if (ce->__get) {
67266726
if (obj && ce->__isset) {
67276727
if (ce->__isset->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
6728-
zend_throw_exception(reflection_exception_ptr, "__isset should not return a reference", 0);
6729-
RETURN_THROWS();
6728+
//php_error_docref(NULL, E_WARNING, "__isset unexpectedly returned a reference!");
6729+
zend_error(E_WARNING, "__isset unexpectedly returned a reference!");
6730+
RETURN_FALSE;
67306731
}
67316732

67326733
uint32_t *guard = zend_get_property_guard(obj, ref->unmangled_name);

ext/reflection/tests/gh22000.phpt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ class TestClass {
2121

2222

2323
function test($class) {
24-
try {
25-
$rc = new ReflectionClass($class);
26-
foreach ($rc->getProperties() as $rp) {
27-
echo $rp->getName() . ' from global: ';
28-
var_dump($rp->isReadable(null, new $class));
29-
}
30-
} catch(\Exception $ex) {
31-
echo $ex->getMessage();
24+
$rc = new ReflectionClass($class);
25+
foreach ($rc->getProperties() as $rp) {
26+
echo $rp->getName() . ' from global:';
27+
var_dump($rp->isReadable(null, new $class));
3228
}
3329
}
3430

3531
test('TestClass');
3632
?>
3733
--EXPECTF--
38-
a from global: bool(false)
39-
b from global: __isset should not return a reference
34+
a from global:bool(false)
35+
b from global:
36+
Warning: __isset unexpectedly returned a reference! in %s/ext/reflection/tests/gh22000.php on line %d
37+
bool(false)
38+
c from global:
39+
Warning: __isset unexpectedly returned a reference! in %s/ext/reflection/tests/gh22000.php on line %d
40+
bool(false)
41+

0 commit comments

Comments
 (0)