NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Breakpoints inside array declarations
Veteran

Joined: 06 Jun 2007
Posts: 289
Location: Vancouver, Canada
Reply with quote
When using an expression inside an array declaration, I can set a breakpoint on the expression, but the debugger seems to ignore it. In the example below, I can set a breakpoint on the "element" line, but cannot stop at that line:
Code:

$a = 1;
$b = 2;
$array = array (
  element => $a + $b
);

I consider this a minor bug, not a show stopper Wink
View user's profileFind all posts by annoSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
This is not a bug. Breakpoints work for lines that can be executed and only for them.

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

Joined: 06 Jun 2007
Posts: 289
Location: Vancouver, Canada
Reply with quote
Quote:
This is not a bug

OK Wink

Quote:
Breakpoints work for lines that can be executed and only for them.

But surely the line "element => $a + $b" can be executed? Allow me use two another example to illustrate the point:

Code:

function calca() {
.. does something..
}

function calcb() {
.. does something..
}

$array = array (
  $a => calca(),
  $b => calcb()
);


Now what should I do to break at the calcb function, for example? I guess I could set a breakpoint in the calcb function itself, or check the array values after declaration. However, since the declaration may be long and complex, it would be nice to debug the array during declaration.
View user's profileFind all posts by annoSend private messageVisit poster's website


Joined: 26 May 2007
Posts: 40
Reply with quote
As dmitri wrote it already, the debugger can break only on an executable line. Putting some more emphasis on line, the way you wrote your array declaration is breaking up one PHP line into many text lines. A PHP line ends with a semicolon and it does not matter if that line spans 20 lines in the editor or just one. From PHP and therefore the debuggers point of view your line looks like this:
Code:
$array = array ($a => calca(), $b => calcb());


Of course, you can break on a line in the calca or calcb function assuming that the functions have an executable line. The debugger doesn't break on comment lines either. Honestly, the IDE shouldn't allow one to set a breakpoint on those lines, but that is a different issue.
View user's profileFind all posts by RamonSSend private message
Veteran

Joined: 06 Jun 2007
Posts: 289
Location: Vancouver, Canada
Reply with quote
Aaaah, I get it now. Thanks for clarifying Smile
View user's profileFind all posts by annoSend private messageVisit poster's website
Breakpoints inside array declarations
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