jetbrains/phpstorm-stubs
PhpStorm Stubs: syntactically correct PHP files with signatures, constants, and PHPDoc for PHP core and many extensions. Used by IDEs for completion, inspections, type inference, and documentation popups. Community-driven support for non-standard extensions.
jetbrains/phpstorm-stubs package provides PHPDoc-annotated stub files for PHP core functions and extensions, directly addressing PhpStorm’s static analysis limitations in Laravel ecosystems. It bridges gaps between IDE autocompletion, type inference, and static analysis tools (e.g., Psalm, PHPStan), which is critical for Laravel’s type-heavy and extension-dependent codebase (e.g., Illuminate\Support, Predis, Symfony Components).Facade::call(), Collection::map()).Redis, PDO, Intl) commonly used in Laravel apps, reducing manual stub maintenance.#[\Override]), which PhpStorm’s built-in stubs may lag on.composer require --dev jetbrains/phpstorm-stubs) with no configuration required. PhpStorm auto-detects stubs in vendor/ directory.Illuminate classes).spatie/laravel-activitylog), conflicts can be resolved via PhpStorm’s stub priority rules or .phpstorm.meta.php.composer.json dev dependency).| Risk | Severity | Mitigation |
|---|---|---|
| Stub Version Mismatch | Medium | Pin to a specific major version (e.g., ^1.0) in composer.json. |
| IDE-Specific Issues | Low | Test in PhpStorm 2024.2+; fallback to manual stubs if needed. |
| False Positives in Analysis | Low | Validate against Psalm/PHPStan baselines to ensure stubs align with static analysis. |
| Custom Extension Gaps | Medium | Supplement with community PECL stubs (e.g., ext-redis) or contribute missing stubs upstream. |
| CI/CD Overhead | Low | Stubs are dev-only; no impact on build times or deployments. |
MongoDB, Propro—may require manual stubs.)phpactor or intelephense instead.stubs/ or vendor/).composer require --dev jetbrains/phpstorm-stubs
array_* functions (e.g., array_map).JsonSerializable and IteratorAggregate.Auth::user()->posts()).composer.json across all Laravel repos with a pinned version:
"require-dev": {
"jetbrains/phpstorm-stubs": "^1.0"
}
CONTRIBUTING.md or IDE_SETUP.md for onboarding.Settings > Languages & Frameworks > PHP > PHP Runtime.vendor/jetbrains/phpstorm-stubs to Excluded Paths.| Component | Compatibility Notes |
|---|---|
| Laravel 10/11 | Full support (PHP 8.1+ stubs included; covers Illuminate and Symfony components). |
| PHP 8.0 | Partial (some newer functions may lack stubs; test thoroughly). |
| Custom Extensions | Requires manual PECL stubs (e.g., ext-mongodb). JetBrains only validates PHPDoc, not functionality. |
| Psalm/PHPStan | Improves alignment but does not replace their type systems. Use stubs to reduce false positives. |
| Docker/CI | No impact; stubs are dev-only. |
| Windows/Linux/macOS | Cross-platform; no OS-specific issues. |
@method annotations, @var for dynamic returns).Collection methods, Facade calls).php-cs-fixer + stubs) to catch docblock inconsistencies.Laravel\Nova, Laravel\Vapor) to the repo.How can I help you explore Laravel packages today?