getConfigurations accesses the super-global variable $_REQUEST. Open
public function getConfigurations()
{
check_ajax_referer( 'kb-read' );
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Avoid using static access to class '\Kontentblocks\Language\I18n' in method 'metaBox'. Open
$i18n = I18n::getPackage( 'Extensions.layoutConfigs' );
- 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 getConfigurations uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
wp_send_json_error();
}
- 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 unused parameters such as '$post_id'. Open
private function _deleteConfiguration( $config, $id, $post_id )
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
TODO found Open
* @TODO add message for success/failure
- Exclude checks
The parameter $post_id is not named in camelCase. Open
private function _deleteConfiguration( $config, $id, $post_id )
{
$configurations = get_option( 'kb_layout_configurations' );
$bucket = ( !empty( $configurations[$config] ) ) ? $configurations[$config] : array();
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
private function _deleteConfiguration( $config, $id, $post_id )
- 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 parameter $post_id is not named in camelCase. Open
private function saveConfiguration( $config, $name, $post_id )
{
$configurations = get_option( 'kb_layout_configurations' );
$id = sanitize_title( $name );
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $post_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = sanitize_title( $name );
- 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
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 1;
- 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 parameter $post_id is not named in camelCase. Open
private function normalizeConfiguration( $post_id )
{
$collection = array();
$layout = get_post_meta( $post_id, 'kb_kontentblocks', true );
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The variable $post_id is not named in camelCase. Open
private function normalizeConfiguration( $post_id )
{
$collection = array();
$layout = get_post_meta( $post_id, 'kb_kontentblocks', true );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $setup_data is not named in camelCase. Open
public function observeQuery()
{
$input = filter_input_array(
INPUT_GET,
array(
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $setup_data is not named in camelCase. Open
public function observeQuery()
{
$input = filter_input_array(
INPUT_GET,
array(
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $Storage is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
private function saveConfiguration( $config, $name, $post_id )
{
$configurations = get_option( 'kb_layout_configurations' );
$id = sanitize_title( $name );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $new_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
public function setConfiguration()
{
check_ajax_referer( 'kb-update' );
$data = $this->parseAjaxRequest();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $new_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $Storage is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $new_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
public function deleteConfiguration()
{
check_ajax_referer( 'kb-delete' );
$data = $this->parseAjaxRequest();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
public function deleteConfiguration()
{
check_ajax_referer( 'kb-delete' );
$data = $this->parseAjaxRequest();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $new_id is not named in camelCase. Open
private function prepareFromConfiguration( $index, $post_id )
{
$i = 1;
$collection = array();
$Storage = new ModuleStorage( $post_id );
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $post_id is not named in camelCase. Open
public function setConfiguration()
{
check_ajax_referer( 'kb-update' );
$data = $this->parseAjaxRequest();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method _deleteConfiguration is not named in camelCase. Open
private function _deleteConfiguration( $config, $id, $post_id )
{
$configurations = get_option( 'kb_layout_configurations' );
$bucket = ( !empty( $configurations[$config] ) ) ? $configurations[$config] : array();
- 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() {
}
}