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: remove new by reference #10

Open jrfnl opened 6 years ago

jrfnl commented 6 years ago
Sniff basics -
Fixable for PHP: 5.0+
Sniff type: Modernize
Fixer type: Safe

Short description

Assigning the return value of new by reference is a PHP4-style practice and is not needed in PHP 5 were objects are always passed by reference.

Related PHPCompatibility sniff(s):

PHP manual references:

Example code:

Detect the following code pattern(s):

$o = &new C;

And fix these to:

$o = new C;