No .ini switches. Forget it. Developers of PHP said it clearly - NO
.ini values that change the behaviour of PHP! Ever! Topic closed.

2010/5/27 魏世江 <shiji...@staff.sina.com.cn>:
> Hi .
> I think there is no need to argue on it  any more.
> Good programmers have the ability to manipulate the variables' types.
> But I think it's the icing on the cake if we give the PHP programmer the 
> choice of whether use explicit types.
> For examlpe, we may add a switch in php.ini, let's say, explict_types=On/Off.
>
> ----- Original Message -----
> From: "Daniel Egeberg" <daniel.egeb...@gmail.com>
> To: "Arvids Godjuks" <arvids.godj...@gmail.com>
> Cc: "Etienne Kneuss" <col...@php.net>; "PHP internals" 
> <internals@lists.php.net>
> Sent: Thursday, May 27, 2010 4:45 PM
> Subject: Re: [PHP-DEV] Type hinting
>
>
>> On Thu, May 27, 2010 at 10:34, Arvids Godjuks <arvids.godj...@gmail.com> 
>> 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']);
>>>
>>> And so on. There is no meaning in doing explicit type casts and then
>>> check the type again! Because if you have bogus data like "123abc"
>>> with type cast you cast it to 123 integer and you function check for
>>> integer will pass without any notice!
>>>
>>> Hm, it just strike me. If you want a strict type checks, you have to
>>> convert your data before you pass it when it comes from outside (and
>>> it always does by the way! - databases, request data, files). So
>>> basically you will first convert it and then pass to functions to
>>> avoid inconsistent type errors. And UPS! Magically you have no errors!
>>> because $data = '123abc'; $data = (int)$data; results in pure 123 int.
>>> No benefit in using type hints at all.
>>
>> If you don't know whether the user/database provided information you
>> have is correct before you pass it along to something else, I would
>> say that the code indeed is bad. Unless you regard "123abc" as a valid
>> value from your user, don't allow the user to give you that value. If
>> you regard it as a valid value, then it's not an int thus you wouldn't
>> want to type cast it in the first place.
>>
>> --
>> Daniel Egeberg
>>
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>

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

Reply via email to