Server IP : 192.158.238.246 / Your IP : 3.14.131.159 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/cpanel/ea-php80/root/usr/share/tests/pecl/igbinary/tests/ |
Upload File : |
--TEST-- __serialize() mechanism (021): Temporary references in serialized arrays should be properly deduplicated --FILE-- <?php // This test will also pass before php 7.4 - it will just not call __serialize in older php versions. // (not a good example, the formats are incompatible) class Test { /** @var int */ public $i; public function __construct(int $i) { $this->i = $i; } public function __serialize() { $j = $this->i + 0x7700; return [&$j, &$j]; } public function __unserialize(array $data) { list($this->i) = $data; } } $values = []; for ($i = 0; $i < 256; $i++) { $values[] = new Test($i); } $ser = igbinary_serialize($values); $result = igbinary_unserialize($ser); printf("Count=%d\n", count($values)); $j = 0; foreach ($values as $i => $v) { if ($i !== $j) { echo "Unexpected key $i, expected $j\n"; } if ($v->i !== $j) { echo "Unexpected value {$v->i}, expected $j\n"; } $j++; } echo "Done\n"; ?> --EXPECT-- Count=256 Done