Weave Code
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

Phpstan Extensions Laravel Package

symplify/phpstan-extensions

Extra PHPStan rules and extensions from Symplify to improve static analysis of PHP projects. Adds better type inference and framework-aware checks, helping catch bugs earlier and keep codebases consistent with minimal configuration.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer:

composer require --dev symplify/phpstan-extensions

Then, enable it in your phpstan.neon config:

includes:
    - vendor/symplify/phpstan-extensions/config/extension.neon

Your first practical use case: use the ignore format to suppress specific errors cleanly—e.g., for known false positives—using the ignoreErrors syntax with structured paths and messages, instead of raw regex. Example:

ignoreErrors:
    -
        message: "#^Call to an undefined method App\\\\Entity\\\\User::getNonExistent\\(\\)\\.$#"
        path: src/Service/EmailService.php

Implementation Patterns

  • Symfony\SplFileInfo extension: Use Phpstan\SplFileInfo as a type hint instead of SplFileInfo. PHPStan now understands methods like getRelativePathname() and getFilenameWithoutExtension() without false positives.
  • ignore error suppression: For symfony/console commands with dynamic options or services, use structured ignoreErrors with files or paths to avoid broad #^.*$# suppression.
  • Integration with Symfony projects: Add config/packages/test/phpstan.php and extend via phpstan.neon to enable stricter checks in test contexts.
  • Custom rule sets: Leverage the symplify/phpstan-extensions/rules directory to include or extend custom rules by registering them in your phpstan.neon under parameters > symplify.

Gotchas and Tips

  • ignore format requires exact message substring match—do not use message regex unless necessary; prefer parameter/path filtering.
  • Symfony\SplFileInfo must be imported explicitly—PHPStan won’t auto-resolve the alias unless the class exists in autoloader or you define it in stubFiles.
  • The package ships with no default rules—all enhancements (e.g., improved ParameterRule, ClassReflection helpers) require you to use them via extension config.
  • ⚠️ Known quirk: When using ignoreErrors, maxMatches defaults to 1; override in the error block to allow multiple occurrences.
  • Debug tip: Run with --debug to see which extension classes are loaded; useful when config updates don’t take effect.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport