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 Coverage

Type Coverage Laravel Package

tomasvotruba/type-coverage

PHPStan extension that measures and enforces a minimum type declaration coverage rate across your properties, params, and return types. Set per-category thresholds in phpstan.neon and raise them gradually, making it easy to adopt even on legacy projects.

View on GitHub
Deep Wiki
Context7

PHPStan extension to require minimal type-coverage

Frequently asked questions about Type Coverage
How do I install tomasvotruba/type-coverage in a Laravel project?
Install it as a dev dependency with composer require tomasvotruba/type-coverage --dev. If you use phpstan/extension-installer, the extension is registered automatically; otherwise add vendor/tomasvotruba/type-coverage/config/extension.neon to the includes section of phpstan.neon. Then add a type_coverage block under parameters with the thresholds you want to enforce.
Does tomasvotruba/type-coverage work with Larastan and existing PHPStan setups?
Yes, it is designed to hook into an existing PHPStan run, so it fits naturally alongside Larastan if your CI already runs static analysis. It adds no service provider, facade, or runtime code, so adoption is a configuration change rather than an architectural one. If you do not already run PHPStan or Larastan, this package is not the right starting point because it depends on that pipeline.
What PHP and Laravel versions are supported by type-coverage?
The package is available on PHP 7.2 and newer. Constant coverage requires PHP 8.3 or newer, while params, return types, and properties work on earlier supported PHP versions. It is a PHPStan extension rather than a Laravel package, so Laravel version support depends mainly on whether your PHPStan or Larastan setup runs on your PHP version.
How do I configure minimum type coverage thresholds per category?
Add a type_coverage block under parameters in phpstan.neon and set return, param, property, and constant values as percentages. For example, you can require return: 50, param: 35.5, and property: 70 independently. PHPStan will then fail the build when coverage in a configured category drops below its threshold.
Does type-coverage count docblock types or only native type declarations?
The README defines type coverage as the ratio of defined type declarations to possible ones across params, returns, properties, and constants. It does not clearly state in the provided context whether docblock @var and @param types count toward the numerator. Treat this as a point to verify with a small test before relying on a target number, especially if your codebase uses docblocks heavily.
Do Eloquent model properties like $fillable and $table count against property coverage?
This is not settled by the package documentation provided, and it is an important unknown for Laravel projects. Eloquent conventionally declares properties such as $table, $fillable, $guarded, $hidden, and $casts without native types and accesses them through magic methods. Before communicating a property coverage target, test a representative model to see whether those framework-mandated properties depress the score.
Can I set different type coverage thresholds per directory or module?
The documented configuration shows per-category thresholds such as return, param, property, and constant, but it does not describe per-directory or per-module scoping. A single global percentage per category is less actionable for a modular monolith, so confirm whether path-based scoping is supported before designing a rollout around it. If it is not available, you may need separate PHPStan configurations for different parts of the codebase.
Does type-coverage work with phpstan-baseline.neon?
The provided context does not confirm how coverage failures interact with phpstan-baseline.neon. Coverage thresholds are a separate enforcement mechanism from ordinary PHPStan errors, so you should test whether baseline entries suppress coverage failures or whether they bypass baselining. In many teams you would want coverage failures to bypass the baseline so the ratchet cannot be silently ignored.
What are the bundled Type Perfect rules and should I enable them?
The 2.3+ release bundles Type Perfect rules such as no_mixed_property, no_mixed_caller, narrow_param, and narrow_return, and they are opt-in and disabled by default. They act as a counterweight to gaming the coverage number, because a mixed type can satisfy the counter while improving nothing. Enable them deliberately if you want the coverage metric to reflect meaningful type quality rather than just declaration count.
Is tomasvotruba/type-coverage safe to use in production and well maintained?
It is a dev-only dependency, so a composer install --no-dev deployment will not include it in the production artifact. The project is maintained by Tomas Votruba, a credible figure in PHP tooling, but it is a single-maintainer package with modest ecosystem validation, so bus factor and long-term maintenance are reasonable concerns. Removal is low-risk: one composer remove plus one config block, which makes it easy to trial and revert if needed.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections