.. _classes-uselesstypehint: .. _useless-typehint: Useless Typehint ++++++++++++++++ `__get() `_ and `__set() `_ magic methods won't enforce any typehint. The name of the magic property is always cast to string. `__call() `_ .. code-block:: php $name = $value; } // typehint is set and ignored function __get(integer $name) { $this->$name = $value; } // typehint is checked by PHP 8.0 linting // typehint is enforced by PHP 7.x function __call(integer $name) { $this->$name = $value; } } $o = new x; $b = array(); // Property will be called 'Array' $o->{$b} = 2; // type of $m is check at calling time. It must be string. $o->{$m}(); ?> See also `__set `_. Related PHP errors ------------------- + `0 `_ Connex PHP features ------------------- + `magic-method `_ Suggestions ___________ * Use `string` for the `$name` parameter * Use no typehint for the `$name` parameter Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Classes/UselessTypehint | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior `, :ref:`Class Review `, :ref:`Suggestions ` | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 2.1.9 | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+