Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split phpstan-baseline into smaller files #9299

Merged

Conversation

paulbalandan
Copy link
Member

@paulbalandan paulbalandan commented Dec 2, 2024

Description
This PR splits our existing enormous phpstan-baseline.php into smaller baseline files named by their identifiers, thanks to https://github.com/shipmonk-rnd/phpstan-baseline-per-identifier/tree/2.0.0. Currently, the baseline contains 4,052 errors. That's very overwhelming to fix. TBH, when looking at the baseline I cannot continue further because of the bulk of technical debt we have.

The pro of this approach is that we can attack the baseline by identifier, making the cleanup less overwhelming. The cleanup would be bite-sized. The con of this approach is that we have too many baselines now, but that is the consequence of having 4k+ errors.

Same command to generate the baseline: composer phpstan:baseline

P.S I have fixed some of the files as PHPStan complains of No error to ignore stuff.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan marked this pull request as draft December 2, 2024 14:19
@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch 4 times, most recently from 4f170cf to 823f364 Compare December 6, 2024 18:13
@paulbalandan paulbalandan marked this pull request as ready for review December 6, 2024 18:36
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea. Smaller baseline files seem like easier to deal with.

@kenjis kenjis added the github_actions Pull requests that update Github_actions code label Dec 9, 2024
@kenjis kenjis added the refactor Pull requests that refactor code label Dec 9, 2024
@ddevsr
Copy link
Collaborator

ddevsr commented Dec 10, 2024

@paulbalandan By the way, i see this another error. Can you update rector to RC3? cc @samsonasik

Rector error
Run vendor/bin/rector process --dry-run --no-progress-bar
{
    "title": "_PHPStan_e6dc705b2\\Nette\\Schema\\ValidationException",
    "type": "_PHPStan_e6dc705b2\\Nette\\Schema\\ValidationException",
    "code": 500,
    "message": "Unexpected item 'parameters › shipmonkBaselinePerIdentifier'.",
    "file": "phar:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php",
    "line": 75,
    "trace": [
        {
            "file": "phar:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php",
            "line": 38,
            "function": "throwsErrors",
            "class": "_PHPStan_e6dc705b2\\Nette\\Schema\\Processor",
            "type": "->"
        },
        {
            "file": "phar:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php",
            "line": 216,
            "function": "process",
            "class": "_PHPStan_e6dc705b2\\Nette\\Schema\\Processor",
            "type": "->"
        },
        {
            "file": "phar:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php",
            "line": 104,
            "function": "validateParameters",
            "class": "PHPStan\\DependencyInjection\\ContainerFactory",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php",
            "line": 51,
            "function": "create",
            "class": "PHPStan\\DependencyInjection\\ContainerFactory",
            "type": "->"
        },
        {
            "function": "__construct",
            "class": "Rector\\NodeTypeResolver\\DependencyInjection\\PHPStanServicesFactory",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 844,
            "function": "newInstanceArgs",
            "class": "ReflectionClass",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 652,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/src/DependencyInjection/LazyContainerFactory.php",
            "line": 273,
            "function": "make",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 807,
            "function": "Rector\\DependencyInjection\\{closure}",
            "class": "Rector\\DependencyInjection\\LazyContainerFactory",
            "type": "::"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 652,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": [9](https://github.com/codeigniter4/CodeIgniter4/actions/runs/12204169604/job/34048691307?pr=9299#step:11:10)47,
            "function": "make",
            "class": "RectorPrefix2024[11](https://github.com/codeigniter4/CodeIgniter4/actions/runs/12204169604/job/34048691307?pr=9299#step:11:12)\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 873,
            "function": "resolveClass",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 838,
            "function": "resolveDependencies",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 652,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 947,
            "function": "make",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 873,
            "function": "resolveClass",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 838,
            "function": "resolveDependencies",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 652,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 947,
            "function": "make",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 873,
            "function": "resolveClass",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 838,
            "function": "resolveDependencies",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 277,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 807,
            "function": "RectorPrefix202411\\Illuminate\\Container\\{closure}",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 652,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 496,
            "function": "make",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "function": "RectorPrefix202411\\Illuminate\\Container\\{closure}",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/ContextualBindingBuilder.php",
            "line": 72,
            "function": "iterator_to_array"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Util.php",
            "line": 40,
            "function": "RectorPrefix202411\\Illuminate\\Container\\{closure}",
            "class": "RectorPrefix202411\\Illuminate\\Container\\ContextualBindingBuilder",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 923,
            "function": "unwrapIfClosure",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Util",
            "type": "::"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 873,
            "function": "resolvePrimitive",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 838,
            "function": "resolveDependencies",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 652,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/src/DependencyInjection/LazyContainerFactory.php",
            "line": 245,
            "function": "make",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 807,
            "function": "Rector\\DependencyInjection\\{closure}",
            "class": "Rector\\DependencyInjection\\LazyContainerFactory",
            "type": "::"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 705,
            "function": "build",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/vendor/illuminate/container/Container.php",
            "line": 662,
            "function": "resolve",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/bin/rector.php",
            "line": [12](https://github.com/codeigniter4/CodeIgniter4/actions/runs/12204169604/job/34048691307?pr=9299#step:11:13)9,
            "function": "get",
            "class": "RectorPrefix202411\\Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/bin/rector",
            "line": 5,
            "args": [
                "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/bin/rector.php"
            ],
            "function": "require_once"
        },
        {
            "file": "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/bin/rector",
            "line": 1[19](https://github.com/codeigniter4/CodeIgniter4/actions/runs/12204169604/job/34048691307?pr=9299#step:11:20),
            "args": [
                "/home/runner/work/CodeIgniter4/CodeIgniter4/vendor/rector/rector/bin/rector"
            ],
            "function": "include"
        }
    ]
}

Ref : https://github.com/codeigniter4/CodeIgniter4/actions/runs/12204169604/job/34048691307?pr=9299

@paulbalandan
Copy link
Member Author

Oh, I didn't notice that. But why does github actions not fail on that?

@ddevsr
Copy link
Collaborator

ddevsr commented Dec 10, 2024

Maybe shipmonk no catch exception, I think this related to shipmonk using nette/neon not tested with phpstan/phpstan v2

@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch 2 times, most recently from 35b2a34 to 17ca6ee Compare December 10, 2024 17:14
@github-actions github-actions bot added the stale Pull requests with conflicts label Dec 11, 2024

This comment was marked as outdated.

@samsonasik
Copy link
Member

@ddevsr the codeigniter phpstan extension needs to be updated to use phpstan v2 first before it can require rector v2.

@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch from 17ca6ee to 5978a9a Compare December 11, 2024 10:33
@paulbalandan paulbalandan removed the stale Pull requests with conflicts label Dec 11, 2024
@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch from 5978a9a to 4270d22 Compare December 11, 2024 16:02
@github-actions github-actions bot added the stale Pull requests with conflicts label Dec 11, 2024

This comment was marked as outdated.

@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch from 4270d22 to 7f62e0e Compare December 11, 2024 16:56
@paulbalandan paulbalandan removed the stale Pull requests with conflicts label Dec 11, 2024
@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch 2 times, most recently from 18d59a4 to e8e2c9f Compare December 14, 2024 18:12
@paulbalandan paulbalandan force-pushed the split-phpstan-baseline branch from e8e2c9f to 8bceabc Compare December 14, 2024 18:14
@paulbalandan paulbalandan requested a review from kenjis December 14, 2024 18:15
@samsonasik
Copy link
Member

@ddevsr see PR:

for upgrade to phpstan 2 and rector 2.

Copy link
Member

@kenjis kenjis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@paulbalandan paulbalandan merged commit 242745c into codeigniter4:develop Dec 15, 2024
41 checks passed
@paulbalandan paulbalandan deleted the split-phpstan-baseline branch December 15, 2024 00:38
@paulbalandan
Copy link
Member Author

Thanks all for the reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update Github_actions code refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants