Open jrfnl opened 6 years ago
PHP 7 introduced a $levels parameter for the dirname() function. Using this parameter is more efficient than having several nested calls to the dirname() function.
$levels
dirname()
NewFunctionParameters
7.0.0 | Added the optional levels parameter.
http://php.net/manual/en/function.dirname.php
Detect the following code pattern(s):
dirname( dirname( $file ) ); dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); dirname(dirname(dirname(__DIR__))); dirname( dirname( dirname( dirname( __DIR__, 2 ) ) ) );
And fix these to:
dirname( $file, 2 ); dirname( __FILE__, 4 ); dirname(__DIR__, 3); dirname( __DIR__, 5 );
Loosely related to issue #2
Short description
PHP 7 introduced a
$levels
parameter for thedirname()
function. Using this parameter is more efficient than having several nested calls to thedirname()
function.Related PHPCompatibility sniff(s):
NewFunctionParameters
PHP manual references:
http://php.net/manual/en/function.dirname.php
Example code:
Detect the following code pattern(s):
And fix these to:
Notes for implementation of the sniff:
Loosely related to issue #2