Skip to content

Upgrading fabpot/php-cs-fixer 2 to 3

Breakingv2.19.3 โ†’ v3.95.27Breaking39Security3Platform8Deprecated18New286Changed323Fixed593Other1272

BreakingUpgrade verdict

39 breaking changes and 8 platform requirement changes and 3 security fixes.

  • The fixer for duplicate PHPDoc types has a new name, so configurations using the old name must be updated.
  • Removes AbstractFixerTestCase::getTestFile().
  • Removes support for an array of patterns in Preg methods.
  • Code constructing XdebugHandler with a second argument will break.
Top 5 of 68 that need code or config changes

fabpot/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.

Breaking39
Renames PhpdocTypesNoDuplicatesFixer to PhpdocNoDuplicateTypesFixer.
PhpdocTypesNoDuplicatesFixerPhpdocNoDuplicateTypesFixer
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 their 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 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
Drops the unused Tokens::warnPhp8SplFixerArrayChange method.
Tokens::warnPhp8SplFixerArrayChange
Drops IsIdenticalConstraint.
IsIdenticalConstraint
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
Fixers stop exposing extra properties and constants.
MethodArgumentSpaceFixer fixSpace is now private.
MethodArgumentSpaceFixerfixSpace
DefinedFixerInterface is incorporated into FixerInterface.
DefinedFixerInterfaceFixerInterface
ConfigurableFixerInterface::configure parameter is now not nullable and not optional.
ConfigurableFixerInterface::configure
ConfigurationDefinitionFixerInterface is incorporated into ConfigurableFixerInterface.
ConfigurationDefinitionFixerInterfaceConfigurableFixerInterface
FixCommand forbids passing the 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.
Removes the 'create' method in internal classes.
create
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.
Platform8
Use shipmonk/composer-dependency-analyser instead of icanhazstring/composer-unused and maglnet/composer-require-checker.
shipmonk/composer-dependency-analysericanhazstring/composer-unusedmaglnet/composer-require-checker
Drop support for justinrainbow/json-schema:^5.
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 or higher.
Bumps the required PHP version to 7.1.
Deprecated18
Explicitly deprecates non-handled objects in rules configuration, which now silently fail, and adds support for JsonSerializable config values.
JsonSerializable
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
Continues deprecating Token::isKeyCaseSensitive in a 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()