modules/Settings/Mail/actions/DownloadAttachment.php
Avoid using static access to class '\App\Fields\File' in method 'process'. Open
Open
header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');
- 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 'Settings_Mail_Module_Model' in method 'process'. Open
Open
$fileInfo = Settings_Mail_Module_Model::getAttachmentInfo($id, $selectedFile);
- 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
When fetching an array index from a value of type string,
found an array index of type 'name',
but expected the index to be of type int
Open
Open
header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'path',
but expected the index to be of type int
Open
Open
readfile($fileInfo['path']);
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'path',
but expected the index to be of type int
Open
Open
header('content-length: ' . filesize($fileInfo['path']));
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'path',
but expected the index to be of type int
Open
Open
if ($fileInfo['path'] ?? null && file_exists($fileInfo['path'])) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Settings_Mail_DownloadAttachment_Action extends Vtiger_Mass_Action
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
Open
$id = $request->getInteger('record');
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class Settings_Mail_DownloadAttachment_Action is not named in CamelCase. Open
Open
class Settings_Mail_DownloadAttachment_Action extends Vtiger_Mass_Action
{
use \App\Controller\Traits\SettingsPermission;
/**
- 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
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$selectedFile = $request->getInteger('selectedFile');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fileInfo = Settings_Mail_Module_Model::getAttachmentInfo($id, $selectedFile);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('content-type: application/octet-stream');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('expires: 0');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('pragma: public');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
readfile($fileInfo['path']);
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
Open
header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
use \App\Controller\Traits\SettingsPermission;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$id = $request->getInteger('record');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Process.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('content-length: ' . filesize($fileInfo['path']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($fileInfo['path'] ?? null && file_exists($fileInfo['path'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('content-description: File Transfer');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
header('cache-control: must-revalidate');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Class name "Settings_Mail_DownloadAttachment_Action" is not in camel caps format Open
Open
class Settings_Mail_DownloadAttachment_Action extends Vtiger_Mass_Action
- Exclude checks