Skip to content

chore: upgrade to Pest 4, drop composer-patches workaround#1481

Merged
herpaderpaldent merged 15 commits into
5.xfrom
chore/pest-4
May 5, 2026
Merged

chore: upgrade to Pest 4, drop composer-patches workaround#1481
herpaderpaldent merged 15 commits into
5.xfrom
chore/pest-4

Conversation

@herpaderpaldent
Copy link
Copy Markdown
Contributor

Summary

Resolves #1477.

The upstream bug in pestphp/pest-plugin-type-coverage (the RuleErrorTransformer::transform() argument mismatch) has been fixed in the released version. This PR removes the workaround that was added in the previous iteration:

  • Remove cweagans/composer-patches from require-dev
  • Remove the patches/ directory entry and patch file from extra.patches
  • Remove tomasvotruba/type-coverage (superseded by pest-plugin-type-coverage v4 built-in type coverage)
  • Remove cweagans/composer-patches from config.allow-plugins

Testing

composer run test passes with Pest 4 natively — no patches needed.

herpaderpaldent and others added 3 commits May 5, 2026 12:15
… API

`pestphp/pest-plugin-type-coverage` v4.0.4 calls
`RuleErrorTransformer::transform()` with wrong argument types:
- arg 3: `[]` (array) instead of `string $nodeType`
- arg 4: `$node` (Node object) instead of `int $nodeLine`

PHPStan's API has always expected `(RuleError, Scope, string, int)`.

Fix:
- Add `patches/pest-plugin-type-coverage-fix-transform-args.patch`
  that corrects both calls to use `$nodeType` and `$node->getLine()`
- Add `cweagans/composer-patches` as a dev dependency so the patch
  is re-applied automatically on `composer install`/`update`
- Allow the composer-patches plugin in config

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Bump larastan/larastan ^2 → ^3 (requires PHPStan 2.x)
- Bump phpstan/phpstan 1.x → 2.x (transitive via larastan)
- Bump rector/rector ^1 → ^2 (PHPStan 2.x compat)
- Bump driftingly/rector-laravel ^1 → ^2 (rector 2.x compat)
- Bump tomasvotruba/type-coverage ^1 → ^2 (PHPStan 2.x compat)

PHPStan 2.x fixes:
- phpstan.neon.dist: add (?) suffix to 3 non-existent excludePaths entries
- phpstan.neon.dist: suppress larastan.noEnvCallsOutsideOfConfig (package config files)
- phpstan.neon.dist: suppress property.notFound for cross-package polymorphic relations
- phpstan.neon.dist: suppress trait.unused for HasWatchlist (registered at runtime)
- ContractsController: replace magic whereCharacterId/whereContractId with where()
- SidebarPermissionChecker: replace magic whereId() with where('id', ...)
- GetEntityFromId: remove nullsafe operators on non-nullable CharacterAffiliation
- SearchService: add @var annotation for Cache::remember() mixed return type
- HasCharacterNecessaryRole: extract typed $characterRoles to resolve CharacterRole::hasRole()

test:unit fix:
- Add --no-coverage to test:unit script (phpunit.xml has <source> which PHPUnit 12
  initialises coverage for — without Xdebug in coverage mode this emits a warning
  that failOnWarning=true turns into a failure)
- Update phpunit.xml schema URL to PHPUnit 12.5

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove cweagans/composer-patches and the patch file that was working
around the pestphp/pest-plugin-type-coverage RuleErrorTransformer bug.
The upstream fix is now released so the patch is no longer needed.
Also removes tomasvotruba/type-coverage which is superseded by the
pest-plugin-type-coverage v4 built-in type coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@what-the-diff
Copy link
Copy Markdown

what-the-diff Bot commented May 5, 2026

PR Summary

  • Upgraded Dependency Versions in 'composer.json'
    These changes allow us to take advantage of the latest features and improvements in these packages. This is akin to updating the software on your phone to ensure it runs smoothly with the latest updates and enhancements.

  • New patches.lock.json file and patch for pestphp/pest-plugin-type-coverage
    We've introduced some code modifications to handle some specific issues the team encountered with one of the tools we use, increasing our efficiency and smoothening our development workflow.

  • Updated phpstan.neon.dist with new rules and adjusted paths
    We've made some adjustments to our automated code checks, reducing 'false positives' (errors that aren't really errors), and informing the tool to disregard some paths. This refines our feedback system during code development increasing efficiency.

  • Updated phpunit.xml to Reference New Schema Version
    We updated our testing tool settings to ensure compatibility with the latest standards, ensuring our tests are up-to-date and fully functional.

  • Improvements in src/Http/Controllers/Character/ContractsController.php and src/Services/Sidebar/SidebarPermissionChecker.php
    The changes made in these files refine our data queries, enhancing our system's data handling efficiency and effectiveness. Think of this as refining the way we pull information from our internal databases for significantly better performance.

  • Enhancements in src/Services/GetEntityFromId.php, src/Services/HasCharacterNecessaryRole.php, and src/Services/SearchService.php
    These updates simplify and clarify our code, increasing readability and efficiency. This means our developer team can navigate and update the code more efficiently, cutting down on development time and potential errors in the future.

herpaderpaldent and others added 2 commits May 5, 2026 14:06
- Deleted `patches/pest-plugin-type-coverage-fix-transform-args.patch`.
- Upstream fix has been released, rendering the local patch unnecessary.
…omId

Larastan v3 infers BelongsTo/HasOne as non-null on in-memory models,
but at runtime the relation IS null when the related record is absent
from the local DB. The ?-> guard ensures the ?? fallback to $this->names
is reachable.

Suppress nullsafe.neverNull and property.notFound for this file
in phpstan.neon.dist — both are Larastan false positives for this pattern.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
herpaderpaldent and others added 10 commits May 5, 2026 15:51
Pest 4 supports --parallel --shard N/M. The single sequential job is
replaced with:
- lint job: coding standards, PHPStan, type coverage (no DB needed)
- test matrix job: 4 shards running in parallel, each with postgres+redis

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…moved)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The three files were deleted previously; the (?) suffix was a temporary
workaround to avoid PHPStan errors on missing paths. Remove them cleanly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ce condition

LazilyRefreshDatabase cannot handle concurrent workers racing to create
the migrations table. The 4-shard matrix already provides CI-level
parallelism; --parallel within each shard is unnecessary and causes
SQLSTATE[42P01] failures on PostgreSQL.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
No point running 4 test shards if static analysis or coding standards
already failed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
phpunit.xml has failOnWarning=true; without --no-coverage pest emits
'WARN No code coverage driver available' which triggers exit code 1
before any tests run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
composer install runs once in 'setup', populates the cache.
'lint' and all 4 'test' shards both depend on 'setup' and restore
from cache — they run concurrently without re-downloading packages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… check

- --shard requires = not a space in Pest v4
- Add summary 'Laravel' job (needs: lint + test) so branch protection
  rule that gates on 'Laravel' status check still passes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…edErrors=false

The shared-cache setup job approach was unreliable: if lint/test got a
cache miss they had no fallback install step, leaving PHPStan without a
vendor dir and reporting all suppressions as 'unmatched'.

Restore the proven per-job cache+install pattern from ace49eb.
Add reportUnmatchedIgnoredErrors: false to phpstan.neon.dist so that
suppressions which don't match on a given Larastan version are silently
skipped rather than causing CI to fail.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@herpaderpaldent herpaderpaldent merged commit 0fc9d0b into 5.x May 5, 2026
8 checks passed
@herpaderpaldent herpaderpaldent deleted the chore/pest-4 branch May 5, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant