是否需要在 Symfony 编码标准进行类型转换后保留 space?

Is it required to keep space after type cast by Symfony coding standards?

我在 the official documentation 中找不到答案。 所以 PHP 代码嗅探器说它是必需的(编码标准包 escapestudios/symfony2-coding-standard)。

示例应该是:

$result = (bool) foo();

反之亦然:

$result = (bool)foo();

是的,it is:

如何申请?

  • 在 CodeSniffer 中,您正在寻找 PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff

  • 在 PHP-CS-Fixer 中,它将是 PhpCsFixer\Fixer\CastNotation\CastSpacesFixer

这里使用的工具是EasyCodingStandard - you can read intro post about it