An inconsistency has been discovered in how the tokenizer handles conditions for T_DEFAULT statements depending on whether they use curly braces or not:
- Without curly braces: The tokenizer sets
conditions for all tokens until just before T_BREAK|T_RETURN|T_CONTINUE, which is the scope closer.
- With curly braces: The tokenizer sets
conditions until the T_BREAK|T_RETURN|T_CONTINUE token, which is not the scope closer.
This behavior was discovered while working on PR #850. It needs to be investigated whether this difference in behavior is intentional or not and if it is a bug that needs to be fixed.
This may be related to squizlabs/PHP_CodeSniffer#3794.
Code sample
switch($var) {
default: // Without curly braces.
echo "a";
break; // T_BREAK does NOT have `conditions`.
}
switch($var) {
default: { // With curly braces.
echo "b";
break; // T_BREAK has `conditions`.
}
}
Please confirm
An inconsistency has been discovered in how the tokenizer handles
conditionsforT_DEFAULTstatements depending on whether they use curly braces or not:conditionsfor all tokens until just beforeT_BREAK|T_RETURN|T_CONTINUE, which is the scope closer.conditionsuntil theT_BREAK|T_RETURN|T_CONTINUEtoken, which is not the scope closer.This behavior was discovered while working on PR #850. It needs to be investigated whether this difference in behavior is intentional or not and if it is a bug that needs to be fixed.
This may be related to squizlabs/PHP_CodeSniffer#3794.
Code sample
Please confirm
masterbranch of PHP_CodeSniffer.