PhpStorm code style php 翻譯

翻譯內容路徑 Editor > Code Style > PHP

括號裏會有我自己的解釋和樣例

導航欄

在這裏插入圖片描述

  • tabs and indents : 製表符tab和縮進
  • spaces : 空格(類,方法,關鍵字的空格控制)
  • wrapping and braces:包裝和括號
  • blank lines:空白行
  • phpdoc:php註釋
  • code conversion:代碼轉換
  • code generation:代碼生成
  • arrangement:安排

tabs and indents 製表符tab和縮進

在這裏插入圖片描述

  • use tab character:顯示製表符(就是tab的符號,會有個箭頭)
  • smart tabs:智能tabs(不知道有什麼用,聰明在哪)
  • tab size:1個tab用多少個箭頭表示,不影響tab的長度
  • indent:縮進(一個tab的長度,距離)
  • continuation indent:持續縮進(不知道有什麼用)
  • keep indents on empty lines:在空行上保持縮進(沒有內容的行,也使用tab)
  • indent code in php tags:php標記中的縮進代碼(以<?php 作爲縮進的起始距離)
    在這裏插入圖片描述

spaces 空格(類,方法,關鍵字的空格控制)

  • before parentheses :括號前的空格控制(處理“ ()” 相關的)

    • function declaration parentheses:函數括號前的空格控制(打勾表示括號前加空格foo ($x, $z))
    • function call parentheses:函數調用的括號前的空格控制(打勾表示括號前加空格$obj->foo ();)
    • anonymous function parentheses:匿名函數的括號前的空格控制(同上)
    • ‘if’ parentheses:if的括號前的空格控制(打勾表示加空格 if (!0 > KaTeX parse error: Expected 'EOF', got '&' at position 3: x &̲& !x < 10))
    • ‘for’ parentheses:同上
    • ‘while’ parentheses:同上
    • ‘switch’ parentheses:同上
    • ‘catch’ parentheses:同上
    • array initializer parentheses:數組初始值設定項括號
  • around operators:運算,操作符周圍空格控制

    • assignment operators(=,+=,=> ,…):賦值操作符(打勾,這些操作符號前後都會有空格, $arr = [])
    • logical operators(&& , ||):邏輯運算符(同上)
  • before left brace:左邊的括號(沒試出來試幹嘛的)

  • before keywords:關鍵字前面的(沒試出來試幹嘛的)

  • within:內部空格相關

    • brackets :括號內空格控制(好像隻影響數組內的括號空格,打勾數組[ ]內加空格,$t = $one[ 0 ];)
    • brackets around variable/expression:括號變量或表達式(數組內變量/表達式前後加空格)
    • grouping parentheses:分組括號(小括號內加空格,declare( strict_types = 1 ) )
    • function declaration parentheses:函數聲明括號( function foo( $x, $z ) )
    • function call parentheses:函數調用括號
  • in ternary operator:三元操作符

    • before ‘?’:在?前加空格
    • after ‘?’:在?後加空格
  • other 其他

    • before comma:逗號前加空格
    • after comma:逗號後加空格
    • before ‘for’ semicolon:for方法中;的前面空格
    • after ‘for’ semicolon:for方法中;的後面加空格
    • after type cast:在類型定義後面(強制類型轉換後面,$j = (int) $z)
    • before colon in return type:在定義方法返回類型冒號前加空格(在: Foo前面加,function bar() : Foo)
    • after colon in return type:在定義方法返回類型冒號後加空格(function bar(): Foo)
    • before unary Not (!):在取反符號前加空格
    • after unary Not (!):在取反符號後加空格

    wrapping and braces:換行和括號

    • keep when reformatting:在重新格式化的時候保持不變
      • line breaks:換行符(比如你在哪進行了換行,在自動格式化的時候不會修改這個換行)
      • comment at first column:第一欄註釋(勾上註釋不會被格式化對其)
      • control statement in one line:控制語句會被集中到同一行( if (true) $x = 10;)
      • simple methods in one line :簡單函數會被集中到同一行( function foo() { return 0; } )
    • braces placement:括號位置
      • in namespace:namespace的花括號位置,next line:單獨一行 ;end of line :關鍵字同一行末尾(其實就是namespace這個花括號的位置控制)
      • in class declaration:類的花括號位置
      • in function declaration:方法的花括號位置
      • in closure declaration:在關閉聲明(不知道是哪個)
      • other:其他的花括號控制(比如do{},foreach(){}的這些方法)
    • extends/implements list :繼承和實現列表換行操作( abstract class Foo extends
      FooBaseClass implements Bar1,
      Bar2,
      Bar3)
      • align when multiline:多行是否對齊
      • extends/implements keyword : extends/implements 關鍵字知否換行
    • function declaration parameters :函數聲明的參數
      • align when multiline:多行是否對齊
      • new line after ’ ( ’ : 函數 ’ ( ’ 後面的參數新起一行
      • place ‘)’ on new line:函數 ‘)’ 是否新起一行
      • keep ‘)’ and ‘{’ on one line:把 ‘)’ 和 ‘{’ 集合到一行
    • function/constructor call arguments:方法/構建方法調用
      • align when multiline:多行是否對齊
      • place‘()’ for constructor: (不知道)
    • chained method calls:鏈接調用(這個:$foo->one(“a”, “b”))
    • ‘if()’ statement:‘if()’ 相關的控制
    • for()/foreach() statement:for()/foreach() 相關的控制
    • binary expressions:二進制表達式
    • assignment statement: 賦值語句控制
    • array initializer:數組定義
      • place ‘)’on new line:把數組的’ ] ’ 放到新一行
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章