Add phpstan-generate-baseline Composer script to root composer.json

Created on 2 November 2024, 5 months ago

Problem/Motivation

Regenerating the baseline is documented here but I always forget the exact commands and have to look them up.

Steps to reproduce

Proposed resolution

Add a phpstan-generate-baseline script to the root composer.json so you can just run composer phpstan-generate-baseline when needed.

Remaining tasks

Decide if there are other PHPStan commands we should add to the root composer.json.

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

composer

Created by

🇬🇧United Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @longwave
  • 🇺🇸United States nicxvan

    Is there a way to overwrite the current baseline with this starter file?

    It runs much more consistently and with lower memory starting empty:

    <?php declare(strict_types = 1);
    
    $ignoreErrors = [];
    
    
    return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
    
  • 🇨🇭Switzerland berdir Switzerland

    This would definitely be useful. I've added ddev commands for now:

    $ cat .ddev/commands/web/phpstan-generate
    #!/usr/bin/env bash
    
    ./vendor/bin/phpstan analyze  --configuration=./core/phpstan.neon.dist --generate-baseline=core/.phpstan-baseline.php
    

    And a phpstan without the --generate-baseline.

  • 🇦🇺Australia mstrelan

    I think we should drop the word "generate" and just have:

    composer phpstan
    composer phpstan-baseline

    I think we should also use these commands in ci for consistency. Then if we need to tweak it in future it will be updated in both places.

  • 🇨🇭Switzerland berdir Switzerland

    the CI job runs phpstan like 3 times with different output formats and arguments, so I don't think we can reuse that.

  • 🇺🇸United States nicxvan

    I figured out why I needed the empty baseline.

    It was because during the conversion there were thousands of changes. A normal baseline process doesn't need that.

  • 🇮🇹Italy mondrake 🇮🇹

    Adding related issue

Production build 0.71.5 2024