mirror of
https://github.com/php/php-src.git
synced 2026-04-28 10:43:30 +02:00
902d64390e
Writing to a proprety that hasn't been declared is deprecated, unless the class uses the #[AllowDynamicProperties] attribute or defines __get()/__set(). RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
37 lines
572 B
PHP
37 lines
572 B
PHP
--TEST--
|
|
Bug #14293 (serialize() and __sleep())
|
|
--FILE--
|
|
<?php
|
|
class t
|
|
{
|
|
public $a;
|
|
|
|
function __construct()
|
|
{
|
|
$this->a = 'hello';
|
|
}
|
|
|
|
function __sleep()
|
|
{
|
|
echo "__sleep called\n";
|
|
return array('a','b');
|
|
}
|
|
}
|
|
|
|
$t = new t();
|
|
$data = serialize($t);
|
|
echo "$data\n";
|
|
$t = unserialize($data);
|
|
var_dump($t);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
__sleep called
|
|
|
|
Warning: serialize(): "b" returned as member variable from __sleep() but does not exist in %s on line %d
|
|
O:1:"t":1:{s:1:"a";s:5:"hello";}
|
|
object(t)#%d (1) {
|
|
["a"]=>
|
|
string(5) "hello"
|
|
}
|