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.
In plain terms
- 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.
Must act 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.
What you must change
Breaking40
Renames PhpdocTypesNoDuplicatesFixer to PhpdocNoDuplicateTypesFixer.
PhpdocTypesNoDuplicatesFixerPhpdocNoDuplicateTypesFixerRenames rule sets from
MAJORMINOR and MAJOR.MINOR to MAJORxMINOR.Renames the
visibility_required rule to modifier_keywords.visibility_requiredmodifier_keywordsRenames RuleSetDescriptionInterface to RuleSetDefinitionInterface.
RuleSetDescriptionInterfaceRuleSetDefinitionInterfaceRemoves AbstractFixerTestCase::getTestFile().
AbstractFixerTestCase::getTestFile()Removes support for an array of patterns in Preg methods.
PregRemoves the second parameter of the XdebugHandler constructor.
XdebugHandlerRemoves __constructor() from RuleSetDescriptionInterface.
RuleSetDescriptionInterface__constructor()show-progress option drops run-in and estimating, and renames estimating-max to dots.
show-progressrun-inestimatingestimating-maxdotsTokenizer removes deprecations and legacy mode.
TokenizerRules change default options.
Drops the SKIP_LINT_TEST_CASES environment variable.
SKIP_LINT_TEST_CASESRules drop rootless configurations.
Rules drop deprecated configurations.
FixerDefinitionInterface drops getConfigurationDescription and getDefaultConfiguration.
FixerDefinitionInterfacegetConfigurationDescriptiongetDefaultConfigurationdiff-format option drops sbd diff, uses udiffer by default, and drops SebastianBergmannDiffer and SebastianBergmannShortDiffer classes.
diff-formatsbdudifferSebastianBergmannDifferSebastianBergmannShortDifferRemoves the Helpers class.
HelpersDrops the AccessibleObject class.
AccessibleObjectDrops 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_incrementRemoves deprecated rules: lowercase_constants, php_unit_ordered_covers and silenced_deprecation_error.
lowercase_constantsphp_unit_ordered_coverssilenced_deprecation_errorRemoves the deprecated no_short_echo_tag rule.
no_short_echo_tagDrops mapping of strings to boolean options other than yes/no.
Drops diff-format.
Drops the deprecated argument of Tokens::findBlockEnd.
Tokens::findBlockEndDrops the deprecated flat list configuration of ClassAttributesSeparationFixer.
ClassAttributesSeparationFixerRuleSet no longer allows null to disable a rule.
RuleSetRemoves Utils::calculateBitmask.
Utils::calculateBitmaskRemoves the parameter from Token::toJson().
Token::toJson()Removes TrailingCommaInMultilineArrayFixer.
TrailingCommaInMultilineArrayFixerDrops support for justinrainbow/json-schema:^5.
justinrainbow/json-schemaFixers stop exposing extra properties and constants.
MethodArgumentSpaceFixer fixSpace is now private.
MethodArgumentSpaceFixerfixSpaceDefinedFixerInterface is incorporated into FixerInterface.
DefinedFixerInterfaceFixerInterfaceConfigurableFixerInterface::configure param is now not nullable and not optional.
ConfigurableFixerInterface::configureConfigurationDefinitionFixerInterface is incorporated into ConfigurableFixerInterface.
ConfigurationDefinitionFixerInterfaceConfigurableFixerInterfaceFixCommand forbids passing 'config' and 'rules' options together.
FixCommandconfigrulesMakes 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.
FileHandlerAddresses a credential exposure concern related to using ergebnis/agent-detector for detecting an AI agent.
ergebnis/agent-detectorHardens 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.
Deprecations to plan for
Deprecated22
Explicitly deprecates usage of non-handled objects in rules configuration, which now silently fail, and adds support for JsonSerializable config values.
JsonSerializableMarks one remaining Analyzer to become internal.
AnalyzerDeprecates loading configuration from the
path CLI argument.pathDeprecates Annotation::getTagsWithTypes in favor of the TAGS_WITH_TYPES constant.
Annotation::getTagsWithTypesTAGS_WITH_TYPESDescribeCommand now indicates that a set is deprecated whenever mentioning one.
DescribeCommandDeprecates the length sorting algorithm of OrderedImportsFixer.
OrderedImportsFixerDeprecates 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@PHP84MigrationDeprecates Token::isKeyCaseSensitive.
Token::isKeyCaseSensitiveDeprecates Token::isKeyCaseSensitive, second part.
Token::isKeyCaseSensitiveDeprecates CompactNullableTypehintFixer and proxies it to CompactNullableTypeDeclarationFixer.
CompactNullableTypehintFixerCompactNullableTypeDeclarationFixerDeprecates NewWithBracesFixer and proxies it to NewWithParenthesesFixer.
NewWithBracesFixerNewWithParenthesesFixerDeprecates CurlyBracesPositionFixer and proxies it to BracesPositionFixer.
CurlyBracesPositionFixerBracesPositionFixerDeprecates NoUnneededCurlyBracesFixer and proxies it to NoUnneededBracesFixer.
NoUnneededCurlyBracesFixerNoUnneededBracesFixerMarks PER-CS v1 as deprecated.
PER-CS1.0Officially deprecates the internal Utils anti-pattern class.
UtilsMarks Tokens::getNamespaceDeclarations as @internal.
Tokens::getNamespaceDeclarationsIntroduces single_space_around_construct and deprecates single_space_after_construct.
single_space_around_constructsingle_space_after_constructDeprecates BracesFixer.
BracesFixerDeprecates ClassKeywordRemoveFixer.
ClassKeywordRemoveFixerDeprecates v2.
Deprecates the parameter of Token::toJson().
Token::toJson()