1 | <?php |
||
27 | class Row extends AbstractRow |
||
28 | { |
||
29 | /** |
||
30 | * @var array Same as fields only indexed using headers rather than numbers |
||
31 | */ |
||
32 | protected $assocCols = []; |
||
33 | |||
34 | /** |
||
35 | * @var array The headers for this row |
||
36 | */ |
||
37 | protected $headers = []; |
||
38 | |||
39 | /** |
||
40 | * Get the current key (column number or header, if available) |
||
41 | * |
||
42 | * @return string The "current" key |
||
43 | * @access public |
||
44 | * @todo Figure out if this can return a CSVelte\Table\HeaderData object so long as it |
||
45 | * has a __toString() method that generated the right key... |
||
46 | */ |
||
47 | 14 | public function key() |
|
51 | |||
52 | /** |
||
53 | * Set the header row (so that it can be used to index the row) |
||
54 | * |
||
55 | * @param \CSVelte\Table\HeaderRow $headers Header row to set |
||
56 | * @return void (return $this?) |
||
57 | * @access public |
||
58 | */ |
||
59 | 19 | public function setHeaderRow(AbstractRow $headers) |
|
60 | { |
||
61 | 19 | if (!($headers instanceof HeaderRow)) { |
|
62 | 1 | $headers = new HeaderRow($headers->toArray()); |
|
63 | 1 | } |
|
64 | 19 | $headerArray = $headers->toArray(); |
|
65 | 19 | if (($hcount = $headers->count()) !== ($rcount = $this->count())) { |
|
66 | 2 | if ($hcount > $rcount) { |
|
67 | // header count is long, could be an error, but lets just fill in the short row with null values... |
||
68 | 1 | $this->fields = array_pad($this->fields, $hcount, null); |
|
69 | 1 | } else { |
|
70 | // @todo This is too strict. I need a way to recover from this a little better... |
||
71 | // header count is short, this is likely an error... |
||
72 | 1 | throw new HeaderException("Header count ({$hcount}) does not match column count ({$rcount}).", HeaderException::ERR_HEADER_COUNT); |
|
73 | } |
||
74 | 1 | } |
|
75 | 18 | $this->headers = $headers; |
|
|
|||
76 | 18 | $this->assocCols = array_combine($headerArray, $this->fields); |
|
77 | 18 | } |
|
78 | |||
79 | /** |
||
80 | * Is there an offset at specified position? |
||
81 | * |
||
82 | * @param integer Offset |
||
83 | * @return boolean |
||
84 | * @access public |
||
85 | */ |
||
86 | 5 | public function offsetExists($offset) |
|
96 | |||
97 | /** |
||
98 | * Retrieve data at specified column offset |
||
99 | * |
||
100 | * @param integer Offset |
||
101 | * @return CSVelte\Table\Data |
||
102 | * @access public |
||
103 | */ |
||
104 | 8 | public function offsetGet($offset) |
|
113 | } |
||
114 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..