                                                    # the start of the line
			(
			    (
			        .*\*/                                                                     # with an end block comment somewhere on the line
			    |   \s* (<\?(php)?\s+)?                                                       # OR a PHP open tag
			    )?                                                                            # the above is optional
			    \s* [}\])]                                                                    # optionally followed by whitespace, followed by a closing: curly brace, square bracket or paren
			|                                                                                 # OR
			    \s* (<\?(php)?\s+)?                                                           # an optional PHP open tag
			    (else(\s*if)?\b.*:\s*($|//|/\*|\?>)|(end(if|for(each)?|switch|while))\b)             # followed by an keyword that ends a control flow block
			)
		]]></string>

		<key>increaseIndentPattern</key>
		<string><![CDATA[(?x)
			# define subexpressions
			(?<string>"(?:[^"]++|\\.)*+"|'(?:[^']++|\\.)*+'){0}
			(?<block_comment>/\*(?:[^*]++|\*(?!/))*+\*/){0}
			(?<not_paren>(?:\g<string>++|\g<block_comment>++|[^()'"/]++|/(?!\*))*+){0}
			(?<balanced_paren>
			    \(                         # an open paren
			    \g<not_paren>              # followed by anything that's not a paren
			    \g<balanced_paren>*+       # followed by any number of nested parens
			    \g<not_paren>              # followed by anything that's not a paren
			    \)                         # a closing paren
			){0}
			# begin rule
			^.*              # anything on the line followed by:
			(
			    \{[^}"']*    # an open curly brace not followed by a closing brace or string punctuation
			|   \[[^]"']*    # an open square bracket not followed by a closing square bracket or string punctuation
			|   \([^)"']*    # an open bracket not followed by a closing bracket or string punctuation
			)$
			| # OR
			^\s* (<\?(php)?\s+)?                                                                # the beginning of the line followed by any amount of whitespace and an optional PHP open tag
			(   (?:
			        (?:else)?if\s*\g<balanced_paren>|else                                       # PHP "if" related statements
			    )\s*:(?!.*\bendif\b)                                                            # followed by a colon, not followed by an "endif" anywhere on the line
			    |
			    (?<php_control_word>foreach|for|switch|while)\s*\g<balanced_paren>              # PHP control keywords, followed by balanced parens
			    \s*:(?!.*\bend\k<php_control_word>\b)                                           # followed by a colon, and where the control structures don't end themselves on the same line
			)
		]]></string>

		<key>indentNextLinePattern</key>
		<string><![CDATA[^(?!.*(#|//|\*/|<\?))(?!.*[};:]\s*(//|/\*.*\*/\s*$)).*[^\s;:{}]\s*$|<\?php.+?\b(if|else(?:if)?|for(?:each)?|while)\b.*:(?!.*end\1)]]></string>

		<key>bracketIndentNextLinePattern</key>
		<string>(?x)
		^ \s* \b(if|while|else|elseif|foreach)\b [^;]* $
		| ^ \s* \b(for)\b .* [^;]\s*$
		</string>
	</dict>
</dict>
</plist>
PK