NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
how to inspect static variables?


Joined: 30 May 2006
Posts: 95
Reply with quote
Hello,

how can I inspect static variables in debugger?
Using PHPEd 7.0 build 7021, DBG 4.5.1.

Is there any scope limitation?

Simple example:

Code:

class Test{
   public static $names = array();

   public static function setName($key, $name){
       self::$names[$key] = $name;
   }
}


If I set breakpoint on line "self::$names[$key] = $name;" - why I cannot see static class variable "self::$names"?
I cannot find it in global nor local variables.
It is strange, because evaluating in window "Immediate" will dump complete array of self::$names correctly.

Thanx in advance for explanation.
Lubos
View user's profileFind all posts by lubosdzSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
In your example $names is not a variable. That's why it's not shown in neither locals nor globals.
This is a class property. In order to see static properties and class constants, just type class name followed by double-colon in Watch or Immediate window, like below:
Test::

you can also use self:: to see statics of current class.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 30 May 2006
Posts: 95
Reply with quote
dmitri wrote:
In your example $names is not a variable. That's why it's not shown in neither locals nor globals.
This is a class property. In order to see static properties and class constants, just type class name followed by double-colon in Watch or Immediate window, like below:
Test::

you can also use self:: to see statics of current class.



Hi Dmitri,

thank you for your reply.

Yes, I am aware of dumping static properties via window Immediate (Watch).

However honestly, this is a very uncomfortable way of inspecting existing variables
(from programming perspective, they ARE still variables, does not matter whether instantiated in class, global or static - programmer needs to see it).

Is there any plan to provide debugger with feature of inspecting static members?
What about extra window called "Static" ..?

Can I put it into feature request please - is it actually doable?

Thanx a lot, Lubos
View user's profileFind all posts by lubosdzSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
yes it's doable. But don't you need to see statics for only 1-2 classes? If so, sending statics for all the classes would bring a big overhead.
I planned some changes in debugger protocol that I'll do during this year. Perhaps, I'll think about this feature at the time.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 30 May 2006
Posts: 95
Reply with quote
dmitri wrote:
yes it's doable. But don't you need to see statics for only 1-2 classes? If so, sending statics for all the classes would bring a big overhead.
I planned some changes in debugger protocol that I'll do during this year. Perhaps, I'll think about this feature at the time.


It is unpredictable which class/method will use static variables, which not.
Some developers favour using static variables - their applications are then very hard to debug, dumping manually static members after each breakpoint.... Sad(

I am not sure about the overhead (if current overhead 5-15% would increase to 10-20% it would be OK), but from developer's point of view, inspecting the code in debug window is much more important than the speed of debugger during development (well, if overhead would cause e.g. +30% slowdown, then it would be a problem).

What about having *fast* filter that will only send to "static window" classes and/or local functions that truly use static variables rather than all classes?
Static windows should also display local static variables within a class's method - depending on the scope.

BTW - inspector for static variables is also on todo list/feature request of XDebug...

Thanx a lot.
Lubos
View user's profileFind all posts by lubosdzSend private message
how to inspect static variables?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic