.. _classes-checkoncallusage: .. _check-on-\_\_call-usage: Check On __Call Usage +++++++++++++++++++++ When using the magic methods `__call() `_ and __staticcall(), make sure the method exists before calling it. If the method doesn't exists, then the same method will be called again, leading to the same failure. Finally, it will crash PHP. .. code-block:: php $name(...$args); } } } class unsafeCall { function __class($name, $args) { // unsafe call, no checks $this->$name(...$args); } } ?> See also `Method overloading `_ and `Magical PHP: __call `_. Connex PHP features ------------------- + `magic-method `_ Suggestions ___________ * Add a call to method_exists() before using any method name * Relay the call to another object that doesn't handle __call() or __callStatic() Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Classes/CheckOnCallUsage | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`CE `, :ref:`CI-checks `, :ref:`Changed Behavior ` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.7.2 | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+