hiphop-php /hphp/test/slow/ir_inlining/headers.php

Language PHP Lines 34
MD5 Hash 257974abaed2baa33076cc55eff749a0 Estimated Cost $609 (why?)
Repository git://github.com/facebook/hiphop-php.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?hh

function mapLookup($map, $key, $default) {
  return $map->containsKey($key) ? $map[$key] : $default;
}

final class HTTPHeaders {
  private $headers;

  public function __construct() {
    $this->headers = Map {
      'foo' => 'bar',
      'baz' => 'quux',
    }
;
  }

  public function getAllHeaders(): Map<string,string> {
    return $this->headers;
  }

  public function getHeader(string $name, ?string $default = null): ?string {
    return mapLookup($this->getAllHeaders(), strtolower($name), $default);
  }
}

function main() {
  $h = new HTTPHeaders();
  $val = $h->getHeader('blah', 'wat');
  echo $val;
  echo "\n";
}
main();
Back to Top