Undefined method appears when Component and Model have the same name
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với reproducer gồm BasicComponent, Basic model và FakeController, sau đó theo dõi cách resolver phân giải $this->Basic khi component và model có cùng tên. Xác nhận cách xử lý khai báo $uses của controller; được xem là hoàn tất khi phương thức của model được nhận diện mà không tạo ra lỗi undefined-method, kèm theo một trường hợp regression cho ví dụ này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
class BasicComponent extends Component {}
<?php
class Basic extends Model
{
public function some_method()
{
}
}
<?php
class FakeController extends Controller
{
public $uses = [
'Basic',
];
public function add_smth()
{
$this->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.
- Ngôn ngữ chính
- PHP
- Star
- 2
- Fork
- 3
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ariddlestone/phpstan-cakephp2
-
Add extension for FlashComponentĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Add stub for lib/Cake/basics.phpĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
-
Add stub for ShellDispatcherĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
Add extension for schema filesĐang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Add stub/extension for modelsCó thể làm lại được @ariddlestone đã nhận 1333 ngày trước và không có pull request nào đang mở. Đang mởenhancement
ariddlestone/phpstan-cakephp2#9 · 1 bình luận · 1 người được giao ·
Tất cả issue của ariddlestone/phpstan-cakephp2
Issue tương tự
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 68/100
components-web-app/docs#244 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
PrestaShopCorp/ps_eventbus#501 · 2 reaction ·
-
category::task maintenance priority::normal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
e0ipso/schema-forms-php#58 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Automattic/blocks-engine#2866 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
community-scripts/ProxmoxVE#17944 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày