Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.11 KB

no_alternative_syntax.rst

File metadata and controls

63 lines (45 loc) · 1.11 KB

Rule no_alternative_syntax

Replace control structure alternative syntax to use braces.

Examples

Example #1

--- Original
+++ New
 <?php
-if(true):echo 't';else:echo 'f';endif;
+if(true) { echo 't';} else { echo 'f';}

Example #2

--- Original
+++ New
 <?php
-while(true):echo 'red';endwhile;
+while(true) { echo 'red';}

Example #3

--- Original
+++ New
 <?php
-for(;;):echo 'xc';endfor;
+for(;;) { echo 'xc';}

Example #4

--- Original
+++ New
 <?php
-foreach(array('a') as $item):echo 'xc';endforeach;
+foreach(array('a') as $item) { echo 'xc';}

Rule sets

The rule is part of the following rule sets:

@PhpCsFixer
Using the @PhpCsFixer rule set will enable the no_alternative_syntax rule.
@Symfony
Using the @Symfony rule set will enable the no_alternative_syntax rule.