1- ---
2- BasedOnStyle : WebKit
3- SortIncludes : ' false'
4- ColumnLimit : 100
5- IndentWidth : 4
6- TabWidth : 4
7- ContinuationIndentWidth : 8
8- UseTab : ForContinuationAndIndentation
9- PointerAlignment : Right
10- IndentCaseLabels : true
11- AlignConsecutiveAssignments : false
12- AlignEscapedNewlines : DontAlign
13- AllowShortFunctionsOnASingleLine : false
14- SpaceAfterCStyleCast : true
15- AlignOperands : false
16- ...
1+ # PHP Clang-Format Configuration
2+ # Based on WebKit style with PHP coding standards compliance
3+ # References: PHP CODING_STANDARDS.md, K&R style, Linux Kernel standards
4+
5+ # Core formatting foundation
6+ BasedOnStyle : WebKit # K&R style foundation (PHP standard requirement)
7+ SortIncludes : ' false' # Preserve PHP include organization structure
8+ ColumnLimit : 120 # Reasonable line length for readability
9+ IndentWidth : 4 # PHP standard: 4-space indentation
10+ TabWidth : 4 # PHP standard: tabs represent 4 spaces
11+ ContinuationIndentWidth : 8 # Double indentation for line continuations
12+ UseTab : ForContinuationAndIndentation # PHP standard: use tabs for indentation
13+
14+ # Pointer and alignment settings
15+ PointerAlignment : Right # Common C convention: int *ptr (not int* ptr)
16+ IndentCaseLabels : true # Standard practice for switch statements
17+ AlignConsecutiveAssignments : false # Avoid artificial alignment per PHP standards
18+ AlignEscapedNewlines : DontAlign # Natural positioning of escaped newlines
19+ AllowShortFunctionsOnASingleLine : false # PHP standard: always use braces and proper formatting
20+ SpaceAfterCStyleCast : true # Standard C practice: (int) value
21+ AlignOperands : false # Natural operator positioning
22+
23+ # Brace placement - K&R style compliance (PHP CODING_STANDARDS.md)
24+ BraceWrapping :
25+ AfterFunction : true # K&R: function braces on new line
26+ AfterClass : true # Consistent with function style
27+ AfterStruct : true # C standard practice
28+ AfterUnion : true # C standard practice
29+ AfterEnum : true # C standard practice
30+ AfterControlStatement : Never # K&R: if/for/while braces on same line
31+ BeforeElse : false # K&R: } else { pattern
32+ IndentBraces : false # Braces at same level as statement
33+ BreakBeforeBraces : Custom # Enable custom brace wrapping
34+
35+ # Spacing and whitespace (PHP standards compliance)
36+ SpaceBeforeParens : ControlStatements # Space before if/for/while parentheses
37+ InsertTrailingCommas : None # Clean, minimal comma usage
38+ MaxEmptyLinesToKeep : 2 # PHP standard: generous whitespace between functions
39+ KeepEmptyLinesAtTheStartOfBlocks : true # PHP standard: empty line after variable declarations
40+
41+ # Short statement prevention (PHP standard: "always use braces")
42+ AllowShortIfStatementsOnASingleLine : Never # PHP requirement: always use braces
43+ AllowShortLoopsOnASingleLine : false # PHP requirement: always use braces
44+ AllowShortBlocksOnASingleLine : Never # PHP requirement: always use braces
45+
46+ # Basic spacing rules
47+ SpaceInEmptyParentheses : false # Clean: func() not func( )
48+ SpaceBeforeAssignmentOperators : true # Standard: a = b not a=b
49+ SpaceBeforeSquareBrackets : false # Clean: array[0] not array [0]
50+
51+ # Preprocessor handling (PHP standard compliance)
52+ IndentPPDirectives : None # Keep #include at column 1, manual indentation for conditionals only
53+
54+ # Advanced formatting for code quality (based on Linux Kernel and GNU standards)
55+ AlignAfterOpenBracket : Align # GNU standard: align function arguments nicely
56+ AlignConsecutiveDeclarations : false # Avoid artificial alignment (PHP philosophy)
57+ AlignConsecutiveMacros : false # Natural macro positioning
58+ AlignTrailingComments : true # Linux Kernel practice: align end-of-line comments
59+ BinPackArguments : false # Google/GNU standard: one argument per line for clarity
60+ BinPackParameters : false # Google/GNU standard: one parameter per line for clarity
61+
62+ # Line breaking preferences
63+ BreakBeforeBinaryOperators : None # Standard practice: operators at end of line
64+ BreakBeforeTernaryOperators : true # Better readability for ternary expressions
65+ BreakStringLiterals : true # MISRA-C compliance: break long string literals
66+ CompactNamespaces : false # Not applicable to C, but consistent spacing
67+ FixNamespaceComments : false # Not applicable to C
68+ IncludeBlocks : Preserve # Maintain PHP's careful include organization
69+
70+ # Line breaking penalties (optimization for readability)
71+ PenaltyBreakAssignment : 2 # Slight penalty for breaking assignments
72+ PenaltyBreakBeforeFirstCallParameter : 19 # Prefer keeping first parameter on same line
73+ PenaltyBreakComment : 300 # High penalty for breaking comments
74+ PenaltyBreakFirstLessLess : 120 # Stream operator handling
75+ PenaltyBreakString : 1000 # High penalty for string breaks
76+ PenaltyExcessCharacter : 1000000 # Very high penalty for exceeding column limit
77+ PenaltyReturnTypeOnItsOwnLine : 60 # Moderate penalty for return type breaks
78+
79+ # Comment and documentation handling
80+ ReflowComments : true # GNU standard: reformat comments for consistency
81+ SeparateDefinitionBlocks : Always # PHP standard: empty lines between functions
82+ SortUsingDeclarations : false # Preserve manual include ordering
83+
84+ # Detailed spacing control (MISRA-C and industry best practices)
85+ SpaceAfterLogicalNot : false # Standard: !condition not ! condition
86+ SpaceAroundPointerQualifiers : Default # Standard C pointer qualifier spacing
87+ SpaceBeforeCpp11BracedList : false # Clean braced list formatting
88+ SpaceBeforeRangeBasedForLoopColon : true # Readability in range-based loops
89+ SpaceInEmptyBlock : false # Clean empty blocks: {} not { }
90+ SpacesBeforeTrailingComments : 1 # Standard: single space before comment
91+ SpacesInAngles : false # Clean template/generic syntax
92+ SpacesInConditionalStatement : false # Clean: if (condition) not if ( condition )
93+ SpacesInContainerLiterals : false # Clean array/container literals
94+ SpacesInCStyleCastParentheses : false # Clean: (int)value not ( int )value
95+ SpacesInParentheses : false # Clean: func(arg) not func( arg )
96+ SpacesInSquareBrackets : false # Clean: array[0] not array[ 0 ]
0 commit comments