【问题标题】:Eclipse PHP code formatter removes pipe symbols from @return commentsEclipse PHP 代码格式化程序从@return 注释中删除管道符号
【发布时间】:2014-05-19 09:37:04
【问题描述】:

我将 Eclipse Kepler (4.3.1) 用于 PHP 项目。

我偶然发现了一个关于 PHPDoc 的带有管道(竖线)符号的 @return 的 PHP Eclipse 代码格式化程序问题: 当有这样的评论时:

<?php

/**
 *
 * @param string|array The parameter. Either a string or an array.
 * @return int|string The return value. Either an int or a string.
 */
function test($param) {
}

使用带有 [CTRL]+[SHIFT]+[F] 的格式化函数会导致:

<?php

/**
 *
 * @param
 *          string|array The parameter. Either a string or an array.
 * @return int string return value. Either an int or a string.
 */
function test($param) {
}

正如你所见,'@return' 语句中'int' 和'string' 之间的管道符号已被替换为空格。但不仅如此。描述的第一个词('The')也被砍掉了。另一方面,它适用于“@param”语句。

phpdoc.org 声明,在处理不明确的返回值时使用管道符号:phpdoc-@return

就在几天前,有人还在 Eclipse 社区论坛:Forum Post 上提出了一个关于此的问题。

使用 '@formatter:off' 和 '@formatter:on' 是不可取的,因为这个设置只是本地的,其他人可能没有设置。

有谁知道如何修复配置 eclipse php 代码格式化程序?有人有解决方法吗?

【问题讨论】:

  • 据我所知,@return 混合用于此类情况,无论如何,我建议您使用更“php 友好”的 IDE,例如 PhpStorm。
  • “混合”作为返回类型的问题是,它可以是任何东西。使用管道符号我可以说它是 A 型或 B 型。这再次有助于 Eclipse 中的自动完成。使用其他 IDE 也不行,因为这是公司的指导方针。

标签: php eclipse phpdoc formatter


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2010-11-04
    • 2019-10-07
    • 2017-08-09
    • 2010-09-11
    • 2015-09-01
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    相关资源
    最近更新 更多