src/Modules/Generators/LoadContentGenerators.php
The method __invoke() contains an exit expression. Open
Open
exit(1);
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
Avoid assigning values to variables in if clauses and the like (line '39', column '15'). Open
Open
public function __invoke(Project $project, OutputInterface $output)
{
if (! $contentGenerators = $this->configuration->get('content_generators', null)) {
$output->writeln('[!] Your project\'s content generators are miss-configured. Doing nothing and exiting.]');
exit(1);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}