No error on use of `unsafe_cast`
[hiphop-php.git] / hphp / hack / test / typecheck / unmagic_stringish / unmagic_stringish2.php
blob85e34bd8fa870051b0d0daa2015334378ad77d70
1 <?hh // strict
3 class CNonStringish {}
5 class CExplicit implements StringishObject{
6 public function __toString(): string {
7 return __CLASS__;
11 class CImplicit {
12 public function __toString(): string {
13 return __CLASS__;
17 interface IImplicit {
18 public function __toString(): string;
21 class CImplicitIntf implements IImplicit {
22 public function __toString(): string {
23 return __CLASS__;
27 trait TStringish {
28 public function __toString(): string {
29 return __TRAIT__;
32 private function foo(): string {
33 return (string) $this;
37 class CImplicitTuse {
38 use TStringish;
41 trait TReq {
42 require implements StringishObject;
44 private function foo(): string {
45 return (string) $this;
49 class CImplicitTreq {
50 use TReq;
52 public function __toString(): string {
53 return __CLASS__;
57 function test(): void {
58 $cnon = new CNonStringish();
60 $cexp = new CExplicit();
61 $cimp = new CImplicit();
62 $cimpintf = new CImplicitIntf();
63 $cimptuse = new CImplicitTuse();
64 $cimptreq = new CImplicitTreq();
66 "$cnon";
67 ''.$cnon;
69 "$cexp";
70 ''.$cexp;
72 "$cimp";
73 ''.$cimp;
75 "$cimpintf";
76 ''.$cimpintf;
78 "$cimptuse";
79 ''.$cimptuse;
81 "$cimptreq";
82 ''.$cimptreq;