1.2.446. False To Array Conversion

The auto vivification of false is deprecated. This feature is the automagical conversion of a boolean into an array, if needed.

Until PHP 8.1, this was possible. This feature is deprecated in PHP 8.1, and will be removed in PHP 9.0.

<?php

$a = false;

//valid in PHP
$a[3] = 1;

?>

See also Autovivification from false.

1.2.446.1. Suggestions

  • Change the typehints from bool or false to array

  • Validate the type returned values of an functioncall before using it

1.2.446.2. Specs

Short name

Php/FalseToArray

Rulesets

All, Analyze, CompatibilityPHP81, CompatibilityPHP82, LintButWontExec

Exakat since

2.3.0

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

array

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud