Released Rector 0.15
We released a new getrector.org website, including new documentation - https://getrector.org/documentation 🎉
You can already find a few new sections there.
This release brings the most significant changes in type safety. Few rules in type declaration worked with docblock types and completed type as strict. These rules lead to crashing code with invalid types. Instead, we've been splitting these rules into smaller and specific ones (Unix style!) that handle exact strict type declarations. This release finalizes the removal of these weak rules.
Welcome new type declaration rules that are safe and work with 100 % known strict types ↓
New Features 🥳
- [TypeDeclaration] Add AddParamTypeBasedOnPHPUnitDataProviderRector + remove too narrow KnownArrayParamTypeInferer (#3104)
- [TypeDeclaration] Add AddParamTypeSplFixedArrayRector (#3105)
- [TypeDeclaration] Add AddReturnTypeDeclarationFromYieldsRector (#3114)
- [TypeDeclaration] Add ReturnTypeFromReturnDirectArrayRector, ReturnTypeFromStrictConstantReturnRector, ReturnTypeFromStrictTypedCallRector (#3125)
- [TypeDeclaration] Add AddParamTypeFromPropertyTypeRector (#3109)
- Add
list-rules
command for tool interoperabtility (#3087) - Add SimplifyEmptyCheckOnEmptyArrayRector #7485 (#3069), Thanks @JohJohan!
- [Php80] Add ClassOnThisVariableObjectRector (#3093)
Bugfixes 🐛
- [Php80] Skip possible numeric string switch cond with all integer case cond on ChangeSwitchToMatchRector (#3067)
- Skip MakeTypedPropertyNullableIfCheckedRector for constructor assigment. (#3074), Thanks @Wohlie!
- Fix StrContainsRector when strpos offset is set (#3086), Thanks @ajgarlag!
- [TypeDeclaration] Handle return self on TypedPropertyFromStrictGetterMethodReturnTypeRector on php 8.0 feature enabled (#3088)
- [Php80] Do not remove existing attribute on NestedAnnotationToAttributeRector (#3116)
- [CodeQuality] Skip from non-typed param on SimplifyEmptyCheckOnEmptyArrayRector (#3115)
- [DeadCode] Fix RemoveJustPropertyFetchRector to skip concat assigns (#3123)
- [DeadCode] Skip re-assigned variable in RemoveJustPropertyFetchRector (#3124)
- [Php74] Register TypedPropertyFromAssignsRector to php74 config set (#3127)
- docs (rectorphp/rector-src@571a1e6)
- [TypeDeclaration] Skip property names in TypedPropertyFromStrictConstructorRector (#3128)
- [TypeDeclaration] Skip doctrine collection type (#3130)
- [TypeDeclaration] Use existing MakePropertyTypedGuard on TypedPropertyFromStrictConstructorRector (#3131)
- [PHP 8.1] Add other methods to ClassFromEnumFactory (rectorphp/rector-src@d206406)
- simplify PHPStanStaticTypeMapper (#3143), Thanks @staabm!
- Fix foreach key evaluation for SimplifyForeachToArrayFilterRector. (#3100), Thanks @Wohlie!
- [Php55] Handle crash on curly parentheses delimiter on PregReplaceEModifierRector (#3144)
- [Php73] Add closure bindings for SimplifyForeachToArrayFilterRector. (#3146), Thanks @Wohlie!
Removed Weak Doc Type Rules 💀
- Deprecated type-declaration-strict to type-declaration set, as single group of rules (#3103)
- Remove deprecated ParamTypeDeclarationRector, that treated docs as strict types to keep type declaration set reliable (#3111)
- Deprecated and remove AddArrayParamDocTypeRector to work with strict type declarations only (#3112)
- [TypeDeclaration] Remove and disable breaking ReturnTypeDeclarationRector, use split rules instead (#3120)
- deprecate generic and breaking PropertyTypeDeclarationRector (rectorphp/rector-src@dd44b98)
- [TypeDeclaration] Disable and deprecate PropertyTypeDeclarationRector and TypedPropertyRector, to avoid breaks; use split strict rules instead (#3122)
- [TypeDeclaration] Deprecate unreliable AddArrayReturnDocTypeRector, used split strict typed rules instead (#3133)
Removed Features 💀
- Remove auto import on changed files only to avoid too detailed setup and making ambiguous code (#3132)
- [config] Deprecate and remove @noRector annotation, as not reliable DX choice; use skip() method instead (#3148)
- Remove deprecated
RectorConfig::disableImportShortClasses()
, useimportShortClasses(false)
instead (rectorphp/rector-src@7507589) - Remove deprecated
RectorConfig::disableImportNames()
, useimportNames(false, false)
instead (#3147) - Remove deprecated APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY option (rectorphp/rector-src@a4e7a43)
- Make Rector PHPOffice optional package, as only migrates ~7 years old version (#3061)