Skip to content

ShortOpenTagUsage ​

info on by default quick-fix

Group: Code style · PhpStorm name: ShortOpenTagUsageInspection

The short open tag <? depends on the short_open_tag ini setting; code using it breaks (prints source code) where that setting is off. Use <?php.

Example ​

php
<? $greeting = 'hi'; ?>
<p>
<? foreach ($users as $u) : ?>
  <b><?= $u ?></b>
<? endforeach ?>
<?
  while (next_row()) { ?><i>row</i><?php } ?>
</p>
<?php $done = true; ?>
php
<?php $greeting = 'hi'; ?>
<p>
<?php foreach ($users as $u) : ?>
  <b><?= $u ?></b>
<?php endforeach ?>
<?php
  while (next_row()) { ?><i>row</i><?php } ?>
</p>
<?php $done = true; ?>

Reported:

  • line 1: Replace the short open tag '<?' with '<?php'.
  • line 3: Replace the short open tag '<?' with '<?php'.
  • line 5: Replace the short open tag '<?' with '<?php'.
  • line 6: Replace the short open tag '<?' with '<?php'.

Configure ​

In custos.json:

json
{
  "rules": {
    "ShortOpenTagUsage": {
      "enabled": false
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file), either of:

php
// @custos-ignore ShortOpenTagUsage

/**
 * @noinspection ShortOpenTagUsageInspection
 */

Released under the MIT License. Rule catalogue modelled on Php Inspections (EA Extended); independent clean-room implementation.