1.2.1026. Redeclared Static Variable

Static variables shall be declared only once. It is forbidden in PHP 8.3 and later. It was silently allowed in PHP 8.2 and older.

<?php

function foo() {
     static $a;
     static $a;
}

?>

1.2.1026.1. Connex PHP features

1.2.1026.1.1. Suggestions

  • Keep the last static call

  • Keep the first static call

1.2.1026.1.2. Specs

Short name

Variables/RedeclaredStaticVariable

Rulesets

All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72, CompatibilityPHP73, CompatibilityPHP74, CompatibilityPHP80, CompatibilityPHP81, CompatibilityPHP82

Exakat since

2.5.3

PHP Version

With PHP 8.3 and older

Severity

Major

Time To Fix

Instant (5 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud