1.2.821. No Parenthesis For Language Construct

Some PHP language constructs, such are include, require, include_once, require_once, print, echo don’t need parenthesis. They accept parenthesis, but it is may lead to strange situations.

It it better to avoid using parenthesis with echo, print, return, throw, yield, yield from, include, require, include_once, require_once.

<?php

// This is an attempt to load 'foo.inc', or kill the script
include('foo.inc') or die();
// in fact, this is read by PHP as : include 1
// include  'foo.inc' or die();

?>

See also ON PHP LANGUAGE CONSTRUCTS AND PARENTHESES and include.

1.2.821.1. Suggestions

  • Remove parenthesis

1.2.821.2. Specs

Short name

Structures/NoParenthesisForLanguageConstruct

Rulesets

All, Analyze, CE, CI-checks, Changed Behavior, Suggestions

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

parenthesis, language-construct, return, include

ClearPHP

no-parenthesis-for-language-construct

Examples

Phpdocumentor, phpMyAdmin

Available in

Entreprise Edition, Community Edition, Exakat Cloud