CRITICAL
Rule Definition
Overriding Methods is a very powerful way to refactor the code and produce complete functionalities. However useless overriding methods can make the source code more complex.
Remediation
Modify the source code to reduce the number of useless overridden Methods.
Violation Code Sample
class CastTest {
public function __construct($a, $b) {
parent::__construct($a, $b);
}
}
Fixed Code Sample
<?php
function optionalBeforeRequired ($optionalParameter = "", $requiredParameter = "")
{
echo "optionalBeforeRequired: violation removed", PHP_EOL;
}
?>
OR
<?php
function optionalBeforeRequired ($requiredParameter, $optionalParameter = "")
{
echo "optionalBeforeRequired: violation removed", PHP_EOL;
}
?>
Reference
Code Sniffer - http://pear.php.net/package/PHP_CodeSniffer/docs/1.5.2/PHP_CodeSniffer/PEAR_Sniffs_Functions_ValidDefaultValueSniff.html
Related Technologies
Technical Criterion
Programming Practices - Structuredness
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.