handleUpload accesses the super-global variable $_REQUEST. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
handleUpload accesses the super-global variable $_REQUEST. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
handleUpload accesses the super-global variable $_FILES. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method handleUpload
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
Method enqueueScripts
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function enqueueScripts()
{
global $post;
$post_id = ( !empty( $post->ID ) ) ? $post->ID : null;
The method handleUpload uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return new AjaxErrorResponse(
'Attachment not generated due to error', array(
'error' => $attachmentId
)
- 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 variable $file_attr is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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 $post_id is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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 $post_id is not named in camelCase. Open
public static function enqueueScripts()
{
global $post;
$post_id = ( !empty( $post->ID ) ) ? $post->ID : null;
- 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 $post_id is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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 $file_attr is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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 $file_attr is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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 $post_id is not named in camelCase. Open
public static function enqueueScripts()
{
global $post;
$post_id = ( !empty( $post->ID ) ) ? $post->ID : null;
- 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 $file_attr is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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 $post_id is not named in camelCase. Open
public static function handleUpload()
{
header( 'Content-Type: text/html; charset=UTF-8' );
if (!defined( 'DOING_AJAX' )) {
- 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();
}
}