Re: Comments on bugs marked bogus
| From: | Bertrand Mansion | Date: | Thu, 28 Jul 2005 09:11:34 +0000 |
| Subject: | Re: Comments on bugs marked bogus | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-38994@lists.php.net to get a copy of this message | ||
Scott Mattocks wrote:
>Bertrand Mansion wrote:
>
>> The only poor coding practice I see is trying to enforce case-sensitivity in
a
>> case-insensitive language, and this is probably found in your __autoload()
>code.
>
>Please run the following code fragment and then revise your statement:
><?php
>$var1 = 'test';
>$var2 = 'TEST';
>
>if ($var1 == $var2) {
> echo 'Case Insensitive';
>} else {
> echo 'Case Sensitive';
>}
>?>
>
>is_a may do a case insensitive comparison but it is an exception to the
>language rule. I would like to hear your arguments stating that using
>inconsistent class naming is good coding practice.
Looks like you don't understand the term case-insensitive, so I will use a
simple example...
Try :
<?php
function BIG() {
echo 'I am BIG !';
}
$small = 'big';
$small();
?>
You see, the function name that is called is written with small letters, but the
function declaration uses BIG letters. Nevertheless, the function is still
called. So is_a() is not an exception, because it's everywhere in PHP. FYI,
get_class() used to return a lowercased string in PHP4. This behaviour has been
changed in PHP5. Furthermore, is_a() has been deprecated in PHP5, you are
supposed to use instanceof IIRC.
>> We won't fix this before an RFC about how to deal with __autoload() and PEAR
>is
>> written and approved. This is the decision of the lazy maintainers of
>> HTML_QuickForm. Now, if you are not lazy, just write it.
>
>Again, what does this issue have to do with how __autoload() is used? An
>autoload function may have been used to find the problematic line of
>code but __autoload() is not the source of the problem. While there may
>be a need for an RFC relating to __autoload(), it is not relavent to the
>current discussion.
I hope my little example helped you understand that the issue is not as simple
as fixing just one line. In a language with no namespaces and
case-insensitivity, you need to follow some rules in order not to mess things
up, just like we did with private members.
So I am repeating myself :
1. is_a() shouldn't call __autoload() IMO, and this is a PHP5 bug.
2. If 1. is not fixed for some reason, then classname comparison in PHP5 is_a()
should be made case-sensitive, just with PHP5 get_class(), and this is again a
PHP5 bug.
3. If __autoload() is to be supported, and neither 1. or 2. are fixed, then
there should be just one class per file and every classnames should be
convertible into a filepath on case-sensitive OSes like Linux. And this should
be written in an RFC and changed in every packages in PEAR, unless the developer
don't want to support PHP5.
Only when one of those will be done, will we know how to deal with this issue
correctly.
Bertrand Mansion
Mamasam