note 78680 added to ref.session

From: Date: Tue, 23 Oct 2007 07:01:23 +0000
Subject: note 78680 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-131654@lists.php.net to get a copy of this message
The manual states that: "Some types of data can not be serialized [...]. It includes [...] objects with circular references (i.e. objects which passes a reference to itself to another object)." I wrote a PHPUnit Test[1] that proofs the opposite. Is it possible, that the information above is outdated and that circular references can be handled by recent PHP versions? class TestPhpSerializationCircular extends PHPUnit_Framework_TestCase { public function testSerializeCircular() { $a = new SerializableObject; $b = new SerializableObject; $a->ref = $b; $b->ref = $a; $serial = serialize( $a ); $this->assertType( 'string', $serial ); $this->assertTrue( strlen( $serial ) > 10 ); } public function testSerializeCircularPreservesIdentity() { $a = new SerializableObject; $b = new SerializableObject; $a->ref = $b; $b->ref = $a; $serial = serialize( $a ); $after = unserialize( $serial ); $after->ref->ref->property = 'test'; $this->assertSame( $after->property, $after->ref->ref->property ); } } [1] http://tinyurl.com/2ktda7 ---- Server IP: 69.147.83.197 Probable Submitter: 194.231.54.229 ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- https://master.php.net/note/edit/78680 Del: integrated -- https://master.php.net/note/delete/78680/integrated Del: useless -- https://master.php.net/note/delete/78680/useless Del: bad code -- https://master.php.net/note/delete/78680/bad+code Del: spam -- https://master.php.net/note/delete/78680/spam Del: non-english -- https://master.php.net/note/delete/78680/non-english Del: in docs -- https://master.php.net/note/delete/78680/in+docs Del: other reasons-- https://master.php.net/note/delete/78680 Reject -- https://master.php.net/note/reject/78680 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131654) next »