User tests: Successful: Unsuccessful:
Cleans up useless uses of else
and unnecessary indentation due to 'reverse-logic' in if
s.
So this improves readability of code by trying to eliminate the use of else
statements and keeping the indentation to the bare minimum.
For instance, instead of wrapping stuff in multiple 'positive' if
checks, simply do 'negative' if
checks and return early.
This means you don't need to nest if statements.
The same can be done with for/foreach loops, but then do continue
in 'negative' if
checks.
Also removed else
statements if the previous if
` block ends with a return, like:
if($something)
{
doStuff();;
return $this;
}
else
{
doOtherStuff();
return $that;
}
Can be replaced with:
if($something)
{
doStuff();;
return $this;
}
doOtherStuff();
return $that;
This affects the JInstaller, so test the installer in Joomla.
This is the first file I went through to improve a bit (can of course be improved even more with more effort). If this fares well, I'll do other files too.
The improvements are based on a few rules from PHP Object Callisthenics. Kudos to @rdohms for inspiring the PHP and Joomla developers with that!
Status | Pending | ⇒ | New |
Labels |
Added:
?
|
Status | New | ⇒ | Pending |
Been lying around for 4 weeks now. So no interest = close.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-09-20 13:04:49 |
@test: successful, tested all the ways to install a extension and found no problems.