jetbrains/phpstorm-attributes
JetBrains PhpStorm attributes provide PHP 8 attributes for richer code completion and analysis in PhpStorm, including Deprecated, ArrayShape, ObjectShape, and Immutable. Bundled with PhpStorm; add as a dev dependency for other static analysis tools.
#[Deprecated] with reason and replacement turns a CHANGELOG line into an inline, actionable warning at every call site — including parameter substitution (e.g. %class%, %parameter0%) so the IDE quick-fix rewrites the call. Support for Laravel major-version upgrades (10 → 11, 11 → 12) and internal API sunsets is the strongest product justification: fewer "is this still safe to use?" Slack threads, and a measurable path to removing legacy surface area.JsonResource::toArray(), config() defaults, report aggregates, validator messages, DB::select() rows. #[ArrayShape] and #[ObjectShape] document those shapes next to the code, giving key autocomplete and type inference with no static-analyser setup. Product impact: fewer integration defects at boundaries, faster onboarding for engineers new to the domain, and less ambiguity in API documentation.composer require --dev plus a convention, not an epic. Scope it as an enabler inside existing feature work — annotate new DTOs and resources as they're written, retrofit deprecations only when you touch them. No dedicated sprint required.phpstan-phpstorm extension gives CI-enforced contracts on purity and immutability — a cheap quality gate that complements, rather than replaces, a typed-DTO migration.Adopt when:
phpstan-phpstorm, with no runtime change.Look elsewhere or defer when:
Maturity note for the risk register: the package is a thin bag of ~8 attribute classes with a low-velocity release cadence and a single maintainer organization (JetBrains). Risk is low — attributes are inert at runtime and the package can be dropped at any time with no code change beyond deleting annotations — but it is a dependency owned by your IDE vendor, not your application. Keep it in require-dev and treat it as tooling, not architecture.
For executives: "This is a free, JetBrains-maintained tooling package that makes our IDE smarter about our own code — flagging deprecated APIs with the exact replacement, catching type mistakes in array and object payloads, and enforcing data contracts before code review reaches a human. It has zero impact on production performance, requires no infrastructure or configuration, and costs one dev-dependency line. Expected outcomes: faster delivery with fewer avoidable defects, a cleaner and more measurable story for deprecating and upgrading systems, and a lower onboarding ramp for engineers new to the codebase."
For engineering: "Add jetbrains/phpstorm-attributes as a dev dependency — no service provider, no config, no facade, no bootstrapping. Requirements are PHP 8+ and PhpStorm 2020.3+. The payoff: key autocomplete and type inference on JsonResource::toArray() and config arrays via #[ArrayShape]; typed dynamic objects such as DB::select() rows and json_decode(..., false) results via #[ObjectShape]; inline strikethrough warnings with IDE quick-fix rewrites on deprecated methods via #[Deprecated] with replacement parameter substitution; immutability contracts on value objects via #[Immutable]; accurate control-flow and dead-code analysis via #[NoReturn]; sharper type inference from #[Pure]; and enum-backed parameter suggestions via #[ExpectedValues]. Start with the two highest value-to-effort attributes: #[Deprecated] on anything currently tagged @deprecated in a docblock, and #[ArrayShape] on API Resources and report payloads. Attributes are ignored at runtime, so non-PhpStorm tools and CI see no behavior change. To get CI-level enforcement, add the phpstan-phpstorm extension. Retrofit high-traffic service boundaries afterward, and keep annotations targeted to public APIs and critical data flows — over-annotating internal methods hurts readability for little gain."
How can I help you explore Laravel packages today?