Bug #78372 [NEW]: Calling __set magic method on ReflectionProperty::setValue()
| From: | i dot spyric at gmail dot com | Date: | Mon, 05 Aug 2019 07:10:32 +0000 |
| Subject: | Bug #78372 [NEW]: Calling __set magic method on ReflectionProperty::setValue() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222082@lists.php.net to get a copy of this message | ||
From: i dot spyric at gmail dot com
Operating system: Debian
PHP version: 7.4.0beta1
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Calling __set magic method on ReflectionProperty::setValue()
Description:
------------
When you use setting value via reflection on uninitialized property
__set magic method will be called.
If you remove type of property or set default value, __set method will
not be called.
Is it a bug? Because in RFC I have not seen anything about this behavior
Test script:
---------------
class Example {
private string $test;
public function __set($name, $value)
{
echo "$name=$value";
}
}
$t = new Example();
$property = new ReflectionProperty($t, 'test');
$property->setAccessible(true);
$property->setValue($t, 'foo');
Expected result:
----------------
No __set is called
Actual result:
--------------
__set is called
--
Edit bug report at https://bugs.php.net/bug.php?id=78372&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78372&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78372&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78372&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78372&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78372&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78372&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78372&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78372&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78372&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78372&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78372&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78372&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78372&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78372&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78372&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78372&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78372&r=mysqlcfg