Skip to content

Check for parentheses around require(_once)/include_(once) #1007

@GaryJones

Description

@GaryJones
Member

There doesn't appear to be any checks if files are included as:

include '/path/to/file.php';

or

include ( '/path/to/file.php' );

(Repeat for include_once, require, require_once.)

WordPress Core apparently does a mixture of both.

Generally, there is no different between them, except when a comparison is done against it - see Example 4 on http://us1.php.net/manual/en/function.include.php. Otherwise, the ( ) are redundant and can be safely removed.

There is a PEAR sniff that could be used / adapted from.

This was mentioned in the #core-coding-standards channel, so while any addition would go into WordPress-Extras right now, it may be that the Handbook has been updated, so this could go into WordPress-Core standard instead.

Activity

johnbillion

johnbillion commented on Jun 30, 2017

@johnbillion
Member

Not including parentheses is actually faster because PHP treats it as the language construct instead of a function. Definitely falls under micro-optimisation though.

added this to the 0.14.0 milestone on Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @GaryJones@johnbillion@jrfnl

        Issue actions

          Check for parentheses around require(_once)/include_(once) · Issue #1007 · WordPress/WordPress-Coding-Standards