/hphp/test/slow/ir_inlining/headers.php
PHP | 37 lines | 30 code | 7 blank | 0 comment | 0 complexity | b6bed1846c2163c5941cc630f46a4fee MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?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();
- }