1.2.116. Cast Unset Usage

Usage of the (unset) cast operator was removed. The operator was deprecated since PHP 7.2.0.

<?php

$a = 1;
(unset) $a;

// functioncall is OK
unset($a);

?>

See also Unset casting.

1.2.116.1. Suggestions

  • Replace (unset) with a call to unset().

  • Remove the unset call altogether.

  • Set the value to NULL.

1.2.116.2. Specs

Short name

Php/CastUnsetUsage

Rulesets

All, CE, CompatibilityPHP80

Exakat since

2.1.8

PHP Version

With PHP 8.0 and older

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

cast, unset

Available in

Entreprise Edition, Community Edition, Exakat Cloud