AppStateESS/InternshipInventory

View on GitHub
class/Command/CopyInternshipToNextTerm.php

Summary

Maintainability
A
1 hr
Test Coverage

execute accesses the super-global variable $_REQUEST.
Open

    public function execute() {
        // Load the existing internship using its ID
        $internship = InternshipFactory::getInternshipById($_REQUEST['internshipId']);

        // Load the emergency contacts from the old internship

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 $_REQUEST.
Open

    public function execute() {
        // Load the existing internship using its ID
        $internship = InternshipFactory::getInternshipById($_REQUEST['internshipId']);

        // Load the emergency contacts from the old internship

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

Method execute has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute() {
        // Load the existing internship using its ID
        $internship = InternshipFactory::getInternshipById($_REQUEST['internshipId']);

        // Load the emergency contacts from the old internship
Severity: Minor
Found in class/Command/CopyInternshipToNextTerm.php - About 1 hr to fix

Missing class import via use statement (line '69', column '23').
Open

            throw new \InvalidArgumentException('Requested term does not exist: ' . $destTermCode);

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\SupervisorFactory' in method 'execute'.
Open

        $supervisor = SupervisorFactory::getSupervisorById($internship->getSupervisorId());

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 '\PHPWS_Core' in method 'execute'.
Open

        return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $copyId);

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\DatabaseStorage' in method 'execute'.
Open

        DatabaseStorage::save($newSupervisor);

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\DatabaseStorage' in method 'execute'.
Open

            DatabaseStorage::save($newContact);

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::SUCCESS, 'Continued internship for ' . $internship->getFullName() . ' to ' . $newTerm->getDescription() . '.');

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::close();

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\TermFactory' in method 'execute'.
Open

        $newTerm = TermFactory::getTermByTermCode($destTermCode);

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\InternshipFactory' in method 'execute'.
Open

        $internship = InternshipFactory::getInternshipById($_REQUEST['internshipId']);

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\EmergencyContactFactory' in method 'execute'.
Open

        $contacts = EmergencyContactFactory::getContactsForInternship($internship);

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\WorkflowStateFactory' in method 'execute'.
Open

        $state = WorkflowStateFactory::getState('CreationState');

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

Suspicious type \Intern\new of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

        return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $copyId);

Call to method reroute from undeclared class \PHPWS_Core
Open

        return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $copyId);
Severity: Critical
Found in class/Command/CopyInternshipToNextTerm.php by phan

Call with 1 arg(s) to \Intern\EmergencyContact::getPhone() which only takes 0 arg(s) defined at /code/class/EmergencyContact.php:106
Open

            $phone = $contact->getPhone($copyId);

Call to method simple from undeclared class \NQ
Open

        \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Continued internship for ' . $internship->getFullName() . ' to ' . $newTerm->getDescription() . '.');
Severity: Critical
Found in class/Command/CopyInternshipToNextTerm.php by phan

Call with 1 arg(s) to \Intern\EmergencyContact::getName() which only takes 0 arg(s) defined at /code/class/EmergencyContact.php:96
Open

            $name = $contact->getName($copyId);

Call with 1 arg(s) to \Intern\EmergencyContact::getRelation() which only takes 0 arg(s) defined at /code/class/EmergencyContact.php:101
Open

            $relation = $contact->getRelation($copyId);

Call with 1 arg(s) to \Intern\EmergencyContact::getEmail() which only takes 0 arg(s) defined at /code/class/EmergencyContact.php:111
Open

            $email = $contact->getEmail($copyId);

Argument 1 (id) is string|string[] but \Intern\InternshipFactory::getInternshipById() takes int defined at /code/class/InternshipFactory.php:37
Open

        $internship = InternshipFactory::getInternshipById($_REQUEST['internshipId']);

Call to method close from undeclared class \NQ
Open

        \NQ::close();
Severity: Critical
Found in class/Command/CopyInternshipToNextTerm.php by phan

There are no issues that match your filters.

Category
Status