Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Type Perfect Laravel Package

rector/type-perfect

Type Perfect adds 10 PHPStan rules to tighten type declarations: replace empty/isset checks with instanceof for precise narrowing, prefer explicit getters over magic array access, and enforce interface signatures. Easy to enable even on legacy code; improves reliability fast.

View on GitHub
Deep Wiki
Context7
2.2.0

This package is deprecated

Keeping 2 very close packages up-to-date is daunting work and keep both behind. T Both focus with custom PHPStan rule on better type coverage and more precise and narrow types if available.

To improve support, the Type Perfect rules have been merged into tomasvotruba/type-coverage as of its 2.3.0 release. This is the final release of rector/type-perfect — it is marked abandoned in composer.json and Composer will now point you at the replacement on every install.

How to switch

1. Swap the package

 "require-dev": {
-    "rector/type-perfect": "^2.1"
+    "tomasvotruba/type-coverage": "^2.3"
 }
composer remove rector/type-perfect --dev
composer require tomasvotruba/type-coverage --dev

If you already use tomasvotruba/type-coverage, only remove rector/type-perfect — keeping both loads every rule twice.

Type Coverage requires PHP ^8.4; Type Perfect required ^8.2.

2. Keep your ignoreErrors as they are

The rules keep the Rector\TypePerfect\ namespace inside Type Coverage, so existing ignore patterns and PHPStan baselines still match. The extension is registered by phpstan/extension-installer, so no includes change is needed either.

3. Enable the rules that used to be on by default

NoParamTypeRemovalRule, NoIssetOnObjectRule and NoEmptyOnObjectRule reported right after install here. In Type Coverage they are opt-in like the rest of the set, one parameter each:

 parameters:
     type_perfect:
         narrow_param: true
         narrow_return: true
         no_mixed_property: true
         no_mixed_caller: true
         null_over_false: true
+        no_param_type_removal: true
+        no_isset_on_object: true
+        no_empty_on_object: true

Every other parameter name is unchanged.

Not carried over

  • NoArrayAccessOnObjectRule — the $object['key'] over $object->getKey() check is not part of Type Coverage. If you rely on it, pin rector/type-perfect:2.2.0 alongside Type Coverage with only that rule enabled.

    $id = $article['id'];  // bad - no idea what the type is
    $id = $article->getId();  // good - we know it is int
    
  • Two fixes released here after the merge are not in Type Coverage yet: the NarrowPublicClassMethodParamTypeRule generic-object false-positive (#74) and the Symfony DomCrawler skip in NoArrayAccessOnObjectRule (#77).

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus