.. _structures-addzero: .. _adding-zero: Adding Zero +++++++++++ Adding 0 is useless, as 0 is the neutral element for addition. Besides, when one of the operands is an integer, PHP silently triggers a cast to integer for the other operand. This rule also report using ``+`` with variables, proeprties, etc. which triggers an automated conversion to integer. It is recommended to make the cast explicit with ``(int)``. .. code-block:: php Connex PHP features ------------------- + `addition `_ + `short-assignation `_ Suggestions ___________ * Remove the +/- 0, may be the whole assignation * Use an explicit type casting operator (int) Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/AddZero | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Rector ` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Instant (5 mins) | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | High | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ClearPHP | `no-useless-math `__ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-thelia-structures-addzero`, :ref:`case-openemr-structures-addzero` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+