File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -218,16 +218,14 @@ public function setFooters(array $footers) {
218218 */
219219 public function setAlignments (array $ alignments ) {
220220 $ valid_alignments = array_flip ( array ( Column::ALIGN_LEFT , Column::ALIGN_RIGHT , Column::ALIGN_CENTER ) );
221+ $ headers_map = ! empty ( $ this ->_headers ) ? array_flip ( $ this ->_headers ) : null ;
221222 foreach ( $ alignments as $ column => $ alignment ) {
222223 if ( ! isset ( $ valid_alignments [ $ alignment ] ) ) {
223224 throw new \InvalidArgumentException ( "Invalid alignment value ' $ alignment' for column ' $ column'. " );
224225 }
225226 // Only validate column names if headers are already set
226- if ( ! empty ( $ this ->_headers ) ) {
227- $ headers_map = array_flip ( $ this ->_headers );
228- if ( ! isset ( $ headers_map [ $ column ] ) ) {
229- throw new \InvalidArgumentException ( "Column ' $ column' does not exist in table headers. " );
230- }
227+ if ( $ headers_map !== null && ! isset ( $ headers_map [ $ column ] ) ) {
228+ throw new \InvalidArgumentException ( "Column ' $ column' does not exist in table headers. " );
231229 }
232230 }
233231 $ this ->_alignments = $ alignments ;
You can’t perform that action at this time.
0 commit comments