1.2.845. No String With Append

PHP 7, and more recent, doesn’t allow the usage of the append operator [] with strings. [] is an array-only operator.

This was possible in PHP 5, and it is forbidden since in PHP 7.

<?php

$string = 'abc';

// Not possible in PHP 7
$string[] = 'd';

?>

1.2.845.1. Connex PHP features

1.2.845.1.1. Suggestions

  • Use the concatenation operator . to append strings.

  • Use the concatenation short assignement .= to append strings.

1.2.845.1.2. Specs

Short name

Php/NoStringWithAppend

Rulesets

All, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56

Exakat since

0.8.4

PHP Version

With PHP 7.0 and more recent

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud