Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix bug #20181: E_NOTICE when using setAlign() but not on first column #3

Merged
merged 1 commit into from

2 participants

This page is out of date. Refresh to see the latest.
Showing with 27 additions and 2 deletions.
  1. +4 −2 Table.php
  2. +23 −0 tests/bug20181.phpt
View
6 Table.php
@@ -719,8 +719,10 @@ function _updateRowsCols($rowdata = null)
}
// Set default column alignments
- for ($i = count($this->_col_align); $i < $this->_max_cols; $i++) {
- $this->_col_align[$i] = $pad;
+ for ($i = 0; $i < $this->_max_cols; $i++) {
+ if (!isset($this->_col_align[$i])) {
+ $this->_col_align[$i] = $pad;
+ }
}
}
View
23 tests/bug20181.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #20181: setAlign() on non-zero column
+--FILE--
+<?php
+error_reporting(E_ALL | E_NOTICE);
+if (file_exists(dirname(__FILE__) . '/../Table.php')) {
+ require_once dirname(__FILE__) . '/../Table.php';
+} else {
+ require_once 'Console/Table.php';
+}
+$table = new Console_Table();
+$table->setAlign(1, CONSOLE_TABLE_ALIGN_RIGHT);
+$table->setHeaders(array('f', 'bar'));
+$table->addRow(array('baz', 'b'));
+
+echo $table->getTable();
+?>
+--EXPECT--
++-----+-----+
+| f | bar |
++-----+-----+
+| baz | b |
++-----+-----+
Something went wrong with that request. Please try again.