Re: Return values in constructor
| From: | Mark Wiesemann | Date: | Sun, 05 Nov 2006 22:12:32 +0000 |
| Subject: | Re: Return values in constructor | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-4048@lists.php.net to get a copy of this message | ||
Hi Eric,
Eric Bouwers wrote:
> I have been working on PHP-Sat, a tool for statically analyzing PHP
> source code. This tool currently supports 14 bugpatterns, one of them
> finds constructors with a return value. This pattern is partly based
> on this thread:
>
> http://beeblex.com/lists/index.php/php.pear.qa/531?s=l:php.pear.qa
> in which Michael Wallner reports 11 constructors that return a value.
>
> I examined the stable packages from pear with the use of the tool and
> found 13 constructors that (still) return a value. Some of the
> constructors are even documented with a '@return' which states that
> the constructors actually return these values.
I can only answer for DB_Table and HTML_Table:
The (very old) @return comment in DB_Table is a little bit bogus, as
@return object DB_Table
is rather obvious. ;-)
The two not empty return statements in the constructor are oversights
and are easy to correct.
The API version check (for HTML_Common) in HTML_Table is rather old and
does not need to stay there.
I'll fix the problems in both packages soon.
Regards,
Mark