Hi
What you said is correct. That is not unique to WordPress or PHP. All programming languages have an order in which logic is evaluated. That is the main reason for parentheses in programming code. It evaluates from the inside out – from what is within parentheses. Each part of an If statement expression breaks down to a True or False.
It gets interesting when AND and OR are involved.
In other words
if ( (TRUE) and (TRUE) ) evaluates to true
if ( (TRUE) and (FALSE) evaluates to false
the reason this is false is because the expression says both must be true
—————
if ( (TRUE) or (TRUE) ) evaluates to true
if ( (TRUE) or (FALSE) evaluates to true
the reason this is true is because the expression says
” if either A or B is true then do what follows”
—–
As you saw, the logical expression itself can run code, so even if the expression evaluates to false, evaluating the logic can cause the program to do things that change its environment or output.
To me the code you asked about is tricky code and its not at all clear at first glance what that code is doing. The way its coded makes the code shorter than it would otherwise be but doesn’t create clarity. None the less its in the widget code of every WordPress theme. So once you understand it you will know what it means and how it works.
Last night I had a theme that had default sidebar code I didn’t want running. I added an empty text widget to the sidebar widget area and just that was enough to cause the default sidebar code to stop appearing.