On 04/28/2011 01:58 AM, Alain Williams wrote:
On Thu, Apr 28, 2011 at 01:35:00AM -0700, Stas Malyshev wrote:
Hi!

to find problems before your users?

Sorry, this doesn't say much. It's a generic, of course we agree it's
good to find bugs sooner rather than later. The question is why would
that specific thing that is being proposed help - in which specific way?

It would mean that the code that follows could benefit from the PHP run
time checking the return type -- at the point of return. Thus eliminating
following errors where the user does not check, eg:

     function array foo() { .... }

     $ret = foo();
     foreach($ret as $val)
         ....

I don't see this being useful at all. All you are doing is duplicating a runtime warning. We can't possibly know at compile-time whether this return value is an array or not, so there is no compile-time benefit.

eg.

function array foo() {
  $ret = bar();
  return $ret;
}

So in this case we get a warning on the return and then another warning on the foreach(). We have not gained anything except an extra warning for the same problem in this code example.

And this gets even worse if you start doing scalar return type checking. Now you are adding warnings for types that are safely interchangeable.

-Rasmus

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

Reply via email to