Function getSearchLabelQuery
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function getSearchLabelQuery(): Db\Query
{
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
->from('u_#__crmentity_search_label csl')
->innerJoin('vtiger_tab', 'csl.tabid = vtiger_tab.tabid')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getSearchLabelQuery
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSearchLabelQuery(): Db\Query
{
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
->from('u_#__crmentity_search_label csl')
->innerJoin('vtiger_tab', 'csl.tabid = vtiger_tab.tabid')
Method getLabelQuery
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getLabelQuery(): Db\Query
{
$query = (new \App\Db\Query())->select(['cl.crmid', 'cl.label', 'vtiger_crmentity.setype'])
->from('u_#__crmentity_label cl')->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid');
$where = ['and'];
Function getLabelQuery
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getLabelQuery(): Db\Query
{
$query = (new \App\Db\Query())->select(['cl.crmid', 'cl.label', 'vtiger_crmentity.setype'])
->from('u_#__crmentity_label cl')->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid');
$where = ['and'];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method getSearchLabelQuery() has an NPath complexity of 780. The configured NPath complexity threshold is 200. Open
public function getSearchLabelQuery(): Db\Query
{
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
->from('u_#__crmentity_search_label csl')
->innerJoin('vtiger_tab', 'csl.tabid = vtiger_tab.tabid')
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getSearchLabelQuery() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
public function getSearchLabelQuery(): Db\Query
{
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
->from('u_#__crmentity_search_label csl')
->innerJoin('vtiger_tab', 'csl.tabid = vtiger_tab.tabid')
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 26 to the 15 allowed. Open
public function getSearchLabelQuery(): Db\Query
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
The class RecordSearch has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13. Open
class RecordSearch
{
/** @var string Table name for search mechanisms */
public const SEARCH_TABLE_NAME = 'u_#__crmentity_search_label';
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '258', column '15'). Open
return (new \Vtiger_Field_Model())->set('name', 'search')->set('uitype', 1)->set('typeofdata', 'V~O')->set('maximumlength', 255);
- 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 __construct has a boolean flag argument $moduleName, which is a certain sign of a Single Responsibility Principle violation. Open
public function __construct($searchValue, $moduleName = false, int $limit = null)
- 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 '161', column '41'). Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(csl.searchlabel) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $word . '*'])]);
- 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 '315', column '25'). Open
$queryGenerator = new \App\QueryGenerator($moduleName, $userId);
- 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 '159', column '27'). Open
$query->andWhere(new \yii\db\Expression('1=0'));
- 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 '177', column '26'). Open
$conditions[] = new \yii\db\Expression("MATCH(csl.searchlabel) AGAINST(:findvalue{$key} IN BOOLEAN MODE)", [":findvalue{$key}" => $word]);
- 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 '217', column '17'). Open
$query = (new \App\Db\Query())->select(['cl.crmid', 'cl.label', 'vtiger_crmentity.setype'])
- 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 '235', column '41'). Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue . '*'])]);
- 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 '240', column '41'). Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue])]);
- 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 '340', column '22'). Open
$dataReader = (new \App\Db\Query())->select(['vtiger_tab.name'])->from('vtiger_entityname')
- 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 '179', column '41'). Open
$query->addSelect(['matcher' => new \yii\db\Expression(implode('+', $matcher), $params)]);
- 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 '\App\Purifier' in method 'getSearchResult'. Open
$row['label'] = \App\Purifier::decodeHtml($labels[$row['crmid']]);
- 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 '\App\Record' in method 'getSearchResult'. Open
$labels = \App\Record::getLabel(array_keys($rows));
- 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 '\Vtiger_Module_Model' in method 'getSearchableModules'. Open
$searchableModules[$moduleName] = \Vtiger_Module_Model::getInstance($moduleName);
- 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 '\App\User' in method 'getSearchableModules'. Open
$userId = $userId ?: \App\User::getCurrentUserId();
- 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
The method getSearchLabelQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$where[] = ['like', 'csl.searchlabel', $this->searchValue];
}
- 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
Avoid using static access to class '\vtlib\Functions' in method 'getSearchResult'. Open
$recordMeta = \vtlib\Functions::getCRMRecordMetadata($row['crmid']);
- 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
The method getQueryByModule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$searchTableName = self::LABEL_TABLE_NAME;
$searchColumnName = "{$searchTableName}.label";
}
- 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
Avoid using static access to class 'App\Cache' in method 'getSearchableModules'. Open
if (Cache::staticHas('getSearchableModules', $userId)) {
- 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 '\App\Privilege' in method 'getSearchResult'. Open
$row['permitted'] = \App\Privilege::isPermitted($row['setype'], 'DetailView', $row['crmid']);
- 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
The method getSearchLabelQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query->andWhere(new \yii\db\Expression('1=0'));
}
- 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
Avoid using static access to class '\Users_Privileges_Model' in method 'getSearchableModules'. Open
$userPrivModel = \Users_Privileges_Model::getInstanceById($userId);
- 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 '\App\Config' in method 'getSearchLabelQuery'. Open
if (2 === \App\Config::search('GLOBAL_SEARCH_SORTING_RESULTS')) {
- 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 assigning values to variables in if clauses and the like (line '203', column '8'). Open
public function parseWordForFullText(string $text): string
{
if (($word = preg_replace('/[><()~*"@+-]/', ' +', $text)) !== $text) {
$words = preg_split('/\s|\+/', $word, -1, PREG_SPLIT_NO_EMPTY);
$word = $words ? '+' . implode(' +', $words) : '';
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\App\User' in method '__construct'. Open
$this->userId = \App\User::getCurrentUserId();
- 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 assigning values to variables in if clauses and the like (line '156', column '9'). Open
public function getSearchLabelQuery(): Db\Query
{
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
->from('u_#__crmentity_search_label csl')
->innerJoin('vtiger_tab', 'csl.tabid = vtiger_tab.tabid')
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method getSearchLabelQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$modules = array_keys($searchableModules);
}
- 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
Avoid using static access to class 'App\Cache' in method 'getSearchableModules'. Open
return Cache::staticGet('getSearchableModules', $userId);
- 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 '\App\Config' in method '__construct'. Open
$limit = \App\Config::search('GLOBAL_SEARCH_MODAL_MAX_NUMBER_RESULT', 20);
- 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 '\Vtiger_Record_Model' in method 'getSearchResult'. Open
$recordInstance = \Vtiger_Record_Model::getCleanInstance($moduleName);
- 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 'App\Cache' in method 'getSearchableModules'. Open
Cache::staticSave('getSearchableModules', $userId, $searchableModules);
- 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 "vtiger_tab.name" 4 times. Open
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
- 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.
Define a constant instead of duplicating this literal "FulltextBegin" 3 times. Open
'PLL_FULLTEXT_BEGIN' => 'FulltextBegin',
- 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.
Define a constant instead of duplicating this literal "getSearchableModules" 3 times. Open
if (Cache::staticHas('getSearchableModules', $userId)) {
- 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.
Define a constant instead of duplicating this literal "setype" 3 times. Open
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
- 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.
Define a constant instead of duplicating this literal "Begin" 3 times. Open
'PLL_STARTS_WITH' => 'Begin',
- 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.
Define a constant instead of duplicating this literal "csl.searchlabel" 5 times. Open
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
- 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.
Define a constant instead of duplicating this literal "Contain" 3 times. Open
'PLL_CONTAINS' => 'Contain',
- 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.
Define a constant instead of duplicating this literal ":findvalue" 3 times. Open
$query->andWhere('MATCH(csl.searchlabel) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $word . '*']);
- 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.
Define a constant instead of duplicating this literal "matcher" 8 times. Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(csl.searchlabel) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $word . '*'])]);
- 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.
Define a constant instead of duplicating this literal "cl.label" 4 times. Open
$query = (new \App\Db\Query())->select(['cl.crmid', 'cl.label', 'vtiger_crmentity.setype'])
- 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.
Define a constant instead of duplicating this literal "crmid" 5 times. Open
->where(['vtiger_tab.presence' => 0])->indexBy('crmid');
- 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.
Define a constant instead of duplicating this literal "FulltextWord" 3 times. Open
'PLL_FULLTEXT_WORD' => 'FulltextWord',
- 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.
Move this "case default" clause to the end of this "switch" statement. Open
default:
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Define a constant instead of duplicating this literal ":searchValue" 3 times. Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(csl.searchlabel) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $word . '*'])]);
- 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.
Call to method __construct
from undeclared class \yii\db\Expression
Open
$query->andWhere(new \yii\db\Expression('1=0'));
- Exclude checks
Return type of getQueryByModule()
is undeclared type \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
public static function getQueryByModule(string $searchValue, string $moduleName, int $limit, int $userId = null): QueryGenerator
- Exclude checks
Return type of getSearchableModules()
is undeclared type \App\Vtiger_Module_Model[]
Open
public static function getSearchableModules(int $userId = null): array
- Exclude checks
Saw a token Phan may have failed to parse after '* @return Db\Query()|bool':
after Db\Query,
saw '('
Open
* @return Db\Query()|bool
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())->select(['cl.crmid', 'cl.label', 'vtiger_crmentity.setype'])
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue . '*'])]);
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$userId = $userId ?: \App\User::getCurrentUserId();
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$conditions[] = new \yii\db\Expression("MATCH(csl.searchlabel) AGAINST(:findvalue{$key} IN BOOLEAN MODE)", [":findvalue{$key}" => $word]);
- Exclude checks
Doc-block of $limit
in __construct
is phpdoc param type int
which is not a permitted replacement of the nullable param type ?int
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param int $limit
- Exclude checks
Call to method searchRecordCondition
from undeclared class \App\Vtiger_Module_Model
Open
$moduleModel->searchRecordCondition($query, $this);
- Exclude checks
Call to undeclared method \App\Db\Query::limit
Open
$query->limit($this->limit);
- Exclude checks
Saw a token Phan may have failed to parse after '* @return Db\Query()':
after Db\Query,
saw '('
Open
* @return Db\Query()
- Exclude checks
Doc-block of $limit
in getSearchResult
is phpdoc param type int
which is not a permitted replacement of the nullable param type ?int
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param int $limit
- Exclude checks
Call to undeclared method \App\Db\Query::all
Open
return $query->all();
- Exclude checks
Saw a token Phan may have failed to parse after '* @return Db\Query()':
after Db\Query,
saw '('
Open
* @return Db\Query()
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields(['id'])
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(csl.searchlabel) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $word . '*'])]);
- Exclude checks
Doc-block of $operator
in getSearchResult
is phpdoc param type string
which is not a permitted replacement of the nullable param type ?string
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param string $operator
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['vtiger_tab.name'])->from('vtiger_entityname')
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue])]);
- Exclude checks
Call to method getColumnName
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
->addJoin(['INNER JOIN', $searchTableName, "{$queryGenerator->getColumnName('id')} = {$searchTableName}.crmid"])
- Exclude checks
Doc-block of $userId
in getQueryByModule
is phpdoc param type int
which is not a permitted replacement of the nullable param type ?int
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param int $userId
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->userId = \App\User::getCurrentUserId();
- Exclude checks
Returning type false
but getQuery()
is declared to return \App\Db\Query
Open
return false;
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$query->addSelect(['matcher' => new \yii\db\Expression(implode('+', $matcher), $params)]);
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = new \App\QueryGenerator($moduleName, $userId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PLL_FULLTEXT_WORD' => 'FulltextWord',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PLL_FULLTEXT_BEGIN' => 'FulltextBegin',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $limit;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Table name for search mechanisms */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Table name for labels */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const LABEL_MODE = 0;
- 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
'PLL_CONTAINS' => 'Contain',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Operators.
- 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 $searchValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const LABEL_TABLE_NAME = 'u_#__crmentity_label';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const SEARCH_MODE = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const OPERATORS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PLL_STARTS_WITH' => 'Begin',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $userId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const SEARCH_TABLE_NAME = 'u_#__crmentity_search_label';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Search mode for labels */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Search mode for search engines */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PLL_ENDS_WITH' => 'End',
- 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
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->limit) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['vtiger_tab.name' => $modules]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'csl.searchlabel', "{$this->searchValue}%", false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'End':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addOrderBy(['matcher' => SORT_DESC]);
- 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 $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->getSearchLabelQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('u_#__crmentity_search_label csl')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->orderBy('vtiger_entityname.sequence');
- Exclude checks
Line exceeds 120 characters; contains 170 characters Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(csl.searchlabel) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $word . '*'])]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$conditions[] = new \yii\db\Expression("MATCH(csl.searchlabel) AGAINST(:findvalue{$key} IN BOOLEAN MODE)", [":findvalue{$key}" => $word]);
- 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->userId = \App\User::getCurrentUserId();
- 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
case self::LABEL_MODE:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- 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
$query->andWhere('MATCH(csl.searchlabel) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $word . '*']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params[":searchValue{$key}"] = $word;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($this->searchValue, '*') || false !== strpos($this->searchValue, '_')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'csl.searchlabel', $this->searchValue];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->andWhere($where);
- 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->searchValue = $searchValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return self
- 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
$where = ['and'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (preg_match('/[><()~*"@+-]/', $this->searchValue)) {
- 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 getQuery()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($this->operator) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Construct.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $searchValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$limit) {
- 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 search()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->limit($this->limit);
- 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
default:
- 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
$modules = \is_array($this->moduleName) ? $this->moduleName : [$this->moduleName];
- 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
$where[] = ['like', 'csl.userid', ",{$this->userId},"];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'csl.searchlabel', "%{$this->searchValue}", false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $entityName = 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
$matcher[] = "MATCH(csl.searchlabel) AGAINST(:searchValue{$key} IN BOOLEAN MODE)";
- 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
$where[] = ['like', 'csl.searchlabel', str_replace('*', '%', "%{$this->searchValue}%"), false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Db\Query()|bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Parse text for Full-Text Search.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new Db\Query())->select(['csl.crmid', 'setype' => 'vtiger_tab.name', 'csl.searchlabel'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_entityname', 'vtiger_tab.tabid = vtiger_entityname.tabid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchableModules = self::getSearchableModules();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 === \App\Config::search('GLOBAL_SEARCH_SORTING_RESULTS')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($words as $key => $word) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table = self::SEARCH_MODE;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $checkPermissions = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$limit = \App\Config::search('GLOBAL_SEARCH_MODAL_MAX_NUMBER_RESULT', 20);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $mode
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Search record.
- 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
->where(['vtiger_tab.presence' => 0])->indexBy('crmid');
- 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
if ($this->checkPermissions) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$words = preg_split('/\s/', $this->searchValue, -1, PREG_SPLIT_NO_EMPTY);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$words[$key] = $this->parseWordForFullText($word);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matcher = $params = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addOrderBy(['matcher' => SORT_DESC]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $moduleName
- 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
if (method_exists($moduleModel, 'searchRecordCondition')) {
- 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
case 'Begin':
- 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->moduleName = $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case self::SEARCH_MODE:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->getLabelQuery();
- 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
if (\count($modules) !== \count($searchableModules)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = array_keys($searchableModules);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($words as $key => $word) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere($conditions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- 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
* Get query.
- 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 Db\Query()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSearchLabelQuery(): Db\Query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(new \yii\db\Expression('1=0'));
- 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
* Set search mode.
- 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->table = $mode;
- 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
->innerJoin('vtiger_tab', 'csl.tabid = vtiger_tab.tabid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = array_intersect($modules, array_keys($searchableModules));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->limit = (int) $limit;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = $searchableModules[$moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setMode(int $mode): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'FulltextBegin':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$query->andWhere('MATCH(csl.searchlabel) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $word . '*']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get search label query.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- 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
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($modules as $moduleName) {
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'FulltextWord':
- 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
$conditions = ['or'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addSelect(['matcher' => new \yii\db\Expression(implode('+', $matcher), $params)]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $text
- 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
if ($word = $this->parseWordForFullText($this->searchValue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$words = [$this->searchValue];
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
$conditions[] = new \yii\db\Expression("MATCH(csl.searchlabel) AGAINST(:findvalue{$key} IN BOOLEAN MODE)", [":findvalue{$key}" => $word]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $operator = 'Contain';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $limit
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct($searchValue, $moduleName = false, int $limit = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = $this->getQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($this->table) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->searchRecordCondition($query, $this);
- 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
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(csl.searchlabel) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $word . '*'])]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- 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
case 'Contain':
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$query->andWhere('MATCH(cl.label) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $this->searchValue . '*']);
- 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
if (isset(self::getSearchableModules()[$moduleName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchTableName = self::SEARCH_TABLE_NAME;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setLimit($limit);
- 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
$words = preg_split('/\s|\+/', $word, -1, PREG_SPLIT_NO_EMPTY);
- 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
$where = ['and'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get field model for search mechanism.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the list of records matching the search key.
- 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
$recordMeta = \vtlib\Functions::getCRMRecordMetadata($row['crmid']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setCustomColumn(['search_label' => $searchColumnName])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivModel = \Users_Privileges_Model::getInstanceById($userId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_tab', 'vtiger_tab.tabid=vtiger_entityname.tabid')
- 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
switch ($this->operator) {
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$query->andWhere('MATCH(cl.label) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $this->searchValue]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->checkPermissions) {
- 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 $limit
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordSearch->operator = $operator;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['id'] = $row['crmid'];
- 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
if ($this->moduleName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'vtiger_crmentity.users', ",$this->userId,"];
- 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
$labels = \App\Record::getLabel(array_keys($rows));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['label'] = \App\Purifier::decodeHtml($labels[$row['crmid']]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['permitted'] = \App\Privilege::isPermitted($row['setype'], 'DetailView', $row['crmid']);
- 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
* Mainly used in autocomplete mechanisms.
- 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
$searchableModules[$moduleName] = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $word;
- 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
->from('u_#__crmentity_label cl')->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['vtiger_crmentity.setype' => $this->moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'cl.label', "{$this->searchValue}%", false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'cl.label', $this->searchValue];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['createdtime'] = $recordMeta['createdtime'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $matchingRecords;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $searchValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($word = preg_replace('/[><()~*"@+-]/', ' +', $text)) !== $text) {
- 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
$query = (new \App\Db\Query())->select(['cl.crmid', 'cl.label', 'vtiger_crmentity.setype'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'FulltextBegin':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addOrderBy(['matcher' => SORT_DESC]);
- 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 (new \Vtiger_Field_Model())->set('name', 'search')->set('uitype', 1)->set('typeofdata', 'V~O')->set('maximumlength', 255);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|string[] $module
- 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
$row['assigned_user_id'] = $recordMeta['smownerid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* The function creates a query gets data from the module with user rights, taking into account special tables.
- 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 $limit
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Vtiger_Module_Model[] List of Vtiger_Module_Model instances
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue . '*'])]);
- 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|null $userId
- 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
$userId = $userId ?: \App\User::getCurrentUserId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::staticGet('getSearchableModules', $userId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['vtiger_tab.name'])->from('vtiger_entityname')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_tab.presence' => 0, 'turn_off' => 1])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['not', ['vtiger_tab.name' => 'Users']])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$where[] = ['like', 'cl.label', "%{$this->searchValue}", false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue])]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere('MATCH(cl.label) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $this->searchValue]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSearchResult($searchKey, $module = null, int $limit = null, string $operator = null): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordSearch = new self($searchKey, $module, $limit);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = new \App\QueryGenerator($moduleName, $userId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->addNativeCondition(['like', $searchColumnName, $searchValue])
- 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
$word = $words ? '+' . implode(' +', $words) : '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Db\Query()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Begin':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- 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 string $searchKey
- 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
$searchColumnName = "{$searchTableName}.searchlabel";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the list of all searchable modules.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSearchableModules(int $userId = null): 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
return $queryGenerator;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchableModules = [];
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->andWhere($where);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rows = $recordSearch->search();
- 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
->addJoin(['INNER JOIN', $searchTableName, "{$queryGenerator->getColumnName('id')} = {$searchTableName}.crmid"])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get label query.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->addOrderBy(['matcher' => SORT_DESC]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
public static function getSearchResult($searchKey, $module = null, int $limit = null, string $operator = null): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matchingRecords = [];
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
public static function getQueryByModule(string $searchValue, string $moduleName, int $limit, int $userId = null): QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($userPrivModel->hasModuleActionPermission($moduleName, 'DetailView')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function parseWordForFullText(string $text): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere('MATCH(cl.label) AGAINST(:findvalue IN BOOLEAN MODE)', [':findvalue' => $this->searchValue . '*']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
->addJoin(['INNER JOIN', $searchTableName, "{$queryGenerator->getColumnName('id')} = {$searchTableName}.crmid"])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::staticHas('getSearchableModules', $userId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $searchableModules;
- 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
Line exceeds 120 characters; contains 176 characters Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue . '*'])]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
return (new \Vtiger_Field_Model())->set('name', 'search')->set('uitype', 1)->set('typeofdata', 'V~O')->set('maximumlength', 255);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($operator) {
- 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
$searchTableName = self::LABEL_TABLE_NAME;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setFields(['id'])
- 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
while ($moduleName = $dataReader->readColumn(0)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::staticSave('getSearchableModules', $userId, $searchableModules);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'End':
- 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
* Used in the global search engine.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $operator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($rows as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordInstance = \Vtiger_Record_Model::getCleanInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matchingRecords[$moduleName][$row['id']] = $recordInstance->setData($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getQueryByModule(string $searchValue, string $moduleName, int $limit, int $userId = null): QueryGenerator
- 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 getLabelQuery(): Db\Query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'FulltextWord':
- Exclude checks
Line exceeds 120 characters; contains 170 characters Open
$query->addSelect(['matcher' => new \yii\db\Expression('MATCH(cl.label) AGAINST(:searchValue IN BOOLEAN MODE)', [':searchValue' => $this->searchValue])]);
- 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
public static function getSearchField(): \Vtiger_Field_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $row['setype'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $userId
- 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
$searchColumnName = "{$searchTableName}.label";
- Exclude checks