Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Traits are not supported (`Mockery::mock()`)

Đang mở
#78 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php
Lĩnh vực
testing

Hướng nghiên cứu

Start by reproducing the two Mockery::mock() examples, comparing a class-only mock with one that includes trait T. Trace how the extension handles Mockery::mock() arguments and verify that trait methods are represented while unknown methods remain rejected; the dumped type should no longer be NEVER.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Mockery::mock() allow to add traits into mocks:

<?php declare(strict_types = 1);

class C {
    public function helloClass(): string { return 'hello class'; }
}

trait T {
    public function helloTrait(): string { return 'hello trait'; }
}

$mock = Mockery::mock(C::class, T::class);
$mock->makePartial();

\PHPStan\dumpType($mock);

echo $mock->helloTrait();

will output hello trait. Unfortunately, it is not supported by this extension (and seems phpstan also cannot create intersections with traits?) so the dumped type will be *NEVER* -> the $mock->helloTrait() actually not validated at all... :(

Mockery::mock(C::class)->helloUnknown();           // Call to an undefined method C&Mockery\MockInterface::helloUnknown()
Mockery::mock(C::class, T::class)->helloUnknown(); // nothing 

If we are on Level 10 and doing something like Mockery::mock(C::class)->getSomething()->method(); we also will get "Cannot call method method() on mixed.".

Ngôn ngữ chính
PHP
Star
110
Fork
25
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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của phpstan/phpstan-mockery

Tất cả issue của phpstan/phpstan-mockery

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.