-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDisallowAlternativeSyntaxStandard.xml
More file actions
47 lines (47 loc) · 1.21 KB
/
DisallowAlternativeSyntaxStandard.xml
File metadata and controls
47 lines (47 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Disallow Alternative Control Structure Syntax">
<standard>
<![CDATA[
Alternative control structure syntax (endif, endforeach, endfor, endwhile, endswitch)
is not allowed. Use curly braces for all control structures.
]]>
</standard>
<code_comparison>
<code title="Valid: Using curly braces for foreach">
<![CDATA[
foreach ( $items as $item ) {
echo $item;
}
]]>
</code>
<code title="Invalid: Using alternative syntax for foreach">
<![CDATA[
foreach ( $items as $item ) :
echo $item;
endforeach;
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Using curly braces for if/else">
<![CDATA[
if ( $condition ) {
echo 'yes';
} else {
echo 'no';
}
]]>
</code>
<code title="Invalid: Using alternative syntax for if/else">
<![CDATA[
if ( $condition ) :
echo 'yes';
else :
echo 'no';
endif;
]]>
</code>
</code_comparison>
</documentation>