Backoffice/Form/Type/Extension/FormTypeGroupExtension.php
Function buildView
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public function buildView(FormView $view, FormInterface $form, array $options)
{
if ($form->getConfig()->getAttribute('group_enabled')) {
$view->vars['group'] = array();
$groupRender = $form->getConfig()->getAttribute('group_render');
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid unused parameters such as '$options'. Open
Open
public function buildView(FormView $view, FormInterface $form, array $options)
- Read upRead up
- Create a ticketCreate a ticket
- 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
Call to method setAttribute
from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open
Open
$builder->setAttribute('sub_group_id', $options['sub_group_id']);
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
$view->vars['group'] = $this->ksortRecursive($view->vars['group']);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $form
has undeclared type \Symfony\Component\Form\FormInterface
Open
Open
public function buildView(FormView $view, FormInterface $form, array $options)
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (search)
is string
but \array_key_exists()
takes array
Open
Open
if (array_key_exists($id, $reference)) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
if (!array_key_exists($groupKey, $view->vars['group'])) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method setAttribute
from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open
Open
$builder->setAttribute('group_id', $options['group_id']);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getConfig
from undeclared class \Symfony\Component\Form\FormInterface
Open
Open
$groupRender = $form->getConfig()->getAttribute('group_render');
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
array_push($view->vars['group'][$groupKey][$subGroupKey]['children'], $child->getName());
- Create a ticketCreate a ticket
- Exclude checks
Call to method getConfig
from undeclared class \Symfony\Component\Form\FormInterface
Open
Open
$id = $form->getConfig()->getAttribute($id);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $builder
has undeclared type \Symfony\Component\Form\FormBuilderInterface
Open
Open
public function buildForm(FormBuilderInterface $builder, array $options)
- Create a ticketCreate a ticket
- Exclude checks
Parameter $view
has undeclared type \Symfony\Component\Form\FormView
Open
Open
public function buildView(FormView $view, FormInterface $form, array $options)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getConfig
from undeclared class \Symfony\Component\Form\FormInterface
Open
Open
$view->vars['group_enabled'] = $form->getConfig()->getAttribute('group_enabled');
- Create a ticketCreate a ticket
- Exclude checks
Parameter $form
has undeclared type \Symfony\Component\Form\FormInterface
Open
Open
protected function generateKeyLabel(FormInterface $form, $id, $default, $reference)
- Create a ticketCreate a ticket
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'label',
but expected the index to be of type int
Open
Open
$label = array_key_exists('label', $reference[$id]) ? $reference[$id]['label'] : $id;
- Create a ticketCreate a ticket
- Exclude checks
Call to method setAttribute
from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open
Open
$builder->setAttribute('group_render', $options['group_render']);
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
if (!array_key_exists($subGroupKey, $view->vars['group'][$groupKey])) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
$view->vars['group_enabled'] = $form->getConfig()->getAttribute('group_enabled');
- Create a ticketCreate a ticket
- Exclude checks
Call to method setAttribute
from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open
Open
$builder->setAttribute('group_enabled', $options['group_enabled']);
- Create a ticketCreate a ticket
- Exclude checks
Call to method setAttribute
from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open
Open
$builder->setAttribute('sub_group_render', $options['sub_group_render']);
- Create a ticketCreate a ticket
- Exclude checks
Call to method all
from undeclared class \Symfony\Component\Form\FormInterface
Open
Open
foreach ($form->all() as $child) {
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (search)
is string
but \array_key_exists()
takes array
Open
Open
$label = array_key_exists('label', $reference[$id]) ? $reference[$id]['label'] : $id;
- Create a ticketCreate a ticket
- Exclude checks
Call to method getConfig
from undeclared class \Symfony\Component\Form\FormInterface
Open
Open
$subGroupRender = $form->getConfig()->getAttribute('sub_group_render');
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
$view->vars['group'][$groupKey] = array();
- Create a ticketCreate a ticket
- Exclude checks
Call to method setDefaults
from undeclared class \Symfony\Component\OptionsResolver\OptionsResolver
Open
Open
$resolver->setDefaults(array(
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \Symfony\Component\Form\AbstractTypeExtension
Open
Open
class FormTypeGroupExtension extends AbstractTypeExtension
- Create a ticketCreate a ticket
- Exclude checks
Parameter $resolver
has undeclared type \Symfony\Component\OptionsResolver\OptionsResolver
Open
Open
public function configureOptions(OptionsResolver $resolver)
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (search)
is string
but \array_key_exists()
takes array
Open
Open
$key = array_key_exists('rank', $reference[$id]) ? $reference[$id]['rank'] : $id;
- Create a ticketCreate a ticket
- Exclude checks
When fetching an array index from a value of type string,
found an array index of type 'rank',
but expected the index to be of type int
Open
Open
$key = array_key_exists('rank', $reference[$id]) ? $reference[$id]['rank'] : $id;
- Create a ticketCreate a ticket
- Exclude checks
Call to method getConfig
from undeclared class \Symfony\Component\Form\FormInterface
Open
Open
if ($form->getConfig()->getAttribute('group_enabled')) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
$view->vars['group'][$groupKey][$subGroupKey] = array(
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property vars
from undeclared class \Symfony\Component\Form\FormView
Open
Open
$view->vars['group'] = array();
- Create a ticketCreate a ticket
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
Open
protected function generateKeyLabel(FormInterface $form, $id, $default, $reference)
- Read upRead up
- Create a ticketCreate a ticket
- 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
PHP keywords must be lowercase; expected "const" but found "CONST" Open
Open
CONST DEFAULT_GROUP = '_default_group';
- Create a ticketCreate a ticket
- Exclude checks
PHP keywords must be lowercase; expected "const" but found "CONST" Open
Open
CONST DEFAULT_SUB_GROUP = '_default_sub_group';
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
Open
list($subGroupKey, $subGroupLabel) = $this->generateKeyLabel($child, 'sub_group_id', self::DEFAULT_SUB_GROUP, $subGroupRender);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
Open
list($groupKey, $groupLabel, $group_name) = $this->generateKeyLabel($child, 'group_id', self::DEFAULT_GROUP, $groupRender);
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 11 Open
Open
if (is_array($value)) {
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 7 Open
Open
ksort($array, SORT_NATURAL);
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 7 Open
Open
foreach ($array as &$value) {
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 15 Open
Open
$this->ksortRecursive($value);
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 11 Open
Open
}
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 7 Open
Open
}
- Create a ticketCreate a ticket
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 7 Open
Open
return $array;
- Create a ticketCreate a ticket
- Exclude checks
The variable $group_name is not named in camelCase. Open
Open
public function buildView(FormView $view, FormInterface $form, array $options)
{
if ($form->getConfig()->getAttribute('group_enabled')) {
$view->vars['group'] = array();
$groupRender = $form->getConfig()->getAttribute('group_render');
- Read upRead up
- Create a ticketCreate a ticket
- 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 $group_name is not named in camelCase. Open
Open
public function buildView(FormView $view, FormInterface $form, array $options)
{
if ($form->getConfig()->getAttribute('group_enabled')) {
$view->vars['group'] = array();
$groupRender = $form->getConfig()->getAttribute('group_render');
- Read upRead up
- Create a ticketCreate a ticket
- 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();
}
}