1--TEST-- 2Bug #42772 (Storing $this in a static var fails while handling a cast to string) 3--FILE-- 4<?php 5class Foo { 6 static public $foo; 7 function __toString() { 8 self::$foo = $this; 9 return 'foo'; 10 } 11} 12 13$foo = (string)new Foo(); 14var_dump(Foo::$foo); 15?> 16--EXPECT-- 17object(Foo)#1 (0) { 18} 19