Hi!

Let me ask you - do you think the existing PHP typehints are pointless too?
Do you feel they don't give you enough flexibility? Do you feel they
reinvented a language construct for the purpose of saving the typing of one
if clause (per argument) (per method) (per class)?

They are not pointless, but I think they are often misunderstood and not
used correctly. And they definitely lack flexibility in many cases. But
they are helpful for one important thing - defining interface between
the method and the method client. Having strictly typed variables does
not serve it, and trying to make PHP into half-baked
half-statically-typed language does not sound like a good idea to me.

All right, your method accepts an array of objects, instances of Foo. How do you enforce this contract?

Here's how my proposal enforces it:

function foobar(array $collectionOfFoo) {
   foreach ($collectionOfFoo as Foo $item) {
       ...
   }
}

What's your proposal? From the discussion so far, I'd guess it's peppering out code with if-s with the same error written everywhere everytime we check the item in an array.

Because I don't think inventing language constructs for the purpose of
helping IDEs simulate static typing in dynamically typed language makes
much sense.

The same applies to typehints, so make up your mind.

Stan

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

Reply via email to