In my opinion, sample #2 seems to be the more readable way of commenting.
But if I apply PSR-2 to both samples, sample #1 won't change but the result of sample #2 changes as below and it's not a proper comment.
What is the best way to comment in these case?
sample #1/* Read cached data */
if ($useCache == true){
// do something
/* Download and cache data */
} else {
// do something
}
sample #2
/* Read cached data */
if ($useCache == true){
// do something
}
/* Download and cache data */
else {
// do something
}
PSR-2 result of sample #2
/* Read cached data */
if ($useCache == true){
// do something
} /* Download and cache data */
else {
// do something
}
Conclusion 2017/12/13
So far the best way seems to be as below: Marking them inside the brackets
if ($useCache == true){
/* Read cached data */
// do something
}
else {
/* Download and cache data */
// do something
}