modules/Vtiger/models/CssScript.php
Remove error control operator '@' on line 74. Open
Open
public function getHref()
{
$href = $this->get('href');
if (empty($href)) {
$href = $this->get('linkurl');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Avoid assigning values to variables in if clauses and the like (line '74', column '29'). Open
Open
public function getHref()
{
$href = $this->get('href');
if (empty($href)) {
$href = $this->get('linkurl');
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Vtiger_CssScript_Model extends \App\Base
- Exclude checks
Avoid variables with short names like $fs. Configured minimum length is 3. Open
Open
if ($this->has('base') && $fs = @filemtime($this->get('base'))) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class Vtiger_CssScript_Model is not named in CamelCase. Open
Open
class Vtiger_CssScript_Model extends \App\Base
{
const DEFAULT_REL = 'stylesheet';
const DEFAULT_MEDIA = 'all';
const DEFAULT_TYPE = 'text/css';
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get the media attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get the href attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$href = $this->get('href');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const DEFAULT_MEDIA = 'all';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const DEFAULT_REL = 'stylesheet';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$type = $this->get('type');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const LESS_REL = 'stylesheet/less';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$rel = $this->get('rel');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const DEFAULT_TYPE = 'text/css';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($this->has('base') && $fs = @filemtime($this->get('base'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$media = $this->get('media');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get the rel attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (empty($type)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$href = $this->get('linkurl');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getType()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getHref()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getRel()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $href;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getMedia()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $media;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$href = $href . '?s=' . $fs;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (empty($href)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (empty($media)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$media = self::DEFAULT_MEDIA;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$rel = self::DEFAULT_REL;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $rel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (empty($rel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get the type attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$type = self::DEFAULT_TYPE;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$linkModel = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static function getInstanceFromLinkObject(vtlib\Link $linkObj)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$objectProperties = get_object_vars($linkObj);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$linkModel->{$properName} = $propertyValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $linkModel->setData($objectProperties);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get the instance of CSS Script model from a given vtlib\Link object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param vtlib\Link $linkObj
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($objectProperties as $properName => $propertyValue) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return Vtiger_CssScript_Model instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Class name "Vtiger_CssScript_Model" is not in camel caps format Open
Open
class Vtiger_CssScript_Model extends \App\Base
- Exclude checks