src/CoreBundle/Controller/Admin/IndexBlocksController.php
The method getItemsUsers uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$items[] = [
'class' => 'item-user-import',
'url' => $this->generateUrl('legacy_main', ['name' => 'admin/user_import.php']),
'label' => $this->translator->trans('Import users list'),
- 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 local variables such as '$languageInterface'. Open
Open
$languageInterface = api_get_language_isocode();
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_SESSION_MANAGER')")]
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Route('/admin/index', name: 'admin_index_blocks')]
- Exclude checks
Missing function doc comment Open
Open
public function __construct(
- Exclude checks
Missing function doc comment Open
Open
public function __invoke(): JsonResponse
- Exclude checks
You must use "/**" style comments for a class comment Open
Open
class IndexBlocksController extends BaseController
- Exclude checks
Add a single space around assignment operators Open
Open
declare(strict_types=1);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly PageRepository $pageRepository,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly PageCategoryRepository $pageCategoryRepository,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly TranslatorInterface $translator,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly SerializerInterface $serializer
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly SettingsManager $settingsManager,
- Exclude checks