Issues (217)

src/controllers/OpclassesController.php (2 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * PHPPgAdmin 6.1.3
5
 */
6
7
namespace PHPPgAdmin\Controller;
8
9
use PHPPgAdmin\Decorators\Decorator;
10
11
/**
12
 * Base controller class.
13
 */
14
class OpclassesController extends BaseController
15
{
16
    public $controller_title = 'stropclasses';
17
18
    /**
19
     * Default method to render the controller according to the action parameter.
20
     */
21
    public function render()
22
    {
23
        if ('tree' === $this->action) {
24
            return $this->doTree();
25
        }
26
27
        $this->printHeader();
28
        $this->printBody();
29
30
        switch ($this->action) {
31
            default:
32
                $this->doDefault();
33
34
                break;
35
        }
36
37
        $this->printFooter();
38
    }
39
40
    /**
41
     * Show default list of opclasss in the database.
42
     *
43
     * @param string $msg
44
     */
45
    public function doDefault($msg = ''): void
46
    {
47
        $data = $this->misc->getDatabaseAccessor();
48
49
        $this->printTrail('schema');
50
        $this->printTabs('schema', 'opclasses');
51
        $this->printMsg($msg);
52
53
        $opclasses = $data->getOpClasses();
54
55
        $columns = [
56
            'accessmethod' => [
57
                'title' => $this->lang['straccessmethod'],
58
                'field' => Decorator::field('amname'),
59
            ],
60
            'opclass' => [
61
                'title' => $this->lang['strname'],
62
                'field' => Decorator::field('opcname'),
63
            ],
64
            'type' => [
65
                'title' => $this->lang['strtype'],
66
                'field' => Decorator::field('opcintype'),
67
            ],
68
            'default' => [
69
                'title' => $this->lang['strdefault'],
70
                'field' => Decorator::field('opcdefault'),
71
                'type' => 'yesno',
72
            ],
73
            'comment' => [
74
                'title' => $this->lang['strcomment'],
75
                'field' => Decorator::field('opccomment'),
76
            ],
77
        ];
78
79
        $actions = [];
80
81
        echo $this->printTable($opclasses, $columns, $actions, 'opclasses-opclasses', $this->lang['strnoopclasses']);
0 ignored issues
show
It seems like $opclasses can also be of type integer; however, parameter $tabledata of PHPPgAdmin\Controller\BaseController::printTable() does only seem to accept ADORecordSet|PHPPgAdmin\ArrayRecordSet, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

81
        echo $this->printTable(/** @scrutinizer ignore-type */ $opclasses, $columns, $actions, 'opclasses-opclasses', $this->lang['strnoopclasses']);
Loading history...
82
    }
83
84
    /**
85
     * Generate XML for the browser tree.
86
     */
87
    public function doTree()
88
    {
89
        $data = $this->misc->getDatabaseAccessor();
90
91
        $opclasses = $data->getOpClasses();
92
93
        // OpClass prototype: "op_class/access_method"
94
        $proto = Decorator::concat(Decorator::field('opcname'), '/', Decorator::field('amname'));
95
96
        $attrs = [
97
            'text' => $proto,
98
            'icon' => 'OperatorClass',
99
            'toolTip' => Decorator::field('opccomment'),
100
        ];
101
102
        return $this->printTree($opclasses, $attrs, 'opclasses');
0 ignored issues
show
It seems like $opclasses can also be of type integer; however, parameter $_treedata of PHPPgAdmin\Controller\BaseController::printTree() does only seem to accept PHPPgAdmin\ADORecordSet|PHPPgAdmin\ArrayRecordSet, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

102
        return $this->printTree(/** @scrutinizer ignore-type */ $opclasses, $attrs, 'opclasses');
Loading history...
103
    }
104
}
105