PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/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
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
  1. <?hh
  2. function mapLookup($map, $key, $default) {
  3. return $map->containsKey($key) ? $map[$key] : $default;
  4. }
  5. final class HTTPHeaders {
  6. private $headers;
  7. public function __construct() {
  8. $this->headers = Map {
  9. 'foo' => 'bar',
  10. 'baz' => 'quux',
  11. }
  12. ;
  13. }
  14. public function getAllHeaders(): Map<string,string> {
  15. return $this->headers;
  16. }
  17. public function getHeader(string $name, ?string $default = null): ?string {
  18. return mapLookup($this->getAllHeaders(), strtolower($name), $default);
  19. }
  20. }
  21. function main() {
  22. $h = new HTTPHeaders();
  23. $val = $h->getHeader('blah', 'wat');
  24. echo $val;
  25. echo "\n";
  26. }
  27. <<__EntryPoint>>
  28. function main_headers() {
  29. main();
  30. }