xref: /PHP-7.1/Zend/tests/strlen.phpt (revision a79b9333)
1--TEST--
2Fixed execute_data corruption with __toString()
3--FILE--
4<?php
5
6class Test
7{
8  public $something = 'hello';
9
10  public function __toString()
11  {
12    return $this->something;
13  }
14}
15
16$t = new Test;
17var_dump(strlen($t));
18var_dump($t->something);
19
20class Test2
21{
22  public $something;
23
24  public function __construct(&$a)
25  {
26    $this->something = &$a;
27  }
28
29  public function __toString()
30  {
31    return $this->something;
32  }
33}
34
35$a = 'world';
36$t2 = new Test2($a);
37var_dump(strlen($t2));
38var_dump($t2->something);
39var_dump($a);
40
41$a = 'foobar';
42var_dump(strlen($t2));
43var_dump($t2->something);
44--EXPECT--
45int(5)
46string(5) "hello"
47int(5)
48string(5) "world"
49string(5) "world"
50int(6)
51string(6) "foobar"
52