The method _retrieveCurrentValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->current_value = 'None';
}
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class PhpSecInfo_Test_Dir_Is_Root_Read extends PhpSecInfo_Test_Dir
- Exclude checks
The property $test_name is not named in camelCase. Open
class PhpSecInfo_Test_Dir_Is_Root_Read extends PhpSecInfo_Test_Dir
{
/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
- 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 class PhpSecInfo_Test_Dir_Is_Root_Read is not named in CamelCase. Open
class PhpSecInfo_Test_Dir_Is_Root_Read extends PhpSecInfo_Test_Dir
{
/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The property $recommended_value is not named in camelCase. Open
class PhpSecInfo_Test_Dir_Is_Root_Read extends PhpSecInfo_Test_Dir
{
/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
- 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
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 23 and the first side effect is on line 15. Open
<?php
- Exclude checks
Method name "_execTest" should not be prefixed with an underscore to indicate visibility Open
public function _execTest()
- Exclude checks
Method name "_setMessages" should not be prefixed with an underscore to indicate visibility Open
public function _setMessages()
- Exclude checks
Method name "_retrieveCurrentValue" should not be prefixed with an underscore to indicate visibility Open
public function _retrieveCurrentValue()
- Exclude checks
Line exceeds 120 characters; contains 173 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTICE, 'en', "Read permission enabled. You should under normal instances never allow Reading of the root ('/').");
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_WARN, 'en', "Write permission enabled for the root ('/') directory! You should never allow writing outside your www base.");
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', "No permissions granted for the root ('/') directory. This is the most secure setup.");
- Exclude checks
Class name "PhpSecInfo_Test_Dir_Is_Root_Read" is not in camel caps format Open
class PhpSecInfo_Test_Dir_Is_Root_Read extends PhpSecInfo_Test_Dir
- Exclude checks
The method _execTest is not named in camelCase. Open
public function _execTest()
{
// Check permissions
if ('None' == $this->current_value) {
return PHPSECINFO_TEST_RESULT_OK;
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _setMessages is not named in camelCase. Open
public function _setMessages()
{
parent::_setMessages();
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', "No permissions granted for the root ('/') directory. This is the most secure setup.");
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _retrieveCurrentValue is not named in camelCase. Open
public function _retrieveCurrentValue()
{
// Get current permissions
if (is_writable('/')) {
$this->current_value = 'Write+Read';
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}