annotate vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml@4c8ae668cc8c
children
rev   line source
Chris@0 1 <documentation title="Switch Declarations">
Chris@0 2 <standard>
Chris@0 3 <![CDATA[
Chris@0 4 Case statements should be indented 4 spaces from the switch keyword. It should also be followed by a space. Colons in switch declarations should not be preceded by whitespace. Break statements should be indented 4 more spaces from the case statement. There must be a comment when falling through from one case into the next.
Chris@0 5 ]]>
Chris@0 6 </standard>
Chris@0 7 <code_comparison>
Chris@0 8 <code title="Valid: Case statement indented correctly.">
Chris@0 9 <![CDATA[
Chris@0 10 switch ($foo) {
Chris@0 11 <em> </em>case 'bar':
Chris@0 12 break;
Chris@0 13 }
Chris@0 14 ]]>
Chris@0 15 </code>
Chris@0 16 <code title="Invalid: Case statement not indented 4 spaces.">
Chris@0 17 <![CDATA[
Chris@0 18 switch ($foo) {
Chris@0 19 <em></em>case 'bar':
Chris@0 20 break;
Chris@0 21 }
Chris@0 22 ]]>
Chris@0 23 </code>
Chris@0 24 </code_comparison>
Chris@0 25 <code_comparison>
Chris@0 26 <code title="Valid: Case statement followed by 1 space.">
Chris@0 27 <![CDATA[
Chris@0 28 switch ($foo) {
Chris@0 29 case<em> </em>'bar':
Chris@0 30 break;
Chris@0 31 }
Chris@0 32 ]]>
Chris@0 33 </code>
Chris@0 34 <code title="Invalid: Case statement not followed by 1 space.">
Chris@0 35 <![CDATA[
Chris@0 36 switch ($foo) {
Chris@0 37 case<em></em>'bar':
Chris@0 38 break;
Chris@0 39 }
Chris@0 40 ]]>
Chris@0 41 </code>
Chris@0 42 </code_comparison>
Chris@0 43 <code_comparison>
Chris@0 44 <code title="Valid: Colons not prefixed by whitespace.">
Chris@0 45 <![CDATA[
Chris@0 46 switch ($foo) {
Chris@0 47 case 'bar'<em></em>:
Chris@0 48 break;
Chris@0 49 default<em></em>:
Chris@0 50 break;
Chris@0 51 }
Chris@0 52 ]]>
Chris@0 53 </code>
Chris@0 54 <code title="Invalid: Colons prefixed by whitespace.">
Chris@0 55 <![CDATA[
Chris@0 56 switch ($foo) {
Chris@0 57 case 'bar'<em> </em>:
Chris@0 58 break;
Chris@0 59 default<em> </em>:
Chris@0 60 break;
Chris@0 61 }
Chris@0 62 ]]>
Chris@0 63 </code>
Chris@0 64 </code_comparison>
Chris@0 65 <code_comparison>
Chris@0 66 <code title="Valid: Break statement indented correctly.">
Chris@0 67 <![CDATA[
Chris@0 68 switch ($foo) {
Chris@0 69 case 'bar':
Chris@0 70 <em> </em>break;
Chris@0 71 }
Chris@0 72 ]]>
Chris@0 73 </code>
Chris@0 74 <code title="Invalid: Break statement not indented 4 spaces.">
Chris@0 75 <![CDATA[
Chris@0 76 switch ($foo) {
Chris@0 77 case 'bar':
Chris@0 78 <em> </em>break;
Chris@0 79 }
Chris@0 80 ]]>
Chris@0 81 </code>
Chris@0 82 </code_comparison>
Chris@0 83 <code_comparison>
Chris@0 84 <code title="Valid: Comment marking intentional fall-through.">
Chris@0 85 <![CDATA[
Chris@0 86 switch ($foo) {
Chris@0 87 case 'bar':
Chris@0 88 <em>// no break</em>
Chris@0 89 default<em></em>:
Chris@0 90 break;
Chris@0 91 }
Chris@0 92 ]]>
Chris@0 93 </code>
Chris@0 94 <code title="Invalid: No comment marking intentional fall-through.">
Chris@0 95 <![CDATA[
Chris@0 96 switch ($foo) {
Chris@0 97 case 'bar':
Chris@0 98 default<em></em>:
Chris@0 99 break;
Chris@0 100 }
Chris@0 101 ]]>
Chris@0 102 </code>
Chris@0 103 </code_comparison>
Chris@0 104 </documentation>