AppStateESS/InternshipInventory

View on GitHub
class/DepartmentFactory.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '95', column '19').
Open

        $db = new \PHPWS_DB('intern_department');
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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 '40', column '22').
Open

           throw new \InvalidArgumentException('Missing department ID.');
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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 '73', column '19').
Open

        $db = new \PHPWS_DB('intern_department');
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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 '\Current_User' in method 'getDepartmentsAssocForUsername'.
Open

        if(!\Current_User::allow('intern', 'all_departments') && !\Current_User::isDeity()){
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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_DB' in method 'getDepartmentById'.
Open

        $result = \PHPWS_DB::getRow($query);
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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_Error' in method 'getDepartmentById'.
Open

        if (\PHPWS_Error::isError($result)) {
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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 '\Current_User' in method 'getDepartmentsAssocForUsername'.
Open

        if(!\Current_User::allow('intern', 'all_departments') && !\Current_User::isDeity()){
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

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

Call to method getRow from undeclared class \PHPWS_DB
Open

        $result = \PHPWS_DB::getRow($query);
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method __construct from undeclared class \Intern\DatabaseException
Open

            throw new DatabaseException($result->toString());
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addColumn from undeclared class \PHPWS_DB
Open

        $db->addColumn('name');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addJoin from undeclared class \PHPWS_DB
Open

            $db->addJoin('LEFT', 'intern_department', 'intern_admin', 'id', 'department_id');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addColumn from undeclared class \PHPWS_DB
Open

        $db->addColumn('id');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method setIndexBy from undeclared class \PHPWS_DB
Open

        $db->setIndexBy('id');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addColumn from undeclared class \PHPWS_DB
Open

        $db->addColumn('name');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addOrder from undeclared class \PHPWS_DB
Open

        $db->addOrder('name');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Parameter $id has undeclared type \Intern\unknown
Open

    public static function getDepartmentById($id)
Severity: Minor
Found in class/DepartmentFactory.php by phan

Call to method addColumn from undeclared class \PHPWS_DB
Open

        $db->addColumn('id');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method select from undeclared class \PHPWS_DB
Open

        return $db->select('col');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addWhere from undeclared class \PHPWS_DB
Open

            $db->addWhere('id', $except, '=', 'OR');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method __construct from undeclared class \PHPWS_DB
Open

        $db = new \PHPWS_DB('intern_department');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addOrder from undeclared class \PHPWS_DB
Open

        $db->addOrder('name');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method __construct from undeclared class \PHPWS_DB
Open

        $db = new \PHPWS_DB('intern_department');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method setIndexBy from undeclared class \PHPWS_DB
Open

        $db->setIndexBy('id');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addWhere from undeclared class \PHPWS_DB
Open

        $db->addWhere('hidden', 0, '=', 'OR', 'grp');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method isDeity from undeclared class \Current_User
Open

        if(!\Current_User::allow('intern', 'all_departments') && !\Current_User::isDeity()){
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addWhere from undeclared class \PHPWS_DB
Open

            $db->addWhere('intern_admin.username', $username);
Severity: Critical
Found in class/DepartmentFactory.php by phan

Returning type null but getDepartmentById() is declared to return \Intern\Department
Open

           return null;
Severity: Minor
Found in class/DepartmentFactory.php by phan

Call to method addWhere from undeclared class \PHPWS_DB
Open

            $db->addWhere('id', $includeHiddenDept, '=', 'OR', 'grp');
Severity: Critical
Found in class/DepartmentFactory.php by phan

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

        $query = "SELECT * FROM intern_department WHERE id = $id";
Severity: Minor
Found in class/DepartmentFactory.php by phan

Call to method allow from undeclared class \Current_User
Open

        if(!\Current_User::allow('intern', 'all_departments') && !\Current_User::isDeity()){
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method addWhere from undeclared class \PHPWS_DB
Open

        $db->addWhere('hidden', 0, '=', 'OR');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method isError from undeclared class \PHPWS_Error
Open

        if (\PHPWS_Error::isError($result)) {
Severity: Critical
Found in class/DepartmentFactory.php by phan

Call to method select from undeclared class \PHPWS_DB
Open

        $depts += $db->select('col');
Severity: Critical
Found in class/DepartmentFactory.php by phan

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = new \PHPWS_DB('intern_department');
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = new \PHPWS_DB('intern_department');
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    public static function getDepartmentById($id)
Severity: Minor
Found in class/DepartmentFactory.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

There are no issues that match your filters.

Category
Status