Platform Improvements
July 27, 2020
We have deployed various improvements and tweaks today. Risky fixers are now disabled by default, we’ve introduced lots of new fixers, and our presets have been tweaked accordingly. Moreover, it is now possible to specify the PHP version you’d like StyleCI to parse your code as. Currently, the only option is version 7, however we will be adding version 8 in the future, leaving 7 as the default, allowing people to opt-in to beta PHP 8 support without us needing to roll it out to everyone.
Our decision to disable risky mode by default has important consequences for our presets. Now when you enable a preset, only the safe rules will be enabled by default, unless you opt-in to risky mode. Enabling risky mode will have the effect of also enabling any risky fixers associated with your chosen preset, along with allowing you to manually enable other risky fixers.
Our new safe PHP fixers are: alpha_ordered_traits, die_to_exit, no_blank_lines_around_break, no_blank_lines_around_cases, no_blank_lines_around_continue, no_blank_lines_around_switch, no_break_comment, no_single_line_asterisk_comment, no_superfluous_phpdoc_tags_symfony, no_unused_lambda_imports, phpdoc_trim_consecutive_blank_line_separation, phpdoc_types_null_last, simplified_if_return, switch_continue_to_break and symfony_braces, and our new risky PHP fixers are: array_push, fopen_flag_order, fopen_flags, native_constant_invocation_symfony, native_function_invocation_symfony, no_trailing_whitespace_in_string, regular_callable_call, ternary_to_elvis_operator and use_arrow_functions. The native_constant_invocation fixer cannot be enabled with native_constant_invocation_symfony, the native_function_invocation fixer cannot be enabled with native_function_invocation_symfony, the no_superfluous_phpdoc_tags fixer cannot be enabled with no_superfluous_phpdoc_tags_symfony, the phpdoc_types_null_last fixer cannot be enabled with phpdoc_types_order, and the psr2_braces, psr12_braces, and symfony_braces fixers all cannot be enabled at the same time as each other. Full details of these fixers is available at https://docs.styleci.io/fixers.
Our no_unneeded_control_parentheses fixer is now more wide-reaching than before, fixing in more contexts, the no_unneeded_curly_braces fixer now removes braces from import statements where only one item is enclosed in the braces, the phpdoc_align fixer now aligns @method and @property doc as well as @param, @return, @throws, @type and @var doc, and the silenced_deprecation_error fixer has been renamed to error_suppression, with its old name acting as an alias for it’s new name. We have also changed the psr12_braces fixer to no longer allow single-line closures: use the new symfony_braces fixer instead for that behaviour.
We now highlight the changes made to our presets:
- Our
noneandpsr1presets have remained unchanged. - From the
psr2preset, themethod_argument_spacefixer has been removed, and themethod_argument_space_strictandno_break_commentfixers have been added. - From the
psr12preset, theno_empty_statementfixer has been removed, and theconst_visibility_required,lowercase_cast,lowercase_static_reference,no_blank_lines_after_class_opening,no_break_comment,no_trailing_whitespace_in_string,no_unreachable_default_argument_value,short_scalar_cast,single_blank_line_before_namespaceandternary_operator_spacesfixers have been added. - From the
symfonypreset, theblank_line_before_break,blank_line_before_continue,blank_line_before_declare,blank_line_before_throw,blank_line_before_try,const_separation,heredoc_to_nowdoc,method_argument_space_strict,phpdoc_no_empty_return,property_separationandpsr12_bracesfixers have been removed, and thealpha_ordered_traits,array_push,backtick_to_shell_exec,combine_nested_dirname,compact_nullable_typehint,die_to_exit,dir_constant,ereg_to_preg,error_suppression,fopen_flag_order,fopen_flags,fully_qualified_strict_types,function_to_constant,implode_call,is_null,linebreak_after_opening_tag,logical_operators,method_argument_space,modernize_types_casting,native_constant_invocation_symfony,native_function_invocation_symfony,no_alternative_syntax,no_binary_string,no_blank_lines_around_cases,no_blank_lines_around_continue,no_blank_lines_around_switch,no_blank_lines_between_traits,no_break_comment,no_homoglyph_names,no_short_echo_tag,no_superfluous_phpdoc_tags_symfony,no_trailing_whitespace_in_string,no_unneeded_final_method,no_unset_cast,no_unused_lambda_imports,non_printable_character,phpdoc_property,phpdoc_trim_consecutive_blank_line_separation,phpdoc_types_null_last,pow_to_exponentiation,protected_to_private,set_type_to_cast,short_array_syntax,standardize_increment,string_line_ending,switch_continue_to_break,symfony_bracesandternary_to_elvis_operatorfixers have been added. - From the
laravelpreset, thepsr2_bracesandsimplified_null_returnfixers have been removed, and thedie_to_exit,no_alternative_syntax,no_binary_string,no_unset_cast,no_unused_lambda_imports,phpdoc_return_self_reference,psr12_bracesandswitch_continue_to_breakfixers have been added. - From the
recommendedpreset, thepsr12_bracesfixer has been removed, and thedie_to_exit,no_binary_string,no_unset_cast,no_unused_lambda_imports,phpdoc_return_self_reference,switch_continue_to_breakandsymfony_bracesfixers have been added.
Many of these additional fixers are risky, in particular in the case of the symfony preset, and so will not be selected unless risky mode has also been enabled. Our preset documentation been updated to clearly show which of the fixers are safe and which are risky.
Please do get in touch with us if you have any questions or comments!