File RespondentModel.php
has 723 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
use Gems\Exception\RespondentAlreadyExists;
/**
Method applyEditSettings
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function applyEditSettings($create = false)
{
$this->applyDetailSettings();
$this->copyKeys(); // The user can edit the keys.
Method applyDetailSettings
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function applyDetailSettings()
{
$dbLookup = $this->util->getDbLookup();
$localized = $this->util->getLocalized();
$translated = $this->util->getTranslated();
The class Gems_Model_RespondentModel has an overall complexity of 119 which is very high. The configured complexity threshold is 50. Open
class Gems_Model_RespondentModel extends \Gems_Model_HiddenOrganizationModel
{
/**
* Store the SSN hashed in the database and display only '*****'
*/
- Exclude checks
The class Gems_Model_RespondentModel has 19 public methods. Consider refactoring Gems_Model_RespondentModel to keep number of public methods under 10. Open
class Gems_Model_RespondentModel extends \Gems_Model_HiddenOrganizationModel
{
/**
* Store the SSN hashed in the database and display only '*****'
*/
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Function save
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function save(array $newValues, array $filter = null, array $saveTables = null)
{
// If the respondent id is not set, check using the
// patient number and then the ssn
if (! (isset($newValues['grs_id_user']) && $newValues['grs_id_user'])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Gems_Model_RespondentModel
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Gems_Model_RespondentModel extends \Gems_Model_HiddenOrganizationModel
{
/**
* Store the SSN hashed in the database and display only '*****'
*/
Function setReceptionCode
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null)
{
if (!$newCode instanceof \Gems_Util_ReceptionCode) {
$newCode = $this->util->getReceptionCode($newCode);
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method merge
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function merge($newPid, $oldPid, $orgId)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
Function merge
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function merge($newPid, $oldPid, $orgId)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method save
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(array $newValues, array $filter = null, array $saveTables = null)
{
// If the respondent id is not set, check using the
// patient number and then the ssn
if (! (isset($newValues['grs_id_user']) && $newValues['grs_id_user'])) {
Method setReceptionCode
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null)
{
if (!$newCode instanceof \Gems_Util_ReceptionCode) {
$newCode = $this->util->getReceptionCode($newCode);
}
Function handleRespondentChanged
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function handleRespondentChanged($patientId, $organization, $respondentId = null)
{
if ($organization instanceof \Gems_User_Organization) {
$org = $organization;
$orgId = $organization->getId();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method copyToOrg
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function copyToOrg($fromOrgId, $fromPid, $toOrgId, $toPid, $keepConsent = false)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
Method addNameToModel
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function addNameToModel(\Gems_Model_JoinModel $model, $label)
{
$nameExpr[] = "COALESCE(grs_last_name, '-')";
$fieldList[] = 'grs_last_name';
if ($model->has('grs_partner_last_name')) {
Method applyBrowseSettings
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function applyBrowseSettings()
{
$dbLookup = $this->util->getDbLookup();
$translated = $this->util->getTranslated();
Method move
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function move($fromOrgId, $fromPid, $toOrgId, $toPid)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
Function addNameToModel
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function addNameToModel(\Gems_Model_JoinModel $model, $label)
{
$nameExpr[] = "COALESCE(grs_last_name, '-')";
$fieldList[] = 'grs_last_name';
if ($model->has('grs_partner_last_name')) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _checkFilterUsed
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _checkFilterUsed($filter)
{
$filter = parent::_checkFilterUsed($filter);
if (isset($filter['gr2o_id_organization'])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function copyToOrg
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function copyToOrg($fromOrgId, $fromPid, $toOrgId, $toPid, $keepConsent = false)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method hideSSN
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function hideSSN($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
Method setReceptionCode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null)
Method copyToOrg
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function copyToOrg($fromOrgId, $fromPid, $toOrgId, $toPid, $keepConsent = false)
Avoid too many return
statements within this method. Open
return false;
The class Gems_Model_RespondentModel has 1182 lines of code. Current threshold is 1000. Avoid really long classes. Open
class Gems_Model_RespondentModel extends \Gems_Model_HiddenOrganizationModel
{
/**
* Store the SSN hashed in the database and display only '*****'
*/
- Exclude checks
The method save() has an NPath complexity of 200. The configured NPath complexity threshold is 200. Open
public function save(array $newValues, array $filter = null, array $saveTables = null)
{
// If the respondent id is not set, check using the
// patient number and then the ssn
if (! (isset($newValues['grs_id_user']) && $newValues['grs_id_user'])) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method applyDetailSettings() has 119 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function applyDetailSettings()
{
$dbLookup = $this->util->getDbLookup();
$localized = $this->util->getLocalized();
$translated = $this->util->getTranslated();
- Exclude checks
The method applyEditSettings() has 127 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function applyEditSettings($create = false)
{
$this->applyDetailSettings();
$this->copyKeys(); // The user can edit the keys.
- Exclude checks
The method merge() has 103 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function merge($newPid, $oldPid, $orgId)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
- Exclude checks
The method setReceptionCode() has an NPath complexity of 364. The configured NPath complexity threshold is 200. Open
public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null)
{
if (!$newCode instanceof \Gems_Util_ReceptionCode) {
$newCode = $this->util->getReceptionCode($newCode);
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method copyToOrg() has an NPath complexity of 288. The configured NPath complexity threshold is 200. Open
public function copyToOrg($fromOrgId, $fromPid, $toOrgId, $toPid, $keepConsent = false)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method copyToOrg() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function copyToOrg($fromOrgId, $fromPid, $toOrgId, $toPid, $keepConsent = false)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method save() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open
public function save(array $newValues, array $filter = null, array $saveTables = null)
{
// If the respondent id is not set, check using the
// patient number and then the ssn
if (! (isset($newValues['grs_id_user']) && $newValues['grs_id_user'])) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method setReceptionCode() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null)
{
if (!$newCode instanceof \Gems_Util_ReceptionCode) {
$newCode = $this->util->getReceptionCode($newCode);
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method merge() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function merge($newPid, $oldPid, $orgId)
{
// Maybe we should disable masking, just to be sure
$this->currentUser->disableMask();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The class Gems_Model_RespondentModel has a coupling between objects value of 24. Consider to reduce the number of dependencies under 13. Open
class Gems_Model_RespondentModel extends \Gems_Model_HiddenOrganizationModel
{
/**
* Store the SSN hashed in the database and display only '*****'
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Avoid unused local variables such as '$changed'. Open
$changed = $this->db->update(
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$reset'. Open
public function copyKeys($reset = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$isNew'. Open
public function saveSSN($value, $isNew = false, $name = null, array $context = array())
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$name'. Open
public function hideSSN($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$isNew'. Open
public function hideSSN($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$context'. Open
public function saveSSN($value, $isNew = false, $name = null, array $context = array())
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$name'. Open
public function saveSSN($value, $isNew = false, $name = null, array $context = array())
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$context'. Open
public function hideSSN($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid excessively long variable names like $toPatientByRespondent. Keep variable name length under 20. Open
$toPatientByRespondent = $this->loadFirst(['gr2o_id_organization' => $toOrgId, 'gr2o_id_user' => $fromPatient['gr2o_id_user']]);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $this->getAdapter();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
protected $db;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = false;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $this->getAdapter();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}