Missing class import via use statement (line '45', column '24'). Open
$content = new Shop_OrderAttachment();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '51', column '27'). Open
throw new Pluf_Form_Invalid(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method save has a boolean flag argument $commit, which is a certain sign of a Single Responsibility Principle violation. Open
function save ($commit = true)
- 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
Missing class import via use statement (line '41', column '23'). Open
throw new Pluf_Exception_Form(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Remove error control operator '@' on line 50. Open
function save ($commit = true)
{
if (! $this->isValid()) {
throw new Pluf_Exception_Form(
'cannot save the content from an invalid form', $this);
- 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
Avoid using static access to class 'Pluf_Tenant' in method 'initFields'. Open
$this->tenant = Pluf_Tenant::current();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Pluf' in method 'save'. Open
$content->file_path = Pluf::f('upload_path') . '/' . $this->tenant->id .
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Merge this if statement with the enclosing one. Open
if (false == @mkdir($content->file_path, 0777, true)) {
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if (condition1) { if (condition2) { ... } }
Compliant Solution
if (condition1 && condition2) { ... }
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Shop_Form_OrderAttachmentCreate extends Pluf_Form_Model
- Exclude checks
The class Shop_Form_OrderAttachmentCreate is not named in CamelCase. Open
class Shop_Form_OrderAttachmentCreate extends Pluf_Form_Model
{
public $tenant = null;
public $user = null;
- 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
Visibility must be declared on method "save" Open
function save ($commit = true)
- Exclude checks
Expected 0 spaces before opening parenthesis; 1 found Open
function save ($commit = true)
- Exclude checks
Expected "function abc(...)"; found "function abc (...)" Open
public function initFields ($extra = array())
- Exclude checks
Expected "function abc(...)"; found "function abc (...)" Open
function save ($commit = true)
- Exclude checks
Expected 0 spaces before opening parenthesis; 1 found Open
public function initFields ($extra = array())
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
'cannot save the content from an invalid form', $this);
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 20 Open
'cannot save the content from an invalid form', $this);
- Exclude checks
Class name "Shop_Form_OrderAttachmentCreate" is not in camel caps format Open
class Shop_Form_OrderAttachmentCreate extends Pluf_Form_Model
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 24 Open
'An error occured when creating the upload path. Please try to send the file again.');
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
'cannot save the content from an invalid form', $this);
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
'An error occured when creating the upload path. Please try to send the file again.');
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Whitespace found at end of line Open
parent::initFields($extra);
- Exclude checks