FormError is not subtype of native type T of FormError|FormErrorIterator.
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
- 48/100
Hướng nghiên cứu
Start by reproducing the reported PHPStan 2 diagnostic with the Symfony Form getErrors() loop shown in the issue, then trace how that method's FormError|FormErrorIterator type is validated against the @var annotation. Done means the intended PhpStorm annotation is either accepted without the subtype error or the supported workaround is documented.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi!
I'm in the process of upgrading to phpstan 2.
One error that I couldn't find any solution yet is the following.
It was working on the latest 1.x versions
<?php
namespace App\Controller;
use App\Entity\Customer;
use App\Form\CustomerType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
class CustomerController extends AbstractController
{
#[Route('/submit')]
public function submit(Request $request): JsonResponse
{
$form = $this->createForm(CustomerType::class, new Customer());
$form->handleRequest($request);
if ($form->isSubmitted() && !$form->isValid()) {
$errors = [];
/** @var FormError $error */
foreach ($form->getErrors(true) as $error) {
// process and handle errors
}
}
return $this->json([]);
}
}
After phpstan 2 I get the following error:
PHPDoc tag
@varwith type Symfony\Component\Form\FormError is not subtype of native type T of Symfony\Component\Form\FormError|Symfony\Component\Form\FormErrorIterator.
I use the @var typehint for phpstorm, to have autocompletion. How can I fix this or is this a bug?
Thanks for your help
- Ngôn ngữ chính
- PHP
- Star
- 806
- Fork
- 107
- Merge trung bình
- 2 giờ 4 phút
- Pull request đã merge (30 ngày)
- 5
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-symfony
-
`ParameterBag::keys()` stub not applied for Symfony ≥ 7.4 → false-positive `is_string()` `alwaysNarrowedType`Có thể đã có người làm @ChrisAbner đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
phpstan/phpstan-symfony#510 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
phpstan/phpstan-symfony#494 · 5 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
phpstan/phpstan-symfony#268 ·
-
Account for `\ErrorException` from `unserialize()` when Symfony’s PHP error conversion is enabledĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
phpstan/phpstan-symfony#514 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
phpstan/phpstan-symfony#509 · 2 bình luận ·
Tất cả issue của phpstan/phpstan-symfony
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Automattic/blocks-engine#4621 ·
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
YunoHost-Apps/snappymail_ynh#205 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Automattic/static-site-importer#2653 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug (unconfirmed) Search :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
FreshRSS/FreshRSS#9533 · 1 reaction ·
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 83/100
ExpressionEngine/ExpressionEngine#5453 ·
Maintainer thường phản hồi trong vòng 1 ngày