language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/class/class.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> class C { const int num = 1; public static function static_m(): void {} public function m(): void {} } function simple_upcast1(): void { $y = C::class upcast dynamic; $y::static_m(); } function simple_upcast2(): void { $y = new C() upcast dynamic; $y->m(); } function simple_upcast3(): void { $y = new C() upcast dynamic; $y::static_m(); } function simple_upcast4(): void { $y = new C() upcast dynamic; $y->num; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/class/class2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> class C { public function m(): void {} public static function static_m(): void {} } <<__SupportDynamicType>> class D { public function m(): void {} } function while_test(): void { $index = 1; while ($index < 10) { if ($index == 9) { (new C() upcast dynamic)->m(); (C::class upcast dynamic)->m(); } $index++; } } function if_test(): void { $b = true; $c = false; $x = new D(); $y = D::class; if ($b) { if ($c) { $x = new D() upcast dynamic; } else { (new C() upcast dynamic)->m(); } } else { if ($c) { $x = new C(); $y = C::class; $y::static_m(); } else { (C::class upcast dynamic)->m(); } } ($x upcast dynamic)->m(); ($y upcast dynamic)->m(); }
hhvm/hphp/hack/test/refactor_sd/dump_constraints/class/dune
(rule (alias refactor_sd) (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/refactor_sd/dump_constraints/class/*.php) (glob_files %{project_root}/hack/test/refactor_sd/dump_constraints/class/*.php.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/refactor_sd/dump_constraints/class --program %{exe:../../../../src/hh_single_type_check.exe} --in-extension .php --flags --enable-sound-dynamic-type --refactor-sound-dynamic dump Class C --error-format plain))) (alias (name runtest) (deps (alias refactor_sd)))
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/assignment.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = f<>; $y = $x; $z = f<>; $x upcast dynamic; $y upcast dynamic; $z upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/assignment2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function g(): void {} <<__SupportDynamicType>> function f(): void {} function h(): void { $b = f<>; $b = g<>; $b upcast dynamic; $c = g<>; $c = f<>; $c upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/bop.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = false && (f<> upcast dynamic is nonnull); }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/call.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = f<>; $x(); }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/call2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $w = f<> upcast dynamic; // Don't report $x = f<> upcast dynamic; // Report $x(); $y = f<> upcast dynamic; // Don't report }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/call3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = f<> upcast dynamic; // Don't report $x = f<> upcast dynamic; // Report $x(); $x(); $x = f<> upcast dynamic; // Don't report $x = g<> upcast dynamic; // Don't report $x(); }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/call_arguments.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> function f(): int { return 1; } function g(int $i): void {} function h(): void { g((f<>)()); }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/call_arguments2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): int { return 1; } <<__SupportDynamicType>> function g(int $i): void {} function h(): void { $x = (g<> upcast dynamic); $y = f<>; $x($y()); } function e(): void { $x = (g<> upcast dynamic); $y = (f<> upcast dynamic); $x($y()); } function d(): void { (g<> upcast dynamic)((f<> upcast dynamic)()); }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/dict.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $d = dict[]; $d['f'] = f<>; $d['g'] = g<>; $d['f'] upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/dict2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $d = dict['f' => f<>, 'g' => g<>]; $d['f'] upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/dict3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $d = dict['f' => f<>]; $d['g'] = g<>; $d['f'] upcast dynamic; $d = dict['g' => g<>]; $d['f'] = f<>; $d['f'] upcast dynamic; }
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/dune
(rule (alias refactor_sd) (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/refactor_sd/dump_constraints/function/*.php) (glob_files %{project_root}/hack/test/refactor_sd/dump_constraints/function/*.php.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/refactor_sd/dump_constraints/function --program %{exe:../../../../src/hh_single_type_check.exe} --in-extension .php --flags --enable-sound-dynamic-type --refactor-sound-dynamic dump Function f --error-format plain))) (alias (name runtest) (deps (alias refactor_sd)))
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/elvis.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { (false ?: f<>) upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/empty.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> function f(): void {} class C { public function m(): void {} }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/if.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function g(): void {} <<__SupportDynamicType>> function f(): void {} function h(): void { if (true) { f<> upcast dynamic; } else { g<> upcast dynamic; } if (true) { $b = g<>; } else { $b = f<>; } $b upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/if2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function g(): void {} <<__SupportDynamicType>> function f(): void {} function h(): void { $b = true; $c = false; $x = g<>; if ($b) { if ($c) { $x = g<>; } else { f<> upcast dynamic; } } else { if ($c) { $x = f<>; } else { f<> upcast dynamic; } } $x upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/no_assignment.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = g<>; g<> upcast dynamic; $x upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/one_assignment.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = f<>; $x upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/questionquestion.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { (Null ?? f<>) upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/questionquestion2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = null; $x ??= f<>; $x upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/simple_upcast.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { f<> upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/switch.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = g<>; $i = 42; switch ($i) { case 0: $x upcast dynamic; $x = f<>; break; case 1: f<> upcast dynamic; break; default: g<> upcast dynamic; } $x upcast dynamic; } function e(): void { $x = f<>; $i = 42; switch ($i) { case 0: $x = g<>; break; case 1: $x = g<>; break; case 2: $x = g<>; break; default: $x = g<>; } $x upcast dynamic; } function d(): void { $x = g<>; $i = 42; switch ($i) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: $x = f<>; break; case 5: break; default: } $x upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/switch2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $i = 42; switch ($i) { case 0: $x = g<>; break; default: $x = f<>; } $x upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/switch3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = g<>; $i = 42; switch ($i) { case 0: $x = f<>; // FALLTHROUGH case 1: $x upcast dynamic; } } function e(): void { $x = g<>; $i = 42; switch ($i) { case 0: $x = f<>; break; case 1: $x upcast dynamic; } }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/ternary.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $b = true; ($b ? f<> : g<>) upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/uop.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { !((f<> upcast dynamic) is nonnull); }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/vec.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = vec[]; $v[] = f<>; $v[] = g<>; $v[0] upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/vec2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = vec[]; $v[] = g<>; $w = $v; $v[] = f<>; $v[0] upcast dynamic; // Report $w[0] upcast dynamic; // Don't report }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/vec3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = vec[f<>, g<>]; $v[0] upcast dynamic; $w = vec[g<>]; $w[] = f<>; $w[0] upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/vector.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = Vector{}; $v[] = f<>; $v[] = g<>; $v[0] upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/vector2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = Vector{}; $v[] = g<>; $w = $v; $w[] = f<>; $v[0] upcast dynamic; // Report $w[0] upcast dynamic; // Report }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/vector3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = Vector{f<>, g<>}; $v[0] upcast dynamic; }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/whileloop.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $index = 1; while ($index < 10) { f<> upcast dynamic; $index++; } }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/whileloop2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $b = f<>; $index = 1; while ($index < 10) { if ($index == 9) { $b upcast dynamic; } $index++; } }
PHP
hhvm/hphp/hack/test/refactor_sd/dump_constraints/function/whileloop3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void { $b = f<>; $index = 1; while (true) { if ($index == 9) { $index = $b; $index upcast dynamic; break; } $index++; } }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/class/class.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> class C { const int num = 1; public static function static_m(): void {} public function m(): void {} } function simple_upcast1(): void { $y = C::class upcast dynamic; $y::static_m(); } function simple_upcast2(): void { $y = new C() upcast dynamic; $y->m(); } function simple_upcast3(): void { $y = new C() upcast dynamic; $y::static_m(); } function simple_upcast4(): void { $y = new C() upcast dynamic; $y->num; }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/class/class2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> class C { public function m(): void {} public static function static_m(): void {} } <<__SupportDynamicType>> class D { public function m(): void {} } function while_test(): void { $index = 1; while ($index < 10) { if ($index == 9) { (new C() upcast dynamic)->m(); (C::class upcast dynamic)->m(); } $index++; } } function if_test(): void { $b = true; $c = false; $x = new D(); $y = D::class; if ($b) { if ($c) { $x = new D() upcast dynamic; } else { (new C() upcast dynamic)->m(); } } else { if ($c) { $x = new C(); $y = C::class; $y::static_m(); } else { (C::class upcast dynamic)->m(); } } ($x upcast dynamic)->m(); ($y upcast dynamic)->m(); }
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/class/dune
(rule (alias refactor_sd) (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/refactor_sd/simplify_constraints/class/*.php) (glob_files %{project_root}/hack/test/refactor_sd/simplify_constraints/class/*.php.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/refactor_sd/simplify_constraints/class --program %{exe:../../../../src/hh_single_type_check.exe} --in-extension .php --flags --enable-sound-dynamic-type --refactor-sound-dynamic simplify Class C --error-format plain))) (alias (name runtest) (deps (alias refactor_sd)))
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/assignment.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = f<>; $y = $x; $z = f<>; ($x upcast dynamic)(); ($y upcast dynamic)(); ($z upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/assignment2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function g(): void {} <<__SupportDynamicType>> function f(): void {} function h(): void { $b = f<>; $b = g<>; ($b upcast dynamic)(); $c = g<>; $c = f<>; ($c upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/bop.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = false && ((f<> upcast dynamic)() is nonnull); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/call.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = f<>; $x(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/call2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $w = f<> upcast dynamic; // Don't report $x = f<> upcast dynamic; // Report $x(); $y = f<> upcast dynamic; // Don't report }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/call3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = f<> upcast dynamic; // Don't report $x = f<> upcast dynamic; // Report $x(); $x(); $x = f<> upcast dynamic; // Don't report $x = g<> upcast dynamic; // Don't report $x(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/call_arguments.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> function f(): int { return 1; } function g(int $i): void {} function h(): void { g((f<>)()); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/call_arguments2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): int { return 1; } <<__SupportDynamicType>> function g(int $i): void {} function h(): void { $x = (g<> upcast dynamic); $y = f<>; $x($y()); } function e(): void { $x = (g<> upcast dynamic); $y = (f<> upcast dynamic); $x($y()); } function d(): void { (g<> upcast dynamic)((f<> upcast dynamic)()); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/dict.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $d = dict[]; $d['f'] = f<>; $d['g'] = g<>; ($d['f'] upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/dict2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $d = dict['f' => f<>, 'g' => g<>]; ($d['f'] upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/dict3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $d = dict['f' => f<>]; $d['g'] = g<>; ($d['f'] upcast dynamic)(); $d = dict['g' => g<>]; $d['f'] = f<>; ($d['f'] upcast dynamic)(); }
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/dune
(rule (alias refactor_sd) (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/refactor_sd/simplify_constraints/function/*.php) (glob_files %{project_root}/hack/test/refactor_sd/simplify_constraints/function/*.php.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/refactor_sd/simplify_constraints/function --program %{exe:../../../../src/hh_single_type_check.exe} --in-extension .php --flags --enable-sound-dynamic-type --refactor-sound-dynamic simplify Function f --error-format plain))) (alias (name runtest) (deps (alias refactor_sd)))
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/elvis.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { ((false ?: f<>) upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/empty.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> function f(): void {} class C { public function m(): void {} }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/if.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function g(): void {} <<__SupportDynamicType>> function f(): void {} function h(): void { if (true) { (f<> upcast dynamic)(); } else { (g<> upcast dynamic)(); } if (true) { $b = g<>; } else { $b = f<>; } ($b upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/if2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function g(): void {} <<__SupportDynamicType>> function f(): void {} function h(): void { $b = true; $c = false; $x = g<>; if ($b) { if ($c) { $x = g<>; } else { (f<> upcast dynamic)(); } } else { if ($c) { $x = f<>; } else { (f<> upcast dynamic)(); } } ($x upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/no_assignment.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = g<>; (g<> upcast dynamic)(); ($x upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/one_assignment.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $x = f<>; ($x upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/questionquestion.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { ((Null ?? f<>) upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/questionquestion2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = null; $x ??= f<>; ($x upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/simple_upcast.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { (f<> upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/switch.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = g<>; $i = 42; switch ($i) { case 0: $x upcast dynamic; $x = f<>; break; case 1: (f<> upcast dynamic)(); break; default: (g<> upcast dynamic)(); } ($x upcast dynamic)(); } function e(): void { $x = f<>; $i = 42; switch ($i) { case 0: $x = g<>; break; case 1: $x = g<>; break; case 2: $x = g<>; break; default: $x = g<>; } ($x upcast dynamic)(); } function d(): void { $x = g<>; $i = 42; switch ($i) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: $x = f<>; break; case 5: break; default: } ($x upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/switch2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $i = 42; switch ($i) { case 0: $x = g<>; break; default: $x = f<>; } ($x upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/switch3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $x = g<>; $i = 42; switch ($i) { case 0: $x = f<>; // FALLTHROUGH case 1: ($x upcast dynamic)(); } } function e(): void { $x = g<>; $i = 42; switch ($i) { case 0: $x = f<>; break; case 1: ($x upcast dynamic)(); } }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/ternary.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $b = true; (($b ? f<> : g<>) upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/uop.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { !((f<> upcast dynamic)() is nonnull); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/vec.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = vec[]; $v[] = f<>; $v[] = g<>; ($v[0] upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/vec2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = vec[]; $v[] = g<>; $w = $v; $v[] = f<>; ($v[0] upcast dynamic)(); // Report ($w[0] upcast dynamic)(); // Don't report }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/vec3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = vec[f<>, g<>]; ($v[0] upcast dynamic)(); } function e(): void { $w = vec[g<>]; $w[] = f<>; ($w[0] upcast dynamic)(); } function d(): void { $w = vec[f<>]; $w[] = g<>; ($w[0] upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/vector.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = Vector{}; $v[] = f<>; $v[] = g<>; ($v[0] upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/vector2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = Vector{}; $v[] = g<>; $w = $v; $w[] = f<>; ($v[0] upcast dynamic)(); // Report ($w[0] upcast dynamic)(); // Report }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/vector3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void {} function h(): void { $v = Vector{f<>, g<>}; ($v[0] upcast dynamic)(); }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/whileloop.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $index = 1; while ($index < 10) { (f<> upcast dynamic)(); $index++; } }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/whileloop2.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} function h(): void { $b = f<>; $index = 1; while ($index < 10) { if ($index == 9) { ($b upcast dynamic)(); } $index++; } }
PHP
hhvm/hphp/hack/test/refactor_sd/simplify_constraints/function/whileloop3.php
<?hh <<file:__EnableUnstableFeatures('upcast_expression')>> <<__SupportDynamicType>> function f(): void {} <<__SupportDynamicType>> function g(): void { $b = f<>; $index = 1; while (true) { if ($index == 9) { $index = $b; ($index upcast dynamic)(); break; } $index++; } }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/basic.php
<?hh type S = shape('a' => int, 'b' => bool); newtype NS = shape('a' => int, 'b' => bool); class C { const type TCShape = shape('a' => int, 'b' => bool); } function redundant_unsafe_casts(string $str, shape('a' => int, 'b' => bool) $s): void { HH\FIXME\UNSAFE_CAST<arraykey, string>($str); HH\FIXME\UNSAFE_CAST<shape(...), S>($s); HH\FIXME\UNSAFE_CAST<NS, S>($s); HH\FIXME\UNSAFE_CAST<shape(...), NS>($s); HH\FIXME\UNSAFE_CAST<C::TCShape, NS>($s); HH\FIXME\UNSAFE_CAST<shape(...), C::TCShape>($s); HH\FIXME\UNSAFE_CAST<S, C::TCShape>($s); }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/capture.php
<?hh function f(): void { // Needs parantheses after removing UNSAFE_CAST 2 * HH\FIXME\UNSAFE_CAST<mixed, int>(3 + 4); }
hhvm/hphp/hack/test/remove_dead_unsafe_casts/dune
(rule (alias remove_dead_unsafe_casts) (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/remove_dead_unsafe_casts/*.php) (glob_files %{project_root}/hack/test/remove_dead_unsafe_casts/*.php.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/remove_dead_unsafe_casts --program %{exe:../../src/hh_single_type_check.exe} --in-extension .php --flags --remove-dead-unsafe-casts --error-format plain))) (alias (name runtest) (deps (alias remove_dead_unsafe_casts)))
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/indirectly_nested.php
<?hh function foo(arraykey $x): int { return 0; } function bar(string $x): num { return HH\FIXME\UNSAFE_CAST<mixed,num>(foo(HH\FIXME\UNSAFE_CAST<mixed,arraykey>($x))); }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/lost_comment.php
<?hh function f(int $i): void { /* We should have a comment on the next line. */ HH\FIXME\UNSAFE_CAST<mixed, int>( /* We would like to retain this comment. It might be a FIXME! */ $i ); }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/mixed.php
<?hh function some_redundant_some_not(string $str): void { HH\FIXME\UNSAFE_CAST<arraykey, string>($str); // redundant HH\FIXME\UNSAFE_CAST<string, int>($str); // not redundant }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/nested.php
<?hh function both_redundant1(string $str): void { HH\FIXME\UNSAFE_CAST<mixed, arraykey>(HH\FIXME\UNSAFE_CAST<arraykey, string>($str)); } function both_redundant2(string $str): void { HH\FIXME\UNSAFE_CAST<mixed, string>(HH\FIXME\UNSAFE_CAST<arraykey, string>($str)); } function outer_redundant(arraykey $str): void { HH\FIXME\UNSAFE_CAST<mixed, arraykey>(HH\FIXME\UNSAFE_CAST<arraykey, string>($str)); } function inner_redundant(string $str): void { HH\FIXME\UNSAFE_CAST<string, int>(HH\FIXME\UNSAFE_CAST<mixed, string>($str)); }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/nested2.php
<?hh function takes_int(int $_): void {} function f(int $i): void { takes_int(HH\FIXME\UNSAFE_CAST<mixed, int>($i)); // Redundant 1 + (HH\FIXME\UNSAFE_CAST<mixed, int>($i) + 2); // Redundant }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/nonnull.php
<?hh function redundant_unsafe_casts(?string $str): void { HH\FIXME\UNSAFE_NONNULL_CAST($str); // Not redundant $str as nonnull; HH\FIXME\UNSAFE_NONNULL_CAST($str); // Redundant }
PHP
hhvm/hphp/hack/test/remove_dead_unsafe_casts/sibling.php
<?hh function f(int $i): void { // Both of these are redundant HH\FIXME\UNSAFE_CAST<mixed,int>($i) + HH\FIXME\UNSAFE_CAST<mixed,int>($i); }
PHP
hhvm/hphp/hack/test/requireclass/parsing/requireclass_01.good.php
<?hh // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; }
PHP
hhvm/hphp/hack/test/requireclass/parsing/requireclass_not_experimental_01.good.php
<?hh // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. trait T { require class C; }
PHP
hhvm/hphp/hack/test/requireclass/typing/aliased_private_properties_01.good.php
<?hh // Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; private int $i; public function bar(): void { $this->i; } } final class C { use T; public function __construct(private int $i) {} }
PHP
hhvm/hphp/hack/test/requireclass/typing/call_01.good.php
<?hh // Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; public function foo(): void { $this->bar(); } } final class C { use T; public function bar(): void { } }
PHP
hhvm/hphp/hack/test/requireclass/typing/call_02.good.php
<?hh // Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; public function foo(): void { } } final class C { use T; public function bar(): void { $this->foo(); } }
PHP
hhvm/hphp/hack/test/requireclass/typing/call_03.good.php
<?hh // Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; public function foo(): void { $this->bar(); } } class D { public function bar(): void {} } final class C extends D { use T; }
PHP
hhvm/hphp/hack/test/requireclass/typing/const_01.bad.php
<?hh // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; public function foo(): int { return C::X; } } final class C { use T; }
PHP
hhvm/hphp/hack/test/requireclass/typing/const_02.good.php
<?hh // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. <<file:__EnableUnstableFeatures('require_class')>> trait T { require class C; public function foo(): int { return C::X; } } final class C { use T; const X = 3; }
hhvm/hphp/hack/test/requireclass/typing/dune
(rule (alias requireclass_typing_good) (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/requireclass/typing/HH_FLAGS) (glob_files %{project_root}/hack/test/requireclass/typing/*.good.php) (glob_files %{project_root}/hack/test/requireclass/typing/*.good.php.exp) (glob_files %{project_root}/hack/test/requireclass/typing/*.good.php.legacy_decl.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/requireclass/typing --program %{exe:../../../src/hh_single_type_check.exe} --in-extension .good.php --out-extension .legacy_decl.out --expect-extension .legacy_decl.exp --fallback-expect-extension .exp --flags --out-extension .legacy_decl.out))) (rule (alias requireclass_typing_bad) (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/requireclass/typing/HH_FLAGS) (glob_files %{project_root}/hack/test/requireclass/typing/*.bad.php) (glob_files %{project_root}/hack/test/requireclass/typing/*.bad.php.exp) (glob_files %{project_root}/hack/test/requireclass/typing/*.bad.php.legacy_decl.exp)) (action (run %{project_root}/hack/test/verify.py %{project_root}/hack/test/requireclass/typing --program %{exe:../../../src/hh_single_type_check.exe} --in-extension .bad.php --out-extension .legacy_decl.out --expect-extension .legacy_decl.exp --fallback-expect-extension .exp --flags --out-extension .legacy_decl.out --error-format plain))) (alias (name runtest) (deps (alias requireclass_typing_good) (alias requireclass_typing_bad)))
PHP
hhvm/hphp/hack/test/requireclass/typing/ent_01.good.php
<?hh // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. <<file:__EnableUnstableFeatures('require_class')>> final class PFooEnt { use PFooAutogenTrait; const type TData = shape('a' => int); public function getData(): this::TData { return shape('a' => 4); } } trait PFooAutogenTrait { require class PFooEnt; public function foo(): int { return $this->getData()['a']; } }
PHP
hhvm/hphp/hack/test/requireclass/typing/ent_02.good.php
<?hh // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. <<file:__EnableUnstableFeatures('require_class')>> abstract class PEntBase { abstract const type TData; abstract public function getData(): this::TData; } final class PFooEnt extends PEntBase { use PFooAutogenTrait; const type TData = shape('a' => int); <<__Override>> public function getData(): this::TData { return shape('a' => 4); } } trait PFooAutogenTrait { require class PFooEnt; public function foo(): int { return $this->getData()['a']; } }
PHP
hhvm/hphp/hack/test/requireclass/typing/ent_03.good.php
<?hh // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. <<file:__EnableUnstableFeatures('require_class')>> final class PFooEnt { use PFooAutogenTrait; const type TData = shape('a' => int); } trait PFooAutogenTrait { require class PFooEnt; const type MyData = this::TData; public function gen(): this::MyData { return shape('a' => 5); } }
PHP
hhvm/hphp/hack/test/requireclass/typing/methods_philippe_01.good.php
<?hh // Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <<file: __EnableUnstableFeatures('require_class')>> interface IPajoux1 { public function foo(int $a): void; } interface IPajoux2 { public function foo(int $a, ?int $b = null): void; } abstract class PajouxBase { public function foo(int $a, ?int $b = null): void { invariant_violation('test'); } } final class Pajoux extends PajouxBase { use TPajoux; } trait TPajoux implements IPajoux1, IPajoux2 { require class Pajoux; }
PHP
hhvm/hphp/hack/test/requireclass/typing/methods_philippe_02.bad.php
<?hh // Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <<file: __EnableUnstableFeatures('require_class')>> interface IPajoux1 { public function foo(int $a): void; } interface IPajoux2 { public function foo(int $a, ?int $b = null): void; } abstract class PajouxBase { public function foo(int $a, ?int $b = null): void {} } final class Pajoux extends PajouxBase { use TPajoux; } trait TPajoux implements IPajoux1, IPajoux2 { public function foo(int $a): void {} require class Pajoux; }