|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-23 20:07 UTC] HMWiesinger at gmx dot at
Description:
------------
It doesn't seem to be possible to get write access to properties of mysqli classes
using the Reflection API.
Test script:
---------------
$mysqli = new MySQLi();
$reflection = new ReflectionClass('\MySQLi');
$property = $reflection->getProperty('affected_rows');
$property->setAccessible(TRUE);
$property->setValue($mysqli, 10);
Expected result:
----------------
No Error
Actual result:
--------------
Fatal error: ReflectionProperty::setValue(): Cannot write property
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 10:00:01 2025 UTC |
hmm, yes, subclass still use that write_func. a solution might be use composite, like: class MysqliMock { public $mysqli; public function __construct() { $this->mysqli = new MySQLi(); } public function __call($method, $args) { call_user_func_array(array($this->mysqli, "method"), $args) } public function __get($name) { //you can mock the properties here } public function __set($name, $value) { } } ?> what do you think? thanks