Missing class import via use statement (line '37', column '27'). Open
throw new Pluf_Form_Invalid('An error occured when creating the upload path. Please try to send the file again.');
- 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 36. Open
function save($commit = true)
{
if (! $this->isValid()) {
throw new Pluf_Exception_Form('cannot save the Part 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
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 '29', column '23'). Open
throw new Pluf_Exception_Form('cannot save the Part from an invalid form', $this);
- 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 '32', column '21'). Open
$part = new ELearn_Part();
- 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
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
$part->file_path = Pluf::f('upload_path') . '/' . $this->tenant->id . '/part';
- 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($part->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) { ... }
Call to undeclared method \ELearn_Part::create
Open
$part->create();
- Exclude checks
Reference to undeclared property \ELearn_Part->file_path
Open
if (! is_dir($part->file_path)) {
- Exclude checks
Call to method current
from undeclared class \Pluf_Tenant
Open
$this->tenant = Pluf_Tenant::current();
- Exclude checks
Reference to undeclared property \ELearn_Part->file_path
Open
$part->file_path = Pluf::f('upload_path') . '/' . $this->tenant->id . '/part';
- Exclude checks
Call to undeclared method \ELearn_Part::setFromFormData
Open
$part->setFromFormData($this->cleaned_data);
- Exclude checks
Reference to undeclared property \ELearn_Form_PartCreate->cleaned_data
Open
$part->setFromFormData($this->cleaned_data);
- Exclude checks
Call to method __construct
from undeclared class \Pluf_Exception_Form
Open
throw new Pluf_Exception_Form('cannot save the Part from an invalid form', $this);
- Exclude checks
Call to method f
from undeclared class \Pluf
Open
$part->file_path = Pluf::f('upload_path') . '/' . $this->tenant->id . '/part';
- Exclude checks
Call to undeclared method \ELearn_Form_PartCreate::isValid
Open
if (! $this->isValid()) {
- Exclude checks
Reference to undeclared class \Pluf_Form_Model
Open
parent::initFields($extra);
- Exclude checks
Call to method loadFunction
from undeclared class \Pluf
Open
Pluf::loadFunction('ELearn_Shortcuts_CleanName');
- Exclude checks
Class extends undeclared class \Pluf_Form_Model
Open
class ELearn_Form_PartCreate extends Pluf_Form_Model
- Exclude checks
Reference to undeclared property \ELearn_Part->file_path
Open
if (false == @mkdir($part->file_path, 0777, true)) {
- Exclude checks
Call to method __construct
from undeclared class \Pluf_Form_Invalid
Open
throw new Pluf_Form_Invalid('An error occured when creating the upload path. Please try to send the file again.');
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class ELearn_Form_PartCreate extends Pluf_Form_Model
- Exclude checks
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 12 and the first side effect is on line 2. Open
<?php
- Exclude checks
The class ELearn_Form_PartCreate is not named in CamelCase. Open
class ELearn_Form_PartCreate extends Pluf_Form_Model
{
public $tenant = 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
Line exceeds 120 characters; contains 130 characters Open
throw new Pluf_Form_Invalid('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
Class name "ELearn_Form_PartCreate" is not in camel caps format Open
class ELearn_Form_PartCreate extends Pluf_Form_Model
- Exclude checks