jetbrains/phpstorm-attributes
JetBrains PhpStorm Attributes for PHP 8+: add IDE-only attributes like Deprecated, ArrayShape, ObjectShape, and Immutable to improve code completion and static analysis. Bundled with PhpStorm 2020.3+, optional composer dev dependency to avoid “Class not found” in other tools.
Install as a dev dependency with composer require --dev jetbrains/phpstorm-attributes. No bootstrapping or config changes are needed — PhpStorm 2020.3+ recognizes these attributes out of the box. Start by applying #[Deprecated] to methods scheduled for removal (e.g., deprecated APIs in Laravel service providers), and use #[ArrayShape] on functions returning structured arrays like config() results or API response payloads. These two yield the biggest immediate IDE improvement with minimal effort.
#[Deprecated(reason: '…', replacement: '…')] in Laravel packages to provide inline warnings and automated find/replace hints in PhpStorm — invaluable during upgrades (e.g., Laravel 10 → 11 migrations).#[ArrayShape([...])] on methods returning config structures (e.g., custom service provider configs) or #[ObjectShape([...])] for dynamic object hydrations from Eloquent or external APIs — enables autocomplete for keys like 'timeout' => 'int'.#[Pure]) in utility classes to let PhpStorm flag unused calls and improve type inference. Mark #[NoReturn] methods like abort(403) wrappers or terminal CLI commands to improve dead-code detection.#[ExpectedValues(valuesFromClass: Status::class)] on controller/route parameters (Status::class being an enum) to restrict autocomplete and surface invalid value warnings at edit time.#[Immutable] to value objects (e.g., Money, EmailAddress) to signal immutability expectations — PhpStorm will warn about direct writes and integrate with static analysis tools for verification.phpstan-phpstorm) interprets them. Safe to commit without conditional checks.#[ArrayShape([...])] must be written on a single line (no newlines in the attribute). Prefer multiline formatting only when targeting PHP ≥8.0.ArrayShape, optional keys require explicit nullable types: 'user' => '?App\Models\User' or 'count' => '?int'. PhpStorm uses this for null-safety diagnostics.valuesFromClass, ObjectShape, or ArrayShape, always use fully qualified names or use statements — PhpStorm resolves attributes statically and may misinfer unqualified names.phpstan-phpstorm extension in PHPStan to surface these attributes in CI/CD pipelines — ensures #[Immutable] and #[Pure] contracts are enforced beyond the IDE.How can I help you explore Laravel packages today?