Will PHP type hinting decrease or increase the number of CPU instructions generated?
| From: | contact at antonphp dot com | Date: | Mon, 18 Nov 2024 13:22:56 +0000 |
| Subject: | Will PHP type hinting decrease or increase the number of CPU instructions generated? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-328575@lists.php.net to get a copy of this message | ||
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