<?xml version="1.0" encoding="UTF-8"?>
<itemizer language-context="php">
	<!-- <?php ... ?>, <?= ?> -->
	<!-- FIXME: figure out a better icon, and axe "processing-instruction" (it's a hack to get the XML-style tag image) -->
    <item name="php.sourcecode.processing-instruction">
		<start-zone>embedded.language-root.php > source.start:capture(name)</start-zone>
		<end-zone>embedded.language-root.php > source.end</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- class MyClass extends SomeClass { ... } -->
	<item name="php.class">
		<class>ESCodeClassItem</class>
		<start-zones>class.definition:has-child(name:capture(name)) + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- class MyClass extends SomeClass /* some comment */ { ... } -->
	<item name="php.class">
		<class>ESCodeClassItem</class>
		<start-zones>class.definition:has-child(name:capture(name)) + comment + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- function myFunction (...) { ... } -->
	<item name="php.function">
		<start-zones>function.definition:has-child(name:capture(name)) + brace.round.open ~ brace.round.close + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- function myFunction (...) /*some comment*/ { ... } -->
	<item name="php.function.commented">
		<start-zones>function.definition:has-child(name:capture(name)) + brace.round.open ~ brace.round.close + comment + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- switch ( ... ) { ... } -->
	<item name="php.block.control.switch">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-switch:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- switch ( ... ) /* comment */ { ... } -->
	<item name="php.block.control.switch">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-switch:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + comment + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- case 'stuff': ... -->
	<item name="php.block.control.case">
		<class>ESJSChunkBlockItem</class>
		<start-zone>x-item-start.x-case:capture(name)</start-zone>
		<end-zone>keyword.control.x-break + punctuation</end-zone>
		<end-before-zone>brace.curly.close, x-item-start.x-case, keyword.control.x-endswitch</end-before-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- if (...) { ... } -->
	<item name="php.block.control">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- if (...) /* comment */ { ... } -->
	<item name="php.block.control">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + comment + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- else { ... } -->
	<item name="php.block.control.generic">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control:capture(name) + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- else /* comment */ { ... } -->
	<item name="php.block.control.generic">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control:capture(name) + comment + brace.curly.open</start-zones>
		<end-zone>brace.curly.close</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- do { ... } while(...) -->
	<item name="php.block.control.do-while">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-do:capture(name) + brace.curly.open</start-zones>
		<end-zone>brace.curly.close + keyword.control.x-while + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters)</end-zone>
	</item>
	<!-- do /* comment */ { ... } while(...) -->
	<item name="php.block.control.do-while">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-do:capture(name) + comment + brace.curly.open</start-zones>
		<end-zone>brace.curly.close + keyword.control.x-while + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters)</end-zone>
	</item>
	
	<!-- This captures single-line statements to prevent them from triggering an alternate syntax zone (for instance, if a ternary conditional statement immediately follows a single-line statement) -->
	<!-- FIXME: this is pretty brittle (tends to fail if there's a function call within the parameters, although this is mitigated by detected function calls without parameters of their own) -->
	<item name="php.block.control.singleton">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control:capture(name) + brace.round.open:capture(open-parameters) ~ *:not(typecast, function + brace.round.open) + brace.round.close:capture(close-parameters) + :not(brace.curly.open, x-item-block, brace.close, operator, punctuation.x-colon, punctuation.x-comma, punctuation.x-semicolon, punctuation.x-arrow, keyword.control.x-as, x-ternary)</start-zones>
		<end-zone>punctuation.x-semicolon</end-zone>
	</item>
	<!-- Single-line else statements -->
	<item name="php.block.control.singleton.else">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-else:capture(name) + :not(brace.curly.open, comment, x-item-block)</start-zones>
		<end-zone>punctuation.x-semicolon</end-zone>
	</item>
	
	<!-- if ( ... ) : ... endif; -->
	<item name="php.block.control.alternative.if">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-if:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + punctuation.x-colon</start-zones>
		<end-zone>keyword.control.alternate-end.x-endif + punctuation.x-semicolon</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- for ( ... ) : ... endfor; -->
	<item name="php.block.control.alternative.for">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-for:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + punctuation.x-colon</start-zones>
		<end-zone>keyword.control.alternate-end.x-endfor + punctuation.x-semicolon</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- foreach ( ... ) : ... endforeach; -->
	<item name="php.block.control.alternative.foreach">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-foreach:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + punctuation.x-colon</start-zones>
		<end-zone>keyword.control.alternate-end.x-endforeach + punctuation.x-semicolon</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- switch ( ... ) : ... endswitch; -->
	<item name="php.block.control.alternative.switch">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-switch:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + punctuation.x-colon</start-zones>
		<end-zone>keyword.control.alternate-end.x-endswitch + punctuation.x-semicolon</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	<!-- while ( ... ) : ... endwhile; -->
	<item name="php.block.control.alternative.while">
		<class>ESJSControlBlockItem</class>
		<start-zones>keyword.control.x-while:capture(name) + brace.round.open:capture(open-parameters) ~ brace.round.close:capture(close-parameters) + punctuation.x-colon</start-zones>
		<end-zone>keyword.control.alternate-end.x-endwhile + punctuation.x-semicolon</end-zone>
		<subitems>
			<include-root-itemizers/>
		</subitems>
	</item>
	
	<!-- //! My Documentation Comment -->
	<item name="php.comment">
	    <class>ESCommentItem</class>
	    <zone>comment.documentation</zone>
	    <subitems>
	    	<item name="php.comment.link">
	    		<class>ESJSMarkupLink</class>
	    		<zone>comment markup.link</zone>
	    	</item>
	    </subitems>
	</item>
	
</itemizer>