Объявление массива защищенных атрибутов всегда находится на новой строке, но я хочу, чтобы оно было в той же строке - PullRequest
0 голосов
/ 05 июня 2018

Код после автоматического форматирования с помощью Ctrl + Alt + L выглядит следующим образом:

class ExampleModel extends Model
{
    public $timestamps = false;
    protected $table = 'table1';
    protected $primaryKey = 'id';
    protected $casts
        = [  //array declaration is on a newline!
            'id' => 'int',
            'aa' => 'int',
            'bb' => 'int',
            'cc' => 'int',
        ];

    protected $fillable
        = [ //array declaration is on a newline!
            'id',
            'aa',
            'bb',
            'cc',
        ];
}

Но я бы хотел, чтобы PhpStorm позволил ему остаться в одной строке:

class ExampleModel extends Model
{
    public $timestamps = false;
    protected $table = 'table1';
    protected $primaryKey = 'id';
    protected $casts = [
            'id' => 'int',
            'aa' => 'int',
            'bb' => 'int',
            'cc' => 'int',
        ];

    protected $fillable = [
            'id',
            'aa',
            'bb',
            'cc',
        ];
}

Я думал, что это под Редактор> Стиль кода> PHP> Инициализатор массива , но, похоже, ничего не работает.

вложение ( ссылка )

<code_scheme name="PSR-2" version="173">
  <option name="AUTODETECT_INDENTS" value="false" />
  <option name="LINE_SEPARATOR" value="&#xA;" />
  <option name="RIGHT_MARGIN" value="500" />
  <option name="SOFT_MARGINS" value="100" />
  <HTMLCodeStyleSettings>
    <option name="HTML_KEEP_BLANK_LINES" value="1" />
  </HTMLCodeStyleSettings>
  <JSCodeStyleSettings>
    <option name="FORCE_SEMICOLON_STYLE" value="true" />
    <option name="SPACE_BEFORE_GENERATOR_MULT" value="true" />
    <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
    <option name="USE_DOUBLE_QUOTES" value="false" />
    <option name="FORCE_QUOTE_STYlE" value="true" />
    <option name="SPACES_WITHIN_IMPORTS" value="true" />
  </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="COMMA_AFTER_LAST_ARRAY_ELEMENT" value="true" />
    <option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
    <option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
    <option name="GROUP_USE_WRAP" value="0" />
    <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="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
    <option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
    <option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
    <option name="IF_RPAREN_ON_NEXT_LINE" value="true" />
  </PHPCodeStyleSettings>
  <codeStyleSettings language="HTML">
    <indentOptions>
      <option name="CONTINUATION_INDENT_SIZE" value="4" />
    </indentOptions>
  </codeStyleSettings>
  <codeStyleSettings language="JavaScript">
    <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    <option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
    <option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
    <option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
    <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
    <indentOptions>
      <option name="INDENT_SIZE" value="2" />
      <option name="CONTINUATION_INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
  <codeStyleSettings language="PHP">
    <option name="RIGHT_MARGIN" value="999" />
    <option name="KEEP_LINE_BREAKS" value="false" />
    <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
    <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
    <option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
    <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    <option name="ALIGN_MULTILINE_FOR" value="false" />
    <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="METHOD_CALL_CHAIN_WRAP" value="2" />
    <option name="BINARY_OPERATION_WRAP" value="1" />
    <option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
    <option name="TERNARY_OPERATION_WRAP" value="1" />
    <option name="FOR_STATEMENT_WRAP" value="1" />
    <option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_WRAP" value="5" />
    <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
    <option name="ASSIGNMENT_WRAP" value="1" />
    <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" />
    <option name="SOFT_MARGINS" value="100" />
  </codeStyleSettings>
  <codeStyleSettings language="SCSS">
    <indentOptions>
      <option name="CONTINUATION_INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
  <codeStyleSettings language="Twig">
    <indentOptions>
      <option name="CONTINUATION_INDENT_SIZE" value="4" />
    </indentOptions>
  </codeStyleSettings>
</code_scheme>

1 Ответ

0 голосов
/ 06 июня 2018
  1. Settings/Preferences
  2. Editor | Code Style | PHP
  3. Wrapping and Braces вкладка

Вы отметили Assignment statement | Assignment sign on next line вариант,Снимите флажок, чтобы иметь желаемое форматирование.

enter image description here

...