Skip to content

New sniff: change casts to (unset) #8

@jrfnl

Description

@jrfnl
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):

  • NewTypeCasts
  • DeprecatedTypeCasts

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:

  • Type casts only have effect when the result is assigned to something. Type casts are not done by reference!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions