/hphp/test/slow/ir_inlining/headers.php
http://github.com/facebook/hiphop-php · PHP · 37 lines · 30 code · 7 blank · 0 comment · 0 complexity · b6bed1846c2163c5941cc630f46a4fee MD5 · raw file
- <?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";
- }
- <<__EntryPoint>>
- function main_headers() {
- main();
- }