Fork me on GitHub
a Sensio Labs Product

Remote Void (v2.18.5) edition

Rule echo_tag_syntax

Replaces short-echo <?= with long format <?php echo/<?php print syntax, or vice-versa.

Configuration

format

The desired language construct.

Allowed values: 'long', 'short'

Default value: 'long'

long_function

The function to be used to expand the short echo tags

Allowed values: 'echo', 'print'

Default value: 'echo'

shorten_simple_statements_only

Render short-echo tags only in case of simple code

Allowed types: bool

Default value: true

Examples

Example #1

Default configuration.

--- Original
+++ New
-<?=1?>
+<?php echo 1?>
 <?php print '2' . '3'; ?>
 <?php /* comment */ echo '2' . '3'; ?>
 <?php print '2' . '3'; someFunction(); ?>

Example #2

With configuration: ['format' => 'long'].

--- Original
+++ New
-<?=1?>
+<?php echo 1?>
 <?php print '2' . '3'; ?>
 <?php /* comment */ echo '2' . '3'; ?>
 <?php print '2' . '3'; someFunction(); ?>

Example #3

With configuration: ['format' => 'long', 'long_function' => 'print'].

--- Original
+++ New
-<?=1?>
+<?php print 1?>
 <?php print '2' . '3'; ?>
 <?php /* comment */ echo '2' . '3'; ?>
 <?php print '2' . '3'; someFunction(); ?>

Example #4

With configuration: ['format' => 'short'].

--- Original
+++ New
 <?=1?>
-<?php print '2' . '3'; ?>
-<?php /* comment */ echo '2' . '3'; ?>
+<?= '2' . '3'; ?>
+<?=/* comment */ '2' . '3'; ?>
 <?php print '2' . '3'; someFunction(); ?>

Example #5

With configuration: ['format' => 'short', 'shorten_simple_statements_only' => false].

--- Original
+++ New
 <?=1?>
-<?php print '2' . '3'; ?>
-<?php /* comment */ echo '2' . '3'; ?>
-<?php print '2' . '3'; someFunction(); ?>
+<?= '2' . '3'; ?>
+<?=/* comment */ '2' . '3'; ?>
+<?= '2' . '3'; someFunction(); ?>

Rule sets

The rule is part of the following rule sets:

@PhpCsFixer

Using the @PhpCsFixer rule set will enable the echo_tag_syntax rule with the default config.

@Symfony

Using the @Symfony rule set will enable the echo_tag_syntax rule with the default config.

The logo is © 2010-2014 Sensio Labs