execute accesses the super-global variable $_REQUEST. Open
public function execute()
{
$departmentId = $_REQUEST['department'];
if (is_null($departmentId) || !isset($departmentId)) {
- Read upRead up
- Create a ticketCreate a ticket
- 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
Missing class import via use statement (line '37', column '23'). Open
throw new \InvalidArgumentException('Missing department id.');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\Intern\DepartmentFactory' in method 'execute'. Open
$department = DepartmentFactory::getDepartmentById($departmentId);
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid using static access to class '\Intern\FacultyFactory' in method 'execute'. Open
$faculty = FacultyFactory::getFacultyByDepartmentAssoc($department);
- Read upRead up
- Create a ticketCreate a ticket
- 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 execute() contains an exit expression. Open
exit; // Exit since this is called by JSON
- Read upRead up
- Create a ticketCreate a ticket
- 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
Call to method __construct
from undeclared class \Intern\Command\Exception
(Did you mean class \Exception) Open
throw new Exception('Department returned was null. Check department id.');
- Create a ticketCreate a ticket
- Exclude checks
Argument 1 (id)
is string|string[]
but \Intern\DepartmentFactory::getDepartmentById()
takes \Intern\unknown
defined at /code/class/DepartmentFactory.php:36
Open
$department = DepartmentFactory::getDepartmentById($departmentId);
- Create a ticketCreate a ticket
- Exclude checks