1 | <?php |
||
14 | class Grid extends Component implements IGrid |
||
15 | { |
||
16 | /** |
||
17 | * %1$s - filter |
||
18 | * %2$s - actions |
||
19 | * %3$s - table |
||
20 | */ |
||
21 | const TEMPLATE_CONTENT = '%1$s%2$s%3$s'; |
||
22 | |||
23 | const TAG_GRID = 'div'; |
||
24 | const TAG_FILTER = 'div'; |
||
25 | const TAG_ACTIONS = 'div'; |
||
26 | const TAG_FORM = 'form'; |
||
27 | |||
28 | const ATTRIBUTE_GRID_CLASS = 'grid'; |
||
29 | const ATTRIBUTE_FILTER_CLASS = 'grid-filters'; |
||
30 | const ATTRIBUTE_ACTIONS_CLASS = 'grid-actions'; |
||
31 | |||
32 | const ATTRIBUTES_FORM = ['class' => 'grid-form']; |
||
33 | |||
34 | /** @var string */ |
||
35 | protected $containerClass = ''; |
||
36 | |||
37 | /** @var ITable */ |
||
38 | protected $table; |
||
39 | |||
40 | /** @var Filters */ |
||
41 | protected $filters; |
||
42 | |||
43 | /** @var Actions */ |
||
44 | protected $actions; |
||
45 | |||
46 | /** @var string */ |
||
47 | protected $whitespace; |
||
48 | |||
49 | /** |
||
50 | * @param ITable $rows |
||
|
|||
51 | * @param Filters|null $filters |
||
52 | * @param Actions|null $massActions |
||
53 | * @param array $attributes |
||
54 | */ |
||
55 | 8 | public function __construct( |
|
56 | ITable $table, |
||
57 | Filters $filters = null, |
||
58 | Actions $actions = null, |
||
59 | array $attributes = [] |
||
60 | ) { |
||
61 | 8 | $this->table = $table; |
|
62 | |||
63 | 8 | parent::__construct('', static::TAG_GRID, $attributes); |
|
64 | |||
65 | 8 | $this->appendToAttribute(Component::ATTRIBUTE_CLASS, static::ATTRIBUTE_GRID_CLASS); |
|
66 | |||
67 | 8 | if ($actions) { |
|
68 | 3 | $this->actions = $actions; |
|
69 | 3 | $this->actions->appendToAttribute(Component::ATTRIBUTE_CLASS, static::ATTRIBUTE_ACTIONS_CLASS); |
|
70 | } |
||
71 | |||
72 | 8 | if ($filters) { |
|
73 | 4 | $this->filters = $filters; |
|
74 | 4 | $this->filters->appendToAttribute(Component::ATTRIBUTE_CLASS, static::ATTRIBUTE_FILTER_CLASS); |
|
75 | } |
||
76 | 8 | } |
|
77 | |||
78 | /** |
||
79 | * @param int $num |
||
80 | * @param string $whitespace |
||
81 | */ |
||
82 | 2 | public function setIndentation(int $num, string $whitespace = ' ') |
|
83 | { |
||
84 | 2 | $indentationStep = $this->filters || $this->actions ? 2 : 1; |
|
85 | |||
86 | 2 | $this->table->setIndentation($num + $indentationStep, $whitespace); |
|
87 | |||
88 | 2 | if ($this->filters) { |
|
89 | 2 | $this->filters->setIndentation($num + $indentationStep, $whitespace); |
|
90 | } |
||
91 | |||
92 | 2 | $this->indentation = str_repeat($whitespace, $num); |
|
93 | 2 | $this->whitespace = $whitespace; |
|
94 | 2 | } |
|
95 | |||
96 | /** |
||
97 | * @param ITranslator $translator |
||
98 | */ |
||
99 | 2 | public function setTranslator(ITranslator $translator) |
|
100 | { |
||
101 | 2 | $this->table->setTranslator($translator); |
|
102 | |||
103 | 2 | if ($this->filters) { |
|
104 | 1 | $this->filters->setTranslator($translator); |
|
105 | } |
||
106 | 2 | } |
|
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | 4 | public function __toString(): string |
|
123 | |||
124 | /** |
||
125 | * @return ITable |
||
126 | */ |
||
127 | public function getTable(): ITable |
||
131 | |||
132 | /** |
||
133 | * @param Filters $filters |
||
134 | */ |
||
135 | public function setFilter(Filters $filters) |
||
139 | |||
140 | 4 | protected function wrapContentInForm() |
|
155 | } |
||
156 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.