public function buzz($s = \HACKLIB_UNINIT) { if ($s === \HACKLIB_UNINIT) { $s = \HH\Map::hacklib_new(array('a'), array('z')); } echo join(", ", (array) \hacklib_cast_as_array($s)) . "\n"; }
function test_all_expression_types() { $v = new \HH\Vector(array()); $f = new Foo(); test_cast("clone", (bool) \hacklib_cast_as_boolean(clone $v)); test_cast("obj_get", (bool) \hacklib_cast_as_boolean($f->prop)); test_cast("array_get", (bool) \hacklib_cast_as_boolean(array($v)[0])); test_cast("class_get", (bool) \hacklib_cast_as_boolean(Foo::$s_prop)); test_cast("cast", (bool) \hacklib_cast_as_boolean((object) $v)); test_cast("cast", (bool) (array) \hacklib_cast_as_array($v)); for ($v_in = new \HH\Vector(array(1)), $i = 1; $i > 0, \hacklib_cast_as_boolean($v_in); $i++, $v_in->pop()) { echo "in here at " . $i . "\n"; if ($i > 5) { break; } } test_cast("Eif", (bool) \hacklib_cast_as_boolean(true ? $v : $f)); test_cast("unsafe_expr", (bool) \hacklib_cast_as_boolean($v)); test_cast("call", (bool) \hacklib_cast_as_boolean(Foo::s_func())); test_cast("Collection", (bool) (!\hacklib_id(new \HH\Vector(array()))->isEmpty())); test_cast("New", (bool) new Foo()); test_cast("New", (bool) (!\hacklib_id(new \HH\Vector(array()))->isEmpty())); test_cast("Eq", (bool) ($y = false)); test_cast("Eq", (bool) \hacklib_cast_as_boolean($z = $f->i_func())); echo $z . "\n"; }
function check_array_cast($c) { $arr = (array) \hacklib_cast_as_array($c); echo \hacklib_cast_as_boolean(is_array($arr)) ? "YES\n" : "NO\n"; echo count($arr) . "\n"; }
public function readSetBegin(&$elemType, &$size) { $val = $this->top->current(); $this->top->next(); $itr = null; if ($val instanceof \HH\Map) { $itr = $val->getIterator(); $size = $val->count(); } else { if ($val instanceof \HH\ImmMap) { $itr = $val->getIterator(); $size = $val->count(); } else { if ($val instanceof \HH\Vector) { $itr = $val->getIterator(); $size = $val->count(); } else { if ($val instanceof \HH\ImmVector) { $itr = $val->getIterator(); $size = $val->count(); } else { if ($val instanceof \HH\Set) { $itr = $val->getIterator(); $size = $val->count(); } else { if ($val instanceof \HH\ImmSet) { $itr = $val->getIterator(); $size = $val->count(); } else { if (\hacklib_cast_as_boolean(is_array($val))) { $itr = new ArrayIterator($val); $size = count($val); } else { $val = array_keys((array) \hacklib_cast_as_array($val)); $itr = new ArrayIterator($val); $size = count($val); } } } } } } } $this->stack->add($itr); $this->top = $itr; if (\hacklib_cast_as_boolean($itr->valid())) { $val_sample = $itr->current(); $elemType = $this->guessTypeForValue($val_sample); } }