prettier / prettier/plugin-php
Some comment positions inside attributes can result in prettier failing with an exception
未关闭
还没有人认领这个 Issue。
- 主要语言
- PHP
- 星标
- 1.9k
- 派生
- 139
- PR 合并指标
- 30 天内没有已合并 PR
描述
Not sure which cases these include exactly but some cases result in pretter stopping with an error:
Error: Comment "// abc" was not printed. Please report this error!
I know that i was also able to produce that error with other positions, but various other work fine so it is a bit weird.
Playground also shows it: Link to playground
Prettier 2.88.0 (but also tried latest)
PHP Plugin 0.19.6 (but also tried latest)
# Options (if any):
--no-options
Input:
<?php declare(strict_types=1);
namespace App\Controller\General;
use App\Dto\BarDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
class EnrollmentController extends AbstractController
{
public function save(
#[
MapRequestPayload(
serializationContext: [ // abc
AbstractNormalizer::CALLBACKS => [
'abc' => 'trim',
],
],
),
]
BarDto $data,
): Response {
return $this->json(['foo']);
}
}
Output:
None. Errror as mentioned above.
Expected behavior:
No error and correctly formatted.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在链接的 playground 或最新插件版本中,使用提供的 PHP 输入重现该异常,然后跟踪 PHP 插件对属性内部注释的处理。完成标准是输入能够成功格式化,并且保留注释而不会出现“Comment was not printed”错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100