ID:               28442
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kell_pt at users dot sf dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: *
-PHP Version:      5CVS-2004-05-19
+PHP Version:      5.0.3
-Assigned To:      
+Assigned To:      helly
 New Comment:

Your code assumption is not fully correct. A static variable will be
inherited unless not defined again. However this 'unless' part is
wrong, it rsults in a compiler error.


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

[2005-03-06 22:10:51] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2004-05-22 04:17:45] kell_pt at users dot sf dot net

Secondly, there have been more bug reports regarding this issue, or
different effects of the model. Anyone having programmed in other
enviroments where class inheritance is possible will not feel at home
with this, and also it doesn't add anything to the language - it is not
only a limitation, but also misleading behaviour. We'd like to see a bit
more discussion on this, it *really* isn't a bogus problem. :)

Cheers, and I apologize for the insistence, but we're using PHP5 for
its new OO features, and it's being hard to cope with the fact that
this seems to be overlooked. Hopefully it will be fixed (can't see a
reason why it wouldn't).

Cheers.

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

[2004-05-22 04:13:56] kell_pt at users dot sf dot net

It most certainly isn't. Declaring a variable as private static just
hides the variable from outside the class. It also allows subclasses to
redeclare it. But it doesn't change a thing, and that's not the intended
behaviour. An example:

class ClassA
{
   private  static   $cn;

   public static function setName( $cn )
   {
      self::$cn   = $cn;
   }

   public static function  getName( )
   {
      return self::$cn;
   }
}


class ClassB extends ClassA
{
   private  static   $cn; // with or without this, result is the same
}


ClassA::setName( 'AAA' );
ClassB::setName( 'BBB' );

print( ClassA::getName() . "\n" ); // prints 'BBB'
print( ClassB::getName() . "\n" ); // prints 'BBB'

ClassB::setName() is using ClassA as self, when that's not the intended
nor propper behaviour. If you call a method on ClassB, it has to affect
ClassB, not ClassA - that's how $this works on instances, that's how it
should work on static classes. 

Secondly,

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

[2004-05-21 18:12:34] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

What you want is \'private static\'

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

[2004-05-21 05:28:11] kell_pt at users dot sf dot net

I would also like to call your attention to Bug #26930 which was
dismissed as "Bogus", where in fact it's a very valid problem.

Seems like the behaviour for static data/methods doesn't follow the OO
paradigm very close. I hope you guys don't dismiss these problems and
provide a sound implementation. :)

Cheers.

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

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/28442

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

Reply via email to