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 = 'Read-Only';
}
- 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_Self_Write extends PhpSecInfo_Test_Dir
- Exclude checks
The class PhpSecInfo_Test_Dir_Is_Self_Write is not named in CamelCase. Open
class PhpSecInfo_Test_Dir_Is_Self_Write 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_Self_Write 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 property $test_name is not named in camelCase. Open
class PhpSecInfo_Test_Dir_Is_Self_Write 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 "_retrieveCurrentValue" should not be prefixed with an underscore to indicate visibility Open
public function _retrieveCurrentValue()
- Exclude checks
Method name "_setMessages" should not be prefixed with an underscore to indicate visibility Open
public function _setMessages()
- Exclude checks
Method name "_execTest" should not be prefixed with an underscore to indicate visibility Open
public function _execTest()
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_WARN, 'en', 'Execute permission enabled! You should never allow execution here.');
- Exclude checks
Line exceeds 120 characters; contains 217 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTICE, 'en', 'Write permission enabled. You should consider revoking this permission since it can allow attackers to more easily modify files on your site.');
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'Only allowing Read permission. This is the most secure setup.');
- Exclude checks
Class name "PhpSecInfo_Test_Dir_Is_Self_Write" is not in camel caps format Open
class PhpSecInfo_Test_Dir_Is_Self_Write extends PhpSecInfo_Test_Dir
- Exclude checks
The method _execTest is not named in camelCase. Open
public function _execTest()
{
// Check permissions
if ('Read-Only' == $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', 'Only allowing Read permission. 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_executable(__FILE__)) {
$this->current_value = 'Execute+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() {
}
}