ID:               19376
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Suspended
 Bug Type:         Scripting Engine problem
 Operating System: Linux/Windows NT 4
 PHP Version:      4.2.2
 New Comment:

One more time, and the last time: This is expected behaviour. It might
be wrong, but it is not a bug. Feel free to write a patch, suspending
until you send one.

Derick


Previous Comments:
------------------------------------------------------------------------

[2002-09-17 21:09:18] [EMAIL PROTECTED]

Ok. I'm really having a serious issue with this.

I am not asking to fix anything that should eliminate backwards
comaptibility, because in any forum you go to, this behavior is wrong,
when considering object-oriented programming.

All I'm saying is that instead of scanning the class hierarchy from the
object class type, in either direction, that the class hierarchy be
scanned towards the base class only from the object class type.

Each variable carries with it, it's type.

You cannot seriously tell me this is difficult to implement, and
obviously since you shouldn't be scanning down a hierarchy from the
current object's class type anyway, you eliminate needing to spend
extra time so the whole process should be faster anyway.

Could you please give me one instance where backwards compability would
be sacrificed?

Having spent a good chunk of my education in studying compilers and
optimization and operating systems, I am really having trouble with the
overall attitude I'm getting about a problem that in my eyes is a
win-win if it's fixed, since we would have a proper object oriented
environment where code would not break just because someone was sloppy
in setting up their classes.

Come on. This is really serious stuff.

Because what you're essentially saying is that if 2 class hierarchies
are derived from PEAR, and that one of the instances in that hierarchy
calls a PEAR function and that PEAR function somehow needs to call
something in the other class hierarchy by some derived module, that
that SECONDARy static call to the alternative class hierarchy from the
same root, would then become a CLASS METHOD call making the situation
untenable and the problem unsolvable.

Is it just resources? Do you want me to look at the code and find out
what would need to be done?

All I've been hearing is "We can't do it, it isn't do-able, there's too
much that will break".

If any of these things were true, PHP would not be the success it is
today.

So what do you want to do??? I'm game for some collaboration.

I'm not asking for a silver bullet.

I've ante'd up. Anyone going to call???

Thanks.

------------------------------------------------------------------------

[2002-09-14 04:17:43] [EMAIL PROTECTED]

This is just how it is implemented, and it can now not be changed
because of backward compatibility -> won't fix.

Derick

------------------------------------------------------------------------

[2002-09-13 00:04:20] [EMAIL PROTECTED]

This is not the same as the one in the documentation that you sent me.

In the documentation, you are calling A::example directly, or calling
B::example which calls up the chain to A.

In that context, it's fine. Objects of type B contain an A context. 

It's when you call B::example from within A::example that all hell
breaks loose. Objects of type A have no B context.

Example.
<?php
error_reporting(E_ALL);
class A
{
  var $a;
  // This should be a static call - the only way it makes sense.
  function example(){echo $this->a;B::Example();}
}

class B extends A
{
  var $b;
  // This should fail when called from objects of type A.
  // And it does, but only because b is undefined, not
  // because $this is undefined. But since an object of 
  // type A called this static method, $this should not
  // exist. The error should be undefined variable $this
  // not undefined property b.
  function example(){echo $this->b;}
}
$a=new A;
$a->example();
?>
---------------

My 3 class script below also illustrates that not only is the class
context passed out of the current object to a static method, when the
function call chain returns to the original class, which should have no
context, the original context is still carried.

I really don't see how this is documented. Is there any further
documentation? You're suggesting I subscribe to php-dev??

Duplicated below w/o the results.

---------------

<?php
// Example of bug in PHP class method passing $this incorrectly

class test1
{
var $a;
function test1()
function showMe()
{
// Since test3::showMe was called as a static method
// This too should be a static method call with no $this
echo 'In test1::showMe<hr>';
echo 'Next 2 lines should fail since this method was not called
from within this object<br>';
echo '$this is of type '. get_class($this)." in
test3::showMe<br>\n";
echo "test1::showMe:a=".$this->a."<br>\n";
}
// Class member to test static method call
function callMe()
{
echo 'In test1::callMe<hr>';
echo '$this is of type '.get_class($this)."in
test1::callMe<hr>\n";
echo 'Calling class method test3::showMe from an object of type
test1<br>';
echo '$this should not be passed since test3::showMe does not exist
in objects of type test1<hr>';
// This is a static method call, since test1 objects
// do not have a test3::showMe.
test3::showMe();
}
}

class test2 extends test1
{
function showMe()
{
echo 'In test2::showMe<br>';
echo "Next 2 lines should fail since objects of type test1 cannot
pass \$this<hr>\n";
echo '$this is of type '. get_class($this)." in
test2::showMe<br>\n";
echo "test2::showMe:a=".$this->a."<hr>\n";
echo 'Calling parent::showMe<hr>';
// Since test3::showMe was called as a static method
// This too should be a static method call with no $this
parent::showMe();
}
}

class test3 extends test2
{
function showMe()
{
echo 'In test3::showMe<br>';
echo "Next 2 lines should fail since objects of type test1 cannot
pass \$this<hr>\n";
echo '$this is of type '. get_class($this)." in
test3::showMe<br>\n";
echo "test3::showMe:a=".$this->a."<hr>\n";
echo 'Calling parent::showMe<hr>';
// Since test3::showMe was called as a static method
// This too should be a static method call with no $this
parent::showMe();
}
}

// object $a is of type test1
$a=new test1;
$a->callMe();
?>

------------------------------------------------------------------------

[2002-09-12 23:50:43] [EMAIL PROTECTED]

oops forgot to mention - its documented
http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php 

"In this context, there is a current object and it may have object
variables. Thus, when used from WITHIN an object function, you may use
$this and object variables."

------------------------------------------------------------------------

[2002-09-12 23:45:09] [EMAIL PROTECTED]

dupe of http://bugs.php.net/bug.php?id=12622

I'm not sure if it will be fixed.. nobody has commented on 12622

It may be worth posting a question on php-dev, just to get a more
definitive answer...



------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/19376

-- 
Edit this bug report at http://bugs.php.net/?id=19376&edit=1

Reply via email to