PHPCompatibility / PHPModernizer

External PHPCS standard with auto-fixers to modernize legacy codebases
GNU Lesser General Public License v3.0
10 stars 0 forks source link

New sniff: change casts to (unset) #8

Open jrfnl opened 6 years ago

jrfnl commented 6 years ago
Sniff basics -
Fixable for PHP: All
Sniff type: Modernize
Fixer type: Risky

Short description

PHP 5.0 introduced an (unset) type cast for feature completeness. This type cast has been deprecated as of PHP 7.2 and is slated to be removed in PHP 8.0.

Related PHPCompatibility sniff(s):

PHP manual references:

Example code:

Detect the following code pattern(s):

$a = (unset) $b;
$b = (unset) $b;

And fix these to:

$a = null;
unset( $b );

Notes for implementation of the sniff: