CRITICAL
Rule Definition
Using a naming convention makes the source code easier to read and therefore to maintain. For example, using the same name for the file and the class it contains will make source code updates much easier.
Remediation
Modify the source code to reduce the number of classes that do not have the same name as the parent file.
Violation Code Sample
NameTest.php
//inside the file
class ClassTest{
// items
var $items;
// add an item
function add_item($artnr, $num) {
$this->items[$artnr] += $num;
}
}
Fixed Code Sample
class NameTest{
// items
var $items;
// add an item
function add_item($artnr, $num) {
$this->items[$artnr] += $num;
}
}
Reference
Code Sniffer - http://pear.php.net/package/PHP_CodeSniffer/docs/1.5.2/PHP_CodeSniffer/Squiz_Sniffs_Classes_ClassFileNameSniff.html
Related Technologies
Technical Criterion
Documentation - Naming Convention Conformity
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.