.. _structures-couldusedir: .. _could-use-\_\_dir\_\_: Could Use __DIR__ +++++++++++++++++ Use `__DIR__ `_ constant to access the current file's `parent `_ `directory `_>`_. Avoid using `dirname() `_ on `__FILE__ `_. `__DIR__ `_ has been introduced in PHP 5.3.0. .. code-block:: php See also `Magic Constants `_. Connex PHP features ------------------- + `magic-constant `_ Suggestions ___________ * Use __DIR__ instead of ``dirname(__FILE__);`` Specs _____ +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/CouldUseDir | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Changed Behavior `, :ref:`Suggestions `, :ref:`php-cs-fixable ` | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Major | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-woocommerce-structures-couldusedir`, :ref:`case-piwigo-structures-couldusedir` | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+