diff options
Diffstat (limited to 'ext/standard/tests/serialize')
56 files changed, 473 insertions, 536 deletions
diff --git a/ext/standard/tests/serialize/001.phpt b/ext/standard/tests/serialize/001.phpt index 5551956e92..147c355b08 100644 --- a/ext/standard/tests/serialize/001.phpt +++ b/ext/standard/tests/serialize/001.phpt @@ -6,36 +6,36 @@ serialize_precision=100 <?php class t { - function __construct() - { - $this->a = "hallo"; - } + function __construct() + { + $this->a = "hallo"; + } } class s { - public $a; - public $b; - public $c; + public $a; + public $b; + public $c; - function __construct() - { - $this->a = "hallo"; - $this->b = "php"; - $this->c = "world"; - $this->d = "!"; - } + function __construct() + { + $this->a = "hallo"; + $this->b = "php"; + $this->c = "world"; + $this->d = "!"; + } - function __sleep() - { - echo "__sleep called\n"; - return array("a","c"); - } + function __sleep() + { + echo "__sleep called\n"; + return array("a","c"); + } - function __wakeup() - { - echo "__wakeup called\n"; - } + function __wakeup() + { + echo "__wakeup called\n"; + } } diff --git a/ext/standard/tests/serialize/002.phpt b/ext/standard/tests/serialize/002.phpt index 635e728968..9d06f22d41 100644 --- a/ext/standard/tests/serialize/002.phpt +++ b/ext/standard/tests/serialize/002.phpt @@ -12,7 +12,6 @@ var_dump(unserialize('a:2:{i:0;a:0:{}i:1;a:0:{}}')); var_dump(unserialize('a:3:{i:0;s:3:"foo";i:1;s:3:"bar";i:2;s:3:"baz";}')); var_dump(unserialize('O:8:"stdClass":0:{}')); ?> -===DONE=== --EXPECTF-- bool(false) bool(true) @@ -41,4 +40,3 @@ array(3) { } object(stdClass)#%d (0) { } -===DONE=== diff --git a/ext/standard/tests/serialize/003.phpt b/ext/standard/tests/serialize/003.phpt index 5011412809..cf54f40406 100644 --- a/ext/standard/tests/serialize/003.phpt +++ b/ext/standard/tests/serialize/003.phpt @@ -6,9 +6,9 @@ serialize_precision=100 --FILE-- <?php foreach(array(1e2, 5.2e25, 85.29e-23, 9e-9) AS $value) { - echo ($ser = serialize($value))."\n"; - var_dump(unserialize($ser)); - echo "\n"; + echo ($ser = serialize($value))."\n"; + var_dump(unserialize($ser)); + echo "\n"; } ?> --EXPECTREGEX-- diff --git a/ext/standard/tests/serialize/005.phpt b/ext/standard/tests/serialize/005.phpt index c0f5917ec9..fd9fcaac18 100644 --- a/ext/standard/tests/serialize/005.phpt +++ b/ext/standard/tests/serialize/005.phpt @@ -7,93 +7,93 @@ serialize()/unserialize() objects function do_autoload($class_name) { - if ($class_name != 'autoload_not_available') - { - require_once(__DIR__ . '/' . strtolower($class_name) . '.inc'); - } - echo __FUNCTION__ . "($class_name)\n"; + if ($class_name != 'autoload_not_available') + { + require_once(__DIR__ . '/' . strtolower($class_name) . '.inc'); + } + echo __FUNCTION__ . "($class_name)\n"; } function unserializer($class_name) { - echo __METHOD__ . "($class_name)\n"; - switch($class_name) - { - case 'TestNAOld': - eval("class TestNAOld extends TestOld {}"); - break; - case 'TestNANew': - eval("class TestNANew extends TestNew {}"); - break; - case 'TestNANew2': - eval("class TestNANew2 extends TestNew {}"); - break; - default: - echo "Try autoloader\n"; - if (!spl_autoload_functions()) { - spl_autoload_register(function ($class_name) { do_autoload($class_name); }); - } - spl_autoload_call($class_name); - break; - } + echo __METHOD__ . "($class_name)\n"; + switch($class_name) + { + case 'TestNAOld': + eval("class TestNAOld extends TestOld {}"); + break; + case 'TestNANew': + eval("class TestNANew extends TestNew {}"); + break; + case 'TestNANew2': + eval("class TestNANew2 extends TestNew {}"); + break; + default: + echo "Try autoloader\n"; + if (!spl_autoload_functions()) { + spl_autoload_register(function ($class_name) { do_autoload($class_name); }); + } + spl_autoload_call($class_name); + break; + } } ini_set('unserialize_callback_func', 'unserializer'); class TestOld { - function serialize() - { - echo __METHOD__ . "()\n"; - } - - function unserialize($serialized) - { - echo __METHOD__ . "()\n"; - } - - function __wakeup() - { - echo __METHOD__ . "()\n"; - } - - function __sleep() - { - echo __METHOD__ . "()\n"; - return array(); - } + function serialize() + { + echo __METHOD__ . "()\n"; + } + + function unserialize($serialized) + { + echo __METHOD__ . "()\n"; + } + + function __wakeup() + { + echo __METHOD__ . "()\n"; + } + + function __sleep() + { + echo __METHOD__ . "()\n"; + return array(); + } } class TestNew implements Serializable { - protected static $check = 0; - - function serialize() - { - echo __METHOD__ . "()\n"; - switch(++self::$check) - { - case 1: - return NULL; - case 2: - return "2"; - } - } - - function unserialize($serialized) - { - echo __METHOD__ . "()\n"; - } - - function __wakeup() - { - echo __METHOD__ . "()\n"; - } - - function __sleep() - { - echo __METHOD__ . "()\n"; - } + protected static $check = 0; + + function serialize() + { + echo __METHOD__ . "()\n"; + switch(++self::$check) + { + case 1: + return NULL; + case 2: + return "2"; + } + } + + function unserialize($serialized) + { + echo __METHOD__ . "()\n"; + } + + function __wakeup() + { + echo __METHOD__ . "()\n"; + } + + function __sleep() + { + echo __METHOD__ . "()\n"; + } } echo "===O1===\n"; @@ -127,8 +127,6 @@ var_dump(unserialize('O:19:"autoload_implements":0:{}')); echo "===AutoNA===\n"; var_dump(unserialize('O:22:"autoload_not_available":0:{}')); ?> -===DONE=== -<?php exit(0); ?> --EXPECTF-- ===O1=== TestOld::__sleep() @@ -182,4 +180,3 @@ object(__PHP_Incomplete_Class)#%d (1) { ["__PHP_Incomplete_Class_Name"]=> string(22) "autoload_not_available" } -===DONE=== diff --git a/ext/standard/tests/serialize/006.phpt b/ext/standard/tests/serialize/006.phpt index 6ba93f4d23..24b3cbbe2d 100644 --- a/ext/standard/tests/serialize/006.phpt +++ b/ext/standard/tests/serialize/006.phpt @@ -2,19 +2,19 @@ serialize()/unserialize() with exotic letters --FILE-- <?php - $åäöÅÄÖ = array('åäöÅÄÖ' => 'åäöÅÄÖ'); + $åäöÅÄÖ = array('åäöÅÄÖ' => 'åäöÅÄÖ'); - class ÜberKööliäå - { - public $åäöÅÄÖüÜber = 'åäöÅÄÖ'; - } + class ÜberKööliäå + { + public $åäöÅÄÖüÜber = 'åäöÅÄÖ'; + } $foo = new Überkööliäå(); - var_dump(serialize($foo)); - var_dump(unserialize(serialize($foo))); - var_dump(serialize($åäöÅÄÖ)); - var_dump(unserialize(serialize($åäöÅÄÖ))); + var_dump(serialize($foo)); + var_dump(unserialize(serialize($foo))); + var_dump(serialize($åäöÅÄÖ)); + var_dump(unserialize(serialize($åäöÅÄÖ))); ?> --EXPECT-- string(55) "O:11:"ÜberKööliäå":1:{s:11:"åäöÅÄÖüÜber";s:6:"åäöÅÄÖ";}" diff --git a/ext/standard/tests/serialize/autoload_implements.inc b/ext/standard/tests/serialize/autoload_implements.inc index 55fcc3cd9f..e5f19c0680 100644 --- a/ext/standard/tests/serialize/autoload_implements.inc +++ b/ext/standard/tests/serialize/autoload_implements.inc @@ -1,10 +1,10 @@ <?php class autoload_implements implements autoload_interface { - function testFunction() - { - return true; - } + function testFunction() + { + return true; + } } ?> diff --git a/ext/standard/tests/serialize/autoload_interface.inc b/ext/standard/tests/serialize/autoload_interface.inc index e6a416e721..6e696f36bf 100644 --- a/ext/standard/tests/serialize/autoload_interface.inc +++ b/ext/standard/tests/serialize/autoload_interface.inc @@ -1,7 +1,7 @@ <?php interface autoload_interface { - function testFunction(); + function testFunction(); } ?> diff --git a/ext/standard/tests/serialize/bug14293.phpt b/ext/standard/tests/serialize/bug14293.phpt index 73636ba56d..875f8b2bc8 100644 --- a/ext/standard/tests/serialize/bug14293.phpt +++ b/ext/standard/tests/serialize/bug14293.phpt @@ -4,16 +4,16 @@ Bug #14293 (serialize() and __sleep()) <?php class t { - function __construct() - { - $this->a = 'hello'; - } + function __construct() + { + $this->a = 'hello'; + } - function __sleep() - { - echo "__sleep called\n"; - return array('a','b'); - } + function __sleep() + { + echo "__sleep called\n"; + return array('a','b'); + } } $t = new t(); diff --git a/ext/standard/tests/serialize/bug21957.phpt b/ext/standard/tests/serialize/bug21957.phpt index 070eda3f4c..9d761a6699 100644 --- a/ext/standard/tests/serialize/bug21957.phpt +++ b/ext/standard/tests/serialize/bug21957.phpt @@ -4,18 +4,18 @@ Bug #21957 (serialize() mangles objects with __sleep) <?php class test { - public $a, $b; + public $a, $b; - function __construct() - { - $this->a = 7; - $this->b = 2; - } + function __construct() + { + $this->a = 7; + $this->b = 2; + } - function __sleep() - { - $this->b = 0; - } + function __sleep() + { + $this->b = 0; + } } $t['one'] = 'ABC'; diff --git a/ext/standard/tests/serialize/bug23298.phpt b/ext/standard/tests/serialize/bug23298.phpt index fe56fccc45..29d09d18e9 100644 --- a/ext/standard/tests/serialize/bug23298.phpt +++ b/ext/standard/tests/serialize/bug23298.phpt @@ -4,10 +4,10 @@ Bug #23298 (serialize() and floats/doubles) serialize_precision=100 --FILE-- <?php - ini_set('precision', 12); - $foo = 1.428571428571428647642857142; - $bar = unserialize(serialize($foo)); - var_dump(($foo === $bar)); + ini_set('precision', 12); + $foo = 1.428571428571428647642857142; + $bar = unserialize(serialize($foo)); + var_dump(($foo === $bar)); ?> --EXPECT-- bool(true) diff --git a/ext/standard/tests/serialize/bug24063.phpt b/ext/standard/tests/serialize/bug24063.phpt index 38c9d6ed24..e3102245f8 100644 --- a/ext/standard/tests/serialize/bug24063.phpt +++ b/ext/standard/tests/serialize/bug24063.phpt @@ -7,8 +7,8 @@ precision=12 <?php $v = 1; for ($i = 1; $i < 10; $i++) { - $v /= 10; - echo "{$v} ".unserialize(serialize($v))."\n"; + $v /= 10; + echo "{$v} ".unserialize(serialize($v))."\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/serialize/bug25378.phpt b/ext/standard/tests/serialize/bug25378.phpt index 70bfbb46a3..ab8cd987e5 100644 --- a/ext/standard/tests/serialize/bug25378.phpt +++ b/ext/standard/tests/serialize/bug25378.phpt @@ -16,7 +16,6 @@ var_dump(unserialize("s:3000:\"123")); var_dump(unserialize("s:3:\"123;")); var_dump(unserialize("s:0:\"123\";")); ?> -===DONE=== --EXPECTF-- Notice: unserialize(): Error at offset 0 of 8 bytes in %sbug25378.php on line %d bool(false) @@ -56,4 +55,3 @@ bool(false) Notice: unserialize(): Error at offset 5 of 10 bytes in %sbug25378.php on line %d bool(false) -===DONE=== diff --git a/ext/standard/tests/serialize/bug26762.phpt b/ext/standard/tests/serialize/bug26762.phpt index ad6c0e0b41..d4daf34464 100644 --- a/ext/standard/tests/serialize/bug26762.phpt +++ b/ext/standard/tests/serialize/bug26762.phpt @@ -10,15 +10,15 @@ Bug #26762 (unserialize() produces lowercase classnames) ini_set('unserialize_callback_func','check'); function check($name) { - var_dump($name); - throw new exception; + var_dump($name); + throw new exception; } try { - @unserialize('O:3:"FOO":0:{}'); + @unserialize('O:3:"FOO":0:{}'); } catch (Exception $e) { - /* ignore */ + /* ignore */ } ?> diff --git a/ext/standard/tests/serialize/bug28325.phpt b/ext/standard/tests/serialize/bug28325.phpt index ee0e60e1ad..cd909dc07d 100644 --- a/ext/standard/tests/serialize/bug28325.phpt +++ b/ext/standard/tests/serialize/bug28325.phpt @@ -3,13 +3,13 @@ Bug #28325 (Problem in serialisation of circular references) --FILE-- <?php class a { - public $b; + public $b; } class b { - public $c; + public $c; } class c { - public $d; + public $d; } $a = new a(); $a->b = new b(); diff --git a/ext/standard/tests/serialize/bug30234.phpt b/ext/standard/tests/serialize/bug30234.phpt index 41ef9dd565..66e5aa3547 100644 --- a/ext/standard/tests/serialize/bug30234.phpt +++ b/ext/standard/tests/serialize/bug30234.phpt @@ -8,8 +8,8 @@ Bug #30234 (__autoload() not invoked for interfaces) <?php spl_autoload_register(function ($class_name) { - require_once(__DIR__ . '/' . strtolower($class_name) . '.inc'); - echo __FUNCTION__ . '(' . $class_name . ")\n"; + require_once(__DIR__ . '/' . strtolower($class_name) . '.inc'); + echo __FUNCTION__ . '(' . $class_name . ")\n"; }); var_dump(interface_exists('autoload_interface', false)); @@ -25,7 +25,6 @@ var_dump(interface_exists('autoload_interface', false)); var_dump(class_exists('autoload_implements', false)); ?> -===DONE=== --EXPECTF-- bool(false) bool(false) @@ -36,4 +35,3 @@ object(autoload_implements)#%d (0) { bool(true) bool(true) bool(true) -===DONE=== diff --git a/ext/standard/tests/serialize/bug31402.phpt b/ext/standard/tests/serialize/bug31402.phpt index 566e959554..66ade571fc 100644 --- a/ext/standard/tests/serialize/bug31402.phpt +++ b/ext/standard/tests/serialize/bug31402.phpt @@ -33,7 +33,6 @@ $after = unserialize($ser); var_dump($before, $after); ?> -===DONE=== --EXPECTF-- object(TestY)#%d (2) { ["A"]=> @@ -85,4 +84,3 @@ object(TestY)#%d (2) { int(1) } } -===DONE=== diff --git a/ext/standard/tests/serialize/bug49649.phpt b/ext/standard/tests/serialize/bug49649.phpt index d6acb80764..455c1e17d4 100644 --- a/ext/standard/tests/serialize/bug49649.phpt +++ b/ext/standard/tests/serialize/bug49649.phpt @@ -23,11 +23,11 @@ $serialized = 'TzozOiJGb28iOjQ6e3M6MTI6IgBGb28AcHJpdmF0ZSI7aToxO3M6MTI6IgAqAHByb class Foo { - public $public = null; + public $public = null; - public $protected = null; + public $protected = null; - public $private = null; + public $private = null; } $class = unserialize(base64_decode($serialized)); diff --git a/ext/standard/tests/serialize/bug49649_1.phpt b/ext/standard/tests/serialize/bug49649_1.phpt index fb6d6dba52..a2f5427edd 100644 --- a/ext/standard/tests/serialize/bug49649_1.phpt +++ b/ext/standard/tests/serialize/bug49649_1.phpt @@ -23,11 +23,11 @@ $serialized = 'TzozOiJGb28iOjQ6e3M6MTI6IgBGb28AcHJpdmF0ZSI7aToxO3M6MTI6IgAqAHByb class Foo { - protected $public = null; + protected $public = null; - protected $protected = null; + protected $protected = null; - protected $private = null; + protected $private = null; } $class = unserialize(base64_decode($serialized)); diff --git a/ext/standard/tests/serialize/bug49649_2.phpt b/ext/standard/tests/serialize/bug49649_2.phpt index fe5b43a6ad..18796b21f7 100644 --- a/ext/standard/tests/serialize/bug49649_2.phpt +++ b/ext/standard/tests/serialize/bug49649_2.phpt @@ -23,11 +23,11 @@ $serialized = 'TzozOiJGb28iOjQ6e3M6MTI6IgBGb28AcHJpdmF0ZSI7aToxO3M6MTI6IgAqAHByb class Foo { - private $public = null; + private $public = null; - private $protected = null; + private $protected = null; - private $private = null; + private $private = null; } $class = unserialize(base64_decode($serialized)); diff --git a/ext/standard/tests/serialize/bug65481.phpt b/ext/standard/tests/serialize/bug65481.phpt index 65634f63ba..ece721b6fe 100644 --- a/ext/standard/tests/serialize/bug65481.phpt +++ b/ext/standard/tests/serialize/bug65481.phpt @@ -5,29 +5,29 @@ Bug #65481 (shutdown segfault due to serialize) echo "Test\n"; class A { - public $e = array(); + public $e = array(); } class Token implements \Serializable { - public function serialize() - { - $c = new A; + public function serialize() + { + $c = new A; - for ($i = 0; $i < 4; $i++) - { - $e = new A; - $c->e[] = $e; - $e->e = $c->e; - } + for ($i = 0; $i < 4; $i++) + { + $e = new A; + $c->e[] = $e; + $e->e = $c->e; + } - return serialize(array(serialize($c))); - } + return serialize(array(serialize($c))); + } - public function unserialize($str) - { - $r = unserialize($str); - $r = unserialize($r[0]); - } + public function unserialize($str) + { + $r = unserialize($str); + $r = unserialize($r[0]); + } } $token = new Token; diff --git a/ext/standard/tests/serialize/bug65806.phpt b/ext/standard/tests/serialize/bug65806.phpt index cefb923f23..166b694442 100644 --- a/ext/standard/tests/serialize/bug65806.phpt +++ b/ext/standard/tests/serialize/bug65806.phpt @@ -33,8 +33,8 @@ class myList { } public function __wakeup() { - $this->_obj = unserialize($this->_serialized); - } + $this->_obj = unserialize($this->_serialized); + } } echo "SCRIPT START" . PHP_EOL; diff --git a/ext/standard/tests/serialize/bug67072.phpt b/ext/standard/tests/serialize/bug67072.phpt index 951db75a07..df0593180d 100644 --- a/ext/standard/tests/serialize/bug67072.phpt +++ b/ext/standard/tests/serialize/bug67072.phpt @@ -2,7 +2,7 @@ Bug #67072 Echoing unserialized "SplFileObject" crash --FILE-- <?php - echo unserialize('O:13:"SplFileObject":1:{s:9:"*filename";s:15:"/home/flag/flag";}'); + echo unserialize('O:13:"SplFileObject":1:{s:9:"*filename";s:15:"/home/flag/flag";}'); ?> ===DONE== --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug68044.phpt b/ext/standard/tests/serialize/bug68044.phpt index 01ada07ad8..dc6053c501 100644 --- a/ext/standard/tests/serialize/bug68044.phpt +++ b/ext/standard/tests/serialize/bug68044.phpt @@ -2,7 +2,7 @@ Bug #68044 Integer overflow in unserialize() (32-bits only) --FILE-- <?php - echo unserialize('C:3:"XYZ":18446744075857035259:{}'); + echo unserialize('C:3:"XYZ":18446744075857035259:{}'); ?> ===DONE== --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug68545.phpt b/ext/standard/tests/serialize/bug68545.phpt index c33155d269..9c37ab7c4f 100644 --- a/ext/standard/tests/serialize/bug68545.phpt +++ b/ext/standard/tests/serialize/bug68545.phpt @@ -4,8 +4,6 @@ Bug #68545 NULL pointer dereference in unserialize.c:var_push_dtor <?php var_dump(unserialize('a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"b22";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";s:3:"bar";')); ?> -===DONE=== --EXPECTF-- Notice: unserialize(): Error at offset %d of %d bytes in %sbug68545.php on line %d bool(false) -===DONE=== diff --git a/ext/standard/tests/serialize/bug68594.phpt b/ext/standard/tests/serialize/bug68594.phpt index fbf9310d0b..69ff9e2bf4 100644 --- a/ext/standard/tests/serialize/bug68594.phpt +++ b/ext/standard/tests/serialize/bug68594.phpt @@ -3,19 +3,19 @@ Bug #68545 Use after free vulnerability in unserialize() --FILE-- <?php for ($i=4; $i<100; $i++) { - $m = new StdClass(); + $m = new StdClass(); - $u = array(1); + $u = array(1); - $m->aaa = array(1,2,&$u,4,5); - $m->bbb = 1; - $m->ccc = &$u; - $m->ddd = str_repeat("A", $i); + $m->aaa = array(1,2,&$u,4,5); + $m->bbb = 1; + $m->ccc = &$u; + $m->ddd = str_repeat("A", $i); - $z = serialize($m); - $z = str_replace("bbb", "aaa", $z); - $y = unserialize($z); - $z = serialize($y); + $z = serialize($m); + $z = str_replace("bbb", "aaa", $z); + $y = unserialize($z); + $z = serialize($y); } ?> ===DONE=== diff --git a/ext/standard/tests/serialize/bug68976.phpt b/ext/standard/tests/serialize/bug68976.phpt index 4e61e65354..514bd8b453 100644 --- a/ext/standard/tests/serialize/bug68976.phpt +++ b/ext/standard/tests/serialize/bug68976.phpt @@ -3,10 +3,10 @@ Bug #68976 Use After Free Vulnerability in unserialize() --FILE-- <?php class evilClass { - public $name; - function __wakeup() { - unset($this->name); - } + public $name; + function __wakeup() { + unset($this->name); + } } $fakezval = pack( @@ -25,7 +25,6 @@ for($i = 0; $i < 5; $i++) { var_dump($data); ?> -===DONE=== --EXPECT-- array(2) { [0]=> @@ -34,4 +33,3 @@ array(2) { [1]=> int(1) } -===DONE=== diff --git a/ext/standard/tests/serialize/bug69152.phpt b/ext/standard/tests/serialize/bug69152.phpt index c4dbcd6926..b11591ffc2 100644 --- a/ext/standard/tests/serialize/bug69152.phpt +++ b/ext/standard/tests/serialize/bug69152.phpt @@ -9,8 +9,6 @@ $x->test(); ?> --EXPECTF-- -Exception in %s:%d -Stack trace: -#0 {main} - -Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "unknown" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d +Fatal error: Uncaught TypeError: Trace is not an array in %s:%d +%a + thrown in %s on line %d diff --git a/ext/standard/tests/serialize/bug69210.phpt b/ext/standard/tests/serialize/bug69210.phpt index c06fe50e02..610c88f879 100644 --- a/ext/standard/tests/serialize/bug69210.phpt +++ b/ext/standard/tests/serialize/bug69210.phpt @@ -4,22 +4,22 @@ serialize() integrity with non string on __sleep <?php class testString { - public $a = true; + public $a = true; - public function __sleep() - { - return array('a', '1'); - } + public function __sleep() + { + return array('a', '1'); + } } class testInteger { - public $a = true; + public $a = true; - public function __sleep() - { - return array('a', 1); - } + public function __sleep() + { + return array('a', 1); + } } $cs = new testString(); diff --git a/ext/standard/tests/serialize/bug69425.phpt b/ext/standard/tests/serialize/bug69425.phpt index c7f4265789..e080fda7dd 100644 --- a/ext/standard/tests/serialize/bug69425.phpt +++ b/ext/standard/tests/serialize/bug69425.phpt @@ -6,12 +6,12 @@ Bug #69425: Use After Free in unserialize() // POC 1 class test { - var $ryat; + var $ryat; - function __wakeup() - { - $this->ryat = 1; - } + function __wakeup() + { + $this->ryat = 1; + } } $data = unserialize('a:2:{i:0;O:4:"test":1:{s:4:"ryat";R:1;}i:1;i:2;}'); diff --git a/ext/standard/tests/serialize/bug69793.phpt b/ext/standard/tests/serialize/bug69793.phpt index 8426c1573e..b2d9fbb256 100644 --- a/ext/standard/tests/serialize/bug69793.phpt +++ b/ext/standard/tests/serialize/bug69793.phpt @@ -7,11 +7,11 @@ $e = unserialize('O:9:"Exception":7:{s:17:"'."\0".'Exception'."\0".'string";s:1: var_dump($e.""); ?> --EXPECTF-- -Notice: Undefined property: Exception::$file in %s%ebug69793.php on line %d +Warning: Undefined property: Exception::$file in %s on line %d -Notice: Undefined property: Exception::$previous in %s%ebug69793.php on line %d +Warning: Undefined property: Exception::$previous in %s on line %d -Notice: Undefined property: Exception::$previous in %s%ebug69793.php on line %d +Warning: Undefined property: Exception::$previous in %s on line %d string(41) "Exception in :1337 Stack trace: #0 {main}" diff --git a/ext/standard/tests/serialize/bug70172.phpt b/ext/standard/tests/serialize/bug70172.phpt index a2359d6434..18bc2fe85d 100644 --- a/ext/standard/tests/serialize/bug70172.phpt +++ b/ext/standard/tests/serialize/bug70172.phpt @@ -3,13 +3,13 @@ Bug #70172 - Use After Free Vulnerability in unserialize() --FILE-- <?php class obj implements Serializable { - var $data; - function serialize() { - return serialize($this->data); - } - function unserialize($data) { - $this->data = unserialize($data); - } + var $data; + function serialize() { + return serialize($this->data); + } + function unserialize($data) { + $this->data = unserialize($data); + } } $fakezval = ptr2str(1122334455); @@ -25,19 +25,19 @@ $exploit = 'a:2:{i:0;i:1;i:1;C:3:"obj":'.strlen($inner).':{'.$inner.'}}'; $data = unserialize($exploit); for ($i = 0; $i < 5; $i++) { - $v[$i] = $fakezval.$i; + $v[$i] = $fakezval.$i; } var_dump($data); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug70172_2.phpt b/ext/standard/tests/serialize/bug70172_2.phpt index 2b12a78edb..771f9ba1d7 100644 --- a/ext/standard/tests/serialize/bug70172_2.phpt +++ b/ext/standard/tests/serialize/bug70172_2.phpt @@ -3,20 +3,20 @@ Bug #70172 - Use After Free Vulnerability in unserialize() --FILE-- <?php class obj implements Serializable { - var $data; - function serialize() { - return serialize($this->data); - } - function unserialize($data) { - $this->data = unserialize($data); - } + var $data; + function serialize() { + return serialize($this->data); + } + function unserialize($data) { + $this->data = unserialize($data); + } } class obj2 { - var $ryat; - function __wakeup() { - $this->ryat = 1; - } + var $ryat; + function __wakeup() { + $this->ryat = 1; + } } $fakezval = ptr2str(1122334455); @@ -32,19 +32,19 @@ $exploit = 'a:2:{i:0;O:4:"obj2":1:{s:4:"ryat";C:3:"obj":'.strlen($inner).':{'.$i $data = unserialize($exploit); for ($i = 0; $i < 5; $i++) { - $v[$i] = $fakezval.$i; + $v[$i] = $fakezval.$i; } var_dump($data); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug70213.phpt b/ext/standard/tests/serialize/bug70213.phpt index fd7d4001f8..7129fe45f6 100644 --- a/ext/standard/tests/serialize/bug70213.phpt +++ b/ext/standard/tests/serialize/bug70213.phpt @@ -6,7 +6,7 @@ Bug #70213: Unserialize context shared on double class lookup ini_set('unserialize_callback_func', 'evil'); function evil() { - spl_autoload_register(function ($arg) { + spl_autoload_register(function ($arg) { var_dump(unserialize('R:1;')); }); } diff --git a/ext/standard/tests/serialize/bug70436.phpt b/ext/standard/tests/serialize/bug70436.phpt index 1bbf3b98ab..9cd97a689c 100644 --- a/ext/standard/tests/serialize/bug70436.phpt +++ b/ext/standard/tests/serialize/bug70436.phpt @@ -5,17 +5,17 @@ Bug #70436: Use After Free Vulnerability in unserialize() class obj implements Serializable { - var $data; + var $data; - function serialize() - { - return serialize($this->data); - } + function serialize() + { + return serialize($this->data); + } - function unserialize($data) - { - $this->data = unserialize($data); - } + function unserialize($data) + { + $this->data = unserialize($data); + } } $fakezval = ptr2str(1122334455); @@ -34,14 +34,14 @@ var_dump($data); function ptr2str($ptr) { - $out = ''; + $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } - return $out; + return $out; } ?> DONE diff --git a/ext/standard/tests/serialize/bug70513.phpt b/ext/standard/tests/serialize/bug70513.phpt index cbdbdb8222..4f228b5b7b 100644 --- a/ext/standard/tests/serialize/bug70513.phpt +++ b/ext/standard/tests/serialize/bug70513.phpt @@ -7,12 +7,12 @@ Bug #70513: GMP Deserialization Type Confusion Vulnerability class obj { - var $ryat; + var $ryat; - function __wakeup() - { - $this->ryat = 1; - } + function __wakeup() + { + $this->ryat = 1; + } } $obj = new stdClass; diff --git a/ext/standard/tests/serialize/bug71995.phpt b/ext/standard/tests/serialize/bug71995.phpt index 0f7ac98722..f1c45d25cc 100644 --- a/ext/standard/tests/serialize/bug71995.phpt +++ b/ext/standard/tests/serialize/bug71995.phpt @@ -4,13 +4,13 @@ Bug #71995 (Returning the same var twice from __sleep() produces broken serializ <?php class A { - public $b; - public function __construct() { - $this->b = new StdClass(); - } - public function __sleep() { - return array("b", "b"); - } + public $b; + public function __construct() { + $this->b = new StdClass(); + } + public function __sleep() { + return array("b", "b"); + } } $a = new A(); $s = serialize($a); diff --git a/ext/standard/tests/serialize/bug72731.phpt b/ext/standard/tests/serialize/bug72731.phpt index 020fb3281f..9489928cfb 100644 --- a/ext/standard/tests/serialize/bug72731.phpt +++ b/ext/standard/tests/serialize/bug72731.phpt @@ -4,10 +4,10 @@ Bug #72731: Type Confusion in Object Deserialization <?php class obj { - var $ryat; - function __wakeup() { - $this->ryat = 0x1122334455; - } + var $ryat; + function __wakeup() { + $this->ryat = 0x1122334455; + } } $poc = 'O:8:"stdClass":1:{i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}'; diff --git a/ext/standard/tests/serialize/bug73341.phpt b/ext/standard/tests/serialize/bug73341.phpt index 86fd457c60..2f38949c1a 100644 --- a/ext/standard/tests/serialize/bug73341.phpt +++ b/ext/standard/tests/serialize/bug73341.phpt @@ -6,7 +6,7 @@ try { $token = 'a:2:{i:0;O:1:"0":2:0s:1:"0";i:0;s:1:"0";a:1:{i:0;C:11:"ArrayObject":7:{x:i:0;r}'; $obj = unserialize($token); } catch(Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } try { @@ -14,7 +14,7 @@ $inner = 'x:i:1;O:8:"stdClass":1:{};m:a:0:{}'; $exploit = 'C:11:"ArrayObject":'.strlen($inner).':{'.$inner.'}'; unserialize($exploit); } catch(Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug74300.phpt b/ext/standard/tests/serialize/bug74300.phpt index d9adda256b..53c6e9a01f 100644 --- a/ext/standard/tests/serialize/bug74300.phpt +++ b/ext/standard/tests/serialize/bug74300.phpt @@ -7,10 +7,8 @@ serialize_precision=10 var_dump(unserialize('d:2e+2;')); var_dump(unserialize('d:2e++2;')); ?> -===DONE=== --EXPECTF-- float(200) Notice: unserialize(): Error at offset 0 of 8 bytes in %s on line %d bool(false) -===DONE=== diff --git a/ext/standard/tests/serialize/bug76300.phpt b/ext/standard/tests/serialize/bug76300.phpt index 13e50f0332..156c31a909 100644 --- a/ext/standard/tests/serialize/bug76300.phpt +++ b/ext/standard/tests/serialize/bug76300.phpt @@ -3,19 +3,19 @@ Bug #76300: Unserialize of extended protected member broken --FILE-- <?php class Base { - private $id; - public function __construct($id) - { - $this->id = $id; - } + private $id; + public function __construct($id) + { + $this->id = $id; + } } class Derived extends Base { - protected $id; - public function __construct($id) - { - parent::__construct($id + 20); - $this->id = $id; - } + protected $id; + public function __construct($id) + { + parent::__construct($id + 20); + $this->id = $id; + } } $a = new Derived(44); $s = serialize($a); diff --git a/ext/standard/tests/serialize/max_depth.phpt b/ext/standard/tests/serialize/max_depth.phpt index f20d9a7ccd..5e1c869b1d 100644 --- a/ext/standard/tests/serialize/max_depth.phpt +++ b/ext/standard/tests/serialize/max_depth.phpt @@ -8,8 +8,17 @@ function create_nested_data($depth, $prefix, $suffix, $inner = 'i:0;') { } echo "Invalid max_depth:\n"; -var_dump(unserialize('i:0;', ['max_depth' => 'foo'])); -var_dump(unserialize('i:0;', ['max_depth' => -1])); +try { + unserialize('i:0;', ['max_depth' => 'foo']); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + unserialize('i:0;', ['max_depth' => -1]); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Array:\n"; var_dump(unserialize( @@ -59,7 +68,7 @@ class Test implements Serializable { public function unserialize($str) { // Should fail, due to combined nesting level var_dump(unserialize(create_nested_data(129, 'a:1:{i:0;', '}'))); - // Should succeeed, below combined nesting level + // Should succeed, below combined nesting level var_dump(unserialize(create_nested_data(128, 'a:1:{i:0;', '}')) !== false); } } @@ -95,12 +104,8 @@ var_dump(is_array(unserialize( ?> --EXPECTF-- Invalid max_depth: - -Warning: unserialize(): max_depth should be int in %s on line %d -bool(false) - -Warning: unserialize(): max_depth cannot be negative in %s on line %d -bool(false) +max_depth should be int +max_depth cannot be negative Array: bool(true) diff --git a/ext/standard/tests/serialize/precision.phpt b/ext/standard/tests/serialize/precision.phpt index 229c514e69..ec6d8e3408 100644 --- a/ext/standard/tests/serialize/precision.phpt +++ b/ext/standard/tests/serialize/precision.phpt @@ -8,30 +8,30 @@ if (pack('s', 1) != "\x01\x00") <?php $numbers = array( - "0000000000000000", //0 - "2d431cebe2362a3f", //.0002 - "2e431cebe2362a3f", //.0002 + 10^-Accuracy[.0002]*1.01 - "0000000000001000", //2^-1022. (minimum normal double) - "0100000000001000", //2^-1022. + 10^-Accuracy[2^-1022.]*1.01 - "ffffffffffffef7f", //2^1024. (maximum normal double) - "feffffffffffef7f", //2^1024. - 10^-Accuracy[2^1024.] - "0100000000000000", //minimum subnormal double - "0200000000000000", //2nd minimum subnormal double - "fffffffffffff000", //maximum subnormal double - "fefffffffffff000", //2nd maximum subnormal double - "0000000000000f7f", //+inf - "0000000000000fff", //-inf + "0000000000000000", //0 + "2d431cebe2362a3f", //.0002 + "2e431cebe2362a3f", //.0002 + 10^-Accuracy[.0002]*1.01 + "0000000000001000", //2^-1022. (minimum normal double) + "0100000000001000", //2^-1022. + 10^-Accuracy[2^-1022.]*1.01 + "ffffffffffffef7f", //2^1024. (maximum normal double) + "feffffffffffef7f", //2^1024. - 10^-Accuracy[2^1024.] + "0100000000000000", //minimum subnormal double + "0200000000000000", //2nd minimum subnormal double + "fffffffffffff000", //maximum subnormal double + "fefffffffffff000", //2nd maximum subnormal double + "0000000000000f7f", //+inf + "0000000000000fff", //-inf ); foreach ($numbers as $ns) { - $num = unpack("d", pack("H*", $ns)); $num = reset($num); - echo "number: ", sprintf("%.17e", $num), "... "; - $num2 = unserialize(serialize($num)); - $repr = unpack("H*", pack("d", $num2)); $repr = reset($repr); - if ($repr == $ns) - echo "OK\n"; - else - echo "mismatch\n\twas: $ns\n\tbecame: $repr\n"; + $num = unpack("d", pack("H*", $ns)); $num = reset($num); + echo "number: ", sprintf("%.17e", $num), "... "; + $num2 = unserialize(serialize($num)); + $repr = unpack("H*", pack("d", $num2)); $repr = reset($repr); + if ($repr == $ns) + echo "OK\n"; + else + echo "mismatch\n\twas: $ns\n\tbecame: $repr\n"; } --EXPECT-- number: 0.00000000000000000e+0... OK diff --git a/ext/standard/tests/serialize/serialization_arrays_002.phpt b/ext/standard/tests/serialize/serialization_arrays_002.phpt index 39212b6455..67ad5b5daa 100644 --- a/ext/standard/tests/serialize/serialization_arrays_002.phpt +++ b/ext/standard/tests/serialize/serialization_arrays_002.phpt @@ -1,5 +1,5 @@ --TEST-- -serialization: arrays with references amonst elements +serialization: arrays with references amongst elements --FILE-- <?php /* Prototype : proto string serialize(mixed variable) @@ -14,18 +14,18 @@ serialization: arrays with references amonst elements */ function check(&$a) { - var_dump($a); - $ser = serialize($a); - var_dump($ser); + var_dump($a); + $ser = serialize($a); + var_dump($ser); - $b = unserialize($ser); - var_dump($b); - $b[0] = "b0.changed"; - var_dump($b); - $b[1] = "b1.changed"; - var_dump($b); - $b[2] = "b2.changed"; - var_dump($b); + $b = unserialize($ser); + var_dump($b); + $b[0] = "b0.changed"; + var_dump($b); + $b[1] = "b1.changed"; + var_dump($b); + $b[2] = "b2.changed"; + var_dump($b); } echo "\n\n--- No references:\n"; diff --git a/ext/standard/tests/serialize/serialization_arrays_003.phpt b/ext/standard/tests/serialize/serialization_arrays_003.phpt index 18238d7b1e..8444f812a5 100644 --- a/ext/standard/tests/serialize/serialization_arrays_003.phpt +++ b/ext/standard/tests/serialize/serialization_arrays_003.phpt @@ -14,18 +14,18 @@ serialization: arrays with references to an external variable */ function check(&$a) { - var_dump($a); - $ser = serialize($a); - var_dump($ser); + var_dump($a); + $ser = serialize($a); + var_dump($ser); - $b = unserialize($ser); - var_dump($b); - $b[0] = "b0.changed"; - var_dump($b); - $b[1] = "b1.changed"; - var_dump($b); - $b[2] = "b2.changed"; - var_dump($b); + $b = unserialize($ser); + var_dump($b); + $b[0] = "b0.changed"; + var_dump($b); + $b[1] = "b1.changed"; + var_dump($b); + $b[2] = "b2.changed"; + var_dump($b); } echo "\n\n--- 0 refs external:\n"; diff --git a/ext/standard/tests/serialize/serialization_arrays_004.phpt b/ext/standard/tests/serialize/serialization_arrays_004.phpt index a6209688ea..b3d630ecf4 100644 --- a/ext/standard/tests/serialize/serialization_arrays_004.phpt +++ b/ext/standard/tests/serialize/serialization_arrays_004.phpt @@ -14,18 +14,18 @@ serialization: arrays with references to the containing array */ function check(&$a) { - var_dump($a); - $ser = serialize($a); - var_dump($ser); + var_dump($a); + $ser = serialize($a); + var_dump($ser); - $b = unserialize($ser); - var_dump($b); - $b[0] = "b0.changed"; - var_dump($b); - $b[1] = "b1.changed"; - var_dump($b); - $b[2] = "b2.changed"; - var_dump($b); + $b = unserialize($ser); + var_dump($b); + $b[0] = "b0.changed"; + var_dump($b); + $b[1] = "b1.changed"; + var_dump($b); + $b[2] = "b2.changed"; + var_dump($b); } echo "\n\n--- 1 refs container:\n"; @@ -55,14 +55,7 @@ echo "Done"; --- 1 refs container: array(3) { [0]=> - &array(3) { - [0]=> - *RECURSION* - [1]=> - int(1) - [2]=> - int(1) - } + *RECURSION* [1]=> int(1) [2]=> @@ -113,23 +106,9 @@ array(3) { --- 1,2 ref container: array(3) { [0]=> - &array(3) { - [0]=> - *RECURSION* - [1]=> - *RECURSION* - [2]=> - int(1) - } + *RECURSION* [1]=> - &array(3) { - [0]=> - *RECURSION* - [1]=> - *RECURSION* - [2]=> - int(1) - } + *RECURSION* [2]=> int(1) } @@ -185,32 +164,11 @@ array(3) { --- 1,2,3 ref container: array(3) { [0]=> - &array(3) { - [0]=> - *RECURSION* - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* [1]=> - &array(3) { - [0]=> - *RECURSION* - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* [2]=> - &array(3) { - [0]=> - *RECURSION* - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* } string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;R:2;i:2;R:2;}i:1;R:2;i:2;R:2;}" array(3) { diff --git a/ext/standard/tests/serialize/serialization_arrays_005.phpt b/ext/standard/tests/serialize/serialization_arrays_005.phpt index 9d3bbcabea..93e3ae5135 100644 --- a/ext/standard/tests/serialize/serialization_arrays_005.phpt +++ b/ext/standard/tests/serialize/serialization_arrays_005.phpt @@ -14,24 +14,24 @@ serialization: arrays with references, nested */ function check(&$a) { - var_dump($a); - $ser = serialize($a); - var_dump($ser); + var_dump($a); + $ser = serialize($a); + var_dump($ser); - $b = unserialize($ser); + $b = unserialize($ser); - // Change each element and dump result. - foreach($b as $k=>$v) { - if (is_array($v)){ - foreach($b[$k] as $sk=>$sv) { - $b[$k][$sk] = "b$k.$sk.changed"; - var_dump($b); - } - } else { - $b[$k] = "b$k.changed"; - var_dump($b); - } - } + // Change each element and dump result. + foreach($b as $k=>$v) { + if (is_array($v)){ + foreach($b[$k] as $sk=>$sv) { + $b[$k][$sk] = "b$k.$sk.changed"; + var_dump($b); + } + } else { + $b[$k] = "b$k.changed"; + var_dump($b); + } + } } echo "\n\n--- Nested array references 1 element in containing array:\n"; @@ -435,14 +435,7 @@ array(3) { [0]=> int(1) [1]=> - &array(3) { - [0]=> - int(1) - [1]=> - int(1) - [2]=> - *RECURSION* - } + *RECURSION* } } string(74) "a:3:{i:0;i:1;i:1;i:1;i:2;a:2:{i:0;i:1;i:1;a:3:{i:0;i:1;i:1;i:1;i:2;R:4;}}}" diff --git a/ext/standard/tests/serialize/serialization_objects_002.phpt b/ext/standard/tests/serialize/serialization_objects_002.phpt Binary files differindex c7f9e1cbd3..920fd35310 100644 --- a/ext/standard/tests/serialize/serialization_objects_002.phpt +++ b/ext/standard/tests/serialize/serialization_objects_002.phpt diff --git a/ext/standard/tests/serialize/serialization_objects_005.phpt b/ext/standard/tests/serialize/serialization_objects_005.phpt index 4c631c6a59..48325f4fba 100644 --- a/ext/standard/tests/serialize/serialization_objects_005.phpt +++ b/ext/standard/tests/serialize/serialization_objects_005.phpt @@ -77,7 +77,7 @@ string(9) "p.changed" bool(false) bool(true) -Notice: Undefined property: C::$x in %s on line 37 +Warning: Undefined property: C::$x in %s on line %d NULL diff --git a/ext/standard/tests/serialize/serialization_objects_007.phpt b/ext/standard/tests/serialize/serialization_objects_007.phpt index ff584a0919..5082b7ff01 100644 --- a/ext/standard/tests/serialize/serialization_objects_007.phpt +++ b/ext/standard/tests/serialize/serialization_objects_007.phpt @@ -14,13 +14,13 @@ Ensure __autoload is called twice if unserialize_callback_func is defined. */ spl_autoload_register(function ($name) { - echo "in autoload($name)\n"; + echo "in autoload($name)\n"; }); ini_set('unserialize_callback_func','check'); function check($name) { - echo "in check($name)\n"; + echo "in check($name)\n"; } $o = unserialize('O:3:"FOO":0:{}'); diff --git a/ext/standard/tests/serialize/serialization_objects_010.phpt b/ext/standard/tests/serialize/serialization_objects_010.phpt index 32205209f7..51938710cd 100644 --- a/ext/standard/tests/serialize/serialization_objects_010.phpt +++ b/ext/standard/tests/serialize/serialization_objects_010.phpt @@ -14,18 +14,18 @@ Serialize() must return a string or NULL */ Class C implements Serializable { - public function serialize() { - return $this; - } + public function serialize() { + return $this; + } - public function unserialize($blah) { - } + public function unserialize($blah) { + } } try { - var_dump(serialize(new C)); + var_dump(serialize(new C)); } catch (Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } echo "Done"; diff --git a/ext/standard/tests/serialize/serialization_objects_011.phpt b/ext/standard/tests/serialize/serialization_objects_011.phpt index a224a13d0c..9f360c2cb9 100644 --- a/ext/standard/tests/serialize/serialization_objects_011.phpt +++ b/ext/standard/tests/serialize/serialization_objects_011.phpt @@ -14,57 +14,57 @@ Object serialization / unserialization with inherited and hidden properties. */ Class A { - private $APriv = "A.APriv"; - protected $AProt = "A.AProt"; - public $APub = "A.APub"; + private $APriv = "A.APriv"; + protected $AProt = "A.AProt"; + public $APub = "A.APub"; - function audit() { - return isset($this->APriv, $this->AProt, $this->APub); - } + function audit() { + return isset($this->APriv, $this->AProt, $this->APub); + } } Class B extends A { - private $BPriv = "B.BPriv"; - protected $BProt = "B.BProt"; - public $BPub = "B.BPub"; - - function audit() { - return parent::audit() && isset($this->AProt, $this->APub, - $this->BPriv, $this->BProt, $this->BPub); - } + private $BPriv = "B.BPriv"; + protected $BProt = "B.BProt"; + public $BPub = "B.BPub"; + + function audit() { + return parent::audit() && isset($this->AProt, $this->APub, + $this->BPriv, $this->BProt, $this->BPub); + } } Class C extends B { - private $APriv = "C.APriv"; - protected $AProt = "C.AProt"; - public $APub = "C.APub"; - - private $CPriv = "C.CPriv"; - protected $CProt = "C.BProt"; - public $CPub = "C.CPub"; - - function audit() { - return parent::audit() && isset($this->APriv, $this->AProt, $this->APub, - $this->BProt, $this->BPub, - $this->CPriv, $this->CProt, $this->CPub); - } + private $APriv = "C.APriv"; + protected $AProt = "C.AProt"; + public $APub = "C.APub"; + + private $CPriv = "C.CPriv"; + protected $CProt = "C.BProt"; + public $CPub = "C.CPub"; + + function audit() { + return parent::audit() && isset($this->APriv, $this->AProt, $this->APub, + $this->BProt, $this->BPub, + $this->CPriv, $this->CProt, $this->CPub); + } } function prettyPrint($obj) { - echo "\n\nBefore serialization:\n"; - var_dump($obj); + echo "\n\nBefore serialization:\n"; + var_dump($obj); - echo "Serialized form:\n"; - $ser = serialize($obj); - $serPrintable = str_replace("\0", '\0', $ser); - var_dump($serPrintable); + echo "Serialized form:\n"; + $ser = serialize($obj); + $serPrintable = str_replace("\0", '\0', $ser); + var_dump($serPrintable); - echo "Unserialized:\n"; - $uobj = unserialize($ser); - var_dump($uobj); + echo "Unserialized:\n"; + $uobj = unserialize($ser); + var_dump($uobj); - echo "Sanity check: "; - var_dump($uobj->audit()); + echo "Sanity check: "; + var_dump($uobj->audit()); } echo "-- Test instance of A --\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_013.phpt b/ext/standard/tests/serialize/serialization_objects_013.phpt index 3ff2d3cc11..547d7f75e8 100644 --- a/ext/standard/tests/serialize/serialization_objects_013.phpt +++ b/ext/standard/tests/serialize/serialization_objects_013.phpt @@ -14,18 +14,18 @@ Object serialization / unserialization: references amongst properties */ function check(&$obj) { - var_dump($obj); - $ser = serialize($obj); - var_dump($ser); + var_dump($obj); + $ser = serialize($obj); + var_dump($ser); - $uobj = unserialize($ser); - var_dump($uobj); - $uobj->a = "obj->a.changed"; - var_dump($uobj); - $uobj->b = "obj->b.changed"; - var_dump($uobj); - $uobj->c = "obj->c.changed"; - var_dump($uobj); + $uobj = unserialize($ser); + var_dump($uobj); + $uobj->a = "obj->a.changed"; + var_dump($uobj); + $uobj->b = "obj->b.changed"; + var_dump($uobj); + $uobj->c = "obj->c.changed"; + var_dump($uobj); } echo "\n\n--- a refs b:\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_014.phpt b/ext/standard/tests/serialize/serialization_objects_014.phpt index fa15a577b0..b8bf6fd3bc 100644 --- a/ext/standard/tests/serialize/serialization_objects_014.phpt +++ b/ext/standard/tests/serialize/serialization_objects_014.phpt @@ -14,18 +14,18 @@ Object serialization / unserialization: references to external values */ function check(&$obj) { - var_dump($obj); - $ser = serialize($obj); - var_dump($ser); + var_dump($obj); + $ser = serialize($obj); + var_dump($ser); - $uobj = unserialize($ser); - var_dump($uobj); - $uobj->a = "obj->a.changed"; - var_dump($uobj); - $uobj->b = "obj->b.changed"; - var_dump($uobj); - $uobj->c = "obj->c.changed"; - var_dump($uobj); + $uobj = unserialize($ser); + var_dump($uobj); + $uobj->a = "obj->a.changed"; + var_dump($uobj); + $uobj->b = "obj->b.changed"; + var_dump($uobj); + $uobj->c = "obj->c.changed"; + var_dump($uobj); } echo "\n\n--- a refs external:\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_015.phpt b/ext/standard/tests/serialize/serialization_objects_015.phpt index c1a6675db4..522450bfc1 100644 --- a/ext/standard/tests/serialize/serialization_objects_015.phpt +++ b/ext/standard/tests/serialize/serialization_objects_015.phpt @@ -4,18 +4,18 @@ Object serialization / unserialization: properties reference containing object <?php function check(&$obj) { - var_dump($obj); - $ser = serialize($obj); - var_dump($ser); + var_dump($obj); + $ser = serialize($obj); + var_dump($ser); - $uobj = unserialize($ser); - var_dump($uobj); - $uobj->a = "obj->a.changed"; - var_dump($uobj); - $uobj->b = "obj->b.changed"; - var_dump($uobj); - $uobj->c = "obj->c.changed"; - var_dump($uobj); + $uobj = unserialize($ser); + var_dump($uobj); + $uobj->a = "obj->a.changed"; + var_dump($uobj); + $uobj->b = "obj->b.changed"; + var_dump($uobj); + $uobj->c = "obj->c.changed"; + var_dump($uobj); } echo "\n\n--- a refs container:\n"; diff --git a/ext/standard/tests/serialize/typed_property_refs.phpt b/ext/standard/tests/serialize/typed_property_refs.phpt index 9475e8a783..3c8096a392 100644 --- a/ext/standard/tests/serialize/typed_property_refs.phpt +++ b/ext/standard/tests/serialize/typed_property_refs.phpt @@ -4,18 +4,18 @@ unserialize with references to typed properties shall skip the references or fai <?php class A { - public int $a; - public $b; + public int $a; + public $b; } class B { - public $a; - public int $b; + public $a; + public int $b; } class C { - public int $a; - public string $b; + public int $a; + public string $b; } class D { @@ -66,8 +66,8 @@ object(B)#1 (2) { ["b"]=> &int(1) } -Typed property A::$a must be int, null used -Typed property B::$b must be int, null used -Typed property C::$b must be string, int used -Typed property C::$a must be int, string used +Cannot assign null to property A::$a of type int +Cannot assign null to property B::$b of type int +Cannot assign int to property C::$b of type string +Cannot assign string to property C::$a of type int Reference with value of type int held by property D::$a of type int is not compatible with property D::$b of type float diff --git a/ext/standard/tests/serialize/unserialize_mem_leak.phpt b/ext/standard/tests/serialize/unserialize_mem_leak.phpt index 2a295d83b9..ad010df535 100644 --- a/ext/standard/tests/serialize/unserialize_mem_leak.phpt +++ b/ext/standard/tests/serialize/unserialize_mem_leak.phpt @@ -5,7 +5,7 @@ report_memleaks=1 --FILE-- <?php function foo() { - gc_collect_cycles(); + gc_collect_cycles(); } $str = 'a:1:{i:0;R:1;}'; |