diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2018-07-02 18:57:14 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-07-02 18:57:25 +0200 |
| commit | 9bbb9e537c4f88eb31038343e567c0eca4b9a00d (patch) | |
| tree | 8604029aeca632b9dc95b28a57bf54e458f2e110 | |
| parent | 3a236d0587aafc762890e61813cb22e63d8b2550 (diff) | |
| parent | c97b8bbf8252c3a493a44bcb91fb137952f03710 (diff) | |
| download | php-git-9bbb9e537c4f88eb31038343e567c0eca4b9a00d.tar.gz | |
Merge branch 'PHP-7.1' into PHP-7.2
| -rw-r--r-- | NEWS | 2 | ||||
| -rw-r--r-- | ext/reflection/php_reflection.c | 2 | ||||
| -rw-r--r-- | ext/reflection/tests/bug75231.phpt | 25 |
3 files changed, 28 insertions, 1 deletions
@@ -45,6 +45,8 @@ PHP NEWS - Reflection: . Fixed bug #76536 (PHP crashes with core dump when throwing exception in error handler). (Laruence) + . Fixed bug #75231 (ReflectionProperty#getValue() incorrectly works with + inherited classes). (Nikita) - Standard: . Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys). diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 9128f76d9d..a0d4ebb4a0 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5531,7 +5531,7 @@ ZEND_METHOD(reflection_property, getValue) return; } - if (!instanceof_function(Z_OBJCE_P(object), ref->ce)) { + if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) { _DO_THROW("Given object is not an instance of the class this property was declared in"); /* Returns from this function */ } diff --git a/ext/reflection/tests/bug75231.phpt b/ext/reflection/tests/bug75231.phpt new file mode 100644 index 0000000000..5aff0be19c --- /dev/null +++ b/ext/reflection/tests/bug75231.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #75231: ReflectionProperty#getValue() incorrectly works with inherited classes +--FILE-- +<?php +class A +{ + public $prop; + public function __construct() + { + $this->prop = 'prop'; + } + public function method() + { + return 'method'; + } +} +class B extends A +{ +} +print_r((new ReflectionMethod(B::class, 'method'))->invoke(new A()).PHP_EOL); +print_r((new ReflectionProperty(B::class, 'prop'))->getValue(new A()).PHP_EOL); +?> +--EXPECT-- +method +prop |
