[wp-trac] [WordPress Trac] #48082: Replace `dirname(__FILE__)` with `__DIR__` (Performance improvement, massive patch)

WordPress Trac noreply at wordpress.org
Sat Sep 21 00:42:54 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 jrf):

 I very much support @joostdevalk's suggestion.

 While it may be a lot in one patch, it does make sense to me to make these
 changes all in one go as they all touch the same lines of code.

 The sniff I previously mentioned which is in the `WordPress-Extra` ruleset
 also checks for use of unconditional `include[_once]` use.

 To run it over WP Core while respecting the existing exclusions for the
 files coming from dependencies, follow the below steps:
 1. Add a new file to the root of your clone of WP Core (directory above
 `src`) called `phpcs.xml`.
 2. Add the following contents to that file:

 {{{
 <?xml version="1.0"?>
 <ruleset name="WP Core local">

         <rule ref="./phpcs.xml.dist"/>

         <rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
                 <type>warning</type>
         </rule>
         <rule ref="PEAR.Files.IncludingFile.UseRequire">
                 <type>warning</type>
         </rule>
         <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
                 <type>warning</type>
         </rule>
 </ruleset>
 }}}

 Note: the file should automatically be git-ignored/svn-ignored.

 3. Run PHPCS with the below command to just and only see the errors coming
 from this sniff:

 {{{
 vendor/bin/phpcs --sniffs=PEAR.Files.IncludingFile
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48082#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list