github rectorphp/rector 2.7.0
Released Rector 2.7

7 hours ago

New Rules ✨

  • Add TernaryToNullsafeCoalesceRector (#8499)
  • Add BoolReturnTypeFromBooleanConstAndStrictReturnsRector for mixed const + strict bool returns (#8498)
  • Add ConstructorReadonlyAssignToDefaultRector for readonly property defaults (#8502)
  • Add RemoveOverriddenAssignBeforeIfElseRector (#8505)

Performance Improvements 🚀

  • Cache class-like name resolution per file version in ShortNameResolver, so name import no longer rescans the whole file for every name - up to ~24 % fewer CPU instructions on large projects (#8524)
  • Cache dry-run files whose FileDiff has no content change (#8523)
  • Key the file cache on project-relative paths, so a cache survives a change of checkout (#8490)
  • Use FileSystem::writeAtomic() in FileCacheStorage to avoid partial cache reads on parallel runs (#8520)
  • Terminate timed-out and unconnected workers (#8522)
  • Fix silently skipped files when the only worker is respawned (#8521)
  • Give the worker the same NDJSON frame limit as the main process (#8489)
  • Bump to PHPStan 2.3

Bugfixes 🐛

  • RenamePropertyRector: rename the property both in the trait and in the class property itself (#8518)
  • RenameClassRector: throw on same old and new class in the configuration (#8515)
  • ScalarParamTypeByMethodCallTypeRector: skip string param inference to avoid unsafe scalar coercion (#8514)
  • RepeatedAndNotEqualToNotInArrayRector / RepeatedOrEqualToInArrayRector: skip short-circuit dependent values (#8516)
  • SeparateMultiUseImportsRector: keep trait use adaptations (#8510)
  • Privatize*Rector: drop the final flag when changing protected to private, since private final is forbidden on PHP 8.4 (#8509)
  • AddNameToBooleanArgumentRector / AddNameToNullArgumentRector: skip callees marked @no-named-arguments (#8508)
  • TypedPropertyFromStrictConstructorRector: skip a protected property redeclared in a child class (#8503)
  • RemoveAlwaysTrueIfConditionRector: skip a maybe-undefined variable (#8501)
  • SingularSwitchToIfRector: skip nested break/continue in the case body (#8500)
  • TypeDeclaration: skip redundant intersection types in union return types (#8527)
  • Naming: keep mass nouns ending in data/info untouched when singularizing (#8492)

rector-doctrine 🟠

  • Add DoctrineQueryBuilderSortDirectionRector (#524)
  • Add DoctrineOrderByAttributeSortDirectionRector (#525)
  • Register the SortDirection rules in the composer-based set and cover Expr\OrderBy::add() (#530)
  • CorrectDefaultTypesOnEntityPropertyRector: support properties initialized as int (#526)

rector-symfony 🎵

  • GetRequestRector: reuse an existing untyped $request param (#1066)
  • CommandConfigureToAttributeRector: do not report a change when nothing is extracted (#1068)
  • Fix PhpAstExtractor import removal in the composer-based Symfony set (#1070)

rector-phpunit 🟢

  • Add WillReturnCallbackFallbackToReturnFalseRector (#784)
  • Extend FlipAssertRector to more assert methods and expected value shapes (#787)
  • AllowMockObjectsForDataProviderRector: skip stub-only ->method() calls (#790)
  • Fix changing keys of data providers for tests with optional arguments (#783)
  • Deprecate ConfiguredMockEntityToSetterObjectRector as experimental (#789)

Don't miss a new rector release

NewReleases is sending notifications on new releases.