Let us suppose we have these 2 methods:
function superFunction($superhero,array $clothes){
if($superhero===CHUCK_NORRIS){
wear($clothes);
} else if($superhero===SUPERMAN) {
wear($clothes[1]);
}
}
function wear(array $clothes)
{
for($piece in $clothes){
echo "Wearing piece";
}
}
So what I want to achieve is to put a breakpoint in PhpStorm into function wear
but I want to get fired only when $superhero
variable has the value CHUCK_NORRIS
how I can do that. Imagine that the function superFunction
is getting called over a zillion times and pressing F9 all over the time is kind of counter productive.
Put the breakpoint in PhpStorm as usual then right-click on the red disc that marks the breakpoint in the editor's gutter. In the popup window that opens enter the condition when you want your breakpoint to stop the execution of the script. Any condition that is valid in the code where you put the breakpoint can be input here.
For example, enter $superhero===CHUCK_NORRIS
.
Press the "Done" button and you're good to go. Debug the script as usual. The debugger evaluates the condition everytime the breakpoint is hit but it stops the script only when the condition is evaluated to true
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With