Re: Type hinting

From: Date: Thu, 27 May 2010 15:47:00 +0000
Subject: Re: Type hinting
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-48527@lists.php.net to get a copy of this message
On 27.05.2010, at 17:40, Derick Rethans wrote: > On Thu, 27 May 2010, Arvids Godjuks wrote: > >> Please read more carefully - what I mean that is we deal mostly with >> numbers witch are represented as strings, because all data that comes >> from external sources are STRING regardless of actual contents - be >> that integer or float - no matter. I don't want to make my code look >> like this: >> >> function doSomeStuffWithDbData(int $id, string $name, int $someFlag) { >> } >> >> $sql = 'SELECT id, name, some_flag, .... FROM table WHERE .....'; >> $res = mysqli_query($db, $sql); >> $row = $res->fetch_assoc(); >> doSomeStuffWithDbData((int)$row['id'], $row['name'], >> (int)$row['some_flag']); > > PDO's bind values already provide the correct type if you specify so. So > this is moot point. well most people do not use that since its just as tedious to use as having to cast your results. of course if we did have strict typing it would probably become more widely used, not that having to add those lines of code are something i would like to see in my code (the speed gains are microoptimizations for most use cases of PHP). regards, Lukas Kahwe Smith mls@pooteeweet.org

« previous php.internals (#48527) next »