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

Switch to Larastan and resolve errors #881

Closed
mzur opened this issue Jul 17, 2024 · 0 comments · Fixed by #892
Closed

Switch to Larastan and resolve errors #881

mzur opened this issue Jul 17, 2024 · 0 comments · Fixed by #892
Assignees

Comments

@mzur
Copy link
Member

mzur commented Jul 17, 2024

As part of the Laravel 11 upgrade (#879) Psalm stopped working again. I'm considering to switch to Larastan instead. Installing and running it is quite straight forward but it seems to be much stricter than Psalm so there will be lots of type issues to be resolved.

I tried it out and here are some issues I encountered:

  • The models with HasConstantInstances (e.g. Role) need @method annotations like this:
    /**
      * A role of a user. Users have one global role and can have many project-
      * specific roles.
      *
      * @method static Role admin()
      * @method static Role adminId()
      * @method static Role expert()
      * @method static Role expertId()
      * @method static Role editor()
      * @method static Role editorId()
      * @method static Role guest()
      * @method static Role guestId()
      */
     class Role extends Model
    
  • Some Models that use inheritance (e.g. Annotation) need explicit property annotations, as Larastan cannot infer the properties from the migrations.
  • There are lots of inconsistent PHPDoc types.
  • Many controller methods have a wrong type annotation because I was too lazy.

All in all this will be some work but I think the stricter checks will only improve the codebase.

@mzur mzur mentioned this issue Jul 17, 2024
12 tasks
@mzur mzur self-assigned this Jul 25, 2024
@mzur mzur linked a pull request Jul 25, 2024 that will close this issue
2 tasks
@mzur mzur closed this as completed Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant