Avoid using undefined variables such as '$ret' which will lead to PHP notices. Open
$ret['average'] = isset($average) ? $average : 0;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$ret' which will lead to PHP notices. Open
$ret['sum'] = isset($sum) ? $sum : 0;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$ret' which will lead to PHP notices. Open
return $ret;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '157', column '30'). Open
$this->pluginsObject = new icms_plugins_Handler();
- 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 '218', column '22'). Open
$criteria->add(new icms_db_criteria_Item('dirname', $dirname));
- 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 '22'). Open
$criteria->add(new icms_db_criteria_Item('itemid', (int) $itemid));
- 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 '215', column '19'). Open
$criteria = new icms_db_criteria_Compo();
- 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 '216', column '22'). Open
$criteria->add(new icms_db_criteria_Item('item', $item));
- 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 '219', column '22'). Open
$criteria->add(new icms_db_criteria_Item('user.uid', (int) $uid));
- 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 'icms_member_user_Handler' in method 'name'. Open
return icms_member_user_Handler::getUserLink($this->getVar('uid', 'e'), TRUE, array());
- 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 'icms_member_user_Handler' in method 'getUnameValue'. Open
return icms_member_user_Handler::getUserLink($this->getVar('uid'));
- 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 already_rated uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return $ret[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
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('itemid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_ITEMID);
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_INT
Open
$this->quickInitVar('uid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_UID);
- Exclude checks
Parameter $item
has undeclared type \str
Open
public function getRatingAverageByItemId($itemid, $dirname, $item) {
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item('dirname', $dirname));
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item('user.uid', (int) $uid));
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_INT
Open
$this->quickInitVar('ratingid', XOBJ_DTYPE_INT, TRUE);
- Exclude checks
Call to method getUserLink
from undeclared class \icms_member_user_Handler
Open
return icms_member_user_Handler::getUserLink($this->getVar('uid'));
- Exclude checks
Class extends undeclared class \icms_ipf_Handler
Open
class SystemRatingHandler extends icms_ipf_Handler {
- Exclude checks
Reference to undeclared property \SystemRatingHandler->_itemname
Open
$this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid';
- Exclude checks
Reference to undeclared property \SystemRatingHandler->db
Open
list($average, $sum) = $this->db->fetchRow($result);
- Exclude checks
Call to undeclared method \SystemRatingHandler::getObjects
Open
$ret = $this->getObjects($criteria);
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_TXTBOX
Open
$this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_DIRNAME);
- Exclude checks
Call to undeclared method \SystemRating::setControl
Open
$this->setControl('item', array('object' => &$this, 'method' => 'getItemList'));
- Exclude checks
Reference to undeclared property \SystemRating->handler
Open
$moduleArray = $this->handler->getModuleList();
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_TXTBOX
Open
$this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_ITEM);
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_INT
Open
$this->quickInitVar('rate', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_RATE);
- Exclude checks
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('rate', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_RATE);
- Exclude checks
Reference to undeclared class \icms_ipf_Object
Open
return parent::getVar($key, $format);
- Exclude checks
Reference to undeclared property \SystemRatingHandler->db
(Did you mean $db) Open
$this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid';
- Exclude checks
Call to method __construct
from undeclared class \icms_plugins_Handler
Open
$this->pluginsObject = new icms_plugins_Handler();
- Exclude checks
Suspicious array access to false
Open
$this->_moduleList[$k] = $v;
- Exclude checks
Parameter $dirname
has undeclared type \str
Open
public function already_rated($item, $itemid, $dirname, $uid) {
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Compo
Open
$criteria = new icms_db_criteria_Compo();
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item('item', $item));
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item('user.uid', (int) $uid));
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_INT
Open
$this->quickInitVar('itemid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_ITEMID);
- Exclude checks
Call to undeclared method \SystemRating::setControl
Open
$this->setControl('dirname', array('method' => 'getModuleList', 'onSelect' => 'submit'));
- Exclude checks
Reference to undeclared property \SystemRatingHandler->db
Open
$result = $this->db->query($sql);
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item('itemid', (int) $itemid));
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_LTIME
Open
$this->quickInitVar('date', XOBJ_DTYPE_LTIME, TRUE, _CO_ICMS_RATING_DATE);
- Exclude checks
Returning type false
but getModuleList()
is declared to return array
Open
return $this->_moduleList;
- Exclude checks
Call to method getUserLink
from undeclared class \icms_member_user_Handler
Open
return icms_member_user_Handler::getUserLink($this->getVar('uid', 'e'), TRUE, array());
- Exclude checks
Reference to undeclared property \SystemRatingHandler->table
Open
$this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid';
- Exclude checks
Class extends undeclared class \icms_ipf_Object
Open
class SystemRating extends icms_ipf_Object {
- Exclude checks
Suspicious array access to false
Open
$this->_moduleList[0] = _CO_ICMS_MAKE_SELECTION;
- Exclude checks
Reference to undeclared class \icms_ipf_Object
Open
parent::__construct($handler);
- Exclude checks
Parameter $item
has undeclared type \str
Open
public function already_rated($item, $itemid, $dirname, $uid) {
- Exclude checks
Reference to undeclared property \SystemRating->handler
Open
$this->_modulePlugin = $this->handler->pluginsObject->getPlugin('rating', $this->getVar('dirname', 'n'));
- Exclude checks
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('ratingid', XOBJ_DTYPE_INT, TRUE);
- Exclude checks
Call to method getPluginsArray
from undeclared class \icms_plugins_Handler
Open
$moduleArray = $this->pluginsObject->getPluginsArray('rating');
- Exclude checks
Assigning array<int></int>
to property but \SystemRatingHandler->_moduleList
is false
Open
$this->_moduleList[0] = _CO_ICMS_MAKE_SELECTION;
- Exclude checks
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_DIRNAME);
- Exclude checks
Reference to undeclared class \icms_ipf_Handler
Open
parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'system');
- Exclude checks
Assigning array
to property but \SystemRatingHandler->_moduleList
is false
Open
$this->_moduleList[$k] = $v;
- Exclude checks
Parameter $dirname
has undeclared type \str
Open
public function getRatingAverageByItemId($itemid, $dirname, $item) {
- Exclude checks
Variable $ret
was undeclared, but array fields are being added to it. Open
$ret['average'] = isset($average) ? $average : 0;
- Exclude checks
Call to undeclared method \SystemRating::setControl
Open
$this->setControl('rate', array('method' => 'getRateList'));
- Exclude checks
Reference to undeclared property \SystemRatingHandler->generalSQL
Open
$this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid';
- Exclude checks
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('date', XOBJ_DTYPE_LTIME, TRUE, _CO_ICMS_RATING_DATE);
- Exclude checks
Call to undeclared method \SystemRating::setControl
Open
$this->setControl('uid', 'user');
- Exclude checks
Saw unextractable annotation for comment '* @return'
Open
* @return
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item('itemid', (int) $itemid));
- Exclude checks
Call to method __construct
from undeclared class \icms_db_criteria_Item
Open
$criteria->add(new icms_db_criteria_Item('dirname', $dirname));
- Exclude checks
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('uid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_UID);
- Exclude checks
Call to undeclared method \SystemRating::quickInitVar
Open
$this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_ITEM);
- Exclude checks
Call to method add
from undeclared class \icms_db_criteria_Compo
Open
$criteria->add(new icms_db_criteria_Item('item', $item));
- Exclude checks
Reference to undeclared constant \XOBJ_DTYPE_TXTBOX
Open
$this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_ICMS_RATING_NAME);
- Exclude checks
Call to undeclared method \SystemRating::initNonPersistableVar
Open
$this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_ICMS_RATING_NAME);
- Exclude checks
Suspicious type \str
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$sql = "SELECT AVG(rate), COUNT(ratingid) FROM " . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid";
- Exclude checks
Reference to undeclared property \SystemRatingHandler->table
Open
$sql = "SELECT AVG(rate), COUNT(ratingid) FROM " . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid";
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SystemRating extends icms_ipf_Object {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class SystemRatingHandler extends icms_ipf_Handler {
- Exclude checks
The property $_moduleList is not named in camelCase. Open
class SystemRatingHandler extends icms_ipf_Handler {
public $_rateOptions = array();
public $_moduleList = FALSE;
public $pluginsObject;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
public function __construct($db) {
- 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 property $_modulePlugin is not named in camelCase. Open
class SystemRating extends icms_ipf_Object {
/** */
public $_modulePlugin = FALSE;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_rateOptions is not named in camelCase. Open
class SystemRatingHandler extends icms_ipf_Handler {
public $_rateOptions = array();
public $_moduleList = FALSE;
public $pluginsObject;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Each class must be in a file by itself Open
class SystemRatingHandler extends icms_ipf_Handler {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('uid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_UID);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
public $_modulePlugin = FALSE;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_DIRNAME);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('date', XOBJ_DTYPE_LTIME, TRUE, _CO_ICMS_RATING_DATE);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
return icms_member_user_Handler::getUserLink($this->getVar('uid', 'e'), TRUE, array());
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('itemid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_ITEMID);
- Exclude checks
Expected 1 space before "=>"; 0 found Open
foreach ($moduleArray as $k=>$v) {
- Exclude checks
Method name "SystemRatingHandler::already_rated" is not in camel caps format Open
public function already_rated($item, $itemid, $dirname, $uid) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_ITEM);
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
public $_moduleList = FALSE;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('rate', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_RATE);
- Exclude checks
Expected 1 space after "=>"; 0 found Open
foreach ($moduleArray as $k=>$v) {
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
return FALSE;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
$this->quickInitVar('ratingid', XOBJ_DTYPE_INT, TRUE);
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Whitespace found at end of line Open
* Retrieve the username associated with a rating
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
The method already_rated is not named in camelCase. Open
public function already_rated($item, $itemid, $dirname, $uid) {
$criteria = new icms_db_criteria_Compo();
$criteria->add(new icms_db_criteria_Item('item', $item));
$criteria->add(new icms_db_criteria_Item('itemid', (int) $itemid));
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
Unexpected trailing spaces found. Open
* Retrieve the username associated with a rating
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected trailing spaces found. Open
*
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected trailing spaces found. Open
*
- Exclude checks
Unexpected trailing spaces found. Open
*
- Exclude checks
Unexpected trailing spaces found. Open
*
- Exclude checks
Unexpected trailing spaces found. Open
*
- Exclude checks