-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When packing/unpacking a zend_object don't call magic methods __set/_…
…_get
- Loading branch information
Showing
2 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--TEST-- | ||
Bug #13 | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("msgpack")) { | ||
echo "skip"; | ||
} | ||
--FILE-- | ||
<?php | ||
|
||
class magicClass { | ||
public function __set($name, $value) { | ||
echo 'Called __set' . PHP_EOL; | ||
$this->$name = $value; | ||
} | ||
public function __get($name) { | ||
echo 'Called __get' . PHP_EOL; | ||
return $this->$name; | ||
} | ||
} | ||
|
||
$magicInstance = new \magicClass; | ||
$magicInstance->val = 5; | ||
var_dump($magicInstance); | ||
|
||
$packed = msgpack_pack($magicInstance); | ||
var_dump(bin2hex($packed)); | ||
$unpacked = msgpack_unpack($packed); | ||
var_dump($unpacked); | ||
|
||
?> | ||
--EXPECTF-- | ||
Called __set | ||
object(magicClass)#%d (1) { | ||
["val"]=> | ||
int(5) | ||
} | ||
string(36) "82c0aa6d61676963436c617373a376616c05" | ||
object(magicClass)#%d (1) { | ||
["val"]=> | ||
int(5) | ||
} |