Fork me on GitHub
a Sensio Labs Product

Remote Void (v2.18.1) edition

Rule no_alternative_syntax

Replace control structure alternative syntax to use braces.

Examples

Example #1

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

Example #2

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

Example #3

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

Example #4

--- Original
+++ New
@@ -1,2 +1,2 @@
 <?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.

The logo is © 2010-2014 Sensio Labs