我正在尝试在PhpStorm中格式化我的代码,但对于多行返回语句,代码是双选项(8个空格),即使我在代码样式选项中指定了4个空格。
这是我的PhpStorm代码风格
<code_scheme name="OneUp_PHP_CodeStyle">
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="COMMA_AFTER_LAST_ARRAY_ELEMENT" value="true" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
<option name="BLANK_LINE_BEFORE_RETURN_STATEMENT" value="true" />
<option name="ALIGN_CLASS_CONSTANTS" value="true" />
<option name="SPACE_BEFORE_COLON_IN_RETURN_TYPE" value="true" />
<option name="NAMESPACE_BRACE_STYLE" value="2" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="SPECIAL_ELSE_IF_TREATMENT" value="true" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
</codeStyleSettings>
</code_scheme>
以下是有问题的代码
// Evaluate that the checkout contains all required coupon items.
collect($coupon->checkout_contains)->reduce(function ($carry, $requiredItem) use ($request) {
// Iterate over checkout items for each required item, and make sure
// that at least one checkout item satisfies each required item.
return $carry && collect($request->items)->reduce(function ($carry, $checkoutItem) use ($requiredItem) {
return $carry || (
$requiredItem->product_id == $checkoutItem->product_id &&
$requiredItem->quantity <= $checkoutItem->quantity &&
$requiredItem->type == $checkoutItem->type
);
}, false);
}, true);
我在Windows 10上使用PhpStorm 2017.2.1
JetBrains问题跟踪器门票: https://youtrack.jetbrains.com/issue/WI-37751