Lukas Kahwe Smith wrote:
Suddenly I need to ensure that all my variables have the proper types. So what will people do? They will start forcing type juggeling manually before they call the library in question. Since this is the glue code, its the kind of code you have to write day in day out. So maybe an "(int)" here or there is not so much more code to type, but you can already see that code you safe on one end, you have to start adding on the other, the one which you write more often. More importantly, in some cases simple type juggeling with "(int)" will not be sufficient, you might have to do some minor checks etc. In the past library authors did this as part of the code that the strict type hinting camp is now hoping to remove. So again more code in my glue code.

You're absolutely right about that glue code. However, I think this serves as a benefit for the developers using the library/framework/component/whatever. It reduces the chances of passing wrong types around, he's forced to grapple with the parameter in a proper way and would, ahead of executing code with possible wrong values, have a change to correct it.

Yes, the code can likely look like

$foo->bar( (int)$baz, (string)$sober, (bool)$result['column_checkbox'] );

but this means he is really forced to think what he is really passing. It will not raise the overall code quality in a major way, but it helps developers on both sides (devs of libraries, devs of using the libraries) to ensure proper passing of varaibles.

It is optional. And it will likely be only used by library/framework/component/whatever. But for them, I think, it's a win.

sincerely,
- Markus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to