No error on use of `unsafe_cast`
[hiphop-php.git] / hphp / hack / test / typecheck / this_anon_bad.php
blob497fbda6a8ff2f93b04795683fc7a7a54da885d7
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 <<__ConsistentConstruct>>
13 class Foo {
14 public function getAnon1(): (function(this): int) {
15 return function(this $x): int {
16 return 4;
20 public function test(): void {
21 $func = $this->getAnon1();
23 // Can pass in $this
24 $func($this);
26 // Can pass an alias of $this
27 $this_alias = $this;
28 $func($this_alias);
30 // Can pass new static()
31 $func(new static());
33 // But not new Foo()
34 $func(new Foo());