Disallow ... without type in function typehints
[hiphop-php.git] / hphp / hack / test / typecheck / stringish.php
blob2cdd718dd4ad56951c6bfbcbff0c284aab9188ec
1 <?hh // strict
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the "hack" directory of this source tree.
12 class CExplicit implements Stringish {
13 public function __toString(): string {
14 return __CLASS__;
18 class CImplicit {
19 public function __toString(): string {
20 return __CLASS__;
24 interface IImplicit {
25 public function __toString(): string;
28 function f1(Stringish $x): string {
29 return __FUNCTION__.': '.$x;
32 function f2(): void {
33 f1("a boring string");
34 $x = "dynamic ";
35 $x .= "string";
36 f1($x);
37 $explicit = new CExplicit();
38 f1($explicit);
39 $implicit = new CImplicit();
40 f1($implicit);
43 function f3(IImplicit $i): void {
44 f1($i);
47 trait TStringish {
48 public function __toString(): string {
49 return __TRAIT__;
52 private function foo(): void {
53 echo 'foo'.$this;
57 trait TReq {
58 require implements Stringish;
60 private function foo(): void {
61 echo 'foo'.$this;