False positive: Call to static method Webmozart\Assert\Assert::allInArray() with array<string> and array<string> will always evaluate to true
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
- 45/100
Hướng nghiên cứu
Start with the test.php reproduction and run the shown PHPStan command using phpstan.neon at level 4. Inspect the phpstan-webmozart-assert extension configuration and the discussion in issue 142; done means this example no longer reports staticMethod.alreadyNarrowedType while the assertion analysis remains correct.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The following code causes a false PHPStan error. The Assert::allInArray($enabledNames, $supportedNames); assertion certainly isn't always true.
use Webmozart\Assert\Assert;
class C
{
/**
* @param array<string> $supportedNames
* @param array<string> $enabledNames
*/
public function __construct(
array $supportedNames,
array $enabledNames,
)
{
Assert::allInArray($enabledNames, $supportedNames);
}
}
$ vendor/bin/phpstan analyse -c phpstan.neon test.php
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ --------------------------------------------------------------------------------------------------------------------------------
Line test.php
------ --------------------------------------------------------------------------------------------------------------------------------
17 Call to static method Webmozart\Assert\Assert::allInArray() with array<string> and array<string> will always evaluate to true.
🪪 staticMethod.alreadyNarrowedType
------ --------------------------------------------------------------------------------------------------------------------------------
[ERROR] Found 1 error
===============
$ vendor/bin/phpstan diagnose
Note: Using configuration file /Users/melka/work/rh/phpstan.neon.
PHP runtime version: 8.3.22
PHP version for analysis: 8.3.22 (from runtime)
PHPStan version: 2.1.29
PHPStan running from:
/Users/melka/work/rh/vendor/phpstan/phpstan
Extension installer: Not installed
Included configs from Composer packages:
phpstan/phpstan-webmozart-assert (extension.neon): 2.0.0
Discovered Composer project root:
/Users/melka/work/rh
===============
$ cat phpstan.neon
includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
parameters:
level: 4 # lowest level where this starts happening
Also discussed in https://github.com/phpstan/phpstan-webmozart-assert/issues/142#issuecomment-3372330454
- Ngôn ngữ chính
- PHP
- Star
- 185
- Fork
- 33
- Merge trung bình
- 20 giờ 40 phút
- Pull request đã merge (30 ngày)
- 7
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
- Đọ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-webmozart-assert
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
phpstan/phpstan-webmozart-assert#187 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 32/100
phpstan/phpstan-webmozart-assert#180 · 5 bình luận ·
-
False positive: Call to inArray() with different object instances will always evaluate to trueĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
phpstan/phpstan-webmozart-assert#142 · 17 bình luận ·
-
Support the new methods in 1.4Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
phpstan/phpstan-webmozart-assert#6 · 3 bình luận · 2 reaction ·
Tất cả issue của phpstan/phpstan-webmozart-assert
Issue tương tự
-
bug needs grooming
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
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 63/100
phpstan/phpstan-phpunit#361 ·
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 72/100
HE-Arc/le-panier-du-coin#49 ·
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
Maintainer thường phản hồi trong vòng 2 ngày
-
15.0
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100