Skip to content

Upgrading friendsofphp/php-cs-fixer 2 to 3

Breakingv2.19.3 โ†’ v3.95.27Breaking40Security3Platform9Deprecated22New274Changed306Fixed556Other1331

BreakingUpgrade verdict

40 breaking changes and 9 platform requirement changes and 3 security fixes.

  • The fixer that removes duplicate types in docblocks now has a new name, so configurations using the old name must be updated.
  • Version-based ruleset names change format, so configs using the old names must be updated.
  • The rule that enforces visibility keywords has a new name, so configs referencing the old name must change.
  • Renames RuleSetDescriptionInterface to RuleSetDefinitionInterface.
Top 5 of 74 that need code or config changes

friendsofphp/php-cs-fixer publishes official migration guides for versions 3, 3, 3. They cover more than the release notes do.

Upgrade guide โ†—Upgrade guide โ†—Upgrade guide โ†—

PHP requirement changed in v3.21.2: ^5.6 || ^7.0 || ^8.0 โ†’ ^7.4 || ^8.0.

Breaking40
Renames PhpdocTypesNoDuplicatesFixer to PhpdocNoDuplicateTypesFixer.
PhpdocTypesNoDuplicatesFixerPhpdocNoDuplicateTypesFixer
Renames rule sets from MAJORMINOR and MAJOR.MINOR to MAJORxMINOR.
Renames the visibility_required rule to modifier_keywords.
visibility_requiredmodifier_keywords
Renames RuleSetDescriptionInterface to RuleSetDefinitionInterface.
RuleSetDescriptionInterfaceRuleSetDefinitionInterface
Removes AbstractFixerTestCase::getTestFile().
AbstractFixerTestCase::getTestFile()
Removes support for an array of patterns in Preg methods.
Preg
Removes the second parameter of the XdebugHandler constructor.
XdebugHandler
Removes __constructor() from RuleSetDescriptionInterface.
RuleSetDescriptionInterface__constructor()
show-progress option drops run-in and estimating, and renames estimating-max to dots.
show-progressrun-inestimatingestimating-maxdots
Tokenizer removes deprecations and legacy mode.
Tokenizer
Rules change default options.
Drops the SKIP_LINT_TEST_CASES environment variable.
SKIP_LINT_TEST_CASES
Rules drop rootless configurations.
Rules drop deprecated configurations.
FixerDefinitionInterface drops getConfigurationDescription and getDefaultConfiguration.
FixerDefinitionInterfacegetConfigurationDescriptiongetDefaultConfiguration
diff-format option drops sbd diff, uses udiffer by default, and drops SebastianBergmannDiffer and SebastianBergmannShortDiffer classes.
diff-formatsbdudifferSebastianBergmannDifferSebastianBergmannShortDiffer
Removes the Helpers class.
Helpers
Drops the AccessibleObject class.
AccessibleObject
Drops deprecated rules: blank_line_before_return, hash_to_slash_comment, method_separation, no_extra_consecutive_blank_lines, no_multiline_whitespace_before_semicolons and pre_increment.
blank_line_before_returnhash_to_slash_commentmethod_separationno_extra_consecutive_blank_linesno_multiline_whitespace_before_semicolonspre_increment
Removes deprecated rules: lowercase_constants, php_unit_ordered_covers and silenced_deprecation_error.
lowercase_constantsphp_unit_ordered_coverssilenced_deprecation_error
Removes the deprecated no_short_echo_tag rule.
no_short_echo_tag
Drops mapping of strings to boolean options other than yes/no.
Drops diff-format.
Drops the deprecated argument of Tokens::findBlockEnd.
Tokens::findBlockEnd
Drops the deprecated flat list configuration of ClassAttributesSeparationFixer.
ClassAttributesSeparationFixer
RuleSet no longer allows null to disable a rule.
RuleSet
Removes Utils::calculateBitmask.
Utils::calculateBitmask
Removes the parameter from Token::toJson().
Token::toJson()
Removes TrailingCommaInMultilineArrayFixer.
TrailingCommaInMultilineArrayFixer
Drops support for justinrainbow/json-schema:^5.
justinrainbow/json-schema
Fixers stop exposing extra properties and constants.
MethodArgumentSpaceFixer fixSpace is now private.
MethodArgumentSpaceFixerfixSpace
DefinedFixerInterface is incorporated into FixerInterface.
DefinedFixerInterfaceFixerInterface
ConfigurableFixerInterface::configure param is now not nullable and not optional.
ConfigurableFixerInterface::configure
ConfigurationDefinitionFixerInterface is incorporated into ConfigurableFixerInterface.
ConfigurationDefinitionFixerInterfaceConfigurableFixerInterface
FixCommand forbids passing 'config' and 'rules' options together.
FixCommandconfigrules
Makes some more classes final.
Further backward compatibility cleanup for 3.0.
Drops the src/Test namespace.
Forbids usage of the old config filename.
Security3
Refuses a symlinked cache path in FileHandler to avoid arbitrary file overwrite.
FileHandler
Addresses a credential exposure concern related to using ergebnis/agent-detector for detecting an AI agent.
ergebnis/agent-detector
Hardens GitHub Workflows security.
Platform9
Adds PHP 8.5 compatibility support.
Adds official support for PHP 8.5.
Adds official support for PHP 8.4.
Adds support for Symfony 7.
Requires PHP ^8.0.1.
Bumps the required PHP version to 7.4.
Bumps the minimum required PHP version to 7.2.
Requires PHP 7.2.
Bumps the required PHP version to 7.1.
Deprecated22
Explicitly deprecates usage of non-handled objects in rules configuration, which now silently fail, and adds support for JsonSerializable config values.
JsonSerializable
Marks one remaining Analyzer to become internal.
Analyzer
Deprecates loading configuration from the path CLI argument.
path
Deprecates Annotation::getTagsWithTypes in favor of the TAGS_WITH_TYPES constant.
Annotation::getTagsWithTypesTAGS_WITH_TYPES
DescribeCommand now indicates that a set is deprecated whenever mentioning one.
DescribeCommand
Deprecates the length sorting algorithm of OrderedImportsFixer.
OrderedImportsFixer
Deprecates ConfigInterface::getPhpExecutable() and ConfigInterface::setPhpExecutable().
ConfigInterface::getPhpExecutable()ConfigInterface::setPhpExecutable()
Deprecates the nullable_type_declaration_for_default_null_value option that conflicts with @PHP84Migration.
nullable_type_declaration_for_default_null_value@PHP84Migration
Deprecates Token::isKeyCaseSensitive.
Token::isKeyCaseSensitive
Deprecates Token::isKeyCaseSensitive, second part.
Token::isKeyCaseSensitive
Deprecates CompactNullableTypehintFixer and proxies it to CompactNullableTypeDeclarationFixer.
CompactNullableTypehintFixerCompactNullableTypeDeclarationFixer
Deprecates NewWithBracesFixer and proxies it to NewWithParenthesesFixer.
NewWithBracesFixerNewWithParenthesesFixer
Deprecates CurlyBracesPositionFixer and proxies it to BracesPositionFixer.
CurlyBracesPositionFixerBracesPositionFixer
Deprecates NoUnneededCurlyBracesFixer and proxies it to NoUnneededBracesFixer.
NoUnneededCurlyBracesFixerNoUnneededBracesFixer
Marks PER-CS v1 as deprecated.
PER-CS1.0
Officially deprecates the internal Utils anti-pattern class.
Utils
Marks Tokens::getNamespaceDeclarations as @internal.
Tokens::getNamespaceDeclarations
Introduces single_space_around_construct and deprecates single_space_after_construct.
single_space_around_constructsingle_space_after_construct
Deprecates BracesFixer.
BracesFixer
Deprecates ClassKeywordRemoveFixer.
ClassKeywordRemoveFixer
Deprecates v2.
Deprecates the parameter of Token::toJson().
Token::toJson()