Re: Type hinting misunderstood

From: Date: Sun, 06 Jan 2008 17:18:33 +0000
Subject: Re: Type hinting misunderstood
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-34533@lists.php.net to get a copy of this message
On Jan 6, 2008 5:55 PM, Sam Barrow <sam@sambarrow.com> wrote: > As I said, this patch is not intended for stuff like $_GET, $_POST, > database data, etc. It is intended for internal functions to your > application. > > function requireFile(string $file, bool $getOutput = false, array $args > = array()) > { > $obLevel = ob_get_level() ; > > ob_start() ; > > $return = require_once($file) ; > > if ($getOutput) > { > $return = ob_get_clean() ; > } > else > { > if > ($_mod['base']['output']['strict'] and ob_get_length() > 0) > { > ::error::go('Output generated in file > "' . $file . '".') ; > } > > ob_end_clean() ; > } > > if ($obLevel !== ob_get_level()) > { > ::error::go('Output buffering level mismatch after > inclusion of file > "' . $file . '".') ; > } > > return $return ; > } > > This function will not be called using input data. I have been watching type hinting for a while now and one thing I don't understand: hows my object of class lets say FileName that implements __toString() is wrong parameter for your requireFile()? Why should I every time calling a function cast variables manually when it can be perfectly done by PHP automatically? Sorry for intrusion and thanks for your time. Giedrius

« previous php.internals (#34533) next »