Arquivos
hhvm/hphp/test/slow/serialization/1541.php
T
Paul Tarjan c2ec1c97c9 sortof format slow tests
A poor man's formatter since I didn't like any of the other ones I found. The original C++ source sometimes put newlines and sometimes not.

Codemods:

    codemod '([;{}])([^\n])' '\1\n\2'
    codemod -m '\s*<\?php\s+' '<?php\n\n'
    codemod '\t' '  '

I hand-fixed all the failing tests
2013-05-30 17:32:57 -07:00

54 linhas
945 B
PHP

<?php
class Small {
private static $nc = 0;
public $name;
public $num;
function __construct() {
$n = self::$nc++;
$this->name = 'foo'.$n;
$this->num = 3*$n;
}
}
class Big {
public $groupAll = array();
public $group1 = array();
public $group2 = array();
public $wacky;
public $nothing;
public $unrelated = array();
function add() {
$s = new Small();
$this->groupAll[] = $s;
if ($s->num % 2 == 0) {
$this->group1[]=array($s->name, $s);
}
else {
$this->group2[]=array($s->name, $s);
}
}
function finish() {
$x = 10;
$this->wacky = array(&$x, &$x);
$s = new Small();
$this->unrelated[] = $s;
$this->unrelated[] = $s;
$this->unrelated[] = $s;
}
}
function t() {
$b = new Big;
for ($i = 0;
$i < 10;
++$i) {
$b->add();
}
$b->finish();
var_dump($b);
$s = serialize($b);
var_dump($s);
$us = unserialize($s);
var_dump($us);
}
t();