Fork me on GitHub
a Sensio Labs Product

7th Gear (v3.59.3) edition

Rule no_alternative_syntax

Replace control structure alternative syntax to use braces.



Whether to also fix code with inline HTML.

Allowed types: bool

Default value: true


Example #1

Default configuration.

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

Example #2

With configuration: ['fix_non_monolithic_code' => true].

--- Original
+++ New
-<?php if ($condition): ?>
+<?php if ($condition) { ?>
 Lorem ipsum.
-<?php endif; ?>
+<?php } ?>

Rule sets

The rule is part of the following rule sets:


The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.