StyleCI Blog

Platform Improvements

July 27, 2020

StyleCI Banner

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:

  1. Our none and psr1 presets have remained unchanged.
  2. From the psr2 preset, the method_argument_space fixer has been removed, and the method_argument_space_strict and no_break_comment fixers have been added.
  3. From the psr12 preset, the no_empty_statement fixer has been removed, and the const_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_namespace and ternary_operator_spaces fixers have been added.
  4. From the symfony preset, the blank_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_separation and psr12_braces fixers have been removed, and the alpha_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_braces and ternary_to_elvis_operator fixers have been added.
  5. From the laravel preset, the psr2_braces and simplified_null_return fixers have been removed, and the die_to_exit, no_alternative_syntax, no_binary_string, no_unset_cast, no_unused_lambda_imports, phpdoc_return_self_reference, psr12_braces and switch_continue_to_break fixers have been added.
  6. From the recommended preset, the psr12_braces fixer has been removed, and the die_to_exit, no_binary_string, no_unset_cast, no_unused_lambda_imports, phpdoc_return_self_reference, switch_continue_to_break and symfony_braces fixers 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!



© 2023 Graham Campbell Technology Ltd. All rights reserved.