use std::fs;
use crate::framework::default_test_settings;
mod framework;
macro_rules! test_case {
($test_name:ident, $settings:expr) => {
#[test]
fn $test_name() {
let content = include_str!(concat!("cases/", stringify!($test_name), ".php"));
$crate::framework::TestCase::new(stringify!($test_name), content).settings($settings).run();
}
};
($test_name:ident) => {
#[test]
fn $test_name() {
let content = include_str!(concat!("cases/", stringify!($test_name), ".php"));
$crate::framework::TestCase::new(stringify!($test_name), content).run();
}
};
}
test_case!(accessing_undefined_class_constant);
test_case!(argument_count);
test_case!(array_list_reconciliation);
test_case!(array_map_non_empty_array);
test_case!(array_map_non_empty_list);
test_case!(array_shape_fields);
test_case!(array_type_combination_threshold);
test_case!(array_unique_non_empty);
test_case!(assert_concrete_to_template_type);
test_case!(assert_generic_array_key_is_array_key);
test_case!(bare_identifier_in_array_access);
test_case!(bin2hex);
test_case!(break_narrowing);
test_case!(by_reference_invalidation);
test_case!(callable_template_inference);
test_case!(class_like_constant_access);
test_case!(collection_types);
test_case!(condition_is_too_complex);
test_case!(conditional_if_else);
test_case!(conditional_return_resolved_to_left);
test_case!(conditional_return_resolved_to_right);
test_case!(conditional_return_with_assignment_in_condition);
test_case!(const_array_key);
test_case!(docblock_type_mismatch);
test_case!(docblock_type_narrowing);
test_case!(docblock_type_parsing_verification);
test_case!(docblock_var_on_non_assignment);
test_case!(empty_switch);
test_case!(empty_construct);
test_case!(generic_shape_coercion);
test_case!(int_or_float);
test_case!(literal_float);
test_case!(multiline_intersection_var);
test_case!(multiline_union_param);
test_case!(int_mask);
test_case!(integer_range_reconciliation);
test_case!(integer_reconciliation);
test_case!(isset_and_nullable_access_assertions);
test_case!(intersection_stringable);
test_case!(iterable_array_comparison);
test_case!(iterable_count);
test_case!(iterable_reconciliation);
test_case!(non_empty_string_magic_constant);
test_case!(numeric_reconciliation);
test_case!(priority_queue_implementation);
test_case!(psl_integration);
test_case!(psr_container_get);
test_case!(flow_php_integration);
test_case!(reconcile_array_index_type);
test_case!(reconcile_empty_string);
test_case!(reconcile_non_empty_string);
test_case!(reconcile_properties);
test_case!(reconciling_generic_parameter);
test_case!(recursive_templates);
test_case!(resource_reconciliation);
test_case!(scalar_types_reconciliation);
test_case!(string_reconciliation);
test_case!(switch_complex_logic);
test_case!(switch_default_only);
test_case!(switch_empty_case);
test_case!(switch_fall_through);
test_case!(switch_mixed_fall_through);
test_case!(switch_multiple_cases);
test_case!(switch_no_break);
test_case!(switch_simple_break);
test_case!(switch_statement);
test_case!(switch_string_subject);
test_case!(switch_with_return);
test_case!(type_guard_followed_by_redundant_check);
test_case!(type_narrowing_and_assertions);
test_case!(unspecified_callable_or_closure);
test_case!(untemplated_generic_parameters);
test_case!(untyped_callable_parameter);
test_case!(yield_array_value);
test_case!(yield_from_generator);
test_case!(yield_from_invalid_key);
test_case!(yield_from_invalid_type);
test_case!(yield_from_non_iterable);
test_case!(yield_global_scope);
test_case!(yield_invalid_key);
test_case!(yield_invalid_value);
test_case!(yield_merge_iterables);
test_case!(switch_always_matching_case);
test_case!(switch_case_after_default_is_unreachable);
test_case!(switch_logically_unreachable_case);
test_case!(switch_on_literal);
test_case!(switch_redundant_condition);
test_case!(conditional_always_truthy);
test_case!(conditional_always_falsy);
test_case!(conditional_mixed_types);
test_case!(conditional_with_assignment);
test_case!(conditional_nested);
test_case!(elvis_operator_with_null);
test_case!(elvis_operator_with_falsy_string);
test_case!(short_ternary_with_truthy);
test_case!(short_ternary_with_falsy);
test_case!(conditional_type_narrowing);
test_case!(conditional_initialization);
test_case!(type_is_not_narrowed_by_nested_conditional_exit);
test_case!(dynamic_array_key_in_string_interpolation);
test_case!(big_numbers);
test_case!(numeric_non_lowercase_string);
test_case!(not_equal_negation);
test_case!(overload_resolution_for_callable);
test_case!(fully_qualified_use_prefix);
test_case!(extends_inheritance_happy_path);
test_case!(extends_inheritance_error_path);
test_case!(implements_inheritance_happy_path);
test_case!(implements_inheritance_error_path);
test_case!(use_inheritance_happy_path);
test_case!(use_inheritance_error_path);
test_case!(templated_trait_use);
test_case!(template_parameter_sanity_check);
test_case!(calling_trait_required_method);
test_case!(useless_statements);
test_case!(complex_template_constraint);
test_case!(docblock_var_override);
test_case!(isset_refinement_on_object_properties);
test_case!(array_shape_reconciliation);
test_case!(retain_possibly_undefined_in_array_access);
test_case!(static_return_generic_override);
test_case!(default_parameter_inference);
test_case!(infer_class_string_on_generic_object);
test_case!(redefined_loop_variables);
test_case!(keyed_array_list_inference);
test_case!(require_implements_inherited);
test_case!(readonly_proptected_set);
test_case!(value_of_enum_resolution);
test_case!(properties_of_enum);
test_case!(properties_of_class);
test_case!(properties_of_generic);
test_case!(properties_of_visibility);
test_case!(assert_or_type);
test_case!(impossible_assertion);
test_case!(negation_operand);
test_case!(infere_closure_parameter_type);
test_case!(negated_union_type);
test_case!(reference_constraint_violation);
test_case!(unreferencable_expression);
test_case!(pass_by_ref);
test_case!(return_by_ref);
test_case!(array_refs);
test_case!(ref_constraint_conflict);
test_case!(match_not_exhaustive);
test_case!(match_expression);
test_case!(match_arm_reaching);
test_case!(missing_constructor);
test_case!(property_initialization);
test_case!(parent_constructor_init);
test_case!(parent_static_return);
test_case!(property_hooks_initialization);
test_case!(trait_property_initialization);
test_case!(deep_inheritance_init);
test_case!(properties_added_to_context);
test_case!(throwing_exceptions);
test_case!(reference_reused_from_confusing_scope);
test_case!(reconcile_literl_class_string);
test_case!(class_string_is_never_equal_to_literal_string);
test_case!(narrow_class_string_match);
test_case!(narrow_non_final_class_string_match);
test_case!(expand_class_constant_type);
test_case!(iterator_to_array);
test_case!(arrow_function_inherits_method_templates);
test_case!(all_paths_return_value);
test_case!(reconcile_scalars);
test_case!(static_anonymous_class);
test_case!(private_static_method);
test_case!(method_docblock);
test_case!(property_docblock);
test_case!(untyped_property_docblock);
test_case!(count);
test_case!(array_key_exists);
test_case!(magic_methods);
test_case!(magic_properties);
test_case!(magic_methods_args);
test_case!(method_annotation_with_inheritance);
test_case!(array_shape_access);
test_case!(closure_wrap);
test_case!(arguments_unpacking);
test_case!(unknown_named_args);
test_case!(constant_type);
test_case!(match_true_and_false);
test_case!(array_reconcile);
test_case!(sealed_array_combine);
test_case!(object_shape);
test_case!(optional_object_with_properties);
test_case!(unsealed_array_overlap);
test_case!(echo_tag);
test_case!(var_docblock);
test_case!(redundant_var_docblock);
test_case!(magic_method_trait);
test_case!(real_pseudo_method);
test_case!(pseudo_method_override);
test_case!(parent_magic_method_call);
test_case!(chunk);
test_case!(chunk_with_keys);
test_case!(trait_alias_vis_self);
test_case!(trait_constant_override);
test_case!(trait_usage_errors);
test_case!(trait_method_closure_self);
test_case!(method_signature_parameter_count);
test_case!(method_signature_param_types);
test_case!(method_signature_return_types);
test_case!(return_type_override_native_vs_docblock);
test_case!(conditional_return_with_default_parameters);
test_case!(method_signature_visibility);
test_case!(method_signature_static);
test_case!(trait_method_conflicts);
test_case!(trait_property_visibility_conflicts);
test_case!(trait_property_default_value_conflicts);
test_case!(trait_class_property_conflicts);
test_case!(trait_property_static_modifiers);
test_case!(trait_property_type_conflicts);
test_case!(trait_property_hierarchy_conflicts);
test_case!(trait_property_readonly_conflicts);
test_case!(readonly_class_trait_non_readonly_property);
test_case!(test_visibility);
test_case!(test_minimal_static);
test_case!(interface_template_signatures);
test_case!(method_signature_complex);
test_case!(method_signature_edge_cases);
test_case!(method_signature_parameter_names);
test_case!(method_signature_template_substitution);
test_case!(multi_level_template_inheritance);
test_case!(true_ident);
test_case!(eliminate_true_and_false_from_scalar);
test_case!(subtract_objects);
test_case!(sealed_class_2_inheritors);
test_case!(sealed_class_5_inheritors);
test_case!(sealed_class_7_inheritors);
test_case!(sealed_class_10_inheritors);
test_case!(sealed_class_15_inheritors);
test_case!(sealed_class_performance);
test_case!(class_instance);
test_case!(conditional_return);
test_case!(literal_int);
test_case!(calling_interface_methods_from_trait);
test_case!(parent_class_constant_validation);
test_case!(interface_constant_validation);
test_case!(trait_constant_conflicts);
test_case!(trait_constant_direct_access);
test_case!(trait_constant_access);
test_case!(trait_override_final_methods);
test_case!(inheritdoc_basic_parent_class);
test_case!(inheritdoc_multiple_interfaces);
test_case!(inheritdoc_nested_generics);
test_case!(inheritdoc_priority);
test_case!(inheritdoc_contravariant_parameters);
test_case!(inherited_docblock_narrowing);
test_case!(type_alias_basic);
test_case!(type_alias_import);
test_case!(type_alias_import_rename);
test_case!(type_alias_complex_types);
test_case!(type_alias_phpstan);
test_case!(type_alias_syntax);
test_case!(type_alias_in_class_method_parameters);
test_case!(change_private_parent_prop);
test_case!(class_in_alias);
test_case!(index_access);
test_case!(merge_arrays_non_empty);
test_case!(expand_generic_params);
test_case!(nullsafe_operator_chain_shortcircuit);
test_case!(property_docblock_type_annotation);
test_case!(array_key_access_after_existence_check);
test_case!(mb_encoding);
test_case!(psl_awaitable_promise);
test_case!(partial_application_function);
test_case!(partial_application_method);
test_case!(partial_application_static_method);
test_case!(partial_application_templates);
test_case!(partial_application_type_inference);
test_case!(partial_application_simple);
test_case!(partial_application_named_argument_reordering);
test_case!(octal_zero_prefix);
test_case!(switch_semicolon);
test_case!(redundant_assert);
test_case!(union_template_constraint);
test_case!(class_string_union_constraint);
test_case!(float_string_concat);
test_case!(array_key_concat);
test_case!(string_concat_combination_threshold);
test_case!(iterator_type_inference);
test_case!(unused_template_parameter);
test_case!(unused_function_template_parameter);
test_case!(unused_method);
test_case!(unused_property);
test_case!(unused_edge_cases);
test_case!(uninitialized_property);
test_case!(property_hooks);
test_case!(interface_property_hook);
test_case!(trait_require_implements_self_return);
test_case!(trait_require_extends_self_return);
test_case!(trait_require_combined);
test_case!(interface_assertion);
test_case!(nullsafe_chain_bug);
test_case!(class_string_instantiation);
test_case!(class_string_comparison);
test_case!(static_var_lazy_init);
test_case!(static_var_coalesce);
test_case!(array_coalesce_assign_check);
test_case!(factory_null_params);
test_case!(clone_dynamic_class);
test_case!(nullable_method_coalesce);
test_case!(property_coalesce_init);
test_case!(ctype_digit_check);
test_case!(mutually_exclusive_null);
test_case!(null_array_key);
test_case!(nullable_getter_check);
test_case!(abstract_factory_pattern);
test_case!(array_key_coalesce);
test_case!(defensive_type_check);
test_case!(enum_empty_check);
test_case!(optional_chain_method);
test_case!(compound_condition);
test_case!(instanceof_assertion);
test_case!(type_narrowing_external);
test_case!(post_narrowing_check);
test_case!(data_transformer_type);
test_case!(symbol_existence_assertions);
test_case!(symbol_existence_edge_cases);
test_case!(type_assert);
test_case!(string_callable_template_inference);
test_case!(clear_narrowed_prop_after_call);
test_case!(binary_throw_used);
test_case!(template_null_comparison);
test_case!(finally_after_return);
test_case!(property_magic_constant);
test_case!(variable_key_narrowing_not_null);
test_case!(bad_path_abstract_instantiation);
test_case!(bad_path_interface_instantiation);
test_case!(bad_path_enum_instantiation);
test_case!(bad_path_invalid_break);
test_case!(bad_path_invalid_continue);
test_case!(bad_path_null_operand);
test_case!(bad_path_null_iterator);
test_case!(bad_path_null_property_access);
test_case!(bad_path_method_access_on_null);
test_case!(bad_path_possibly_null_operand);
test_case!(bad_path_possibly_null_iterator);
test_case!(bad_path_possibly_null_property_access);
test_case!(bad_path_invalid_iterator);
test_case!(bad_path_invalid_clone);
test_case!(bad_path_invalid_throw);
test_case!(bad_path_redundant_null_coalesce);
test_case!(bad_path_redundant_nullsafe);
test_case!(bad_path_assignment_to_this);
test_case!(typed_property_null_coalesce);
test_case!(docblock_var_override_foreach);
test_case!(mixin);
test_case!(issue_contravariant_params_diamond);
test_case!(issue_contravariant_params_simple);
test_case!(anonymous_class_constructor_args);
test_case!(undefined_type_reference);
test_case!(duplicate_definition);
test_case!(method_call_assertions);
test_case!(class_must_be_final, {
let mut s = crate::framework::default_test_settings();
s.enforce_class_finality = true;
s
});
test_case!(missing_api_or_internal, {
let mut s = crate::framework::default_test_settings();
s.require_api_or_internal = true;
s
});
test_case!(spread_list);
test_case!(or_never);
test_case!(abstract_method_inheritance);
test_case!(issue_659);
test_case!(issue_660);
test_case!(issue_663);
test_case!(issue_265);
test_case!(issue_275);
test_case!(issue_306);
test_case!(issue_355);
test_case!(issue_356);
test_case!(issue_357);
test_case!(issue_358);
test_case!(issue_359);
test_case!(issue_360);
test_case!(issue_361);
test_case!(issue_362);
test_case!(issue_366);
test_case!(issue_368);
test_case!(issue_388);
test_case!(issue_390);
test_case!(issue_391);
test_case!(issue_393);
test_case!(issue_396);
test_case!(issue_400);
test_case!(issue_413);
test_case!(issue_414);
test_case!(issue_415);
test_case!(issue_417);
test_case!(issue_425_json_encode);
test_case!(issue_451);
test_case!(issue_461);
test_case!(issue_459);
test_case!(issue_465);
test_case!(issue_448);
test_case!(issue_498);
test_case!(issue_513);
test_case!(issue_514);
test_case!(issue_493);
test_case!(issue_504);
test_case!(issue_508);
test_case!(issue_510);
test_case!(issue_511);
test_case!(issue_519);
test_case!(issue_520);
test_case!(issue_521);
test_case!(issue_523);
test_case!(issue_528);
test_case!(issue_474);
test_case!(issue_531);
test_case!(issue_535);
test_case!(issue_537);
test_case!(issue_538);
test_case!(issue_540);
test_case!(issue_541);
test_case!(issue_542);
test_case!(issue_542_part_2);
test_case!(issue_546);
test_case!(issue_557_part_1);
test_case!(issue_557_part_2);
test_case!(issue_559);
test_case!(issue_563);
test_case!(issue_564);
test_case!(issue_567);
test_case!(issue_568);
test_case!(issue_570);
test_case!(issue_571);
test_case!(issue_573);
test_case!(issue_549);
test_case!(issue_551);
test_case!(issue_553);
test_case!(issue_577);
test_case!(issue_574);
test_case!(issue_583);
test_case!(issue_586);
test_case!(issue_588);
test_case!(issue_596);
test_case!(issue_598);
test_case!(issue_606);
test_case!(issue_607);
test_case!(issue_617);
test_case!(issue_620);
test_case!(issue_621);
test_case!(issue_622);
test_case!(issue_623);
test_case!(issue_626);
test_case!(issue_627);
test_case!(issue_633);
test_case!(issue_637);
test_case!(issue_639);
test_case!(issue_658);
test_case!(issue_664);
test_case!(issue_665);
test_case!(issue_666);
test_case!(issue_667);
test_case!(issue_670);
test_case!(issue_671);
test_case!(issue_672);
test_case!(issue_676);
test_case!(issue_684);
test_case!(issue_689);
test_case!(issue_690);
test_case!(issue_701);
test_case!(issue_706);
test_case!(issue_709);
test_case!(issue_710);
test_case!(issue_708_part_1);
test_case!(issue_708_part_2);
test_case!(issue_711);
test_case!(issue_712);
test_case!(issue_716);
test_case!(issue_717);
test_case!(issue_718);
test_case!(issue_719);
test_case!(issue_720);
test_case!(issue_721);
test_case!(issue_722);
test_case!(issue_725);
test_case!(issue_728_symfony_reference);
test_case!(issue_729);
test_case!(issue_731);
test_case!(issue_732);
test_case!(issue_733);
test_case!(issue_735);
test_case!(issue_736);
test_case!(issue_737);
test_case!(issue_739);
test_case!(issue_742);
test_case!(issue_743);
test_case!(issue_749);
test_case!(issue_746_part_1);
test_case!(issue_746_part_2);
test_case!(issue_746_part_3);
test_case!(issue_746_part_4);
test_case!(issue_746_part_5);
test_case!(issue_746_part_6);
test_case!(issue_752);
test_case!(issue_754);
test_case!(issue_755);
test_case!(issue_756);
test_case!(issue_764);
test_case!(issue_765);
test_case!(issue_766);
test_case!(issue_776);
test_case!(issue_782);
test_case!(issue_784);
test_case!(issue_785);
test_case!(issue_789);
test_case!(issue_801);
test_case!(issue_806);
test_case!(issue_809);
test_case!(issue_822);
test_case!(issue_830);
test_case!(issue_835);
test_case!(issue_837);
test_case!(issue_845);
test_case!(issue_849);
test_case!(issue_859);
test_case!(issue_861);
test_case!(issue_863);
test_case!(issue_870);
test_case!(issue_871);
test_case!(issue_872);
test_case!(issue_880);
test_case!(issue_886);
test_case!(issue_900);
test_case!(issue_912);
test_case!(issue_923);
test_case!(issue_932);
test_case!(issue_940);
test_case!(issue_941);
test_case!(issue_945);
test_case!(issue_946);
test_case!(issue_949);
test_case!(issue_954);
test_case!(issue_955);
test_case!(issue_957);
test_case!(issue_958);
test_case!(issue_960);
test_case!(issue_962);
test_case!(issue_964);
test_case!(issue_969);
test_case!(issue_970);
test_case!(issue_973);
test_case!(issue_976);
test_case!(issue_980);
test_case!(issue_984);
test_case!(issue_985);
test_case!(issue_996);
test_case!(issue_998);
test_case!(issue_1002_part_1);
test_case!(issue_1002_part_2);
test_case!(issue_1002_part_3);
test_case!(issue_1002_part_4);
test_case!(issue_1005);
test_case!(issue_1006);
test_case!(issue_1021);
test_case!(issue_1025);
test_case!(issue_1026);
test_case!(issue_1029);
test_case!(issue_1030);
test_case!(issue_1038);
test_case!(issue_1040);
test_case!(issue_1045);
test_case!(issue_1057);
test_case!(issue_1064);
test_case!(issue_1061);
test_case!(issue_1068);
test_case!(issue_1069, {
let mut s = default_test_settings();
s.find_unused_definitions = true;
s
});
test_case!(issue_1070);
test_case!(issue_1071);
test_case!(issue_1072);
test_case!(issue_1074);
test_case!(issue_1031);
test_case!(issue_1081);
test_case!(issue_1083);
test_case!(issue_1084);
test_case!(issue_1086);
test_case!(issue_1087);
test_case!(issue_1088);
test_case!(issue_1089);
test_case!(issue_1096);
test_case!(issue_1099);
test_case!(issue_1103);
test_case!(issue_1106);
test_case!(issue_1107);
test_case!(issue_1110);
test_case!(issue_1112);
test_case!(issue_1116);
test_case!(issue_1104);
test_case!(issue_1117);
test_case!(issue_1119);
test_case!(issue_1108);
test_case!(issue_1102);
test_case!(issue_1093);
#[test]
fn test_all_test_cases_are_ran() {
let test_case_file = include_str!("mod.rs");
let test_cases_dir = fs::read_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/cases")).unwrap();
for entry in test_cases_dir {
let path = entry.unwrap().path();
if !path.is_file() {
continue;
}
let file_name = path.file_stem().unwrap().to_str().unwrap();
let has_test = test_case_file.contains(&format!("test_case!({file_name})"))
|| test_case_file.contains(&format!("test_case!({file_name},"));
assert!(has_test, "File '{file_name}' was not found as a test case");
}
}