mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
7aacc705d0
Closes GH-5958
53 lines
702 B
PHP
53 lines
702 B
PHP
--TEST--
|
|
Fixed execute_data corruption with __toString()
|
|
--FILE--
|
|
<?php
|
|
|
|
class Test
|
|
{
|
|
public $something = 'hello';
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->something;
|
|
}
|
|
}
|
|
|
|
$t = new Test;
|
|
var_dump(strlen($t));
|
|
var_dump($t->something);
|
|
|
|
class Test2
|
|
{
|
|
public $something;
|
|
|
|
public function __construct(&$a)
|
|
{
|
|
$this->something = &$a;
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->something;
|
|
}
|
|
}
|
|
|
|
$a = 'world';
|
|
$t2 = new Test2($a);
|
|
var_dump(strlen($t2));
|
|
var_dump($t2->something);
|
|
var_dump($a);
|
|
|
|
$a = 'foobar';
|
|
var_dump(strlen($t2));
|
|
var_dump($t2->something);
|
|
?>
|
|
--EXPECT--
|
|
int(5)
|
|
string(5) "hello"
|
|
int(5)
|
|
string(5) "world"
|
|
string(5) "world"
|
|
int(6)
|
|
string(6) "foobar"
|