Skip to content

Bump larastan/larastan from 2.9.12 to 3.10.0#60

Merged
spawnia merged 6 commits into
masterfrom
dependabot/composer/larastan/larastan-3.10.0
Jun 12, 2026
Merged

Bump larastan/larastan from 2.9.12 to 3.10.0#60
spawnia merged 6 commits into
masterfrom
dependabot/composer/larastan/larastan-3.10.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Jun 12, 2026

Copy link
Copy Markdown
Contributor

Bumps larastan/larastan from 2.9.12 to 3.10.0.

Release notes

Sourced from larastan/larastan's releases.

3.10.0

What's Changed

Added

Fixed

Internal

New Contributors

Full Changelog: larastan/larastan@v3.9.6...v3.10.0

3.9.6

What's Changed

Added

Fixed

Full Changelog: larastan/larastan@v3.9.5...v3.9.6

3.9.5

What's changed?

Fixed

Full Changelog: larastan/larastan@v3.9.4...v3.9.5

3.9.4

What's Changed

Changed

... (truncated)

Upgrade guide

Sourced from larastan/larastan's upgrade guide.

Upgrade Guide

Upgrading to 3.0 from 2.x

This is a new major release with lots of breaking changes.

Please first read PHPStan's 2.0 upgrade guide here carefully.

Correct return types for model relation methods

Likelihood Of Impact: High

Normally PHPStan warns the users when a return type of method does not provide its generic types. For example, the following code will produce a PHPStan error:

class User extends Model
{
    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }
}
// Method User::posts() return type with generic class HasMany does not specify its types: TRelatedModel, TDeclaringModel

In the previous versions of Larastan, in this case Larastan would parse the model file and read the method body to understand the generic types of the relation. But this approach is slow (because it requires parsing the file) and the maintenance of this feature is hard. So in this version, Larastan will not parse the method body to understand the generic types of the relation. Instead, you need to provide the correct generic types in the return type of the relation method. Here is how you can fix the above example:

class User extends Model
{
    /**
     * @return HasMany<Post, $this>
     */
    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }
}

Manually adding these annotations can be tedious. To help with this, we've created a Rector rule that can automatically add them for you! You can use this rule to automatically add the correct generic annotations. It detects your Laravel version and adds the appropriate generic types accordingly.

If you're not currently using Rector, or can't use it due to dependency conflicts, don't worry! We've also prepared a simple script that can run Rector for you without requiring a full installation.

First install cpx:

composer global require cpx/cpx

Then download this script from the gist and run with:

... (truncated)

Commits
  • 2970f83 feat: add type narrowing for where method on collections (#2483)
  • 936f20b fix failing tests on Windows (#2486)
  • c856507 Add export-ignore for assets directory in .gitattributes (#2490)
  • 9b014b5 chore: bump phpstan memory limit
  • d58d982 chore: run SA on Laravel 13 too
  • 7c4347c docs: use correct coding standard name
  • 1e243f1 docs: update coding style guidelines in CONTRIBUTING.md (#2447)
  • 45a4414 chore: update codestyle check to latest version (#2484)
  • 0e774c5 chore: allow PHPUnit v13 (#2485)
  • 9ef66e1 fix: invalid parameter name (#2488)
  • Additional commits viewable in compare view

@dependabot dependabot Bot added dependencies Pull requests that update a dependency file php Pull requests that update Php code labels Jun 12, 2026
@spawnia spawnia enabled auto-merge (squash) June 12, 2026 07:50
@dependabot dependabot Bot force-pushed the dependabot/composer/larastan/larastan-3.10.0 branch from da401e4 to 9bf66ef Compare June 12, 2026 07:52
Bumps [larastan/larastan](https://github.com/larastan/larastan) from 2.9.12 to 3.10.0.
- [Release notes](https://github.com/larastan/larastan/releases)
- [Changelog](https://github.com/larastan/larastan/blob/3.x/RELEASE.md)
- [Upgrade guide](https://github.com/larastan/larastan/blob/3.x/UPGRADE.md)
- [Commits](larastan/larastan@v2.9.12...v3.10.0)

---
updated-dependencies:
- dependency-name: larastan/larastan
  dependency-version: 3.10.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot Bot force-pushed the dependabot/composer/larastan/larastan-3.10.0 branch from 9bf66ef to 7148e2e Compare June 12, 2026 07:54
spawnia added 5 commits June 12, 2026 10:10
- Add generic types to DatabaseNotificationCollection
- Type-narrow Application in CreatesApplication trait
- Cast Post::max() result to int
- Remove trivial ExampleTest

🤖 Generated with Claude Code
🤖 Generated with Claude Code
Larastan 3.x at max level forbids casting mixed to int directly.

🤖 Generated with Claude Code
🤖 Generated with Claude Code
RefreshDatabase ensures an empty DB, so the first post always gets ID 1.
Avoids the mixed-type issue from Post::max() entirely.

🤖 Generated with Claude Code
@spawnia spawnia merged commit efd4771 into master Jun 12, 2026
3 checks passed
@spawnia spawnia deleted the dependabot/composer/larastan/larastan-3.10.0 branch June 12, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant