Skip to content

New sniff: change casts to (unset) #8

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions