Michael Morris,

Type hinting means that we have hints when declaring function/method
signatures, example:

functiion do(int $someVal) {}
function doOther(string $str, mixed $pos = null) {}

As I remember, there was never a discussion about adding type hints
when declaring vars. The original discussion was and is about
finishing the support for type hints because PHP allready has
typehinting for arrays and objects. Additionaly there was launched a
discussion about function/method return typehints.
I do think the variable declaration type hints are pointless because
variables are chaning their types on the fly. But mostly it will
polute current discussion even more and adds a whole new super-global
level of thinking through and implementation details. It's just too
much.
We had type hinting  discussions for a few years now and never reached
any conclusion and patches that have been made still had lots of
problems. We should really focus on param type hints and maybe on
return type hints for now and see where it takes us.

Because the new thread has been created, I will leave my arguments
here for the record.

I, as a user land developer, would like the weak type hinting, which
takes care of transparent conversions where no data loss is happening.
I would like to get a E_NOTICE or E_WARNING when some loss is
happening (for example I pass a string "aaa", but function expects an
integer or double. It would convert it to 1, but also will emit the
warning/notice for me to inspect what went wrong). And fatal errors on
serious type miss match like it is now done with objects and arrays.
This way is 100% backwards compatible, it does not add a ton of new
rules to remember when write code and is based on the mechanics PHP
already has, just extended a little. Same goes for the return type
hints.
The only case I do not remember being discussed in detail (maybe it
was and I somehow missed that part) is when we accept (and return for
return type hints) a mixed type param. Is it somehow described or we
just leave out the type hints at all. It's not so rare to see
something like this: function do(string $str = null). By logic it
accepts 2 types - null and string, but type hint says it accepts only
string and doing a call do(null) should work despite the type hint.

My 2 cents.

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

Reply via email to