post accesses the super-global variable $_REQUEST. Open
public function post()
{
$affiliationId = $_REQUEST['affiliation_agreement_id'];
// Sanity checking
- 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
execute accesses the super-global variable $_SERVER. Open
public function execute()
{
/* Check if user should have access to Affiliate Agreement page */
if(!\Current_User::allow('intern', 'affiliation_agreement')){
\NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, 'You do not have permission to add Affiliation Agreements.');
- 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
get accesses the super-global variable $_REQUEST. Open
public function get()
{
$affiliationId = $_REQUEST['affiliation_agreement_id'];
$agreement = AffiliationAgreementFactory::getAffiliationById($affiliationId);
- 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 '32', column '23'). Open
throw new \Intern\Exception\PermissionException('You do not have permission to add Affiliation Agreements.');
- 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
Missing class import via use statement (line '68', column '14'). Open
throw new \InvalidArgumentException('Missing Affiliation 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\AffiliationAgreementFactory' in method 'post'. Open
$affiliation = AffiliationAgreementFactory::getAffiliationById($affiliationId);
- 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 post uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
}else{
$affiliation->setTerminated(1);
}
- Read upRead up
- Create a ticketCreate a ticket
- 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 using static access to class '\Current_User' in method 'execute'. Open
if(!\Current_User::allow('intern', 'affiliation_agreement')){
- 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 '\NQ' in method 'execute'. Open
\NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, 'You do not have permission to add Affiliation Agreements.');
- 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\AffiliationAgreementFactory' in method 'get'. Open
$agreement = AffiliationAgreementFactory::getAffiliationById($affiliationId);
- 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\AffiliationAgreementFactory' in method 'post'. Open
AffiliationAgreementFactory::save($affiliation);
- 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;
- 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
The method execute() contains an exit expression. Open
exit;
- 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
The method execute() contains an exit expression. Open
exit;
- 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
TODO found Open
// TODO: Don't just toggle this. Actually get it from the data passed in.
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
// TODO: this should return the whole affiliation agreement object
- Create a ticketCreate a ticket
- Exclude checks
Call to method allow
from undeclared class \Current_User
Open
if(!\Current_User::allow('intern', 'affiliation_agreement')){
- Create a ticketCreate a ticket
- Exclude checks
Argument 1 (id)
is string|string[]
but \Intern\AffiliationAgreementFactory::getAffiliationById()
takes int
defined at /code/class/AffiliationAgreementFactory.php:35
Open
$affiliation = AffiliationAgreementFactory::getAffiliationById($affiliationId);
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \Intern\AffiliationAgreement->depratments
Open
$agreement->depratments = array();
- Create a ticketCreate a ticket
- Exclude checks
Call to method simple
from undeclared class \NQ
Open
\NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, 'You do not have permission to add Affiliation Agreements.');
- Create a ticketCreate a ticket
- Exclude checks
Argument 1 (id)
is string|string[]
but \Intern\AffiliationAgreementFactory::getAffiliationById()
takes int
defined at /code/class/AffiliationAgreementFactory.php:35
Open
$agreement = AffiliationAgreementFactory::getAffiliationById($affiliationId);
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \Intern\AffiliationAgreement->states
Open
$agreement->states = array();
- Create a ticketCreate a ticket
- Exclude checks