The method POP3::displayErrors() calls the typical debug function print_r() which is mostly only used during development. Open
print_r($single_error);
- Read upRead up
- Exclude checks
DevelopmentCodeFragment
Since: 2.3.0
Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.
Example
class SuspectCode {
public function doSomething(array $items)
{
foreach ($items as $i => $item) {
// …
if ('qafoo' == $item) var_dump($i);
// …
}
}
}
Source https://phpmd.org/rules/design.html#developmentcodefragment
Method connect
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect($host, $port = false, $tval = 30)
{
// Are we already connected?
if ($this->connected) {
return true;
Function connect
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function connect($host, $port = false, $tval = 30)
{
// Are we already connected?
if ($this->connected) {
return true;
- 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 authorise
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
Function login
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function login($username = '', $password = '')
{
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
- 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 popBeforeSmtp
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$host,
$port = false,
$tval = false,
$username = '',
$password = '',
Function authorise
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if ($port === false) {
- 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
The method popBeforeSmtp has a boolean flag argument $tval, which is a certain sign of a Single Responsibility Principle violation. Open
$tval = false,
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method connect has a boolean flag argument $port, which is a certain sign of a Single Responsibility Principle violation. Open
public function connect($host, $port = false, $tval = 30)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method popBeforeSmtp has a boolean flag argument $port, which is a certain sign of a Single Responsibility Principle violation. Open
$port = false,
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method authorise has a boolean flag argument $port, which is a certain sign of a Single Responsibility Principle violation. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Remove error control operator '@' on line 339. Open
public function disconnect()
{
$this->sendString('QUIT');
//The QUIT command may cause the daemon to exit, which will kill our connection
//So ignore errors here
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
The method authorise has a boolean flag argument $tval, which is a certain sign of a Single Responsibility Principle violation. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method connect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// Does not work on Windows
if (substr(PHP_OS, 0, 3) !== 'WIN') {
socket_set_timeout($this->pop_conn, $tval, 0);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method checkResponse uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return true;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method authorise uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->tval = $tval;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method authorise uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->port = $port;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid unused private methods such as 'catchWarning'. Open
private function catchWarning($errno, $errstr, $errfile, $errline)
{
$this->error[] = [
'error' => 'Connecting to the POP3 server raised a PHP warning: ',
'errno' => $errno,
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod
The property $pop_conn is not named in camelCase. Open
class POP3
{
/**
* The POP3 PHPMailer Version number.
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $r. Configured minimum length is 3. Open
$r = fgets($this->pop_conn, $size);
- 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
The property $do_debug is not named in camelCase. Open
class POP3
{
/**
* The POP3 PHPMailer Version number.
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The parameter $debug_level is not named in camelCase. Open
public static function popBeforeSmtp(
$host,
$port = false,
$tval = false,
$username = '',
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The property $POP3_PORT is not named in camelCase. Open
class POP3
{
/**
* The POP3 PHPMailer Version number.
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $POP3_TIMEOUT is not named in camelCase. Open
class POP3
{
/**
* The POP3 PHPMailer Version number.
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The parameter $debug_level is not named in camelCase. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if ($port === false) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The variable $single_error is not named in camelCase. Open
private function displayErrors()
{
echo '<pre>';
foreach ($this->error as $single_error) {
print_r($single_error);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $login_result is not named in camelCase. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if ($port === false) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $login_result is not named in camelCase. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if ($port === false) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $debug_level is not named in camelCase. Open
public static function popBeforeSmtp(
$host,
$port = false,
$tval = false,
$username = '',
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $debug_level is not named in camelCase. Open
public function authorise($host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if ($port === false) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $pop3_response is not named in camelCase. Open
public function login($username = '', $password = '')
{
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $single_error is not named in camelCase. Open
private function displayErrors()
{
echo '<pre>';
foreach ($this->error as $single_error) {
print_r($single_error);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $pop3_response is not named in camelCase. Open
public function login($username = '', $password = '')
{
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $pop3_response is not named in camelCase. Open
public function connect($host, $port = false, $tval = 30)
{
// Are we already connected?
if ($this->connected) {
return true;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $pop3_response is not named in camelCase. Open
public function login($username = '', $password = '')
{
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $pop3_response is not named in camelCase. Open
public function login($username = '', $password = '')
{
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $pop3_response is not named in camelCase. Open
public function connect($host, $port = false, $tval = 30)
{
// Are we already connected?
if ($this->connected) {
return true;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}