ariddlestone / ariddlestone/phpstan-cakephp2
Undefined method appears when Component and Model have the same name
- Dominant language
- PHP
- Stars
- 2
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Hi.
Thanks for this brilliant extension first of all.
I'm working with project where all Models don't have `Model` suffix. Like described in the official documentation (https://book.cakephp.org/2/en/models.html#understanding-models)
So in case we have Component and Model with the same name it leads to `Call to an undefined method BasicComponent::some_method`.
Code sample:
```php
Basic->some_method();
}
}
```
As I can see component service is setup first so probably it found `BasicComponent` and tries to look method inside of it only and doesn't take into account that models is also exists.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the BasicComponent, Basic model, and FakeController reproducer, then trace how the extension resolves $this->Basic when components and models share a name. Confirm the resolver's handling of the controller's $uses declaration; done means the model method is recognized without producing an undefined-method error, with a regression case for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100