Ezrab_
Ezrab_

Reputation: 973

PhpStorm disable formatting array initialization on new line

I've tried playing around with the array wrapping options in the "Wrapping and Braces" section in the PHP's code style. But I can't seem to find the setting for this issue.

My arrays should be likes this (the Laravel code style way):

protected $fillable = [
    'name',
    'email',
    'password',
];

But PhpStorm keeps reformatting them this way:

protected $fillable
= [
    'name',
    'email',
    'password',
];

Edit 1: PhpStorm version is 2020.3 RC 3 (Though this same behavior happens on 2020.2). enter image description here

XML Codestyle:

<code_scheme name="Default" version="173">
  <JSCodeStyleSettings version="0">
    <option name="FORCE_SEMICOLON_STYLE" value="true" />
    <option name="USE_DOUBLE_QUOTES" value="false" />
    <option name="FORCE_QUOTE_STYlE" value="true" />
    <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
    <option name="JSX_ATTRIBUTE_VALUE" value="Based on type" />
  </JSCodeStyleSettings>
  <PHPCodeStyleSettings>
    <option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
    <option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
    <option name="ALIGN_PHPDOC_COMMENTS" value="true" />
    <option name="ALIGN_ASSIGNMENTS" value="true" />
    <option name="CONCAT_SPACES" value="false" />
    <option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
    <option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
    <option name="PHPDOC_WRAP_LONG_LINES" value="true" />
    <option name="BLANK_LINES_BETWEEN_IMPORTS" value="1" />
    <option name="PHPDOC_PARAM_SPACES_BETWEEN_TAG_AND_TYPE" value="2" />
    <option name="PHPDOC_PARAM_SPACES_BETWEEN_TYPE_AND_NAME" value="2" />
    <option name="PHPDOC_PARAM_SPACES_BETWEEN_NAME_AND_DESCRIPTION" value="2" />
    <option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
    <option name="LOWER_CASE_NULL_CONST" value="true" />
    <option name="ELSE_IF_STYLE" value="COMBINE" />
    <option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
    <option name="ALIGN_CLASS_CONSTANTS" value="true" />
    <option name="BLANK_LINES_AFTER_OPENING_TAG" value="1" />
    <option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="0" />
    <option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
    <option name="NEW_LINE_AFTER_PHP_OPENING_TAG" value="true" />
    <option name="PHPDOC_USE_FQCN" value="true" />
  </PHPCodeStyleSettings>
  <editorconfig>
    <option name="ENABLED" value="false" />
  </editorconfig>
  <codeStyleSettings language="HTML">
    <indentOptions>
      <option name="INDENT_SIZE" value="2" />
      <option name="CONTINUATION_INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
  <codeStyleSettings language="JavaScript">
    <indentOptions>
      <option name="INDENT_SIZE" value="2" />
      <option name="CONTINUATION_INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
  <codeStyleSettings language="Markdown">
    <option name="WRAP_ON_TYPING" value="1" />
  </codeStyleSettings>
  <codeStyleSettings language="PHP">
    <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
    <option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
    <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    <option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
    <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
    <option name="ALIGN_GROUP_FIELD_DECLARATIONS" value="true" />
    <option name="SPACE_AFTER_TYPE_CAST" value="true" />
    <option name="CALL_PARAMETERS_WRAP" value="1" />
    <option name="METHOD_PARAMETERS_WRAP" value="5" />
    <option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="EXTENDS_LIST_WRAP" value="5" />
    <option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
    <option name="PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE" 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>
  <codeStyleSettings language="TypeScript">
    <indentOptions>
      <option name="INDENT_SIZE" value="2" />
      <option name="CONTINUATION_INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
</code_scheme>

Upvotes: 0

Views: 574

Answers (1)

LazyOne
LazyOne

Reputation: 165148

Imported your Code Style schema, found the issue.

You need to disable Assigment statement | Assignment sign on next line option at Settings/Preferences | Editor | Code Style | PHP | Wrapping and Braces

enter image description here


P.S. You can just import from existing predefined schema: just use Set from... and select most desired entry (e.g. PSR12 or Laravel).

enter image description here

Upvotes: 1

Related Questions