1.2.64. Avoid Parenthesis With Language Construct

Avoid Parenthesis for language construct. Languages constructs are a few PHP native elements, that looks like functions but are not.

Among other distinction, those elements cannot be directly used as variable function call, and they may be used with or without parenthesis. The usage of parenthesis actually give some feeling of comfort, it won’t prevent PHP from combining those argument with any later operators, leading to unexpected results.

Even if most of the time, usage of parenthesis is legit, it is recommended to avoid them.

<?php

// normal usage of include
include 'file.php';

// This looks like a function and is not
include('file2.php');

?>

1.2.64.1. Suggestions

  • Remove the parenthesis

1.2.64.2. Specs

Short name

Structures/PrintWithoutParenthesis

Rulesets

All, Analyze, CE, CI-checks

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

language-construct

Available in

Entreprise Edition, Community Edition, Exakat Cloud