Will PHP type hinting decrease or increase the number of CPU instructions generated?
[email protected] Mon, 18 Nov 2024 23:52:56 +1030
| Newsgroups | gmane.comp.php.general |
|---|---|
| Message-ID | <[email protected]> |
From one side, type hinting assures that some variables of a certain type, so type checks can be eliminated at run time. This should produce less CPU instructions. From the other side, type hinting will make PHP to make extra checks - i.e. that the values assigned are of the allowed type. This should produce more CPU instructions at runtime because PHP is not a statically typed and compiled language. So, what is true? Is type hinting increasing or decreasing the number of CPU instructions generated? Thanks, Anton