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

Psalm Plugin Laravel Package

redaxo/psalm-plugin

Psalm plugin for REDAXO projects providing improved static analysis through framework-specific stubs and type information. Helps Psalm understand REDAXO APIs, reduces false positives, and catches issues earlier in CI and local development.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the plugin via Composer in your REDAXO project:

    composer require --dev redaxo/psalm-plugin
    

    (Assumes Psalm is already installed; if not, run composer require --dev vimeo/psalm first.)

  2. Enable the plugin in your psalm.xml:

    <pluginClass class="Redaxo\PsalmPlugin\Plugin"/>
    

    No additional config is required—the plugin auto-discovers REDAXO’s structure (e.g., redaxo/src, packages/).

  3. Run your first analysis:

    ./vendor/bin/psalm
    

    Expect immediate improvements in type accuracy for REDAXO-specific patterns, including default value type resolution (new in 2.2.1). For example, rex_addon::get('yforms', ['default' => new rex_yforms_addon()]) will now correctly infer the resolved return type.


Implementation Patterns

  • Leverage framework-aware stubs without manual overrides: The plugin injects precise signatures for core classes (rex_backend_login, rex_logger, rex_file, etc.) and add-on APIs. New in 2.2.1: Default values in method calls (e.g., rex_sql::factory(['table' => 'rex_content', 'default' => []])) now resolve to their explicit types, reducing mixed inferences.

  • Analyze dynamic patterns confidently: Use Psalm’s @psalm-return/@psalm-param alongside REDAXO conventions (e.g., rex_addon::get(), rex_fragment::show()). The plugin now propagates default value types through method chains, e.g.:

    $addon = rex_addon::get('yforms', ['default' => new rex_yforms_addon()]);
    // $addon is now correctly typed as rex_yforms_addon|rex_addon
    
  • Integrate with CI: Add psalm --output-format=checkstyle > psalm-report.xml to your pipeline. The 2.2.1 fix reduces false positives for default-value-heavy code (e.g., rex_config::get('foo', ['default' => []])).

  • Extend type safety with custom stubs: For private add-ons, use additionalFiles in psalm.xml to include stubs. The plugin now respects default value types in stubs, ensuring consistency with core behavior.


Gotchas and Tips

  • Stubs may lag behind REDAXO core updates: Check the plugin’s src/Stub/ directory for compatibility (≥5.13+). If signatures (e.g., rex_sql methods) are outdated, override via <stubs> in psalm.xml. New in 2.2.1: Default value types in stubs now take precedence, so test overrides thoroughly.

  • rex_sql type inference nuances: While the plugin handles rex_sql::factory(), chained methods like ->getValue('foo') may still infer mixed. Mitigate with:

    /** @var string $foo */
    $foo = $sql->getValue('foo');
    

    Pro Tip: Enable _propertyReferences in psalm.xml for better default value resolution.

  • Avoid rex_addon::load() false negatives: Psalm now correctly infers rex_yforms_addon for rex_addon::get('yforms') if default values are typed. Ensure packages/ is scanned in psalm.xml:

    <directory name="packages"/>
    <directory name="redaxo/src/addons"/>
    
  • Suppress only REDAXO-specific false positives: Use @psalm-suppress sparingly. For default-value issues (e.g., rex_config::get()), verify the fix in 2.2.1 resolves it before suppressing:

    /** @psalm-suppress InvalidArgument */
    rex_config::get('foo', ['default' => ['bar']]); // Now correctly typed as array<string, mixed>
    

    Check the plugin issue tracker for known edge cases.

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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel