craftcms / craftcms/phpstan

ActiveRecord issues and other Yii-specific issues being picked up

Open
#1 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
No language data
Stars
12
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Description

Hello, we have inherited a codebase and added PHPStan to it. There are lots of very specific YIi/ActiveRecord issues being picked up that we think this PHPStan extension might fix: https://github.com/erickskrauch/phpstan-yii2, but it depends on PHPStan 2.0^.

For example, we get errors like this where CrmContact extends ActiveRecord:

 69     Access to an undefined property modules\modulename\records\CrmContact::$id.

The record doesn't explicitly have an $id parameter set, which would solve this, but there is a lot of code to cover and we're trying to focus on the important areas to resolve first.

Is there a way to either upgrade this to PHPStan 2.X so we can experiment with the Yii2 extension, or perhaps a stub you could add/suggest for us?

Steps to reproduce
  1. Include the craftcms PHPStan config
  2. Run PHPStan
Additional info
  • Craft version:4
  • PHP version: 8.2.X

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Craft PHPStan configuration and the documented PHPStan invocation, then check the requested PHPStan 2.x compatibility and the reported undefined ActiveRecord property case. Done should be defined as either a working PHPStan 2.x configuration or a documented stub-based way to address the example error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.