Missing class import via use statement (line '138', column '18'). Open
$request = new \App\Request([], false);
- 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 '116', column '18'). Open
$request = new \App\Request([], false);
- 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 '41', column '24'). Open
$fieldInstance = new \vtlib\Field();
- 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 '\Vtiger_Field_Model' in method 'createFieldModel'. Open
return self::$fields[$key] = \Vtiger_Field_Model::getInstanceFromFieldObject($fieldInstance);
- 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
Define a constant instead of duplicating this literal "varchar(255)" 20 times. Open
[5, 'D~O', 'varchar(255)', '2018-07-02'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Assigning 'custom_sender'
to property but \vtlib\Field->column
is false
Open
$fieldInstance->column = 'custom_sender';
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::expectExceptionCode
Open
$this->expectExceptionCode(406);
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::expectExceptionCode
Open
$this->expectExceptionCode(406);
- Exclude checks
Assigning 'vtiger_contactsubdetails'
to property but \vtlib\Field->table
is false
Open
$fieldInstance->table = 'vtiger_contactsubdetails';
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::expectExceptionCode
Open
$this->expectExceptionCode(406);
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::assertNull
Open
$this->assertNull($fieldModel->getUITypeModel()->setDefaultValueFromRequest($request));
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::assertNull
Open
$this->assertNull($fieldModel->getUITypeModel()->validate($value, true));
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::assertSame
Open
$this->assertSame($value, $fieldModel->get('defaultvalue'));
- Exclude checks
Call to undeclared method \Tests\App\FieldModel::assertNull
Open
$this->assertNull($fieldModel->getUITypeModel()->validate($value, false));
- Exclude checks
Assigning string
to property but \vtlib\Field->columntype
is false
Open
$fieldInstance->columntype = $columnType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $columnType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test validate for wrong data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function providerGoodDataForDefault()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $fields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('val', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Data provider for the test of correct data. For the "setDefaultValueFromRequest" method test.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function createFieldModel(int $uiType, string $typeOfData, string $columnType)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerGoodData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNull($fieldModel->getUITypeModel()->validate($value, false));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $typeOfData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test default value for wrong data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\Security
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '2018-07-02'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : first day of next month)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testValidateGoodData(int $uiType, string $typeOfData, string $columnType, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test validate for user format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testValidateWrongData(int $uiType, string $typeOfData, string $columnType, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = self::createFieldModel($uiType, $typeOfData, $columnType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '201872a'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$date : now$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->label = 'FL_LABEL';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $uiType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testValidateUserFormatWrongData(int $uiType, string $typeOfData, string $columnType, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->getUITypeModel()->validate($value, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDefaultValueGoodData(int $uiType, string $typeOfData, string $columnType, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = new \App\Request([], false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function providerWrongData()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '(date : now)'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->getUITypeModel()->setDefaultValueFromRequest($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Data provider for the test of wrong data. For the "validate" method test.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : yesterday)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->expectExceptionCode(406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '2018-72-12'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : monday next week)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : last day of this month)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '201807o2'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance = new \vtlib\Field();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->expectExceptionCode(406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->expectExceptionCode(406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Data provider for the test of correct data. For the "validate" method test.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var \Vtiger_Field_Model[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $uiType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->name = 'custom_sender';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->uitype = $uiType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $columnType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNull($fieldModel->getUITypeModel()->validate($value, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerWrongData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function providerGoodData()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Data provider for the test of wrong data. For the "setDefaultValueFromRequest" method test.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$fields[$key] = \Vtiger_Field_Model::getInstanceFromFieldObject($fieldInstance);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test validate for good data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Create Vtiger_Field_Model for tests.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $uiType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $typeOfData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = self::createFieldModel($uiType, $typeOfData, $columnType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $columnType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = self::createFieldModel($uiType, $typeOfData, $columnType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request->set('val', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->name = 'val';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $columnType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', 20180612],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : tomorrow)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : first day of this month)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', 20180612],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$key = \md5($uiType . $typeOfData . $columnType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->typeofdata = $typeOfData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = self::createFieldModel($uiType, $typeOfData, $columnType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $typeOfData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $columnType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerWrongData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = self::createFieldModel($uiType, $typeOfData, $columnType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->name = 'val';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = new \App\Request([], false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $uiType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '2018-07-02'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Vtiger_Field_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(self::$fields[$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->column = 'custom_sender';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $uiType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\Security
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerGoodDataForDefault
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDefaultValueWrongData(int $uiType, string $typeOfData, string $columnType, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $typeOfData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$fields[$key];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->table = 'vtiger_contactsubdetails';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->columntype = $columnType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $typeOfData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $columnType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->getUITypeModel()->validate($value, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNull($fieldModel->getUITypeModel()->setDefaultValueFromRequest($request));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($value, $fieldModel->get('defaultvalue'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $typeOfData
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerWrongDataForDefault
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : monday this week)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function providerWrongDataForDefault()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '$(date : now)$'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $uiType
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test default value for good data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', '-2018-02-12'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[5, 'D~O', 'varchar(255)', 'abc'],
- Exclude checks