Open jrfnl opened 6 years ago
PHP 5.3 introduced the magic constant __DIR__ which is equivalent to dirname( __FILE__ ) and more efficient to use - function call vs native PHP (magic) constant -.
__DIR__
dirname( __FILE__ )
NewKeywords
5.3.0 | Added DIR and NAMESPACE constants This is equivalent to dirname(FILE).
5.3.0 | Added DIR and NAMESPACE constants
This is equivalent to dirname(FILE).
http://php.net/manual/en/language.constants.predefined.php
Detect the following code pattern(s):
dirname( __FILE__ );
And fix these to:
$dir = defined('__DIR__') ? __DIR__ : dirname(__FILE__);
dir_constant
Short description
PHP 5.3 introduced the magic constant
__DIR__
which is equivalent todirname( __FILE__ )
and more efficient to use - function call vs native PHP (magic) constant -.Related PHPCompatibility sniff(s):
NewKeywords
PHP manual references:
http://php.net/manual/en/language.constants.predefined.php
Example code:
Detect the following code pattern(s):
And fix these to:
Notes for implementation of the sniff:
Prior art:
dir_constant