Skip to content

Instantly share code, notes, and snippets.

@asm89
asm89 / gist:8622724
Created January 25, 2014 20:08
Memory leak in hhvm?
<?php
class Foo
{
private $bar;
public function __construct(Bar $bar)
{
$this->bar = $bar;
}
}
@asm89
asm89 / a.php
Created February 19, 2014 21:40
Generators in HHVM and PHP
<?php
function xs() {
$i = 0;
while (true) {
yield $i++;
}
}
$xs = xs();
<?php
mb_internal_encoding("UTF-8");
function λ($fn) {
list($args, $body) = explode('=>', $fn, 2);
$args = trim($args);
$args = ltrim($args, '(');
$args = rtrim($args, ')');
<?hh
function addOne(int $x): int {
return $x + 1;
}
function main() {
addOne(42);
addOne('foo');
}
FROM ubuntu
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y install wget
RUN wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
RUN echo deb http://dl.hhvm.com/ubuntu trusty main | tee /etc/apt/sources.list.d/hhvm.list
RUN apt-get update
RUN apt-get -y install hhvm
<?hh
function f(?int $x): ?int {
if ($x === null) return $x;
else return $x * 2;
}
function x(): ?int {
return null;
}