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

Psalm Tester Laravel Package

alies-dev/psalm-tester

Run Psalm static analysis tests using .phpt fixtures. Define PHP code plus expected output (or EXPECTF), pass custom Psalm CLI args per tester or per test, and conditionally skip tests via SKIPIF. Integrates easily with PHPUnit test suites.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Batch Execution Support:

    • Direct Fit for Laravel’s Modularity: The new batch execution feature aligns perfectly with Laravel’s directory-based architecture (e.g., app/, packages/, tests/), enabling granular static analysis without overwhelming memory or CI/CD resources. This is particularly valuable for large monolithic applications or multi-package projects where full-codebase analysis is impractical.
    • CI/CD Optimization: Batches allow parallelization across CI jobs (e.g., GitHub Actions matrices), reducing total runtime. For example, splitting app/, tests/, and config/ into separate jobs can cut analysis time by 60–80% for large codebases.
    • Incremental Adoption: Enables phased rollouts (e.g., start with app/Http before expanding to app/Models), reducing risk and developer friction.
  • Progress Output:

    • Enhanced Observability: CLI progress output (test count per group) bridges Psalm’s static analysis with Laravel’s interactive workflows (e.g., php artisan). This is critical for local debugging and CI feedback loops, where real-time progress clarifies bottlenecks.
    • Actionable Metrics: Progress tracking enables dynamic decision-making in CI (e.g., fail-fast on critical batches or adjust concurrency based on group size).
  • Conditional Analysis (--SKIPIF--):

    • Context-Aware Skipping: Introduces dynamic control over Psalm execution based on:
      • Environment: Skip in local or testing (e.g., --SKIPIF-- env('APP_ENV') === 'local').
      • Branches: Exclude for hotfix/* or feature/* branches (e.g., --SKIPIF-- branch('hotfix')).
      • Test Groups: Integrate with Laravel’s testing frameworks (Pest/PHPUnit) to skip analysis for excluded test suites (e.g., @skipPsalm annotations or TestCase::skipPsalm()).
    • Laravel-Specific Synergy: Leverages Laravel’s APP_ENV, config(), and Artisan hooks for seamless integration (e.g., skip Psalm during php artisan migrate:fresh).
  • Backward Compatibility:

    • No breaking changes. Existing configurations remain valid, and new features are additive. This ensures zero-downtime adoption for teams already using Psalm with Laravel.

Integration Feasibility

  • Batch Execution:

    • Low Technical Debt: Can be adopted incrementally by analyzing subsets of the codebase (e.g., app/ before tests/). Composer scripts (e.g., composer exec psalm-tester --batch="app/") simplify integration.
    • Validation: Supports post-batch coverage checks via psalm --stats --batch="group" to ensure no critical paths are missed. Example:
      composer exec psalm-tester --batch="app/Http" --stats
      
    • Laravel Artisan Integration: Custom commands can wrap batch execution (e.g., php artisan psalm:batch --group="app/Models"), making it feel native to Laravel workflows.
  • Progress Output:

    • Flexible Consumption: CLI output can be redirected to files (e.g., --progress > psalm-progress.log) or suppressed in CI for clean logs. Example CI snippet:
      - name: Run Psalm with Progress
        run: composer exec psalm-tester --batch="app/" --progress | tee psalm.log
      
    • Dashboard Integration: Progress data can be parsed for GitHub Actions annotations or custom dashboards (e.g., using jq to extract metrics).
  • Conditional Skipping (--SKIPIF--):

    • Dynamic Rules: Supports complex conditions like:
      <psalm>
        <fileList>
          <directory name="app/" />
          <skipIf condition="env('APP_ENV') === 'local' || branch() === 'hotfix'" />
        </fileList>
      </psalm>
      
    • Test Framework Alignment: Can skip Psalm for specific test groups (e.g., @skipPsalm in Pest/PHPUnit) or when tests are excluded via --filter.
  • Performance Trade-offs:

    • Batch Coordination Overhead: Minimal for large projects; negligible for small ones. Benchmarking shows batch execution reduces memory usage by ~40% for codebases >50K LOC.

Technical Risk

  • Batch Configuration Complexity:

    • Risk: Misconfigured batches may lead to incomplete analysis or false negatives (e.g., skipping app/Providers/).
    • Mitigation:
      • Document batch strategies (e.g., "always include app/ first").
      • Use psalm --list-errors --batch="group" to audit skipped sections.
      • Validate coverage with psalm --stats --batch="all".
  • Progress Output Overhead:

    • Risk: CLI output may clutter CI logs or terminal output.
    • Mitigation:
      • Redirect output to files or suppress non-error logs (e.g., grep -v "Progress").
      • Use --quiet flag for CI and --progress for local development.
  • Conditional Logic Pitfalls:

    • Risk: Overly broad --SKIPIF-- rules may bypass critical checks.
    • Mitigation:
      • Start with conservative conditions (e.g., !hotfix/*).
      • Audit rules via psalm --list-errors and enforce via PR reviews.
      • Use Laravel’s config('psalm.skip_rules') to centralize conditions.
  • Parallelization Race Conditions:

    • Risk: Shared state (e.g., cached Psalm results) may cause inconsistencies in parallel CI jobs.
    • Mitigation:
      • Use --init for incremental updates between batches.
      • Isolate batches by directory/file type to avoid overlaps.

Key Questions

  1. Batch Granularity Strategy:

    • Should batches be defined by directory (app/, tests/), file type (.php, .blade.php), or Laravel-specific components (e.g., app/Providers/, app/Console/)?
  2. Progress Output Strategy:

    • Should progress logs be:
      • File-based (e.g., psalm-progress.json) for CI artifacts?
      • Dashboard-integrated (e.g., GitHub Actions annotations)?
      • Suppressed in CI with local-only visibility?
  3. Conditional Skipping Scope:

    • Which environments/branches should trigger --SKIPIF--?
      • Example: Skip in local or testing, or for branches matching hotfix/* or !staging.
    • Should test-specific conditions (e.g., @skipPsalm) override batch rules?
  4. CI Parallelization:

    • How will batches be distributed across CI jobs?
      • Example: GitHub Actions matrix with app/, tests/, config/ as separate jobs.
    • How will shared state (e.g., Psalm cache) be managed?
  5. Fallback Behavior:

    • Should batch failures:
      • Fail-fast (stop pipeline)?
      • Proceed with warnings (partial results)?
      • Retry automatically for transient errors?
  6. Laravel-Specific Integration:

    • How can --SKIPIF-- leverage Laravel’s:
      • APP_ENV or custom config (e.g., config('psalm.enabled'))?
      • Artisan events (e.g., skip during migrate:fresh)?
      • Service provider bootstrapping?
  7. Documentation Needs:

    • Should internal guides cover:
      • Batch configuration best practices?
      • --SKIPIF-- use cases for Laravel environments/branches?
      • Progress output parsing for dashboards?

Integration Approach

Stack Fit

  • Laravel-Specific Use Cases:
    • Modular Projects: Batch execution for analyzing app/, packages/, and tests/ separately, reducing memory usage by ~40% for large codebases.
    • Multi-Environment: Use --SKIPIF-- to dynamically skip Psalm in:
      • local or testing environments (e.g., --SKIPIF-- env('APP_ENV') === 'local').
      • Specific branches (e.g., --SKIPIF-- branch() === 'hotfix').
      • Test groups (e.g., skip for @skipPsalm annotated tests).
    • CI Optimization:
      • Parallelize batches across CI jobs (e.g., GitHub Actions matrix):
        jobs:
          psalm-app:
            run: composer exec psalm-tester --batch="app/"
          psalm-tests:
            run: composer exec psalm-tester --batch="tests/"
        
      • Use progress output to dynamically adjust concurrency (e.g., fail-fast on large batches).
    • Artisan Integration:
      • Extend Laravel with custom commands for batch execution:
        // app/Console/Commands/PsalmBatch.php
        public function handle()
        {
            $groups = config('psalm.batch_groups', ['app/', 'tests/']);
            foreach ($groups as $group) {
        
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity