代码行的 PSR-2 和 "Line exceeds by 120 characters"
PSR-2 and "Line exceeds by 120 characters" for a Codeline
我正在尝试为 PSR-2 PHP 标准编写一些代码。
在验证时我遇到了很多这样的错误:
Line exceeds 120 characters; contains 122 characters
我已经尝试了几种方法来解决这个问题。这是原始行:
$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
//Same Codeline with added spaces
$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
我试过这样做:
$s = sprintf(
'%.2F %.2F %.2F %.2F re %s ',
$this->x * $k,
($this->h - $this->y) * $k,
$w * $k,
-$h * $k,
$op
);
但随后错误变为 "Opening parenthesis of a multi-line function call must be the last content on the line"
我也试过这个:
$he1p = $this->x * $k;
$h3lp = ($this->h - $this->y) * $k;
$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $he1p, $h3lp, $w * $k, -$h * $k, $op);
...但似乎不需要将其分解为多个语句。
But then the Error changed to "Opening parenthesis of a multi-line function call must be the last content on the line"
您在 sprintf(
之后有一个空的 space 字符,而该行中的最后一个字符应该是左括号,因为错误状态是
尝试在 sprintf(
之后删除 space
$s = sprintf(
'%.2F %.2F %.2F %.2F re %s ',
$this->x * $k,
($this->h - $this->y) * $k,
$w * $k,
-$h * $k,
$op
);
我正在尝试为 PSR-2 PHP 标准编写一些代码。
在验证时我遇到了很多这样的错误:
Line exceeds 120 characters; contains 122 characters
我已经尝试了几种方法来解决这个问题。这是原始行:
$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
//Same Codeline with added spaces
$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
我试过这样做:
$s = sprintf(
'%.2F %.2F %.2F %.2F re %s ',
$this->x * $k,
($this->h - $this->y) * $k,
$w * $k,
-$h * $k,
$op
);
但随后错误变为 "Opening parenthesis of a multi-line function call must be the last content on the line"
我也试过这个:
$he1p = $this->x * $k;
$h3lp = ($this->h - $this->y) * $k;
$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $he1p, $h3lp, $w * $k, -$h * $k, $op);
...但似乎不需要将其分解为多个语句。
But then the Error changed to "Opening parenthesis of a multi-line function call must be the last content on the line"
您在 sprintf(
之后有一个空的 space 字符,而该行中的最后一个字符应该是左括号,因为错误状态是
尝试在 sprintf(
之后删除 space$s = sprintf(
'%.2F %.2F %.2F %.2F re %s ',
$this->x * $k,
($this->h - $this->y) * $k,
$w * $k,
-$h * $k,
$op
);