1 | <?php |
||
33 | class Grid implements Component |
||
34 | { |
||
35 | /** |
||
36 | * @var GridStyle |
||
37 | */ |
||
38 | private $style; |
||
39 | |||
40 | /** |
||
41 | * @var string[] |
||
42 | */ |
||
43 | private $cells = array(); |
||
44 | |||
45 | /** |
||
46 | * @var int |
||
47 | */ |
||
48 | private $minNbColumns = 4; |
||
49 | |||
50 | /** |
||
51 | * @var int |
||
52 | */ |
||
53 | private $maxNbColumns = PHP_INT_MAX; |
||
54 | |||
55 | /** |
||
56 | * Creates a new grid. |
||
57 | * |
||
58 | * @param GridStyle $style The rendering style. By default, the grid is |
||
|
|||
59 | * rendered with the style |
||
60 | * {@link GridStyle::borderless()}. |
||
61 | */ |
||
62 | 11 | public function __construct(GridStyle $style = null) |
|
66 | |||
67 | /** |
||
68 | * Adds a data cell to the grid. |
||
69 | * |
||
70 | * @param string $cell The data cell. |
||
71 | * |
||
72 | * @return static The current instance. |
||
73 | */ |
||
74 | public function addCell($cell) |
||
80 | |||
81 | /** |
||
82 | * Adds data cells to the grid. |
||
83 | * |
||
84 | * @param string[] $cells The data cells. |
||
85 | * |
||
86 | * @return static The current instance. |
||
87 | */ |
||
88 | 10 | public function addCells(array $cells) |
|
89 | { |
||
90 | 10 | foreach ($cells as $cell) { |
|
91 | 10 | $this->cells[] = $cell; |
|
92 | } |
||
93 | |||
94 | 10 | return $this; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * Sets the data cells in the grid. |
||
99 | * |
||
100 | * @param string[] $cells The data cells to set. |
||
101 | * |
||
102 | * @return static The current instance. |
||
103 | */ |
||
104 | public function setCells(array $cells) |
||
112 | |||
113 | /** |
||
114 | * Returns the minimum number of columns in the grid. |
||
115 | * |
||
116 | * The default minimum is 4. |
||
117 | * |
||
118 | * @return int The minimum number of columns. |
||
119 | */ |
||
120 | public function getMinNbColumns() |
||
124 | |||
125 | /** |
||
126 | * Sets the minimum number of columns in the grid. |
||
127 | * |
||
128 | * The default minimum is 4. |
||
129 | * |
||
130 | * @param int $minNbColumns The minimum number of columns. |
||
131 | * |
||
132 | * @return static The current instance. |
||
133 | */ |
||
134 | 1 | public function setMinNbColumns($minNbColumns) |
|
141 | |||
142 | /** |
||
143 | * Returns the maximum number of columns in the grid. |
||
144 | * |
||
145 | * The default maximum is unlimited. |
||
146 | * |
||
147 | * @return int The maximum number of columns. |
||
148 | */ |
||
149 | public function getMaxNbColumns() |
||
153 | |||
154 | /** |
||
155 | * Sets the maximum number of columns in the grid. |
||
156 | * |
||
157 | * The default maximum is unlimited. |
||
158 | * |
||
159 | * @param int $maxNbColumns The maximum number of columns. |
||
160 | * |
||
161 | * @return static The current instance. |
||
162 | */ |
||
163 | 1 | public function setMaxNbColumns($maxNbColumns) |
|
170 | |||
171 | /** |
||
172 | * Renders the grid. |
||
173 | * |
||
174 | * @param IO $io The I/O. |
||
175 | * @param int $indentation The number of spaces to indent. |
||
176 | */ |
||
177 | 11 | public function render(IO $io, $indentation = 0) |
|
191 | |||
192 | 10 | private function getCellWrapper(Formatter $formatter, $screenWidth, $excessColumnWidth, $indentation) |
|
218 | |||
219 | 10 | private function renderRows(IO $io, array $rows, array $columnLengths, $excessColumnLength, $indentation) |
|
251 | } |
||
252 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.