Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-7099

PHP include/require do not require parenthesis

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 3.2.5, 3.3
    • Local: Code checker
    • None

      The codechecker plugin contains a sniff (IncludingFileSniff.php) that enforces the inclusion of redundant parenthesis around the path to be included.
      e.g. "require_once" must be immediately followed by an open parenthesis

      There is a common misconception about the nature of include, require, include_once, and require_once.
      None of these language constructs require parenthesis, and it can be argued that enforcing this behaviour as a matter of course is bad practice.

      _PHP manual - see examples #4 and #5 http://php.net/manual/en/function.include.php_
      "Because include is a special language construct, parentheses are not needed around its argument. Take care when comparing return value."

      _Pear coding standards - http://pear.php.net/manual/en/standards.including.php_
      "include_once and require_once are statements, not functions. Parentheses should not surround the subject filename."

      It is for a similar reason echo and print do not require the use of parenthesis (and their use can potentially break normal use of echo).

      Note: List of PHP keywords http://php.net/manual/en/reserved.keywords.php

            davidaylmer David Aylmer
            davidaylmer David Aylmer
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.