src/CoreBundle/Controller/Admin/AdminController.php
The method listFilesInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$fileUrls[$file->getId()] = null;
$creator = null;
}
- 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 '$creator'. Open
Open
$creator = $resourceNode->getCreator();
- 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
Closing brace must be on a line by itself Open
Open
) {}
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Route('/register-campus', name: 'admin_register_campus', methods: ['POST'])]
- Exclude checks
You must use "/**" style comments for a class comment Open
Open
class AdminController extends BaseController
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[IsGranted('ROLE_ADMIN')]
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[IsGranted('ROLE_ADMIN')]
- Exclude checks
Add a single space around assignment operators Open
Open
declare(strict_types=1);
- Exclude checks
You must use "/**" style comments for a function comment Open
Open
public function listFilesInfo(Request $request, ResourceFileRepository $resourceFileRepository): Response
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Route('/admin')]
- Exclude checks
Missing function doc comment Open
Open
public function __construct(
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Route('/files_info', name: 'admin_files_info', methods: ['GET'])]
- Exclude checks
You must use "/**" style comments for a function comment Open
Open
public function registerCampus(Request $request, SettingsManager $settingsManager): Response
- Exclude checks
Closing brace must be on a line by itself Open
Open
) {}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly ResourceNodeRepository $resourceNodeRepository,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly AccessUrlHelper $accessUrlHelper
- Exclude checks