[wp-trac] [WordPress Trac] #48082: Replace `dirname(__FILE__)` with `__DIR__` (Performance improvement, massive patch)
WordPress Trac
noreply at wordpress.org
Fri Sep 20 00:55:16 UTC 2019
#48082: Replace `dirname(__FILE__)` with `__DIR__` (Performance improvement,
massive patch)
-------------------------+--------------------------------------------
Reporter: ayeshrajans | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version:
Severity: minor | Resolution:
Keywords: has-patch | Focuses: performance, coding-standards
-------------------------+--------------------------------------------
Comment (by netweb):
Replying to [comment:1 jrf]:
> 2. As nearly all of these touch `include/require` statements, may this
be a good time to remove the unnecessary parentheses which are often used
with them ?
> `include`/`require` are language constructs, not function calls and not
using the parentheses has an - albeit marginal - performance benefit.
>
> {{{#!php
> <?php
> // Bad:
> require_once( dirname( __FILE__ ) . '/admin.php' );
>
> // Good:
> require_once dirname( __FILE__ ) . '/admin.php';
> }}}
>
> The `WordPress-Extra` PHPCS ruleset actually contains a sniff which
already checks for this. If the unneeded parentheses would be removed, the
sniff could move from the `Extra` ruleset to the `Core` ruleset. /cc
@pento
I think this is a great idea, two birds with one stone and all that, or in
other words, it would make SVN/Git blame a little nicer doing this at the
same time.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48082#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list