1.2.548. Illegal Name For Method¶
PHP has reserved usage of methods starting with __
for magic methods. It is recommended to avoid using this prefix, to prevent confusions.
<?php
class foo{
// Constructor
function __construct() {}
// Constructor's typo
function __constructor() {}
// Illegal function name, even as private
private function __bar() {}
}
?>
See also Magic Methods.
1.2.548.1. Connex PHP features¶
1.2.548.1.1. Suggestions¶
Avoid method names starting with a double underscore :
__
Use method visibilities to ensure that methods are only available to the current class or its children
1.2.548.1.2. Specs¶
Short name |
Classes/WrongName |
Rulesets |
|
Exakat since |
0.9.2 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Examples |
|
Available in |