Inconsistent behavior with `class_string` of mocks for intersection types
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
- devtools, testing-qa
Hướng nghiên cứu
Start with the makeInstanceReturnsClassInstance test and reproduce the reported diagnostic involving get_class(), getMock(), and GeneralUtility::makeInstance(). Trace how phpstan-phpunit represents the mock's class-string intersection versus the expected class-string; done means the valid test no longer produces this mismatch.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have not been able to create a working example for this on the PHPStan playground as this bug involves PHPUnit and the phpstan-phpunit package.
We have a class with a generator function that looks like this:
/**
* Creates an instance of a class taking into account the class-extensions
* API of TYPO3. USE THIS method instead of the PHP "new" keyword.
* Eg. "$obj = new myclass;" should be "$obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("myclass")" instead!
*
* You can also pass arguments for a constructor:
* \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\myClass::class, $arg1, $arg2, ..., $argN)
*
* @template T of object
* @param class-string<T> $className name of the class to instantiate, must not be empty and not start with a backslash
* @param array<int, mixed> $constructorArguments Arguments for the constructor
* @return T the created instance
*/
public static function makeInstance($className, ...$constructorArguments)
{…}
One of the tests for this method looks like this:
/**
* @test
*/
public function makeInstanceReturnsClassInstance(): void
{
$className = get_class($this->getMockBuilder('foo')->getMock());
self::assertInstanceOf($className, GeneralUtility::makeInstance($className));
}
PHPStan (or phpstan-phpunit) now seems to mix up two different representations of a class string for a intersection types (which both look plausible to me, but they're not the same to PHPStan):
3123 Parameter #1 $className of static method TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance() expects
class-string<foo&PHPUnit\Framework\MockObject\MockObject>,
class-string<foo>&class-string<PHPUnit\Framework\MockObject\MockObject> given.
- Ngôn ngữ chính
- PHP
- Star
- 544
- Fork
- 58
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 5
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 phpstan/phpstan-phpunit
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
phpstan/phpstan-phpunit#332 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
phpstan/phpstan-phpunit#321 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
phpstan/phpstan-phpunit#309 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
phpstan/phpstan-phpunit#299 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
phpstan/phpstan-phpunit#292 · 3 bình luận ·
Tất cả issue của phpstan/phpstan-phpunit
Issue tương tự
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Automattic/blocks-engine#2161 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/static-site-importer#1824 ·
-
[Chore] Keep one viget-block-generator skill and replicate it, instead of four tracked copies Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Cannot reset column width Đang mở0. Needs triage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
0. Needs triage 35-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100