Check for void/noreturn in conditionals
[hiphop-php.git] / hphp / hack / test / typecheck / storoman2.php
blobf7a6acfa1860b385df8d5a867b7d260c6909c85b
1 <?hh
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
6 * This source code is licensed under the BSD-style license found in the
7 * LICENSE file in the "hack" directory of this source tree. An additional grant
8 * of patent rights can be found in the PATENTS file in the same directory.
12 class WebHelp2Controller {
13 public static function empty(): ?WebHelp2Controller {
14 return null;
16 public function foo(): void {}
18 class WebHelp2HubController extends WebHelp2Controller {}
19 class WebHelp2PageController extends WebHelp2Controller {}
20 class WebHelp2FrequentQuestionController extends WebHelp2Controller {}
23 function test(string $huri, bool $cmsid): WebHelp2Controller {
24 $controller = null;
26 switch ($huri) {
27 case 'hub':
28 $controller = new WebHelp2HubController();
29 break;
30 case 'page':
31 $controller = new WebHelp2PageController();
32 break;
33 case 'faq':
34 $controller = new WebHelp2FrequentQuestionController();
35 break;
36 default:
37 throw new Exception('You shouldn\'t be here');
39 $controller->foo();
40 return $controller;