language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
PHP
hhvm/hphp/hack/test/fanout/modules/module-add-reference.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// base-a-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> class FooA {} //// changed-a-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class FooA {}
PHP
hhvm/hphp/hack/test/fanout/modules/module-change-class-membership.php
//// base-decls.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} new module B {} //// changed-decls.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} new module B {} //// base-foobar.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class Foobar {} //// changed-foobar.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; internal class Foobar {} //// base-bing.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; final internal class Bing extends Foobar {} //// changed-bing.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; final internal class Bing extends Foobar {}
PHP
hhvm/hphp/hack/test/fanout/modules/module-change-class-module.php
//// base-decls.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} new module B {} //// changed-decls.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} new module B {} //// base-foobar.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foobar { internal function foo(): void {} } //// changed-foobar.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; public class Foobar { internal function foo(): void {} } //// base-bing.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function test(Foobar $x): void { $x->foo(); // will error here after change } //// changed-bing.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function test(Foobar $x): void { $x->foo(); // will error here after change }
PHP
hhvm/hphp/hack/test/fanout/modules/module-change-membership.php
//// base-decls.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} new module B {} //// changed-decls.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} new module B {} //// base-f.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal function f(): void {} //// changed-f.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; internal function f(): void {} //// base-g.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function g(): void { f(); } //// changed-g.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function g(): void { f(); }
PHP
hhvm/hphp/hack/test/fanout/modules/module-make-internal-func.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function foo(): void {} //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal function foo(): void {} //// base-foo-use.php <?hh function call_foo(): void { foo(); } //// changed-foo-use.php <?hh function call_foo(): void { foo(); } //// base-foo-use-in-module.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function call_foo_in_module(): void { foo(); } //// changed-foo-use-in-module.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; function call_foo_in_module(): void { foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/module-make-internal-typedef.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; type Foo = int; //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal type Foo = int; //// base-foo-use.php <?hh function return_foo(): Foo { return 42; } //// changed-foo-use.php <?hh function return_foo(): Foo { return 42; }
PHP
hhvm/hphp/hack/test/fanout/modules/module-make-internal.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; class FooA {} //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class FooA {} //// base-foo-use.php <?hh function make_fooa(): FooA { return new FooA(); } function make_secret_fooa(): mixed { return new FooA(); } //// changed-foo-use.php <?hh function make_fooa(): FooA { return new FooA(); } function make_secret_fooa(): mixed { return new FooA(); }
PHP
hhvm/hphp/hack/test/fanout/modules/module-remove-decl-by-comment.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> // module A {} //// base-a-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class FooA {} //// changed-a-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class FooA {} //// base-b-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal function foobar(): void {} //// changed-b-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal function foobar(): void {} //// base-c-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal newtype Foo = int; //// changed-c-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal newtype Foo = int;
PHP
hhvm/hphp/hack/test/fanout/modules/module-remove-decl.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh //// base-a-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class FooA {} //// changed-a-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal class FooA {} //// base-b-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal function foobar(): void {} //// changed-b-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; internal function foobar(): void {} //// base-c-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; module newtype Bar = Foo; internal newtype Foo = int; //// changed-c-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; module newtype Bar = Foo; internal newtype Foo = int;
PHP
hhvm/hphp/hack/test/fanout/modules/module-simple.php
//// base-a.php <?hh <<file: __EnableUnstableFeatures('modules')>> //// changed-a.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {}
PHP
hhvm/hphp/hack/test/fanout/modules/module_internal_method.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> new module A {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; class Foo { internal function foo(): void {} } //// base-foo-use.php <?hh function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_export_change_explicit.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { B } } //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { } } //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_export_change_explicit2.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { } } //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { B } } //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_export_change_global.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { global } } //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { } } //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_export_change_prefix.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { B.* } } //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { } } //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_export_change_prefix2.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { B.* } } //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { exports { B.X.* } } //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B {} //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_import_change_explicit.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { A } } //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { } } //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_import_change_explicit2.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { } } //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { A } } //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_import_change_global.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { imports { global } } //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A { imports { } } //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void { bar(); } } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void { bar(); } } //// base-foo-use.php <?hh function bar(): void { } //// changed-foo-use.php <?hh function bar(): void { }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_import_change_prefix.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { A.* } } //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { } } //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
PHP
hhvm/hphp/hack/test/fanout/modules/references/module_reference_import_change_prefix2.php
//// base-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// changed-a-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module A {} //// base-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { A.* } } //// changed-b-decl.php <?hh <<file: __EnableUnstableFeatures('modules')>> <<file: __EnableUnstableFeatures('module_references')>> new module B { imports { A.X.* } } //// base-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// changed-foo-defn.php <?hh <<file: __EnableUnstableFeatures('modules')>> module A; public class Foo { public function foo(): void {} } //// base-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); } //// changed-foo-use.php <?hh <<file: __EnableUnstableFeatures('modules')>> module B; function call_foo(Foo $f): void { $f->foo(); }
Python
hhvm/hphp/hack/test/fanout/tools/fanout.py
#!/usr/bin/env python3 # pyre-strict from __future__ import annotations import argparse import logging import os import tempfile from enum import Enum import attr from .fanout_test_driver import ( Binaries, run_scenario_incremental_no_old_decls, run_scenario_incremental_with_old_decls, run_scenario_saved_state_init, ) from .fanout_test_parser import FanoutTest logging.basicConfig( format="[%(asctime)s] [%(levelname)s] %(message)s", datefmt="%m/%d/%Y %H:%M:%S %Z", level=logging.WARNING, ) class Mode(Enum): SAVED_STATE_INIT = "saved-state-init" INCREMENTAL_OLD_DECLS_ENABLED = "incremental-old-decls-enabled" INCREMENTAL_OLD_DECLS_DISABLED = "incremental-old-decls-disabled" def __str__(self) -> str: return self.value @attr.s(auto_attribs=True) class Opts(object): hh_client: str hh_server: str hh_single_type_check: str legacy_hh_fanout: str debug: bool mode: Mode input_file: str def to_bins(self) -> Binaries: return Binaries( hh_client=self.hh_client, hh_server=self.hh_server, legacy_hh_fanout=self.legacy_hh_fanout, hh_single_type_check=self.hh_single_type_check, ) def get_temporary_dir(prefix: str) -> tempfile.TemporaryDirectory[str]: # sandcastle sets TEMP as a directory that's cleaned up when the job ends return tempfile.TemporaryDirectory(prefix=prefix, dir=os.getenv("TEMP")) def go(opts: Opts) -> None: logging.debug("hh_client: %s", opts.hh_client) logging.debug("hh_server: %s", opts.hh_server) logging.debug("hh_single_type_check: %s", opts.hh_single_type_check) logging.debug("legacy_hh_fanout: %s", opts.legacy_hh_fanout) logging.debug("mode: %s", opts.mode) logging.debug("input_file: %s", opts.input_file) test = FanoutTest.from_file(opts.input_file) if opts.mode is Mode.SAVED_STATE_INIT: run_scenario_saved_state_init(opts.to_bins(), test) elif opts.mode is Mode.INCREMENTAL_OLD_DECLS_ENABLED: run_scenario_incremental_with_old_decls(opts.to_bins(), test) elif opts.mode is Mode.INCREMENTAL_OLD_DECLS_DISABLED: run_scenario_incremental_no_old_decls(opts.to_bins(), test) else: raise AssertionError() def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("--hh-client", type=os.path.abspath) parser.add_argument("--hh-server", type=os.path.abspath) parser.add_argument("--hh-single-type-check", type=os.path.abspath) parser.add_argument("--legacy-hh-fanout", type=os.path.abspath) parser.add_argument("--debug", action="store_true") parser.add_argument( "--mode", type=Mode, choices=list(Mode), default=Mode.SAVED_STATE_INIT ) parser.add_argument("input_file") args = parser.parse_args() opts = Opts(**vars(args)) if opts.debug: logging.getLogger().setLevel(level=logging.DEBUG) go(opts) if __name__ == "__main__": main()
Python
hhvm/hphp/hack/test/fanout/tools/fanout_information.py
# pyre-strict import json import re from typing import List import attr # pyre-fixme[24]: Generic type `re.Pattern` expects 1 type parameter. FANOUT_INFORMATION_RE: re.Pattern = re.compile(r"\[fanout_information\]\s+(.*)$") @attr.s(auto_attribs=True) class FanoutInformation(object): tag: str hashes: List[str] @staticmethod def from_json(json_str: str) -> "FanoutInformation": o = json.loads(json_str) tag = str(o["tag"]) hashes = [str(h) for h in o["hashes"]] return FanoutInformation(tag=tag, hashes=hashes) @staticmethod def extract_from_log_file(log_file: str) -> List["FanoutInformation"]: infos = [] with open(log_file, "r") as fp: for line in fp: m = FANOUT_INFORMATION_RE.search(line) if m is not None: infos.append(FanoutInformation.from_json(m.group(1))) return infos
Python
hhvm/hphp/hack/test/fanout/tools/fanout_test_driver.py
# pyre-strict from __future__ import annotations import json import logging import os import re import shutil import subprocess import sys import tempfile from typing import Any, Dict, List, Optional, Tuple import attr from .fanout_information import FanoutInformation from .fanout_test_parser import FanoutTest # pyre-fixme[24]: Generic type `re.Pattern` expects 1 type parameter. WHITESPACE_SPLITTER: re.Pattern = re.compile(r"\s+") DEFAULT_HH_SERVER_FLAGS: List[str] = [ "--config", "hg_aware=false", "--config", "remote_type_check_enabled=false", "--config", "use_dummy_informant=true", "--config", "experiments_config_enabled=false", "--config", "symbolindex_search_provider=NoIndex", "--config", "num_local_workers=1", "--config", "max_workers=1", "--config", "allow_unstable_features=true", "--config", "allow_all_files_for_module_declarations=true", "--config", "disable_xhp_element_mangling=false", ] @attr.s(auto_attribs=True) class Binaries(object): hh_client: str hh_server: str hh_single_type_check: str legacy_hh_fanout: str def validate(self) -> None: if os.path.join(os.path.dirname(self.hh_client), "hh_server") != self.hh_server: # We don't have a way to specify the executable hh_client should use, and OCaml # resolves symlinks, so hh_server is not in the same directory as hh_client. # We does have to use PATH raise ValueError("{} must be an executable called hh_server") def exec_hh( self, args: List[str], allow_type_errors: bool = True, env: Optional[Dict[str, str]] = None, check: bool = True, **kwargs: Any, ) -> subprocess.CompletedProcess[str]: if env is None: env = {} prev_path = env.get("PATH", ":" + (os.getenv("PATH") or "")) env["PATH"] = os.path.dirname(self.hh_server) + prev_path if "HH_TEST_MODE" not in env: env["HH_TEST_MODE"] = "true" r = _exec([self.hh_client] + args, env=env, check=False, **kwargs) if allow_type_errors and r.returncode == 2: return r if check: r.check_returncode() return r def exec_hh_stop(self, repo_root: str) -> subprocess.CompletedProcess[str]: return self.exec_hh(["stop", repo_root]) def exec_hh_single_type_check( self, args: List[str], **kwargs: Any ) -> subprocess.CompletedProcess[str]: return _exec([self.hh_single_type_check] + args, **kwargs) def exec_legacy_hh_fanout( self, args: List[str], **kwargs: Any ) -> subprocess.CompletedProcess[str]: return _exec([self.legacy_hh_fanout] + args, **kwargs) @attr.s(auto_attribs=True) class RepoRoot(object): path: str def cleanup(self) -> None: shutil.rmtree(self.path) def hhconfig_file(self) -> str: return os.path.join(self.path, ".hhconfig") @attr.s(auto_attribs=True) class SavedStateDir(object): path: str def cleanup(self) -> None: shutil.rmtree(self.path) def edges_dir(self) -> str: return os.path.join(self.path, "edges") def naming_table_blob_file(self) -> str: return os.path.join(self.path, "hh_mini") def depgraph_file(self) -> str: return os.path.join(self.path, "hh_mini.hhdg") def naming_table_sqlite_file(self) -> str: return os.path.join(self.path, "hh_naming.sql") def saved_state_spec(self, changed_files: List[str]) -> str: return json.dumps( { "data_dump": { "deptable": self.depgraph_file(), "state": self.naming_table_blob_file(), "changes": changed_files, "prechecked_changes": [], "corresponding_base_revision": "-1", } } ) @attr.s(auto_attribs=True) class ExecResult(object): exit_code: int stdout: str stderr: str def _exec( args: List[str], capture_output: bool = True, timeout: int = 300, text: bool = True, check: bool = True, **kwargs: Any, ) -> subprocess.CompletedProcess[str]: logging.debug("_exec: run: %s (%s)", args, kwargs) try: v = subprocess.run( args, capture_output=capture_output, timeout=timeout, text=text, check=check, **kwargs, ) except subprocess.CalledProcessError as e: logging.debug( "_exec: error (%d):\n=== STDOUT ===\n%s\n=== STDERR ===\n%s\n", e.returncode, e.stdout, e.stderr, ) raise logging.debug("_exec: result: %s", repr(v)) return v def _create_temporary_directory(category: str, filename: str) -> str: # use TEMP on Sandcastle, this is autocleaned return tempfile.mkdtemp( prefix="{}-{}-".format(os.path.basename(filename), category), dir=os.getenv("TEMP"), ) def _prepare_repo_root(test: FanoutTest) -> RepoRoot: repo_root = RepoRoot(_create_temporary_directory("repo", test.filename)) logging.debug("Preparing repo root in %s", repo_root.path) os.mknod(repo_root.hhconfig_file()) test.prepare_base_php_contents(repo_root.path) return repo_root def _make_repo_change(repo_root: RepoRoot, test: FanoutTest) -> List[str]: logging.debug("Updating repo root at %s", repo_root.path) return test.prepare_changed_php_contents(repo_root.path) def _create_saved_state( bins: Binaries, repo_root: RepoRoot, test: FanoutTest ) -> Tuple[subprocess.CompletedProcess[str], SavedStateDir]: saved_state_dir = SavedStateDir(_create_temporary_directory("ss", test.filename)) logging.debug( "Generating saved-state for %s in %s", repo_root.path, saved_state_dir.path ) logging.debug("Step 1/3: Generating edges to %s", saved_state_dir.edges_dir()) _exec(["mkdir", "-p", saved_state_dir.edges_dir()]) bins.exec_hh( [ "--no-load", "--save-64bit", saved_state_dir.edges_dir(), "--save-state", saved_state_dir.naming_table_blob_file(), "--gen-saved-ignore-type-errors", "--error-format", "raw", "--config", "store_decls_in_saved_state=true", ] + DEFAULT_HH_SERVER_FLAGS + [ repo_root.path, ] ) hh_result = bins.exec_hh(["--error-format", "raw", repo_root.path]) logging.debug( "Step 2/3: Writing naming table to %s", saved_state_dir.naming_table_sqlite_file(), ) bins.exec_hh( [ "--save-naming", saved_state_dir.naming_table_sqlite_file(), repo_root.path, ] ) bins.exec_hh_stop(repo_root.path) logging.debug( "Step 3/3: Building dependency graph to %s", saved_state_dir.depgraph_file() ) bins.exec_legacy_hh_fanout( [ "build", "--edges-dir", saved_state_dir.edges_dir(), "--output", saved_state_dir.depgraph_file(), ] ) _exec(["rm", "-rf", saved_state_dir.edges_dir()]) return (hh_result, saved_state_dir) def _build_fanout_hash_map(bins: Binaries, test: FanoutTest) -> Dict[str, str]: m = {} r = bins.exec_hh_single_type_check( ["--dump-dep-hashes", "--no-builtins", test.filename] ) for line in r.stdout.splitlines(): line = line.strip() symbol_hash, symbol_name = WHITESPACE_SPLITTER.split(line, 1) m[symbol_hash] = symbol_name return m def _launch_hh_from_saved_state( bins: Binaries, repo_root: RepoRoot, saved_state_dir: SavedStateDir, changed_files: List[str], ) -> subprocess.CompletedProcess[str]: logging.debug("Launching hh from saved-state for %s", repo_root.path) hh_result = bins.exec_hh( [ "--config", "use_mini_state=true", "--config", "lazy_decl=true", "--config", "lazy_init2=true", "--config", "lazy_parse=true", "--with-mini-state", saved_state_dir.saved_state_spec(changed_files), "--config", "naming_sqlite_path={}".format(saved_state_dir.naming_table_sqlite_file()), "--config", "naming_sqlite_path={}".format(saved_state_dir.naming_table_sqlite_file()), "--config", "enable_naming_table_fallback=true", "--config", "log_categories=fanout_information", "--error-format", "raw", ] + DEFAULT_HH_SERVER_FLAGS + [ repo_root.path, ] ) return hh_result def _extract_fanout_information( bins: Binaries, repo_root: RepoRoot, tags: List[str] ) -> List[FanoutInformation]: server_log_file = bins.exec_hh(["--logname", repo_root.path]).stdout.strip() logging.debug("Extracting fanout information from %s", server_log_file) fis = FanoutInformation.extract_from_log_file(server_log_file) return [fi for fi in fis if fi.tag in tags] def _strip_repo_root_from_output(repo_root: str, output: str) -> str: if repo_root[-1:] != os.sep: repo_root += os.sep return output.replace(repo_root, "") def _format_result( fanout_information: List[FanoutInformation], fanout_hash_map: Dict[str, str], ) -> None: symbols = [] for fi in fanout_information: symbols += [fanout_hash_map.get(h, h) for h in fi.hashes] symbols.sort() for s in symbols: print(s) def run_scenario_saved_state_init(bins: Binaries, test: FanoutTest) -> None: """Run the saved-state init fanout scenario. This scenario involves a saved-state init with some local changes. It includes the following steps: 1. Build a saved-state for the base version 2. Kill hack 3. Make the repo changes 4. Initialize from the saved-state 5. Extract saved-state fanout """ repo_root = _prepare_repo_root(test) fanout_hash_map = _build_fanout_hash_map(bins, test) (hh_result_base, saved_state_dir) = _create_saved_state(bins, repo_root, test) changed_files = _make_repo_change(repo_root, test) _launch_hh_from_saved_state( bins, repo_root, saved_state_dir, changed_files=changed_files, ) bins.exec_hh_stop(repo_root.path) fanout_information = _extract_fanout_information( bins, repo_root, tags=["saved_state_init_fanout"] ) _format_result( fanout_information=fanout_information, fanout_hash_map=fanout_hash_map, ) repo_root.cleanup() saved_state_dir.cleanup() def run_scenario_incremental_no_old_decls(bins: Binaries, test: FanoutTest) -> None: """Run the incremental fanout scenario with old decls unavailable. This scenario involves calculating the fanout in an incremental change scenario (i.e. after saved-state initialization was successful), but where the old versions of the declarations are unavailable and thus fine-grained decl diffing is impossible. 1. Build a saved-state for the base version 2. Kill hack 3. Initialize from the saved-state, but disabled cached decl loading 4. Make the change 5. Type check and extract fanout """ repo_root = _prepare_repo_root(test) fanout_hash_map = _build_fanout_hash_map(bins, test) (hh_result_base, saved_state_dir) = _create_saved_state(bins, repo_root, test) _launch_hh_from_saved_state( bins, repo_root, saved_state_dir, changed_files=[], ) _make_repo_change(repo_root, test) bins.exec_hh(["--error-format", "raw", repo_root.path]) bins.exec_hh_stop(repo_root.path) fanout_information = _extract_fanout_information( bins, repo_root, tags=["incremental_fanout"] ) _format_result( fanout_information=fanout_information, fanout_hash_map=fanout_hash_map, ) repo_root.cleanup() saved_state_dir.cleanup() def run_scenario_incremental_with_old_decls(bins: Binaries, test: FanoutTest) -> None: """Run the incremental fanout scenario with old decls available. This scenario involves calculating the fanout in an incremental change scenario (i.e. after saved-state initialization was successful), and where the old versions of the declarations are available and thus fine-grained decl diffing is possible. 1. Build a saved-state for the base version 2. Kill hack 3. Initialize from the saved-state, forcing a re-typecheck of all files to make sure all decls are present in shared memory. 4. Make the change 5. Type check and extract fanout """ repo_root = _prepare_repo_root(test) fanout_hash_map = _build_fanout_hash_map(bins, test) (hh_result_base, saved_state_dir) = _create_saved_state(bins, repo_root, test) _launch_hh_from_saved_state( bins, repo_root, saved_state_dir, changed_files=test.all_base_php_files(), ) _make_repo_change(repo_root, test) bins.exec_hh(["--error-format", "raw", repo_root.path]) bins.exec_hh_stop(repo_root.path) fanout_information = _extract_fanout_information( bins, repo_root, tags=["incremental_fanout"] ) _format_result( fanout_information=fanout_information, fanout_hash_map=fanout_hash_map, ) repo_root.cleanup() saved_state_dir.cleanup()
Python
hhvm/hphp/hack/test/fanout/tools/fanout_test_parser.py
# pyre-strict import logging import os import re from typing import Dict, List import attr # pyre-fixme[24]: Generic type `re.Pattern` expects 1 type parameter. MULTIFILE_SPLITTER: re.Pattern = re.compile(r"^////\s*(.*?)\s*$") # pyre-fixme[24]: Generic type `re.Pattern` expects 1 type parameter. FILENAME_MATCHER: re.Pattern = re.compile(r"^(base|changed)-(.+?)\s*$") @attr.s(auto_attribs=True, str=True) class MultifileParseError(Exception): filename: str line_number: int error: str @attr.s(auto_attribs=True, str=True) class FanoutTestReadError(Exception): filename: str error: str def parse_multifile_contents(filename: str) -> Dict[str, str]: result = {} current_file = None current_body = [] with open(filename, "r") as fp: for line_no, line in enumerate(fp): line_no = line_no + 1 m = MULTIFILE_SPLITTER.match(line) if m: if current_file is not None: result[current_file] = "".join(current_body) current_file = m.group(1) current_body = [] if len(current_file) == 0: raise MultifileParseError( filename, line_no, "No filename specified on this line." ) if current_file in result: raise MultifileParseError( filename, line_no, "Duplicate filename on this line." ) else: if current_file is None: raise MultifileParseError( filename, line_no, "Expected a multifile filename on this line." ) current_body.append(line) if current_file is not None: result[current_file] = "".join(current_body) return result @attr.s(auto_attribs=True) class FanoutTest(object): """Represents a fanout test scenario. We make use of the multifile format, e.g.: ``` //// base-a.php <?hh class A {} //// base-b.php class B extends A {} //// changed-a.php <?hh class A { public function foo(): void {}} //// changed-b.php <?hh class B extends A {} ``` Corresponds to a repo with two files `a.php` and `b.php` """ filename: str base_php_contents: Dict[str, str] changed_php_contents: Dict[str, str] @staticmethod def from_file(filename: str) -> "FanoutTest": multifile = parse_multifile_contents(filename) base_php_contents = {} changed_php_contents = {} for fn, contents in multifile.items(): m = FILENAME_MATCHER.match(fn) if not m: raise FanoutTestReadError( filename=filename, error="Could not interpret multifile item with name {}".format(fn), ) kind = m.group(1) subfn = m.group(2) if kind == "base": base_php_contents[subfn] = contents elif kind == "changed": changed_php_contents[subfn] = contents else: raise AssertionError() return FanoutTest( filename=filename, base_php_contents=base_php_contents, changed_php_contents=changed_php_contents, ) def prepare_base_php_contents(self, destination_dir: str) -> None: for fn, contents in self.base_php_contents.items(): fn = os.path.join(destination_dir, fn) logging.debug("Writing to %s:\n%s\nEOF", fn, contents) with open(fn, "w") as fp: fp.write(contents) def prepare_changed_php_contents(self, destination_dir: str) -> List[str]: changed_files = [ fn for fn in self.base_php_contents if fn not in self.changed_php_contents ] for fn in changed_files: fn = os.path.join(destination_dir, fn) logging.debug("Removing %s", fn) os.unlink(fn) for fn, contents in self.changed_php_contents.items(): if self.base_php_contents.get(fn, "").strip() != contents.strip(): changed_files.append(fn) fn = os.path.join(destination_dir, fn) logging.debug("Writing to %s:\n%s\nEOF", fn, contents) with open(fn, "w") as fp: fp.write(contents) return changed_files def all_base_php_files(self) -> List[str]: return list(self.base_php_contents.keys())
PHP
hhvm/hphp/hack/test/fanout/xhp/add_attr_missing.php
//// base-a.php <?hh class :element { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; } //// changed-a.php <?hh class :element { attribute string prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/add_attr_missing_child.php
//// base-a.php <?hh class :element { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-child.php <?hh class :child extends :element { } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child prop={$prop} />; } //// changed-a.php <?hh class :element { attribute string prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-child.php <?hh class :child extends :element { } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/add_attr_missing_child_special.php
//// base-a.php <?hh class :element { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-child.php <?hh class :child extends :element { } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child aria-x={$prop} />; } //// changed-a.php <?hh class :element { attribute string aria-x; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-child.php <?hh class :child extends :element { } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child aria-x={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/add_attr_missing_special.php
//// base-a.php <?hh class :element { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element data-x={$prop} />; } //// changed-a.php <?hh class :element { attribute string data-x; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element data-x={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/add_attr_parent_has.php
//// base-a.php <?hh class :element { attribute arraykey prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-child.php <?hh class :child extends :element { } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child prop={$prop} />; } //// changed-a.php <?hh class :element { attribute arraykey prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-child.php <?hh class :child extends :element { attribute string prop; } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/change_attribute.php
//// base-a.php <?hh class :element { attribute int prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; } //// changed-a.php <?hh class :element { attribute string prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/change_attr_use_child.php
//// base-a.php <?hh class :element { attribute arraykey prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-child.php <?hh class :child extends :element { } //// base-gchild.php <?hh class :gchild extends :child { attribute arraykey prop; } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child prop={$prop} />; } //// changed-a.php <?hh class :element { attribute float prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-child.php <?hh class :child extends :element { } //// changed-gchild.php <?hh class :gchild extends :child { attribute arraykey prop; } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <child prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/make_required_attributes.php
//// base-a.php <?hh class :element { attribute int prop @required, string prop2; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; } //// changed-a.php <?hh class :element { attribute int prop @required, string prop2 @required; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/remove_attributes.php
//// base-a.php <?hh class :element { attribute int prop; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; } //// changed-a.php <?hh class :element { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/required_attributes.php
//// base-a.php <?hh class :element { attribute int prop @required; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; } //// changed-a.php <?hh class :element { attribute int prop @required, string prop2 @required; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :element{ return <element prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/required_attributes_hierarchy.php
//// base-a.php <?hh class :element { attribute int prop @required; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-child.php <?hh class :child extends :element {} //// base-b.php <?hh function xhp_simple_attribute(int $prop): :child { return <child prop={$prop} />; } //// changed-a.php <?hh class :element { attribute int prop @required, string prop2 @required; public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-child.php <?hh class :child extends :element {} //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :child { return <child prop={$prop} />; }
PHP
hhvm/hphp/hack/test/fanout/xhp/required_attributes_hierarchy_2.php
//// base-parent.php <?hh abstract class :base { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// base-a.php <?hh abstract class :element extends :base { attribute int prop @required; } //// base-child.php <?hh final class :child extends :element {} //// base-b.php <?hh function xhp_simple_attribute(int $prop): :child{ return <child prop={$prop} />; } //// changed-parent.php <?hh abstract class :base { public function __construct( public darray<string, dynamic> $attributes, public varray<dynamic> $children, public string $file, public int $line, ) {} } //// changed-a.php <?hh abstract class :element extends :base { attribute int prop @required, string prop2 @required; } //// changed-child.php <?hh final class :child extends :element {} //// changed-b.php <?hh function xhp_simple_attribute(int $prop): :child{ return <child prop={$prop} />; }
PHP
hhvm/hphp/hack/test/find_local/class.php
<?hh class C { public function f($x) { $this->g($this); // Should find both } public function g($x) { $this->f($this); // Should not find } }
PHP
hhvm/hphp/hack/test/find_local/dollardollar.php
<?hh function test() { (a() |> // introduces $$ 1 b($$)) // $$ 1 |> // introduces $$ 2 (c( (d($$) // $$ 2 should find |> // introduces $$ 3 e($$)), // $$ 3 $$)); // $$ 2 should find }
hhvm/hphp/hack/test/find_local/dune
(rule (alias find_local) (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/find_local/HH_FLAGS) (glob_files %{project_root}/hack/test/find_local/*.flags) (glob_files %{project_root}/hack/test/find_local/*.php) (glob_files %{project_root}/hack/test/find_local/*.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/find_local --program %{exe:../../src/hh_single_type_check.exe}))) (alias (name runtest) (deps (alias find_local)))
PHP
hhvm/hphp/hack/test/find_local/error.php
<?hh class C { private static float $foo = $bar + ; // Parse error public function M($bar) // $bar should be found regardless of the error. { $abc = $bar; // $bar should be found regardless of the error. } public function N() { $abc = $bar; // Should not be found } }
PHP
hhvm/hphp/hack/test/find_local/function.php
<?hh // 2 function test($x) { // 3 Should match $x = 3; // Looking for this $x. // 4 Should match g($x) + $x + h("\$x = $x"); // 5 First three should match $lambda1 = $x ==> $x + 1; // 6 Should not match $lambda2 = $a ==> $x + $a; // 7 Should match $lambda3 = function($x) { // 8 Should not match return $x + 1; }; // 9 Should not match $lambda4 = function($b) use($x) { // 10 Should match return $x + $b; }; // 11 Should match $lambda5 = function($x) use($x) { // 12 Second should match return $x; }; // 13 Should not match if (f($x)) g($x); else h($x); // 14 Three should match do { g($x); } while (f($x)); // 15 Two should match for ($x = 1; $x < 3; $x = 2 * $x) // 16 Four should match while (f(shape('x' => $x)) // 17 Should match foreach($x as $x) // 18 Two should match foreach($x as $x => $x) ; // 19 Three should match try { f(clone $x); } // 20 Should match catch (F $x) { g($x); } // 21 Should not match catch (G $e) { g($x); } // 22 Should match switch (f($x)) { // 23 Should match case $x: g($x); break; } // 24 Two should match echo $x, (string)$x; // 25 Two should match return <div>{$x}</div>; } // 26 Should match
PHP
hhvm/hphp/hack/test/find_refs/abs_const.php
<?hh // strict abstract class C { abstract const string FOO; public function test(): void { static::FOO; } } class D extends C { const FOO = "aa"; } function test(): void { D::FOO; }
PHP
hhvm/hphp/hack/test/find_refs/class.php
<?hh abstract class Foo { public Foo $prop = "aaa"; public static Foo $static_prop = "aaa"; const Foo CONST = "aaa"; abstract const Foo ABS_CONST; const type type_const = Foo; public function method(Generic<Foo> $x, $y) { if ($y is Foo) { } try { might_throw(); } catch (Foo $foo) { } } public static function staticMethod() {} public static function anotherStaticMethod() { self::staticMethod(); self::$static_prop = "bbb"; } } function might_throw(): void {} type Alias = Foo; trait T { require extends Foo; } abstract class C extends Foo { public static function yetAnotherStaticMethod() { parent::staticMethod(); } } function test<T as Foo>( Foo $c ): Foo { return new Foo(); } function special_funcs() { Foo::staticMethod<>; meth_caller(Foo::class, 'method'); meth_caller('Foo', 'method'); Alias::staticMethod<>; // TODO: This is not detected meth_caller(Alias::class, 'method'); // TODO: This is not detected meth_caller('Alias', 'method'); // TODO: This is not detected }
PHP
hhvm/hphp/hack/test/find_refs/class_const.php
<?hh class C { const int foo = 3; public static ?string $foo; public static function foo() {} public function test() { self::foo; $this::foo; C::foo; static::foo; } } class D extends C { public function test() { self::foo; $this::foo; C::foo; static::foo; parent::foo; } } type E = C; newtype F = C; function test(C $c, D $d, E $e, F $f) { $c::foo; $d::foo; $e::foo; $f::foo; C::foo; D::foo; $c::$foo; $c::foo(); }
PHP
hhvm/hphp/hack/test/find_refs/dead_code.php
<?hh // strict class E extends Exception {} function test_invariant(): void { invariant_violation('This is dead code'); new E(); } function test_if_false(): void { if (false) { new E(); } } function test_try_catch(): void { try {} catch (E $_) { new E(); } try { () ==> {}(); } catch (E $_) { new E(); } }
hhvm/hphp/hack/test/find_refs/dune
(rule (alias find_refs) (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/find_refs/HH_FLAGS) (glob_files %{project_root}/hack/test/find_refs/*.flags) (glob_files %{project_root}/hack/test/find_refs/*.php) (glob_files %{project_root}/hack/test/find_refs/*.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/find_refs --program %{exe:../../src/hh_single_type_check.exe}))) (alias (name runtest) (deps (alias find_refs)))
PHP
hhvm/hphp/hack/test/find_refs/enum.php
<?hh //strict enum Size: int { SMALL = 0; MEDIUM = 1; LARGE = 2; } function test_rename(): void { $size = Size::SMALL; // Find ref }
PHP
hhvm/hphp/hack/test/find_refs/enum_class.php
<?hh interface IBox {} class Box<T> implements IBox { public function __construct(public T $x)[] {} } enum class EBox : IBox { Box<int> A = new Box(42); Box<string> B = new Box('zuck'); } function f(HH\MemberOf<EBox, Box<int>> $member) : int { return $member->x; } function testit(): void { echo f(EBox::A); echo "\n"; }
PHP
hhvm/hphp/hack/test/find_refs/function.php
<?hh function foo() { foo(); foo<>; } class C { public function __construct( public $x = foo(), ) { foo(); foo<>; } } function test() { foo(); foo<>; }
PHP
hhvm/hphp/hack/test/find_refs/global_use_of_const.php
<?hh // strict // Copyright 2004-present Facebook. All Rights Reserved. class Foo { const string FOO = 'foo'; } function foo() { Foo::FOO; } const string BAR = Foo::FOO;
PHP
hhvm/hphp/hack/test/find_refs/localvar.php
<?hh class C { public function foo() { $this->foo(); $x = 1; // 1 Should not match } public function x() { $x = 2; // 2 Should not match } } function test($x) { // 3 Should match $x = 3; // Looking for this $x // 4 Should match g($x) + $x + h("\$x = $x"); // 5 First, second, and fourth should match $lambda1 = $x ==> $x + 1; // 6 Should not match $lambda2 = $a ==> $x + $a; // 7 Should match $lambda3 = function($x) { // 8 Should not match return $x + 1; }; // 9 Should not match $lambda4 = function($b) use($x) { // 10 Should match return $x + $b; }; // 11 Should match $lambda5 = function($x) use($x) { // 12 Second should match return $x; }; // 13 Should not match if (f($x)) g($x); else h($x); // 14 Three should match do { g($x); } while (f($x)); // 15 Two should match for ($x = 1; $x < 3; $x = 2 * $x) // 16 Four should match while (f(shape('x' => $x)) // 17 Should match foreach($x as $x) // 18 Two should match foreach($x as $x => $x) ; // 19 Three should match try { f(clone $x); } // 20 Should match catch (F $x) { g($x); } // 21 Should not match catch (G $e) { g($x); } // 22 Should match switch (f($x)) { // 23 Should match case $x: g($x); break; } // 24 Two should match echo $x, (string)$x; // 25 Two should match return <div>{$x}</div>; // 26 Should match }
PHP
hhvm/hphp/hack/test/find_refs/method.php
<?hh class C { public function foo(): void { $this->foo(); } } class D extends C { public function f(): void { $this->foo(); } } class F extends D { public function foo(): void {} } class G extends F {} class Unrelated { public function foo(): void {} } type E = D; function test(C $c, D $d, E $e, F $f, G $g, Unrelated $u) { $c->foo(); $d->foo(); $e->foo(); //TODO(?): this will say D::foo(). Should it say E::foo() instead? $f->foo(); $g->foo(); $u->foo(); meth_caller('C', 'foo'); meth_caller('D', 'foo'); meth_caller('E', 'foo'); // TODO: This is not detected meth_caller('F', 'foo'); // TODO: This is not detected meth_caller('G', 'foo'); // TODO: This is not detected meth_caller('Unrelated', 'foo'); // TODO: This is not detected }
PHP
hhvm/hphp/hack/test/find_refs/method_vs_prop.php
<?hh class C { const int foo = 3; public ?string $foo; public function foo() {} } function test(C $c) { $c->foo; $c->foo(); C::foo; }
PHP
hhvm/hphp/hack/test/find_refs/property.php
<?hh class C { const int foo = 3; public ?string $foo; public function foo() {} public function test() { $this->foo; } } class D extends C { public function test() { $this->foo; } } type E = C; newtype F = C; function test(C $c, D $d, E $e, F $f) { $c->foo; $d->foo; $e->foo; $f->foo; $c->foo(); C::foo; }
PHP
hhvm/hphp/hack/test/find_refs/rename_class_meth.php
<?hh //strict class RenameClassMethClass { public function instance_test_method(): int { return 2; } // Find-refs should be able to find all these uses of instance_test_method // When the method is wrapped in apostrophes, the capture should be only // the method name public function other_method(): int { $this->instance_test_method(); meth_caller(RenameClassMethClass::class, 'instance_test_method'); return 0; } }
PHP
hhvm/hphp/hack/test/find_refs/rename_global_meth.php
<?hh //strict function global_test_method(): int { return 1; } class RenameGlobalMethClass { // Find-refs should be able to find all these uses of global_test_method // When the method is wrapped in apostrophes, the capture should be only // the method name public static function other_method(): int { global_test_method(); $bar = global_test_method<>; return 0; } }
PHP
hhvm/hphp/hack/test/find_refs/rename_static_meth.php
<?hh //strict final class RenameStaticMethClass { public static function static_test_method(): int { return 1; } // Find-refs should be able to find all these uses of static_test_method // When the method is wrapped in apostrophes, the capture should be only // the method name public static function other_method(): int { self::static_test_method(); RenameStaticMethClass::static_test_method(); self::static_test_method<>; RenameStaticMethClass::static_test_method<>; return 0; } }
PHP
hhvm/hphp/hack/test/find_refs/require_extends.php
<?hh class ReqExtendsClass { public function foo(): int { return 0; } } interface FooRequireExtends { require extends ReqExtendsClass; } function foo_test_require_extends(FooRequireExtends $req_extends_test) { $req_extends_test->foo(); // Find ref }
PHP
hhvm/hphp/hack/test/find_refs/shape_key.php
<?hh enum ShapeKey: string as string { A = 'a'; } type Foo = shape( ShapeKey::A => string, // Find ref ); function test_shape_key(): void { shape(ShapeKey::A => '123'); // Find ref }
PHP
hhvm/hphp/hack/test/find_refs/static_method.php
<?hh class C { public static function foo() { self::foo(); C::foo(); } } class D extends C { public function f() { self::foo(); static::foo(); } } type E = D; function test() { C::foo(); D::foo(); E::foo(); // TODO: This is not detected C::foo<>; D::foo<>; E::foo<>; // TODO: This is not detected }
PHP
hhvm/hphp/hack/test/find_refs/static_property.php
<?hh class C { const int foo = 3; public static ?string $foo; public static function foo() {} public function test() { self::$foo; $this::$foo; C::$foo; static::$foo; } } class D extends C { public function test() { self::$foo; $this::$foo; C::$foo; static::$foo; parent::$foo; } } type E = C; newtype F = C; function test(C $c, D $d, E $e, F $f) { $c::$foo; $d::$foo; $e::$foo; $f::$foo; C::$foo; D::$foo; $c::foo(); C::foo; } function takesString(string $s): void {} function testFakeMembers(C $c, D $d, E $e, F $f): void { if ($c::$foo === null) { $c::$foo = 'foo'; takesString($c::$foo); } if ($d::$foo === null) { $d::$foo = 'foo'; takesString($d::$foo); } if ($e::$foo === null) { $e::$foo = 'foo'; takesString($e::$foo); } if ($f::$foo === null) { $f::$foo = 'foo'; takesString($f::$foo); } if (C::$foo === null) { C::$foo = 'foo'; takesString(C::$foo); } if (D::$foo === null) { D::$foo = 'foo'; takesString(D::$foo); } }
PHP
hhvm/hphp/hack/test/find_refs/typeconst.php
<?hh abstract class C { abstract const type BAR as string; } class D extends C { const type BAR = string; } class E { const type FOO = D; } function test(D::BAR $_): E::FOO::BAR { return ""; }
PHP
hhvm/hphp/hack/test/find_refs/xhp_class.php
<?hh class :xhp:foo-element {} class :xhp:bar { attribute :xhp:foo-element; public function genFoo( :xhp:foo-element $e, ): :xhp:foo-element { return <xhp:foo-element />; } } function test( :xhp:foo-element $e, ): :xhp:foo-element { return <xhp:foo-element />; }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/await_new_precedence.php
<?hh // strict // Copyright 2004-present Facebook. All Rights Reserved. async function foo(mixed $a, mixed $b, mixed $c, mixed $x) : Awaitable<void> { await $a++; // still await ($a++) to force people to make their // callsites (await $a)++ to clarify readability. await ++$a; // and this doesn't care because they're unary prefix. await $a + $x; await await $a; await $a->bar($x); await $a->bar($x) is vec; await $a * $x; await $a |> $b($$) |> $c($$); await $a ? $b : $c; await foo<int>(); }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/await_old_precedence.php
<?hh // strict // Copyright 2004-present Facebook. All Rights Reserved. async function foo(mixed $a, mixed $b, mixed $c, mixed $x) : Awaitable<void> { await $a++; // still await ($a++) to force people to make their // callsites (await $a)++ to clarify readability. await ++$a; // and this doesn't care because they're unary prefix. await $a + $x; await await $a; await $a->bar($x); await $a->bar($x) is vec; await $a * $x; await $a |> $b($$) |> $c($$); await $a ? $b : $c; }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/collection_initializers16.php
<?hh // strict // Copyright 2004-present Facebook. All Rights Reserved. function foo(): void { $n = Map<arraykey,bool>{}; }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/const_expression_tree.php
<?hh <<file:__EnableUnstableFeatures('expression_trees')>> function test(): void { ExampleDsl`MY_CONST`; }
hhvm/hphp/hack/test/full_fidelity/cases/dune
(rule (alias full_fidelity_errors_test) (deps %{exe:../../../src/hh_parse.exe} %{project_root}/hack/test/verify.py %{project_root}/hack/test/review.sh (glob_files %{project_root}/hack/test/full_fidelity/cases/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/*.flags) (glob_files %{project_root}/hack/test/full_fidelity/cases/abstract_static_props/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/abstract_static_props/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/abstract_static_props/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/atted_attribute_syntax/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/atted_attribute_syntax/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/atted_attribute_syntax/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/error/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/error/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/error/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/byref-assignment/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/byref-assignment/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/byref-assignment/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/error/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/error/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/context/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/context/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/final_interface_trait/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/final_interface_trait/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/final_interface_trait/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/function_default_args/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/function_default_args/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/function_default_args/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/hh_parse/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/hh_parse/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/hh_parse/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_attribute_syntax/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_attribute_syntax/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_attribute_syntax/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_soft_typehints/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_soft_typehints/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_soft_typehints/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/error/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/error/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/error/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/modes/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/modes/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/static_const_props/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/static_const_props/*.errors.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/static_const_props/HH_FLAGS)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/full_fidelity/cases --out-extension .errors.out --expect-extension .errors.exp --program %{exe:../../../src/hh_parse.exe} --flags --full-fidelity-errors --allow-unstable-features))) (rule (alias full_fidelity_json_test) (deps %{exe:../../../src/hh_parse.exe} %{project_root}/hack/test/verify.py %{project_root}/hack/test/review.sh (glob_files %{project_root}/hack/test/full_fidelity/cases/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/*.flags) (glob_files %{project_root}/hack/test/full_fidelity/cases/abstract_static_props/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/abstract_static_props/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/abstract_static_props/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/atted_attribute_syntax/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/atted_attribute_syntax/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/atted_attribute_syntax/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/error/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/error/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/await_as_an_expression/error/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/byref-assignment/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/byref-assignment/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/byref-assignment/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/error/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/concurrent/error/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/context/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/context/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/final_interface_trait/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/final_interface_trait/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/final_interface_trait/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/function_default_args/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/function_default_args/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/function_default_args/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/hh_parse/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/hh_parse/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/hh_parse/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_attribute_syntax/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_attribute_syntax/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_attribute_syntax/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_soft_typehints/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_soft_typehints/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/legacy_soft_typehints/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/error/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/error/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/lval_as_an_expression/error/HH_FLAGS) (glob_files %{project_root}/hack/test/full_fidelity/cases/modes/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/modes/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/static_const_props/*.php) (glob_files %{project_root}/hack/test/full_fidelity/cases/static_const_props/*.json.exp) (glob_files %{project_root}/hack/test/full_fidelity/cases/static_const_props/HH_FLAGS)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/full_fidelity/cases --out-extension .json.out --expect-extension .json.exp --program %{exe:../../../src/hh_parse.exe} --flags --full-fidelity-json-parse-tree --pretty-print-json --allow-unstable-features --ignore-missing-json))) (alias (name runtest) (deps (alias full_fidelity_errors_test) (alias full_fidelity_json_test)))
PHP
hhvm/hphp/hack/test/full_fidelity/cases/empty_stdClass_prop.php
<?hh // Copyright 2004-present Facebook. All Rights Reserved. class EmptyStdClassProp { public function foo():void{ $o = new stdClass(); $o->{''} = true; } }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/higher_kinded_types_good.php
<?hh // strict function test1<T1<_>>() : void {} class Test1<T1<X>> {} type foo<T1<X> as SomeClass> = bool; function test2<T1<TX as Foo<X>>>() : void {} function test3<T1<TX as Foo<TX>> as Foo<TX>>() : void {} function test4<T1<+TX>, T2>() : void {} function test5<C<_>, T2>() : void {}
PHP
hhvm/hphp/hack/test/full_fidelity/cases/inout_in_new.php
<?hh // strict class Foo { public function __construct(inout $bar) {} } function foo($bar) { new Foo(inout $bar); PHP\var_dump($bar); }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_class.php
<?hh // We can't write many of the modifiers or this won't parse as a class (yet). // Eventually we want to be testing: // abstract final static private protected public async coroutine class C {} abstract final class C {} abstract abstract class D {}
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_const.php
<?hh class C { abstract final static private protected public async const X; abstract abstract const Y; }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_function.php
<?hh // async needs to be first so that we parse this as a function declaration async abstract final static private protected public function f() {} async async function g() {}
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_interface.php
<?hh // We can't write many of the modifiers or this won't parse as an interface (yet). // Eventually we want to be testing: // abstract final static private protected public async coroutine interface C {} abstract final interface C {} abstract abstract interface D {}
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_method.php
<?hh abstract class C { // For now, methods are allowed to have all the possible modifiers, so this // verifies that we only get errors about the way they're being combined abstract final static private protected public async function f(); abstract abstract public function g(); }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_property.php
<?hh class C { abstract final static private protected public async $x = 1; static static public $y = 2; }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_trait.php
<?hh // We can't write many of the modifiers or this won't parse as a trait (yet). // Eventually we want to be testing: // abstract final static private protected public async coroutine trait C {} abstract final trait C {} abstract abstract trait D {}
PHP
hhvm/hphp/hack/test/full_fidelity/cases/invalid_modifiers_type_const.php
<?hh class C { abstract final static private protected public async coroutine const type T = int; abstract abstract const type U = string; }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_class_allowed.php
<?hh class attribute {} class binary {} class category {} class children {} class enum {} class fallthrough {} class is {} class let {} class newtype {} class Object {} class object {} class super {} class type {} class where {} new attribute(); new binary(); new category(); new children(); new enum(); new fallthrough(); new is(); new let(); new newtype(); new Object(); new object(); new super(); new type(); new where();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_class_reserved.php
<?hh // not allowed because reserved class arraykey {} class bool {} class boolean {} class classname {} class darray {} class dict {} class double {} class false {} class float {} class int {} class integer {} class keyset {} class mixed {} class noreturn {} class null {} class num {} class parent {} class real {} class resource {} class self {} class string {} class this {} class true {} class varray {} class vec {} class void {} new arraykey(); new bool(); new boolean(); new classname(); new darray(); new dict(); new double(); new false(); new float(); new int(); new integer(); new keyset(); new mixed(); new noreturn(); new null(); new num(); new parent(); new real(); new resource(); new self(); new string(); new this(); new true(); new varray(); new vec(); new void();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_class_reserved_php.php
<?hh // make sure hack reserved keywords are allowed in php files class arraykey {} class bool {} class boolean {} class classname {} class darray {} class dict {} class double {} class false {} class float {} class int {} class integer {} class keyset {} class mixed {} class noreturn {} class null {} class num {} class parent {} class real {} class resource {} class self {} class string {} class this {} class true {} class varray {} class vec {} class void {} new arraykey(); new bool(); new boolean(); new classname(); new darray(); new dict(); new double(); new false(); new float(); new int(); new integer(); new keyset(); new mixed(); new noreturn(); new null(); new num(); new parent(); new real(); new resource(); new self(); new string(); new this(); new true(); new varray(); new vec(); new void();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_class_unexpected.php
<?hh // Raise "Unexpected token" class abstract {} class array {} class as {} class break {} class case {} class catch {} class class {} class clone {} class const {} class continue {} class default {} class do {} class echo {} class else {} class empty {} class endif {} class eval {} class extends {} class final {} class finally {} class for {} class foreach {} class function {} class global {} class if {} class implements {} class include {} class include_once {} class inout {} class instanceof {} class insteadof {} class interface {} class isset {} class list {} class namespace {} class new {} class print {} class private {} class protected {} class public {} class require {} class require_once {} class return {} class shape {} class static {} class switch {} class throw {} class trait {} class try {} class unset {} class use {} class using {} class var {} class while {} class yield {} new abstract(); new array(); new as(); new break(); new case(); new catch(); // new class(); // can't test this; error recovery makes us stop parsing the new expression when we see the class token; then we start parsing from the class token as if we have a classish declaration, and the entire rest of the test is seen as a classish body new clone(); new const(); new continue(); new declare(); new default(); new do(); new echo(); new else(); new empty(); new endfor(); new endforeach(); new enddeclare(); new endif(); new endswitch(); new endwhile(); new eval(); new extends(); new final(); new finally(); new for(); new foreach(); new function(); new global(); new if(); new implements(); new include(); new include_once(); new inout(); new instanceof(); new insteadof(); // new interface(); // can't test this; error recovery makes us stop parsing the new expression when we see the interface token; then we start parsing from the interface token as if we have a classish declaration, and the entire rest of the test is seen as a classish body new isset(); new list(); new namespace(); new new(); new print(); new private(); new protected(); new public(); new require(); new require_once(); new return(); new shape(); new static(); new switch(); new throw(); // new trait(); // can't test this; error recovery makes us stop parsing the new expression when we see the trait token; then we start parsing from the trait token as if we have a classish declaration, and the entire rest of the test is seen as a classish body new try(); new unset(); new use(); new using(); new var(); new while(); new yield();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_const.php
<?hh // everything is allowed as a constant!! const abstract = 1; const and = 1; const array = 1; const arraykey = 1; const as = 1; const attribute = 1; const binary = 1; const bool = 1; const boolean = 1; const break = 1; const case = 1; const catch = 1; const category = 1; const children = 1; const class = 1; const classname = 1; const clone = 1; // const const = 1; // "Notice: Constant const already defined" const continue = 1; const coroutine = 1; const darray = 1; const declare = 1; const default = 1; const dict = 1; const do = 1; const double = 1; const echo = 1; const else = 1; const empty = 1; const enddeclare = 1; const endfor = 1; const endforeach = 1; const endif = 1; const endswitch = 1; const endwhile = 1; const enum = 1; // const eval = 1; // Unexpected token const extends = 1; const fallthrough = 1; const false = 1; const final = 1; const finally = 1; const float = 1; const for = 1; const foreach = 1; const from = 1; const global = 1; const goto = 1; const if = 1; const implements = 1; const include = 1; const include_once = 1; const inout = 1; const instanceof = 1; const insteadof = 1; const int = 1; const integer = 1; const interface = 1; const is = 1; // const isset = 1; // Unexpected token const keyset = 1; const let = 1; const list = 1; const mixed = 1; const namespace = 1; const new = 1; const newtype = 1; const noreturn = 1; const null = 1; const num = 1; const object = 1; const or = 1; const parent = 1; const print = 1; const private = 1; const protected = 1; const public = 1; const real = 1; const require = 1; const require_once = 1; const resource = 1; const return = 1; const self = 1; const shape = 1; const static = 1; const string = 1; const super = 1; const suspend = 1; const switch = 1; const this = 1; const throw = 1; const trait = 1; const try = 1; const true = 1; const type = 1; const unset = 1; const use = 1; const using = 1; const var = 1; const varray = 1; const vec = 1; const void = 1; const where = 1; const while = 1; const xor = 1; const yield = 1;
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_const_w_ty_spec.php
<?hh // everything is allowed as a constant!! const int abstract = 1; const int and = 1; const int array = 1; const int arraykey = 1; const int as = 1; const int attribute = 1; const int binary = 1; const int bool = 1; const int boolean = 1; const int break = 1; const int case = 1; const int catch = 1; const int category = 1; const int children = 1; const int class = 1; const int classname = 1; const int clone = 1; // const int const int = 1; // "Notice: Constant const int already defined" const int continue = 1; const int coroutine = 1; const int darray = 1; const int declare = 1; const int default = 1; const int dict = 1; const int do = 1; const int double = 1; const int echo = 1; const int else = 1; const int empty = 1; const int enddeclare = 1; const int endfor = 1; const int endforeach = 1; const int endif = 1; const int endswitch = 1; const int endwhile = 1; const int enum = 1; // const int eval = 1; // Unexpected token const int extends = 1; const int fallthrough = 1; const int false = 1; const int final = 1; const int finally = 1; const int float = 1; const int for = 1; const int foreach = 1; const int from = 1; const int global = 1; const int goto = 1; const int if = 1; const int implements = 1; const int include = 1; const int include_once = 1; const int inout = 1; const int instanceof = 1; const int insteadof = 1; const int int = 1; const int integer = 1; const int interface = 1; const int is = 1; // const int isset = 1; // Unexpected token const int keyset = 1; const int let = 1; const int list = 1; const int mixed = 1; const int namespace = 1; const int new = 1; const int newtype = 1; const int noreturn = 1; const int null = 1; const int num = 1; const int object = 1; const int or = 1; const int parent = 1; const int print = 1; const int private = 1; const int protected = 1; const int public = 1; const int real = 1; const int require = 1; const int require_once = 1; const int resource = 1; const int return = 1; const int self = 1; const int shape = 1; const int static = 1; const int string = 1; const int super = 1; const int suspend = 1; const int switch = 1; const int this = 1; const int throw = 1; const int trait = 1; const int try = 1; const int true = 1; const int type = 1; const int unset = 1; const int use = 1; const int using = 1; const int var = 1; const int varray = 1; const int vec = 1; const int void = 1; const int where = 1; const int while = 1; const int xor = 1; const int yield = 1;
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_enum.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. * * */ /* All keywords are allowed as enum. */ enum A: int { abstract = 1; and = 1; array = 1; arraykey = 1; as = 1; attribute = 1; binary = 1; bool = 1; boolean = 1; break = 1; case = 1; catch = 1; category = 1; children = 1; class = 1; classname = 1; clone = 1; const = 1; continue = 1; coroutine = 1; darray = 1; declare = 1; default = 1; dict = 1; do = 1; double = 1; echo = 1; else = 1; empty = 1; enddeclare = 1; endfor = 1; endforeach = 1; endif = 1; endswitch = 1; endwhile = 1; enum = 1; eval = 1; extends = 1; fallthrough = 1; false = 1; final = 1; finally = 1; float = 1; for = 1; foreach = 1; from = 1; global = 1; goto = 1; if = 1; implements = 1; include = 1; include_once = 1; inout = 1; instanceof = 1; insteadof = 1; int = 1; integer = 1; interface = 1; is = 1; isset = 1; keyset = 1; let = 1; list = 1; mixed = 1; namespace = 1; new = 1; newtype = 1; noreturn = 1; null = 1; num = 1; object = 1; or = 1; parent = 1; print = 1; private = 1; protected = 1; public = 1; real = 1; require = 1; require_once = 1; resource = 1; return = 1; self = 1; shape = 1; static = 1; string = 1; super = 1; suspend = 1; switch = 1; this = 1; throw = 1; trait = 1; true = 1; try = 1; type = 1; unset = 1; use = 1; using = 1; var = 1; varray = 1; vec = 1; void = 1; where = 1; while = 1; xor = 1; yield = 1; } A::and; A::array; A::arraykey; A::as; A::attribute; A::binary; A::bool; A::boolean; A::break; A::case; A::catch; A::category; A::children; A::class; A::classname; A::clone; A::const; A::continue; A::coroutine; A::darray; A::declare; A::default; A::dict; A::do; A::double; A::echo; A::else; A::enddeclare; A::endfor; A::endforeach; A::endif; A::endswitch; A::endwhile; A::enum; A::eval; A::extends; A::fallthrough; A::false; A::final; A::finally; A::float; A::for; A::foreach; A::from; A::global; A::goto; A::if; A::implements; A::include; A::include_once; A::inout; A::instanceof; A::insteadof; A::int; A::integer; A::interface; A::is; A::isset; A::keyset; A::let; A::list; A::mixed; A::namespace; A::new; A::newtype; A::noreturn; A::null; A::num; A::object; A::or; A::parent; A::print; A::private; A::protected; A::public; A::real; A::require; A::require_once; A::resource; A::return; A::self; A::shape; A::static; A::string; A::super; A::suspend; A::switch; A::this; A::throw; A::trait; A::true; A::try; A::type; A::unset; A::use; A::using; A::var; A::varray; A::vec; A::void; A::where; A::while; A::xor; A::yield;
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_function_allowed.php
<?hh function arraykey() {} function attribute() {} function binary() {} function bool() {} function boolean() {} function category() {} function children() {} function classname() {} function darray() {} function define() {} function dict() {} function double() {} function empty() {} function enum() {} function fallthrough() {} function false() {} function float() {} function from() {} function int() {} function integer() {} function is() {} function isset() {} function keyset() {} function let() {} function mixed() {} function newtype() {} function noreturn() {} function null() {} function num() {} function object() {} function parent() {} function real() {} function resource() {} function self() {} function string() {} function super() {} function this() {} function true() {} function type() {} function unset() {} function varray() {} function vec() {} function void() {} function where() {} arraykey(); attribute(); binary(); bool(); boolean(); category(); children(); classname(); darray(); define(); dict(); double(); empty(); enum(); fallthrough(); false(); float(); from(); int(); integer(); is(); isset(); keyset(); let(); mixed(); newtype(); noreturn(); null(); num(); object(); parent(); real(); resource(); self(); string(); super(); this(); true(); type(); unset(); varray(); vec(); void(); where();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_function_unexpected.php
<?hh // Raise "Unexpected token" function abstract() {} function array() {} function as() {} function async() {} function await() {} function break() {} function case() {} function catch() {} function class() {} function clone() {} function const() {} function continue() {} function default() {} function do() {} function echo() {} function else() {} function endfor() {} function endforeach() {} function endif() {} function eval() {} function extends() {} function final() {} function finally() {} function for() {} function foreach() {} function function() {} function global() {} function if() {} function implements() {} function include() {} function include_once() {} function inout() {} function instanceof() {} function insteadof() {} function interface() {} function list() {} function namespace() {} function new() {} function print() {} function private() {} function protected() {} function public() {} function require() {} function require_once() {} function return() {} function shape() {} function static() {} function switch() {} function throw() {} function trait() {} function try() {} function use() {} function using() {} function var() {} function while() {} function yield() {} // abstract(); // can't test this; this token kicks us into parse_classish_declaration and makes the parser think the rest of the test is a classish body array(); as(); async(); await(); break(); case(); catch(); // class(); // can't test this; this token kicks us into parse_classish_declaration and makes the parser think the rest of the test is a classish body clone(); const(); continue(); declare(); default(); do(); echo(); else(); endfor(); endforeach(); enddeclare(); endif(); endswitch(); endwhile(); eval(); extends(); // final(); // can't test this; this token kicks us into parse_classish_declaration and makes the parser think the rest of the test is a classish body finally(); for(); foreach(); function(); global(); if(); implements(); include(); include_once(); inout(); instanceof(); insteadof(); // interface(); // can't test this; this token kicks us into parse_classish_declaration and makes the parser think the rest of the test is a classish body list(); namespace(); new(); print(); private(); protected(); public(); require(); require_once(); return(); shape(); static(); // switch(); // can't test this; this token kicks us into parse_switch_statement and makes the parser think the rest of the test is a switch body throw(); // trait(); // can't test this; this token kicks us into parse_classish_declaration and makes the parser think the rest of the test is a classish body // try(); // can't test this; this token kicks us into parse_try_statement and makes the parser think the rest of the test is the body of a try use(); using(); var(); while(); yield();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_member.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. * * */ /* All keywords are allowed as member. */ class A { public int $abstract = 1; public int $and = 1; public int $array = 1; public int $arraykey = 1; public int $as = 1; public int $attribute = 1; public int $binary = 1; public int $bool = 1; public int $boolean = 1; public int $break = 1; public int $case = 1; public int $catch = 1; public int $category = 1; public int $children = 1; public int $class = 1; public int $classname = 1; public int $clone = 1; public int $const = 1; public int $continue = 1; public int $coroutine = 1; public int $darray = 1; public int $declare = 1; public int $default = 1; public int $dict = 1; public int $do = 1; public int $double = 1; public int $echo = 1; public int $else = 1; public int $empty = 1; public int $enddeclare = 1; public int $endfor = 1; public int $endforeach = 1; public int $endif = 1; public int $endswitch = 1; public int $endwhile = 1; public int $enum = 1; public int $eval = 1; public int $extends = 1; public int $fallthrough = 1; public int $false = 1; public int $final = 1; public int $finally = 1; public int $float = 1; public int $for = 1; public int $foreach = 1; public int $from = 1; public int $global = 1; public int $goto = 1; public int $if = 1; public int $implements = 1; public int $include = 1; public int $include_once = 1; public int $inout = 1; public int $instanceof = 1; public int $insteadof = 1; public int $int = 1; public int $integer = 1; public int $interface = 1; public int $is = 1; public int $isset = 1; public int $keyset = 1; public int $let = 1; public int $list = 1; public int $mixed = 1; public int $namespace = 1; public int $new = 1; public int $newtype = 1; public int $noreturn = 1; public int $null = 1; public int $num = 1; public int $object = 1; public int $or = 1; public int $parent = 1; public int $print = 1; public int $private = 1; public int $protected = 1; public int $public = 1; public int $real = 1; public int $require = 1; public int $require_once = 1; public int $resource = 1; public int $return = 1; public int $self = 1; public int $shape = 1; public int $static = 1; public int $string = 1; public int $super = 1; public int $suspend = 1; public int $switch = 1; public int $this = 1; public int $throw = 1; public int $trait = 1; public int $true = 1; public int $try = 1; public int $type = 1; public int $unset = 1; public int $use = 1; public int $using = 1; public int $var = 1; public int $varray = 1; public int $vec = 1; public int $void = 1; public int $where = 1; public int $while = 1; public int $xor = 1; public int $yield = 1; public function foo() { $this->abstract = 1; $this->$and = 1; $this->array = 1; $this->arraykey = 1; $this->as = 1; $this->attribute = 1; $this->binary = 1; $this->bool = 1; $this->boolean = 1; $this->break = 1; $this->case = 1; $this->catch = 1; $this->category = 1; $this->children = 1; $this->class = 1; $this->classname = 1; $this->clone = 1; $this->const = 1; $this->continue = 1; $this->coroutine = 1; $this->darray = 1; $this->declare = 1; $this->default = 1; $this->dict = 1; $this->do = 1; $this->double = 1; $this->echo = 1; $this->else = 1; $this->enddeclare = 1; $this->endfor = 1; $this->endforeach = 1; $this->endif = 1; $this->endswitch = 1; $this->endwhile = 1; $this->enum = 1; $this->eval = 1; $this->extends = 1; $this->fallthrough = 1; $this->false = 1; $this->final = 1; $this->finally = 1; $this->float = 1; $this->for = 1; $this->foreach = 1; $this->from = 1; $this->global = 1; $this->goto = 1; $this->if = 1; $this->implements = 1; $this->include = 1; $this->include_once = 1; $this->inout = 1; $this->instanceof = 1; $this->insteadof = 1; $this->int = 1; $this->integer = 1; $this->interface = 1; $this->is = 1; $this->isset = 1; $this->keyset = 1; $this->let = 1; $this->list = 1; $this->mixed = 1; $this->namespace = 1; $this->new = 1; $this->newtype = 1; $this->noreturn = 1; $this->null = 1; $this->num = 1; $this->object = 1; $this->or = 1; $this->parent = 1; $this->print = 1; $this->private = 1; $this->protected = 1; $this->public = 1; $this->real = 1; $this->require = 1; $this->require_once = 1; $this->resource = 1; $this->return = 1; $this->self = 1; $this->shape = 1; $this->static = 1; $this->string = 1; $this->super = 1; $this->suspend = 1; $this->switch = 1; $this->this = 1; $this->throw = 1; $this->trait = 1; $this->true = 1; $this->try = 1; $this->type = 1; $this->unset = 1; $this->use = 1; $this->using = 1; $this->var = 1; $this->varray = 1; $this->vec = 1; $this->void = 1; $this->where = 1; $this->while = 1; $this->xor = 1; $this->yield = 1; } } $a = new A(); $a->and = 1; $a->array = 1; $a->arraykey = 1; $a->as = 1; $a->attribute = 1; $a->binary = 1; $a->bool = 1; $a->boolean = 1; $a->break = 1; $a->case = 1; $a->catch = 1; $a->category = 1; $a->children = 1; $a->class = 1; $a->classname = 1; $a->clone = 1; $a->const = 1; $a->continue = 1; $a->coroutine = 1; $a->darray = 1; $a->declare = 1; $a->default = 1; $a->dict = 1; $a->do = 1; $a->double = 1; $a->echo = 1; $a->else = 1; $a->empty = 1; $a->endfor = 1; $a->endforeach = 1; $a->endif = 1; $a->endswitch = 1; $a->endwhile = 1; $a->enum = 1; $a->eval = 1; $a->extends = 1; $a->fallthrough = 1; $a->false = 1; $a->final = 1; $a->finally = 1; $a->float = 1; $a->for = 1; $a->foreach = 1; $a->from = 1; $a->global = 1; $a->goto = 1; $a->if = 1; $a->implements = 1; $a->include = 1; $a->include_once = 1; $a->inout = 1; $a->instanceof = 1; $a->insteadof = 1; $a->int = 1; $a->integer = 1; $a->interface = 1; $a->is = 1; $a->isset = 1; $a->keyset = 1; $a->let = 1; $a->list = 1; $a->mixed = 1; $a->namespace = 1; $a->new = 1; $a->newtype = 1; $a->noreturn = 1; $a->null = 1; $a->num = 1; $a->object = 1; $a->or = 1; $a->parent = 1; $a->print = 1; $a->private = 1; $a->protected = 1; $a->public = 1; $a->real = 1; $a->require = 1; $a->require_once = 1; $a->resource = 1; $a->return = 1; $a->self = 1; $a->shape = 1; $a->static = 1; $a->string = 1; $a->super = 1; $a->suspend = 1; $a->switch = 1; $a->this = 1; $a->throw = 1; $a->trait = 1; $a->true = 1; $a->try = 1; $a->type = 1; $a->unset = 1; $a->use = 1; $a->using = 1; $a->var = 1; $a->varray = 1; $a->vec = 1; $a->void = 1; $a->where = 1; $a->while = 1; $a->xor = 1; $a->yield = 1;
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_method.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. * * */ /* All keywords are allowed as member. */ class A { public function abstract() {} public function and() {} public function array() {} public function arraykey() {} public function as() {} public function attribute() {} public function binary() {} public function bool() {} public function boolean() {} public function break() {} public function case() {} public function catch() {} public function category() {} public function children() {} public function class() {} public function classname() {} public function clone() {} public function const() {} public function continue() {} public function coroutine() {} public function darray() {} public function declare() {} public function default() {} public function dict() {} public function do() {} public function double() {} public function echo() {} public function else() {} public function empty() {} public function enddeclare() {} public function endfor() {} public function endforeach() {} public function endif() {} public function endswitch() {} public function endwhile() {} public function enum() {} // public function eval() {} // unexpected token public function extends() {} public function fallthrough() {} public function false() {} public function final() {} public function finally() {} public function float() {} public function for() {} public function foreach() {} public function from() {} public function global() {} public function goto() {} public function if() {} public function implements() {} public function include() {} public function include_once() {} public function inout() {} public function instanceof() {} public function insteadof() {} public function int() {} public function integer() {} public function interface() {} public function is() {} // public function isset() {} // unexpected token public function keyset() {} public function let() {} public function list() {} public function mixed() {} public function namespace() {} public function new() {} public function newtype() {} public function noreturn() {} public function null() {} public function num() {} public function object() {} public function or() {} public function parent() {} public function print() {} public function private() {} public function protected() {} public function public() {} public function real() {} public function require() {} public function require_once() {} public function resource() {} public function return() {} public function self() {} // public function shape() {} // unexpected token public function static() {} public function string() {} public function super() {} public function suspend() {} public function switch() {} public function this() {} public function throw() {} public function trait() {} public function true() {} public function try() {} public function type() {} public function unset() {} public function use() {} public function using() {} public function var() {} public function varray() {} public function vec() {} public function void() {} public function where() {} public function while() {} public function xor() {} public function yield() {} public function foo() { $this->abstract(); $this->$and(); $this->array(); $this->arraykey(); $this->as(); $this->attribute(); $this->binary(); $this->bool(); $this->boolean(); $this->break(); $this->case(); $this->catch(); $this->category(); $this->children(); $this->class(); $this->classname(); $this->clone(); $this->const(); $this->continue(); $this->coroutine(); $this->darray(); $this->declare(); $this->default(); $this->dict(); $this->do(); $this->double(); $this->echo(); $this->else(); $this->empty(); $this->enddeclare(); $this->endfor(); $this->endforeach(); $this->endif(); $this->endswitch(); $this->endwhile(); $this->enum(); $this->eval(); $this->extends(); $this->fallthrough(); $this->false(); $this->final(); $this->finally(); $this->float(); $this->for(); $this->foreach(); $this->from(); $this->global(); $this->goto(); $this->if(); $this->implements(); $this->include(); $this->include_once(); $this->inout(); $this->instanceof(); $this->insteadof(); $this->int(); $this->integer(); $this->interface(); $this->is(); $this->isset(); $this->keyset(); $this->let(); $this->list(); $this->mixed(); $this->namespace(); $this->new(); $this->newtype(); $this->noreturn(); $this->null(); $this->num(); $this->object(); $this->or(); $this->parent(); $this->print(); $this->private(); $this->protected(); $this->public(); $this->real(); $this->require(); $this->require_once(); $this->resource(); $this->return(); $this->self(); $this->shape(); $this->static(); $this->string(); $this->super(); $this->suspend(); $this->switch(); $this->this(); $this->throw(); $this->trait(); $this->true(); $this->try(); $this->type(); $this->unset(); $this->use(); $this->using(); $this->var(); $this->varray(); $this->vec(); $this->void(); $this->where(); $this->while(); $this->xor(); $this->yield(); } } $a = new A(); $a->and(); $a->array(); $a->arraykey(); $a->as(); $a->attribute(); $a->binary(); $a->bool(); $a->boolean(); $a->break(); $a->case(); $a->catch(); $a->category(); $a->children(); $a->class(); $a->classname(); $a->clone(); $a->const(); $a->continue(); $a->coroutine(); $a->darray(); $a->declare(); $a->default(); $a->dict(); $a->do(); $a->double(); $a->echo(); $a->else(); $a->empty(); $a->enddeclare(); $a->endfor(); $a->endforeach(); $a->endif(); $a->endswitch(); $a->endwhile(); $a->enum(); $a->eval(); $a->extends(); $a->fallthrough(); $a->false(); $a->final(); $a->finally(); $a->float(); $a->for(); $a->foreach(); $a->from(); $a->global(); $a->goto(); $a->if(); $a->implements(); $a->include(); $a->include_once(); $a->inout(); $a->instanceof(); $a->insteadof(); $a->int(); $a->integer(); $a->interface(); $a->is(); $a->isset(); $a->keyset(); $a->let(); $a->list(); $a->mixed(); $a->namespace(); $a->new(); $a->newtype(); $a->noreturn(); $a->null(); $a->num(); $a->object(); $a->or(); $a->parent(); $a->print(); $a->private(); $a->protected(); $a->public(); $a->real(); $a->require(); $a->require_once(); $a->resource(); $a->return(); $a->self(); $a->shape(); $a->static(); $a->string(); $a->super(); $a->suspend(); $a->switch(); $a->this(); $a->throw(); $a->trait(); $a->true(); $a->try(); $a->type(); $a->unset(); $a->use(); $a->using(); $a->var(); $a->varray(); $a->vec(); $a->void(); $a->where(); $a->while(); $a->xor(); $a->yield();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/keyword_as_static_method.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. * * */ /* All keywords are allowed as member. */ class A { public static function abstract() {} public static function and() {} public static function array() {} public static function arraykey() {} public static function as() {} public static function attribute() {} public static function binary() {} public static function bool() {} public static function boolean() {} public static function break() {} public static function case() {} public static function catch() {} public static function category() {} public static function children() {} public static function class() {} public static function classname() {} public static function clone() {} public static function const() {} public static function continue() {} public static function coroutine() {} public static function darray() {} public static function declare() {} public static function default() {} public static function dict() {} public static function do() {} public static function double() {} public static function echo() {} public static function else() {} public static function empty() {} public static function enddeclare() {} public static function endfor() {} public static function endforeach() {} public static function endif() {} public static function endswitch() {} public static function endwhile() {} public static function enum() {} // public static function eval() {} // unexpected token public static function extends() {} public static function fallthrough() {} public static function false() {} public static function final() {} public static function finally() {} public static function float() {} public static function for() {} public static function foreach() {} public static function from() {} public static function global() {} public static function goto() {} public static function if() {} public static function implements() {} public static function include() {} public static function include_once() {} public static function inout() {} public static function instanceof() {} public static function insteadof() {} public static function int() {} public static function integer() {} public static function interface() {} public static function is() {} // public static function isset() {} // unexpected token public static function keyset() {} public static function let() {} public static function list() {} public static function mixed() {} public static function namespace() {} public static function new() {} public static function newtype() {} public static function noreturn() {} public static function null() {} public static function num() {} public static function object() {} public static function or() {} public static function parent() {} public static function print() {} public static function private() {} public static function protected() {} public static function public() {} public static function real() {} public static function require() {} public static function require_once() {} public static function resource() {} public static function return() {} public static function self() {} // public static function shape() {} // unexpected token public static function static() {} public static function string() {} public static function super() {} public static function suspend() {} public static function switch() {} public static function this() {} public static function throw() {} public static function trait() {} public static function true() {} public static function try() {} public static function type() {} public static function unset() {} public static function use() {} public static function using() {} public static function var() {} public static function varray() {} public static function vec() {} public static function void() {} public static function where() {} public static function while() {} public static function xor() {} public static function yield() {} public static function foo() { static::abstract(); static::$and(); static::array(); static::arraykey(); static::as(); static::attribute(); static::binary(); static::bool(); static::boolean(); static::break(); static::case(); static::catch(); static::category(); static::children(); static::class(); static::classname(); static::clone(); static::const(); static::continue(); static::coroutine(); static::darray(); static::declare(); static::default(); static::dict(); static::do(); static::double(); static::echo(); static::else(); static::empty(); static::enddeclare(); static::endfor(); static::endforeach(); static::endif(); static::endswitch(); static::endwhile(); static::enum(); // static::eval(); // unexpected token static::extends(); static::fallthrough(); static::false(); static::final(); static::finally(); static::float(); static::for(); static::foreach(); static::from(); static::global(); static::goto(); static::if(); static::implements(); static::include(); static::include_once(); static::inout(); static::instanceof(); static::insteadof(); static::int(); static::integer(); static::interface(); static::is(); // static::isset(); // unexpected token static::keyset(); static::let(); static::list(); static::mixed(); static::namespace(); static::new(); static::newtype(); static::noreturn(); static::null(); static::num(); static::object(); static::or(); static::parent(); static::print(); static::private(); static::protected(); static::public(); static::real(); static::require(); static::require_once(); static::resource(); static::return(); static::self(); // static::shape(); // unexpected token static::static(); static::string(); static::super(); static::suspend(); static::switch(); static::this(); static::throw(); static::trait(); static::true(); static::try(); static::type(); static::unset(); static::use(); static::using(); static::var(); static::varray(); static::vec(); static::void(); static::where(); static::while(); static::xor(); static::yield(); } } A::and(); A::array(); A::arraykey(); A::as(); A::attribute(); A::binary(); A::bool(); A::boolean(); A::break(); A::case(); A::catch(); A::category(); A::children(); A::class(); A::classname(); A::clone(); A::const(); A::continue(); A::coroutine(); A::darray(); A::declare(); A::default(); A::dict(); A::do(); A::double(); A::echo(); A::else(); A::empty(); A::enddeclare(); A::endfor(); A::endforeach(); A::endif(); A::endswitch(); A::endwhile(); A::enum(); // A::eval(); // unexpected token A::extends(); A::fallthrough(); A::false(); A::final(); A::finally(); A::float(); A::for(); A::foreach(); A::from(); A::global(); A::goto(); A::if(); A::implements(); A::include(); A::include_once(); A::inout(); A::instanceof(); A::insteadof(); A::int(); A::integer(); A::interface(); A::is(); // A::isset(); // unexpected token A::keyset(); A::let(); A::list(); A::mixed(); A::namespace(); A::new(); A::newtype(); A::noreturn(); A::null(); A::num(); A::object(); A::or(); A::parent(); A::print(); A::private(); A::protected(); A::public(); A::real(); A::require(); A::require_once(); A::resource(); A::return(); A::self(); // A::shape(); // unexpected token A::static(); A::string(); A::super(); A::suspend(); A::switch(); A::this(); A::throw(); A::trait(); A::true(); A::try(); A::type(); A::unset(); A::use(); A::using(); A::var(); A::varray(); A::vec(); A::void(); A::where(); A::while(); A::xor(); A::yield();
PHP
hhvm/hphp/hack/test/full_fidelity/cases/methodish_trait_resolution.php
<?hh trait T1 { public function animal(): void { echo "Dog"; } } trait T2 { public function animal(): void { echo "Cat"; } } class C { use T1, T2; public function animal(): void = T1::animal; } class D { public function animal(): void = animal; public function animal(): void = T1::class; public function animal(): void = \MyNamespace\T2::foo; // ok }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/method_dispatch_06.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. * * */ /** * Hack treats method dispatch in a different way from PHP. */ class A { public function f1(): void {} public static function f2(): void {} } class B extends A { public function f1(): void {} public static function f2(): void {} public function test1(): void {} public static function test2(): void { $this->f2(); } } class C { public function f3(): void {} public static function f4(): void {} }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/method_dispatch_07.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. * * */ /** * Hack treats method dispatch in a different way from PHP. */ class A { public function f1(): void {} public static function f2(): void {} } class B extends A { public function f1(): void {} public static function f2(): void {} public function test1(): void {} public static function test2(): void { $this::f2(); } } class C { public function f3(): void {} public static function f4(): void {} }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/method_dispatch_15.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. * * */ /** * Hack treats method dispatch in a different way from PHP. */ class A { public function f1(): void {} public static function f2(): void {} } class B extends A { public function f1(): void {} public static function f2(): void {} public function test1(): void {} public static function test2(): void { $this->f1(); } } class C { public function f3(): void {} public static function f4(): void {} }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/method_dispatch_16.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. * * */ /** * Hack treats method dispatch in a different way from PHP. */ class A { public function f1(): void {} public static function f2(): void {} } class B extends A { public function f1(): void {} public static function f2(): void {} public function test1(): void {} public static function test2(): void { $this::f1(); } } class C { public function f3(): void {} public static function f4(): void {} }
PHP
hhvm/hphp/hack/test/full_fidelity/cases/module_newtype.php
<?hh <<file:__EnableUnstableFeatures("modules")>> module foo; module newtype Foo as int = int; <<Foo>> module newtype Bar as int = int;
PHP
hhvm/hphp/hack/test/full_fidelity/cases/module_newtype_bad4.php
<?hh <<file:__EnableUnstableFeatures("modules")>> module foo; internal module newtype Foo = int; // error
PHP
hhvm/hphp/hack/test/full_fidelity/cases/nested_expression_trees.php
<?hh <<file:__EnableUnstableFeatures('expression_trees')>> function test(): void { ExampleDsl`ExampleDsl`4``; }