language
stringlengths 0
24
| filename
stringlengths 9
214
| code
stringlengths 99
9.93M
|
---|---|---|
PHP | hhvm/hphp/hack/test/deps/overriding_method.php | <?hh
class B {
public function foo()[write_props]: int {
return 0;
}
}
class C extends B {
<<__Override>>
public function foo()[]: int {
return 1;
}
}
function f1()[]: int {
return 0;
}
function f2()[]: int {
return f1();
} |
PHP | hhvm/hphp/hack/test/deps/requirements.php | <?hh
trait Bar {
require extends FooParent<G>;
}
interface IFoo {
require extends FooParent<G>;
}
class FooParent<T> {}
class G {}
class Foo extends FooParent<G> implements IFoo {
use Bar;
} |
PHP | hhvm/hphp/hack/test/deps/static_method_function_deps.php | <?hh
interface I {
public function interface_only_method(): void;
}
class C implements I {
public static function static_counter(): void { obj_only(); }
public function interface_only_method(): void { bar(); }
public function class_only_method(): void {
$C_obj = new C();
foo($C_obj);
}
}
class A {
public function call_static_method(): void {
C::static_counter();
}
}
function foo(I $I_obj): void {
C::static_counter();
$I_obj->interface_only_method();
}
function bar(): void {
$C_obj = new C();
$C_obj->class_only_method();
foo($C_obj);
}
function obj_only(): void{
$C_obj = new C();
} |
PHP | hhvm/hphp/hack/test/deps/tconst.php | <?hh
class M {}
class N extends M {}
abstract class Foo {
abstract const type T as M;
}
class Bar extends Foo {
const type T = N;
} |
PHP | hhvm/hphp/hack/test/deps/virtualclass_trait_interface.php | <?hh
trait T {}
interface I {}
abstract class A {
use T;
}
class B extends A implements I {} |
hhvm/hphp/hack/test/deregister/dune | (rule
(alias deregister)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/deregister/*.php)
(glob_files %{project_root}/hack/test/deregister/*.exp)
(glob_files %{project_root}/hack/test/deregister/HH_FLAGS))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/deregister
--program
%{exe:../../src/hh_single_type_check.exe}
--flags
--error-format
plain)))
(alias
(name runtest)
(deps
(alias deregister))) |
|
Hack | hhvm/hphp/hack/test/dot_hack/dot_hack_can_have_literal_less_than_question_mark.hack | <<__EntryPoint>>
function do_some_codegen(): void {
file_put_contents('foo.hack', "<?hh // strict");
} |
Hack | hhvm/hphp/hack/test/dot_hack/dot_hack_has_hack_syntax_tree.hack | function foo(): vec<string> {
// if we don't have a hack syntax tree, this is a parser error: it's trying
// to access the constant `vec`, and index it as a list. lists aren't valid
// subscript indices.
return vec['foo', 'bar'];
} |
hhvm/hphp/hack/test/dot_hack/dune | (rule
(alias dot_hack)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/dot_hack/*.hack)
(glob_files %{project_root}/hack/test/dot_hack/*.exp)
(glob_files %{project_root}/hack/test/dot_hack/HH_FLAGS))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/dot_hack
--program
%{exe:../../src/hh_single_type_check.exe}
--out-extension
.legacy.out
--in-extension
.hack
--batch
--flags
--error-format
plain
--out-extension
.legacy.out))) |
|
hhvm/hphp/hack/test/dot_php/dune.disabled | (alias
(name dot_php)
(deps %{exe:../../src/hh_single_type_check.exe}
%{project_root}/test/verify.py
%{project_root}/test/review.sh
(glob_files %{project_root}/test/dot_php/*.php)
(glob_files %{project_root}/test/dot_php/*.exp)
(glob_files %{project_root}/test/dot_php/HH_FLAGS))
(action (run %{project_root}/test/verify.py %{project_root}/test/dot_php
--program %{exe:../../src/hh_single_type_check.exe}
--out-extension .legacy.out
--in-extension .php
--batch
--flags --error-format plain --out-extension .legacy.out)))
(alias
(name runtest)
(deps (alias dot_php))) |
|
PHP | hhvm/hphp/hack/test/dot_php/php-invalid.php | <?php
This is an invalid un-parseable PHP file, but it does not matter
because Hack should ignore all PHP files.
~!@#$%^&*() |
PHP | hhvm/hphp/hack/test/dot_php/php-shebang.php | #!/usr/bin/env php
<?php
echo "I am a valid PHP file, hack should ignore me";
function foo(): array {} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/async_lambda.php | <?hh // strict
async function genString(string $s): Awaitable<string> { return $s; }
function test(): void {
$f0 = async () ==> {
$str = await genString('foo');
};
$f1 = async $x ==> {
$str = await genString($x);
};
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/autoimportedfunctions.php | <?hh
class C {
public function instanceFoo(): void {}
}
function test(C $c): void {
meth_caller(C::class, 'instanceFoo');
meth_caller(C::class, 'instanceFoo')($c);
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/basic.php | <?hh
function none_member_function($num): int {
$obj = AnotherTestClass::createInstance();
$obj->publicMethod("another test");
return $num + 1;
}
class AnotherTestClass {
private string $field;
public function __construct(string $input) {
$this->field = $input;
}
public function publicMethod($arg): int {
return 100;
}
static public function createInstance(): AnotherTestClass {
$obj = new AnotherTestClass("test");
$obj->publicMethod("dummy");
AnotherTestClass::staticMethod();
none_member_function(10);
return $obj;
}
static public function staticMethod(): void {}
} |
hhvm/hphp/hack/test/dumpsymbolinfo/dune | (rule
(alias dumpsymbolinfo)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/dumpsymbolinfo/HH_FLAGS)
(glob_files %{project_root}/hack/test/dumpsymbolinfo/*.php)
(glob_files %{project_root}/hack/test/dumpsymbolinfo/*.exp))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/dumpsymbolinfo
--program
%{exe:../../src/hh_single_type_check.exe})))
(alias
(name runtest)
(deps
(alias dumpsymbolinfo))) |
|
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/generic_argument.php | <?hh // strict
abstract class C {
public function foo(): int { return 1; }
}
function test<T as C>(T $x): int {
return $x->foo();
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/lambda_argument.php | <?hh // strict
function map<Tv1, Tv2>(vec<Tv1> $v, (function(Tv1): Tv2) $f): vec<Tv2> {
return vec[];
}
function test(): void {
$f = $nums ==> {
$v = map($nums, $n ==> $n);
};
$f(vec[1, 2, 3]);
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/lambda_argument_contextual.php | <?hh // strict
function map<Tv1, Tv2>(vec<Tv1> $v, (function(Tv1): Tv2) $f): vec<Tv2> {
return vec[];
}
function test(): void {
map(vec[1, 2, 3], $n ==> $n));
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/lambda_argument_reused.php | <?hh // strict
class C {
public function foo(): string { return 's'; }
}
class D {
public function foo(): int { return 1; }
}
function test(): void {
$f = $x ==> {
$y = $x->foo();
return $y;
};
$f(new C());
$f(new D());
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/multiple_type.php | <?hh // strict
// Copyright 2004-present Facebook. All Rights Reserved.
class C1 {
public function foo() {}
}
class C2 {
public function foo() {}
}
function test(C1 $c1, C2 $c2, bool $b) {
if ($b) {
$x = $c1;
$x->foo();
} else {
$x = $c2;
$x->foo();
}
// this is both C1::foo() and C2::foo()
$x->foo();
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/new_parent.php | <?hh // strict
class B {
public function foo(): void {}
}
class A extends B {
public static function bar(): void {
$x = new parent();
$x->foo();
echo 'test';
}
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/new_self.php | <?hh // strict
class A {
public function foo(): void {}
public static function bar(): void {
$x = new self();
$x->foo();
}
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/new_static.php | <?hh // strict
<<__ConsistentConstruct>>
abstract class A {
public function foo(): void {}
public static function bar(): void {
$x = new static();
$x->foo();
echo 'test';
}
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/parent_construct.php | <?hh // strict
class B {
public function __construct(num $x) {}
}
class A extends B {
public function __construct(int $x) {
parent::__construct($x);
}
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/parent_method.php | <?hh
class C1 {
public static function foo(): string {
return 'foo';
}
}
class C2 extends C1 {
public static function test(): string {
return parent::foo();
}
}
class C3 extends C2 {
public static function test2(): string {
return parent::foo();
}
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/pseudofunctions.php | <?hh
class C {
public static function staticFoo(): void {}
public function instanceFoo(): void {}
}
function test(C $c): void {
echo('foo');
print('foo');
tuple(1, 2);
shape('x' => 5);
isset($c);
unset($c);
invariant(true, 'foo');
invariant_violation('foo');
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/same_name_args.php | <?hh
class F {
/* FIXME: the arguments to f() and g() should be given different ident
* numbers in the test output, but right now they are the same. */
public function f($x) {}
public function g($x) {}
} |
PHP | hhvm/hphp/hack/test/dumpsymbolinfo/static_in_trait.php | <?hh // strict
interface A {}
<<__ConsistentConstruct>>
trait X implements A {
public function foo(): A {
return new static();
}
}
class Y {
use X;
public function buildAnObjectAFromTrait(): A {
return $this->foo();
}
} |
hhvm/hphp/hack/test/dump_inheritance/dune | (rule
(alias dump_inheritance)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/dump_inheritance/HH_FLAGS)
(glob_files %{project_root}/hack/test/dump_inheritance/*.php)
(glob_files %{project_root}/hack/test/dump_inheritance/*.exp))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/dump_inheritance
--program
%{exe:../../src/hh_single_type_check.exe})))
(alias
(name runtest)
(deps
(alias dump_inheritance))) |
|
PHP | hhvm/hphp/hack/test/dump_inheritance/test.php | <?hh
interface IFoo {
public function implement_me();
}
interface IBar {}
interface IQux extends IFoo, IBar {}
class Foo implements IFoo {
public function implement_me() {}
public function override_me() {}
}
class Bar extends Foo implements IQux {
public function not_overridden() {}
}
class Baz extends Bar {
public function override_me() {}
} |
PHP | hhvm/hphp/hack/test/duplicates/const.php | //// a.php
<?hh
const int f = 1;
const int g = 1;
const int h = 1;
const string H = "";
const int i = 1;
const string i = "";
const int j = 1;
//// b.php
<?hh
const string F = "";
const string g = ""; |
PHP | hhvm/hphp/hack/test/duplicates/fun.php | //// a.php
<?hh
function f(): int {return 1;}
function g(): int {return 1;}
function h(): int {return 1;}
function H(): void {}
function i(): int {return 1;}
function i(): void {}
function j(): void {}
//// b.php
<?hh
function F(): void {}
function g(): void {} |
PHP | hhvm/hphp/hack/test/duplicates/module.php | //// a.php
<?hh
new module f {}
new module g {}
new module h {}
new module H {}
new module i {}
new module i {}
new module j {}
//// b.php
<?hh
new module F {}
new module g {} |
PHP | hhvm/hphp/hack/test/duplicates/type.php | //// a.php
<?hh
class mcci {} // "m"ultifile, "c"lass in a.php, "c"lass in b.php, "i"nsensitive (i.e. differ in case)
class mcc {} // as above, but they don't differ in case
class mcti {} // "c"lass in a.php vs "t"ypedef in b.php
class mct {}
type mtti = int;
type mtt = int;
type mtci = int;
type mtc = int;
class cci {} // similar to the above, but not multifile; all just in a single file.
class CCI {}
class cc {}
class cc {}
class cti {}
type CTI = string;
class ct {}
type ct = string;
type tti = int;
type TTI = string;
type tt = int;
type tt = string;
type tci = int;
class TCI {}
type tc = int;
class tc {}
class c {} // here are some non-dupe definitions!
type t = int;
//// b.php
<?hh
class MCCI {}
class mcc {}
type MCTI = string;
type mct = string;
type MTTI = string;
type mtt = string;
class MTCI {}
class mtc {} |
PHP | hhvm/hphp/hack/test/elab/num_type_hint.php | <?hh // strict
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*
*/
function f(num $n1, num $n2): num {
return $n1 / $n2;
}
function div(int $n1, int $n2): num {
return $n1 / $n2;
}
function cast(num $n1, num $n2): (float, int) {
return tuple((float) $n1, (int) $n2);
}
// We _could_ be a tiny bit smarter and consider the following code correct
// by observing that the is_int and is_float guards are exhaustive.
//
// function disjoint_conditions(num $n): int {
// if (is_int($n)) {
// $x = 1;
// } else if (is_float($n)) {
// invariant_violation('This should be it');
// }
// return $x;
// }
function f_opt(?num $n1, num $n2): num {
if (null === $n1) {
return 1.0;
}
return f($n1, $n2);
}
function test(): void {
f(1, 1);
f(1.5, 1.5);
f(1.0, 1);
f(1, 1.5);
f_opt(1, 1);
f_opt(1.5, 1.5);
f_opt(1.0, 1);
f_opt(1, 1.5);
f_opt(null, 1);
}
function test_switch(int $x, int $y): bool {
$n = $x / $y;
hh_show($n);
$c = 1.0;
if ($c == $n) {
return true;
}
switch ($n) {
case $c: // == comparison, $n type shouldn't change
hh_show($n);
return true;
case 2.0:
$res = false;
break;
case 3:
$res = true;
break;
default:
$res = true;
}
return $res;
} |
PHP | hhvm/hphp/hack/test/elab/tuple_hints.php | <?hh
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*
*/
function foo(tuple<int> $x): void {} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/double_abstract.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
abstract abstract enum class C : mixed {}
abstract enum class D : mixed {
abstract abstract int X;
} |
hhvm/hphp/hack/test/enum_class/parsing/dune | (rule
(alias enum_class_parsing_good)
(deps
%{exe:../../../src/hh_parse.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/enum_class/parsing/HH_FLAGS)
(glob_files %{project_root}/hack/test/enum_class/parsing/*.good.php)
(glob_files %{project_root}/hack/test/enum_class/parsing/*.good.php.exp))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/enum_class/parsing
--program
%{exe:../../../src/hh_parse.exe}
--in-extension
.good.php
--flags
--full-fidelity-errors
--full-fidelity-errors-all
--full-fidelity-json-parse-tree
--pretty-print-json)))
(rule
(alias enum_class_parsing_bad)
(deps
%{exe:../../../src/hh_parse.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/enum_class/parsing/HH_FLAGS)
(glob_files %{project_root}/hack/test/enum_class/parsing/*.bad.php)
(glob_files %{project_root}/hack/test/enum_class/parsing/*.bad.php.exp))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/enum_class/parsing
--program
%{exe:../../../src/hh_parse.exe}
--in-extension
.bad.php
--flags
--full-fidelity-errors
--full-fidelity-errors-all)))
(alias
(name runtest)
(deps
(alias enum_class_parsing_good)
(alias enum_class_parsing_bad))) |
|
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_abstract.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
final enum class E : mixed {}
enum class E : mixed {
int A;
}
abstract enum class G : mixed {
abstract int A = 42;
}
enum class G : mixed {
final int A = 42;
}
final abstract enum class K0 : int {}
abstract final enum class K1 : int {} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_abstract.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
abstract enum class E : mixed {
abstract int A;
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_definition.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
class IBox extends Box<int> {
public function add(int $x): void {
$this->data = $this->data + $x;
}
}
abstract final class Helper {
public static function ibox(): IBox {
return new IBox(42);
}
}
enum class E: ExBox {
Box<string> A = new Box('bli');
IBox B = Helper::ibox();
Box<int> C = new Box(42);
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_definition0.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
enum class E: ExBox {
A = new Box('bli');
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_definition1.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
enum class E: ExBox {
Box<string> A;
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_definition2.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
enum class E: ExBox {
A;
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_definition3.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
trait MyTrait {
}
enum class E: ExBox {
// Cannot use a trait inside an enum class
use MyTrait;
Box<string> A = new Box('bli');
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_definition4.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
enum class E: ExBox {
// a single initializer is needed here.
Box<string> A = new Box('bli'), 'some other arg';
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_extension.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
class IBox extends Box<int> {
public function add(int $x): void {
$this->data = $this->data + $x;
}
}
abstract final class Helper {
public static function ibox(): IBox {
return new IBox(42);
}
}
enum class E: ExBox {
Box<string> A = new Box('bli');
IBox B = Helper::ibox();
Box<int> C = new Box(42);
}
enum class F: ExBox extends E {
Box<int> D = new Box(1664);
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/enum_class_extension0.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
interface ExBox {}
class Box<T> implements ExBox {
public function __construct(public T $data) {}
}
class IBox extends Box<int> {
public function add(int $x): void {
$this->data = $this->data + $x;
}
}
abstract final class Helper {
public static function ibox(): IBox {
return new IBox(42);
}
}
enum class E: ExBox {
Box<string> A = new Box('bli');
IBox B = Helper::ibox();
Box<int> C = new Box(42);
}
// use `extends`, not `use`
enum class F: ExBox {
use E;
Box<int> D = new Box(1664);
} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/modifiers_enum.bad.php | <?hh
abstract enum E : int {
X = 42;
}
enum F : int {
abstract X;
}
final enum G : int {
X = 42;
}
abstract final enum H : int {}
final abstract enum K : int {} |
PHP | hhvm/hphp/hack/test/enum_class/parsing/name_class.bad.php | <?hh
// we don't allow class as a name, which would make ::class ambiguous
enum class E : int {
int class = 42;
} |
hhvm/hphp/hack/test/enum_class_label/format/dune | (rule
(alias enum_class_label_format)
(deps
%{exe:../../../src/hackfmt.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/enum_class_label/format/*.php)
(glob_files %{project_root}/hack/test/enum_class_label/format/*.php.exp))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/enum_class_label/format
--program
%{exe:../../../src/hackfmt.exe})))
(alias
(name runtest)
(deps
(alias enum_class_label_format))) |
|
PHP | hhvm/hphp/hack/test/enum_class_label/format/label_format.php | <?hh
enum class E : int { int A = 42;
}
function f(HH\EnumClass\Label<E, int> $_): void {}
function g(HH\EnumClass\Label<E, int> $_, int $_): void {}
class Chains {
public function f(HH\EnumClass\Label<E, int> $_) : this { return $this; }
public function g(HH\EnumClass\Label<E, int> $_, int $_) : this { return $this; }
}
function main(): void {
f(#A);
g(#A, 42);
$c = new Chains();
$c->f(#A);
$c->f(#A)->g(#A, 42);
} |
hhvm/hphp/hack/test/enum_class_label/parsing/dune | (rule
(alias enum_class_label_parsing)
(deps
%{exe:../../../src/hh_parse.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/enum_class_label/parsing/*.php)
(glob_files %{project_root}/hack/test/enum_class_label/parsing/HH_FLAGS)
(glob_files %{project_root}/hack/test/enum_class_label/parsing/*.php.exp))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/enum_class_label/parsing
--program
%{exe:../../../src/hh_parse.exe}
--flags
--full-fidelity-errors
--full-fidelity-errors-all
--full-fidelity-json-parse-tree
--pretty-print-json)))
(alias
(name runtest)
(deps
(alias enum_class_label_parsing))) |
|
PHP | hhvm/hphp/hack/test/enum_class_label/parsing/enum_class_label.good.php | <?hh
function foo(): void {
var_dump(\NS\E#A);
if (E#A == $x) { echo "42\n"; }
$c->get(#list);
$c->get(E#list);
} |
PHP | hhvm/hphp/hack/test/enum_class_label/parsing/hash_underscore.good.php | <?hh
enum class E : mixed {
int __YOLO = 42;
int X = 42;
}
enum F : int {
__YOLO = 42;
}
function show(HH\EnumClass\Label<E, int> $label): void {
echo E::valueOf($label);
echo "\n";
}
<<__EntryPoint>>
function f(): void {
echo E::__YOLO;
echo "\n";
echo F::__YOLO;
echo "\n";
show(#X);
show(#__YOLO);
} |
PHP | hhvm/hphp/hack/test/enum_class_label/parsing/short.bad.php | <?hh
enum class E : int {
int A = 42;
}
function main(): void {
E::valueOf#A(); // experimental feature
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/missing_included.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F : int {
use;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/missing_includes.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E1 : int {}
enum E2 : int {}
enum F : int {
E1, E2;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/multiple_includes.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E1 : int {}
enum E2 : int {}
enum F : int {
use E1, E2;
}
enum G : int {
use E1;
use E2;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/old_includes_syntax.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E : int {}
enum F : int includes E {} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/single_includes.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E : int {}
enum F : int {
use E;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/use_constant.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F : int {
}
enum E : int {
USE = "use";
use F;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/use_constant.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F : string {}
enum E : string {
use F;
USE = "use";
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/parsing/wrong_order.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E : int {}
enum F : int {
A = 0;
use E;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/base.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum A : int {}
enum B : string {
use A;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/constant_access.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E1: int as int {
A = 0;
}
enum E2: int as int {
B = 1;
}
enum F: int as int {
use E1;
use E2;
C = 2;
}
<<__EntryPoint>>
function test(): void {
print F::C;
print F::A;
print F::B;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/constant_cycle.bad.php | <?hh
enum B : int as int {
X = B::X;
Y = self::Y;
}
enum F : int as int {
use E;
}
enum E : int as int {
X = F::X;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/diamond.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E1 : int {
A = 1;
}
enum E2 : int {
use E1;
}
enum E3 : int {
use E1;
}
enum E : int {
use E2;
use E3;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/duplicate_parent.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E: int as int {
A = 0;
}
enum F: int {
use E;
A = 42;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/duplicate_parent_siblings.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E1: int as int {
A = 0;
}
enum E2: int as int {
A = 1;
}
enum F1: int {
use E1;
use E2;
A = 2;
}
enum F2: int {
use E1, E2;
A = 2;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/duplicate_parent_transitive.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E: int as int {
A = 0;
}
enum F: int {
use E;
}
enum G: int {
use F;
A = 42;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/duplicate_siblings.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F: int as int {
A = 0;
}
enum G: int as int {
A = 1;
}
enum H: int {
use F;
use G;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/duplicate_siblings_transitive.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E: int as int {
A = 0;
}
enum F: int as int {
use E;
}
enum G: int as int {
A = 1;
}
enum H: int {
use F;
use G;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/function_argument.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F: int as int {
A = 0;
}
enum G: int {
use F;
B = 1;
}
function foo(F $e) : void {}
<<__EntryPoint>>
function main(): void {
foo(G::A);
foo(G::B);
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/function_argument_2.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F: int as int {
A = 0;
}
enum G: int {
use F;
B = 1;
}
function foo(G $e) : G { return $e; }
<<__EntryPoint>>
function main(): void {
echo foo(F::A);
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/function_return.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F: int as int {
A = 0;
}
enum G: int {
use F;
B = 1;
}
function foo3() : F {
return G::A;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/function_return_2.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F: int as int {
A = 0;
}
enum G: int {
use F;
B = 1;
}
function foo1() : G {
return G::A;
}
function foo2() : G {
return F::A;
}
function foo3() : F {
return F::A;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/includes-not-enum.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
class C {}
enum A : int {
use C;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/multiple_includes.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum F: int as int {
A = 0;
}
enum G: int as int {
B = 1;
}
enum H: int {
use F;
use G;
C = 42;
}
<<__EntryPoint>>
function main(): void {
echo F::A . "\n";
echo G::B . "\n";
echo H::A . "\n";
echo H::B . "\n";
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/ordering.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum B: string as string {
use A;
}
enum A: string as string {
FOO = 'foo';
}
<<__EntryPoint>>
function main() : void {
print B::FOO;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/transitive_includes.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum E: int as int {
A = 0;
}
enum F: int as int {
B = 1;
}
enum G: int {
use E;
}
enum H: int {
use F;
use G;
MY_ADDITIONAL_CONST = 42;
}
<<__EntryPoint>>
function main(): void {
echo E::A . "\n";
echo F::B . "\n";
echo H::A . "\n";
echo H::B . "\n";
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/visibility.bad.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum A : int {}
enum B : int as int {
use A;
} |
PHP | hhvm/hphp/hack/test/enum_supertyping/typing/visibility.good.php | <?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
enum A : int {}
enum B : int {
use A;
}
enum C : int as int {}
enum D : int as int {
use C;
}
enum E : int {
use C;
} |
PHP | hhvm/hphp/hack/test/error_formatting/big_file.php | <?hh // strict
function foo(): void {}
/* A very long comment to push us over 1,000 lines.
*/
function bar() {
foo(1);
} |
hhvm/hphp/hack/test/error_formatting/dune | (rule
(alias context_formatting)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/error_formatting/*.php)
(glob_files %{project_root}/hack/test/error_formatting/*.exp)
(glob_files %{project_root}/hack/test/error_formatting/HH_FLAGS))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/error_formatting
--program
%{exe:../../src/hh_single_type_check.exe})))
(alias
(name runtest)
(deps
(alias context_formatting))) |
|
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/big_file.php | <?hh // strict
function foo(): void {}
/* A very long comment to push us over 1,000 lines.
*/
function bar() {
foo(1);
} |
hhvm/hphp/hack/test/error_formatting_highlighted/dune | (rule
(alias highlighted_formatting)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files %{project_root}/hack/test/error_formatting_highlighted/*.php)
(glob_files %{project_root}/hack/test/error_formatting_highlighted/*.exp)
(glob_files %{project_root}/hack/test/error_formatting_highlighted/HH_FLAGS))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/error_formatting_highlighted
--program
%{exe:../../src/hh_single_type_check.exe})))
(alias
(name runtest)
(deps
(alias highlighted_formatting))) |
|
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/long_directory_name.php | ////long/directory/name/class_def.php
<?hh // strict
class Foo {
public function f(int $x): void {}
}
////another/directory/treq_ext_foo.php
<?hh // strict
trait TReqExtFoo {
require extends Foo;
}
////child.php
<?hh // strict
class Child extends Foo {
public function f(string $x): void {}
}
////some/more/directories/treq_ext_child.php
<?hh // strict
trait TReqExtChild {
require extends Child;
}
////long/directory/name/again/tboth_traits.php
<?hh // strict
trait TBothTraits {
use TReqExtChild;
use TReqExtFoo;
} |
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/message_order2.php | <?hh
function takes_one_arg(int $_): void {}
function takes_string(string $_): void {}
function takes_foo(): void {
takes_string(1); // error 4110
takes_one_arg(123, 1); // error 4105
} |
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/mul_union.php | <?hh // strict
// Copyright 2020-present Facebook. All Rights Reserved.
function badInt(bool $b): int {
if ($b) {
$x = 3;
} else {
$x = 3.4;
}
$z = 3 * $x;
if ($z is int) {
echo 'int';
} else {
echo 'not int';
}
return $z;
}
function main(): void {
badInt(false);
} |
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/pos_across_multiple_lines.php | <?hh
function f(): dict<int,
int>
{
return "hello";
}
function g(): void {
echo "hello";
}
<<__EntryPoint>>
function main(): void {
g(1,
2,
3);
} |
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/pos_across_multiple_lines2.php | <?hh
function g(): void {
echo "hello";
}
<<__EntryPoint>>
function main(): void {
g(1,
2,
3);
} |
PHP | hhvm/hphp/hack/test/error_formatting_highlighted/required_field_optional.php | <?hh
type my_shape = shape(
'x' => int,
'y' => bool,
);
function foo(bool $cond): my_shape {
$s = shape('x' => 0);
if ($cond) {
$s['y'] = true;
}
return $s;
} |
hhvm/hphp/hack/test/error_formatting_highlighted_raw_color/dune | (rule
(alias highlighted_formatting_raw_color)
(deps
%{exe:../../src/hh_single_type_check.exe}
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/review.sh
(glob_files
%{project_root}/hack/test/error_formatting_highlighted_raw_color/*.php)
(glob_files
%{project_root}/hack/test/error_formatting_highlighted_raw_color/*.exp)
(glob_files
%{project_root}/hack/test/error_formatting_highlighted_raw_color/HH_FLAGS))
(action
(run
%{project_root}/hack/test/verify.py
%{project_root}/hack/test/error_formatting_highlighted_raw_color
--program
%{exe:../../src/hh_single_type_check.exe}
--expect-extension
.raw_color.exp
--out-extension
.raw_color.out
--force-color)))
(alias
(name runtest)
(deps
(alias highlighted_formatting_raw_color))) |
|
PHP | hhvm/hphp/hack/test/error_formatting_highlighted_raw_color/required_field_optional.php | <?hh
type my_shape = shape(
'x' => int,
'y' => bool,
);
function foo(bool $cond): my_shape {
$s = shape('x' => 0);
if ($cond) {
$s['y'] = true;
}
return $s;
} |
Hack | hhvm/hphp/hack/test/extracted_from_manual/01-getting-started/01-getting-started-01.hack | // @generated by hh_manual from manual/hack/01-getting-started/01-getting-started.md
// @codegen-command : buck run fbcode//hphp/hack/src/hh_manual:hh_manual extract fbcode/hphp/hack/manual/hack/
use namespace HH\Lib\IO;
<<__EntryPoint>>
async function main(): Awaitable<void> {
await IO\request_output()->writeAllAsync("Hello World!\n");
} |
hhvm/hphp/hack/test/extracted_from_manual/01-getting-started/03-starting-a-real-project-01.hack_error | // @generated by hh_manual from manual/hack/01-getting-started/03-starting-a-real-project.md
// @codegen-command : buck run fbcode//hphp/hack/src/hh_manual:hh_manual extract fbcode/hphp/hack/manual/hack/
use namespace HH\Lib\Vec;
function square_vec(vec<num> $numbers): vec<int> {
return Vec\map($numbers, $number ==> $number * $number);
} |
|
Hack | hhvm/hphp/hack/test/extracted_from_manual/01-getting-started/05-input-and-output-01.hack | // @generated by hh_manual from manual/hack/01-getting-started/05-input-and-output.md
// @codegen-command : buck run fbcode//hphp/hack/src/hh_manual:hh_manual extract fbcode/hphp/hack/manual/hack/
use namespace HH\Lib\{File, IO};
async function main_async(): Awaitable<void> {
// STDIN for CLI, or HTTP POST data
$_in = IO\request_input();
// STDOUT for CLI, or HTTP response
$out = IO\request_output();
$message = "Hello, world\n";
await $out->writeAllAsync($message);
// copy to a temporary file, automatically closed at scope exit
using ($tf = File\temporary_file()) {
$f = $tf->getHandle();
await $f->writeAllAsync($message);
$f->seek(0);
$content = await $f->readAllAsync();
await $out->writeAllAsync($content);
}
} |
Hack | hhvm/hphp/hack/test/extracted_from_manual/02-source-code-fundamentals/04-program-structure-01.hack | #!/usr/bin/env hhvm
// @generated by hh_manual from manual/hack/02-source-code-fundamentals/04-program-structure.md
// @codegen-command : buck run fbcode//hphp/hack/src/hh_manual:hh_manual extract fbcode/hphp/hack/manual/hack/
<<__EntryPoint>>
function main(): void {
print("Hello, World!\n");
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.