@@ -80,6 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @param boolean whether this list is read-only or not |
83 | + * @param boolean $value |
|
83 | 84 | */ |
84 | 85 | protected function setReadOnly($value) |
85 | 86 | { |
@@ -220,6 +221,7 @@ discard block |
||
220 | 221 | * Merges iterable data into the map. |
221 | 222 | * Existing data in the map will be kept and overwritten if the keys are the same. |
222 | 223 | * @param mixed the data to be merged with, must be an array or object implementing Traversable |
224 | + * @param TMap $data |
|
223 | 225 | * @throws TInvalidDataTypeException If data is neither an array nor an iterator. |
224 | 226 | */ |
225 | 227 | public function mergeWith($data) |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @package System.Collections |
31 | 31 | * @since 3.0 |
32 | 32 | */ |
33 | -class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable |
|
33 | +class TMap extends TComponent implements IteratorAggregate, ArrayAccess, Countable |
|
34 | 34 | { |
35 | 35 | /** |
36 | 36 | * @var array internal data storage |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | protected function __getZappableSleepProps(&$exprops) |
51 | 51 | { |
52 | 52 | parent::__getZappableSleepProps($exprops); |
53 | - if ($this->_d===array()) |
|
54 | - $exprops[] = "\0TMap\0_d"; |
|
55 | - if ($this->_r===false) |
|
56 | - $exprops[] = "\0TMap\0_r"; |
|
53 | + if($this->_d===array()) |
|
54 | + $exprops[]="\0TMap\0_d"; |
|
55 | + if($this->_r===false) |
|
56 | + $exprops[]="\0TMap\0_r"; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param boolean whether the list is read-only |
64 | 64 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
65 | 65 | */ |
66 | - public function __construct($data=null,$readOnly=false) |
|
66 | + public function __construct($data=null, $readOnly=false) |
|
67 | 67 | { |
68 | 68 | if($data!==null) |
69 | 69 | $this->copyFrom($data); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getIterator() |
95 | 95 | { |
96 | - return new ArrayIterator( $this->_d ); |
|
96 | + return new ArrayIterator($this->_d); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | * @param mixed value |
141 | 141 | * @throws TInvalidOperationException if the map is read-only |
142 | 142 | */ |
143 | - public function add($key,$value) |
|
143 | + public function add($key, $value) |
|
144 | 144 | { |
145 | 145 | if(!$this->_r) |
146 | 146 | $this->_d[$key]=$value; |
147 | 147 | else |
148 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
148 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | if(!$this->_r) |
160 | 160 | { |
161 | - if(isset($this->_d[$key]) || array_key_exists($key,$this->_d)) |
|
161 | + if(isset($this->_d[$key]) || array_key_exists($key, $this->_d)) |
|
162 | 162 | { |
163 | 163 | $value=$this->_d[$key]; |
164 | 164 | unset($this->_d[$key]); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | else |
171 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
171 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function contains($key) |
188 | 188 | { |
189 | - return isset($this->_d[$key]) || array_key_exists($key,$this->_d); |
|
189 | + return isset($this->_d[$key]) || array_key_exists($key, $this->_d); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | { |
208 | 208 | if(is_array($data) || $data instanceof Traversable) |
209 | 209 | { |
210 | - if($this->getCount()>0) |
|
210 | + if($this->getCount() > 0) |
|
211 | 211 | $this->clear(); |
212 | 212 | foreach($data as $key=>$value) |
213 | - $this->add($key,$value); |
|
213 | + $this->add($key, $value); |
|
214 | 214 | } |
215 | 215 | else if($data!==null) |
216 | 216 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | if(is_array($data) || $data instanceof Traversable) |
228 | 228 | { |
229 | 229 | foreach($data as $key=>$value) |
230 | - $this->add($key,$value); |
|
230 | + $this->add($key, $value); |
|
231 | 231 | } |
232 | 232 | else if($data!==null) |
233 | 233 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * @param integer the offset to set element |
262 | 262 | * @param mixed the element value |
263 | 263 | */ |
264 | - public function offsetSet($offset,$item) |
|
264 | + public function offsetSet($offset, $item) |
|
265 | 265 | { |
266 | - $this->add($offset,$item); |
|
266 | + $this->add($offset, $item); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -163,11 +163,9 @@ discard block |
||
163 | 163 | $value=$this->_d[$key]; |
164 | 164 | unset($this->_d[$key]); |
165 | 165 | return $value; |
166 | - } |
|
167 | - else |
|
166 | + } else |
|
168 | 167 | return null; |
169 | - } |
|
170 | - else |
|
168 | + } else |
|
171 | 169 | throw new TInvalidOperationException('map_readonly',get_class($this)); |
172 | 170 | } |
173 | 171 | |
@@ -211,8 +209,7 @@ discard block |
||
211 | 209 | $this->clear(); |
212 | 210 | foreach($data as $key=>$value) |
213 | 211 | $this->add($key,$value); |
214 | - } |
|
215 | - else if($data!==null) |
|
212 | + } else if($data!==null) |
|
216 | 213 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
217 | 214 | } |
218 | 215 | |
@@ -228,8 +225,7 @@ discard block |
||
228 | 225 | { |
229 | 226 | foreach($data as $key=>$value) |
230 | 227 | $this->add($key,$value); |
231 | - } |
|
232 | - else if($data!==null) |
|
228 | + } else if($data!==null) |
|
233 | 229 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
234 | 230 | } |
235 | 231 |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @param boolean whether to allow custom paging |
95 | + * @param boolean $value |
|
95 | 96 | */ |
96 | 97 | public function setCustomPaging($value) |
97 | 98 | { |
@@ -139,6 +140,7 @@ discard block |
||
139 | 140 | * Raises <b>OnPageIndexChanged</b> event. |
140 | 141 | * This event is raised each time when the list changes to a different page. |
141 | 142 | * @param TPagedListPageChangedEventParameter event parameter |
143 | + * @param TPagedListPageChangedEventParameter|null $param |
|
142 | 144 | */ |
143 | 145 | public function onPageIndexChanged($param) |
144 | 146 | { |
@@ -151,6 +153,7 @@ discard block |
||
151 | 153 | * and needs the new page of data. This event can only be raised when |
152 | 154 | * {@link setCustomPaging CustomPaging} is true. |
153 | 155 | * @param TPagedListFetchDataEventParameter event parameter |
156 | + * @param TPagedListFetchDataEventParameter $param |
|
154 | 157 | */ |
155 | 158 | public function onFetchData($param) |
156 | 159 | { |
@@ -380,6 +383,7 @@ discard block |
||
380 | 383 | /** |
381 | 384 | * Constructor. |
382 | 385 | * @param integer old page index |
386 | + * @param integer $oldPage |
|
383 | 387 | */ |
384 | 388 | public function __construct($oldPage) |
385 | 389 | { |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @param array|Iterator the initial data. Default is null, meaning no initialization. |
78 | 78 | * @param boolean whether the list is read-only. Always true for paged list. |
79 | 79 | */ |
80 | - public function __construct($data=null,$readOnly=false) |
|
80 | + public function __construct($data=null, $readOnly=false) |
|
81 | 81 | { |
82 | - parent::__construct($data,true); |
|
82 | + parent::__construct($data, true); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setPageSize($value) |
113 | 113 | { |
114 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
114 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
115 | 115 | $this->_pageSize=$value; |
116 | 116 | else |
117 | 117 | throw new TInvalidDataValueException('pagedlist_pagesize_invalid'); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function onPageIndexChanged($param) |
144 | 144 | { |
145 | - $this->raiseEvent('OnPageIndexChanged',$this,$param); |
|
145 | + $this->raiseEvent('OnPageIndexChanged', $this, $param); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function onFetchData($param) |
156 | 156 | { |
157 | - $this->raiseEvent('OnFetchData',$this,$param); |
|
157 | + $this->raiseEvent('OnFetchData', $this, $param); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | return $pageIndex; |
169 | 169 | if($this->_customPaging) |
170 | 170 | { |
171 | - if($pageIndex>=0 && ($this->_virtualCount<0 || $pageIndex<$this->getPageCount())) |
|
171 | + if($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount())) |
|
172 | 172 | { |
173 | - $param=new TPagedListFetchDataEventParameter($pageIndex,$this->_pageSize*$pageIndex,$this->_pageSize); |
|
173 | + $param=new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize); |
|
174 | 174 | $this->onFetchData($param); |
175 | 175 | if(($data=$param->getData())!==null) |
176 | 176 | { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
193 | - if($pageIndex>=0 && $pageIndex<$this->getPageCount()) |
|
193 | + if($pageIndex >= 0 && $pageIndex < $this->getPageCount()) |
|
194 | 194 | { |
195 | 195 | $this->_currentPageIndex=$pageIndex; |
196 | 196 | $this->onPageIndexChanged(null); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function nextPage() |
209 | 209 | { |
210 | - return $this->gotoPage($this->_currentPageIndex+1); |
|
210 | + return $this->gotoPage($this->_currentPageIndex + 1); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function previousPage() |
218 | 218 | { |
219 | - return $this->gotoPage($this->_currentPageIndex-1); |
|
219 | + return $this->gotoPage($this->_currentPageIndex - 1); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function setVirtualCount($value) |
234 | 234 | { |
235 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
235 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
236 | 236 | $value=-1; |
237 | 237 | $this->_virtualCount=$value; |
238 | 238 | } |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | { |
245 | 245 | if($this->_customPaging) |
246 | 246 | { |
247 | - if($this->_virtualCount>=0) |
|
248 | - return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize); |
|
247 | + if($this->_virtualCount >= 0) |
|
248 | + return (int) (($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize); |
|
249 | 249 | else |
250 | 250 | return -1; |
251 | 251 | } |
252 | 252 | else |
253 | - return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize); |
|
253 | + return (int) ((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function getIsLastPage() |
268 | 268 | { |
269 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
269 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | return parent::getCount(); |
279 | 279 | else |
280 | 280 | { |
281 | - if($this->_currentPageIndex===$this->getPageCount()-1) |
|
282 | - return parent::getCount()-$this->_pageSize*$this->_currentPageIndex; |
|
281 | + if($this->_currentPageIndex===$this->getPageCount() - 1) |
|
282 | + return parent::getCount() - $this->_pageSize * $this->_currentPageIndex; |
|
283 | 283 | else |
284 | 284 | return $this->_pageSize; |
285 | 285 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | if($this->_customPaging) |
312 | 312 | return parent::itemAt($index); |
313 | 313 | else |
314 | - return parent::itemAt($this->_pageSize*$this->_currentPageIndex+$index); |
|
314 | + return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function indexOf($item) |
322 | 322 | { |
323 | 323 | $c=$this->getCount(); |
324 | - for($i=0;$i<$c;++$i) |
|
324 | + for($i=0; $i < $c; ++$i) |
|
325 | 325 | if($this->itemAt($i)===$item) |
326 | 326 | return $i; |
327 | 327 | return -1; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function offsetExists($offset) |
337 | 337 | { |
338 | - return ($offset>=0 && $offset<$this->getCount()); |
|
338 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | { |
358 | 358 | $c=$this->getCount(); |
359 | 359 | $array=array(); |
360 | - for($i=0;$i<$c;++$i) |
|
360 | + for($i=0; $i < $c; ++$i) |
|
361 | 361 | $array[$i]=$this->itemAt($i); |
362 | 362 | return $array; |
363 | 363 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @param integer offset of the first item in the new page |
424 | 424 | * @param integer number of items in the new page desired |
425 | 425 | */ |
426 | - public function __construct($pageIndex,$offset,$limit) |
|
426 | + public function __construct($pageIndex, $offset, $limit) |
|
427 | 427 | { |
428 | 428 | $this->_pageIndex=$pageIndex; |
429 | 429 | $this->_offset=$offset; |
@@ -181,22 +181,18 @@ discard block |
||
181 | 181 | $this->_currentPageIndex=$pageIndex; |
182 | 182 | $this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage)); |
183 | 183 | return $pageIndex; |
184 | - } |
|
185 | - else |
|
184 | + } else |
|
186 | 185 | return false; |
187 | - } |
|
188 | - else |
|
186 | + } else |
|
189 | 187 | return false; |
190 | - } |
|
191 | - else |
|
188 | + } else |
|
192 | 189 | { |
193 | 190 | if($pageIndex>=0 && $pageIndex<$this->getPageCount()) |
194 | 191 | { |
195 | 192 | $this->_currentPageIndex=$pageIndex; |
196 | 193 | $this->onPageIndexChanged(null); |
197 | 194 | return $pageIndex; |
198 | - } |
|
199 | - else |
|
195 | + } else |
|
200 | 196 | return false; |
201 | 197 | } |
202 | 198 | } |
@@ -248,8 +244,7 @@ discard block |
||
248 | 244 | return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize); |
249 | 245 | else |
250 | 246 | return -1; |
251 | - } |
|
252 | - else |
|
247 | + } else |
|
253 | 248 | return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize); |
254 | 249 | } |
255 | 250 |
@@ -137,6 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * This must be called internally or when instantiated. |
139 | 139 | * @param numeric sets the default priority of inserted items without a specified priority |
140 | + * @param integer $value |
|
140 | 141 | */ |
141 | 142 | protected function setDefaultPriority($value) |
142 | 143 | { |
@@ -154,6 +155,7 @@ discard block |
||
154 | 155 | /** |
155 | 156 | * This must be called internally or when instantiated. |
156 | 157 | * @param integer The precision of numeric priorities. |
158 | + * @param integer $value |
|
157 | 159 | */ |
158 | 160 | protected function setPrecision($value) |
159 | 161 | { |
@@ -590,6 +592,7 @@ discard block |
||
590 | 592 | * Combines the map elements which have a priority below the parameter value |
591 | 593 | * @param numeric the cut-off priority. All items of priority less than this are returned. |
592 | 594 | * @param boolean whether or not the input cut-off priority is inclusive. Default: false, not inclusive. |
595 | + * @param integer $priority |
|
593 | 596 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
594 | 597 | * The priorities are sorted so important priorities, lower numerics, are first. |
595 | 598 | */ |
@@ -610,6 +613,7 @@ discard block |
||
610 | 613 | * Combines the map elements which have a priority above the parameter value |
611 | 614 | * @param numeric the cut-off priority. All items of priority greater than this are returned. |
612 | 615 | * @param boolean whether or not the input cut-off priority is inclusive. Default: true, inclusive. |
616 | + * @param integer $priority |
|
613 | 617 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
614 | 618 | * The priorities are sorted so important priorities, lower numerics, are first. |
615 | 619 | */ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param integer the precision of the numeric priorities |
82 | 82 | * @throws TInvalidDataTypeException If data is not null and is neither an array nor an iterator. |
83 | 83 | */ |
84 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
84 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
85 | 85 | { |
86 | 86 | parent::__construct(); |
87 | 87 | if($data!==null) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | if($priority===null) |
121 | 121 | $priority=$this->getDefaultPriority(); |
122 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
122 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
123 | 123 | |
124 | 124 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
125 | 125 | return false; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function setDefaultPriority($value) |
142 | 142 | { |
143 | - $this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p); |
|
143 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function sortPriorities() { |
188 | 188 | if(!$this->_o) { |
189 | - ksort($this->_d,SORT_NUMERIC); |
|
189 | + ksort($this->_d, SORT_NUMERIC); |
|
190 | 190 | $this->_o=true; |
191 | 191 | } |
192 | 192 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $this->sortPriorities(); |
203 | 203 | $this->_fd=array(); |
204 | 204 | foreach($this->_d as $priority => $itemsatpriority) |
205 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
205 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
206 | 206 | return $this->_fd; |
207 | 207 | } |
208 | 208 | |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function itemAt($index) |
218 | 218 | { |
219 | - if($index>=0&&$index<$this->getCount()) { |
|
219 | + if($index >= 0 && $index < $this->getCount()) { |
|
220 | 220 | $arr=$this->flattenPriorities(); |
221 | 221 | return $arr[$index]; |
222 | 222 | } else |
223 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
223 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | { |
233 | 233 | if($priority===null) |
234 | 234 | $priority=$this->getDefaultPriority(); |
235 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
235 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
236 | 236 | |
237 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
237 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | * @param numeric the priority which to index. no parameter or null will result in the default priority |
244 | 244 | * @return mixed the element at the offset, false if no element is found at the offset |
245 | 245 | */ |
246 | - public function itemAtIndexInPriority($index,$priority=null) |
|
246 | + public function itemAtIndexInPriority($index, $priority=null) |
|
247 | 247 | { |
248 | 248 | if($priority===null) |
249 | 249 | $priority=$this->getDefaultPriority(); |
250 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
250 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
251 | 251 | |
252 | - return !isset($this->_d[$priority])?false:( |
|
253 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
252 | + return !isset($this->_d[$priority]) ? false : ( |
|
253 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | * @return int the index within the flattened array |
263 | 263 | * @throws TInvalidOperationException if the map is read-only |
264 | 264 | */ |
265 | - public function add($item,$priority=null) |
|
265 | + public function add($item, $priority=null) |
|
266 | 266 | { |
267 | 267 | if($this->getReadOnly()) |
268 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
268 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
269 | 269 | |
270 | - return $this->insertAtIndexInPriority($item,false,$priority,true); |
|
270 | + return $this->insertAtIndexInPriority($item, false, $priority, true); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
279 | 279 | * @throws TInvalidOperationException if the list is read-only |
280 | 280 | */ |
281 | - public function insertAt($index,$item) |
|
281 | + public function insertAt($index, $item) |
|
282 | 282 | { |
283 | 283 | if($this->getReadOnly()) |
284 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
284 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
285 | 285 | |
286 | - if(($priority=$this->priorityAt($index,true))!==false) |
|
287 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
286 | + if(($priority=$this->priorityAt($index, true))!==false) |
|
287 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
288 | 288 | else |
289 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
289 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -299,54 +299,54 @@ discard block |
||
299 | 299 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
300 | 300 | * @throws TInvalidOperationException if the list is read-only |
301 | 301 | */ |
302 | - public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false) |
|
302 | + public function insertAtIndexInPriority($item, $index=false, $priority=null, $preserveCache=false) |
|
303 | 303 | { |
304 | 304 | if($this->getReadOnly()) |
305 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
305 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
306 | 306 | |
307 | 307 | if($priority===null) |
308 | 308 | $priority=$this->getDefaultPriority(); |
309 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
309 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
310 | 310 | |
311 | 311 | if($preserveCache) { |
312 | 312 | $this->sortPriorities(); |
313 | 313 | $cc=0; |
314 | 314 | foreach($this->_d as $prioritykey=>$items) |
315 | - if($prioritykey>=$priority) |
|
315 | + if($prioritykey >= $priority) |
|
316 | 316 | break; |
317 | 317 | else |
318 | 318 | $cc+=count($items); |
319 | 319 | |
320 | - if($index===false&&isset($this->_d[$priority])) { |
|
320 | + if($index===false && isset($this->_d[$priority])) { |
|
321 | 321 | $c=count($this->_d[$priority]); |
322 | 322 | $c+=$cc; |
323 | 323 | $this->_d[$priority][]=$item; |
324 | 324 | } else if(isset($this->_d[$priority])) { |
325 | - $c=$index+$cc; |
|
326 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
325 | + $c=$index + $cc; |
|
326 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
327 | 327 | } else { |
328 | - $c = $cc; |
|
329 | - $this->_o = false; |
|
328 | + $c=$cc; |
|
329 | + $this->_o=false; |
|
330 | 330 | $this->_d[$priority]=array($item); |
331 | 331 | } |
332 | 332 | |
333 | - if($this->_fd&&is_array($this->_fd)) // if there is a flattened array cache |
|
334 | - array_splice($this->_fd,$c,0,array($item)); |
|
333 | + if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache |
|
334 | + array_splice($this->_fd, $c, 0, array($item)); |
|
335 | 335 | } else { |
336 | 336 | $c=null; |
337 | - if($index===false&&isset($this->_d[$priority])) { |
|
337 | + if($index===false && isset($this->_d[$priority])) { |
|
338 | 338 | $cc=count($this->_d[$priority]); |
339 | 339 | $this->_d[$priority][]=$item; |
340 | 340 | } else if(isset($this->_d[$priority])) { |
341 | 341 | $cc=$index; |
342 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
342 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
343 | 343 | } else { |
344 | 344 | $cc=0; |
345 | 345 | $this->_o=false; |
346 | 346 | $this->_d[$priority]=array($item); |
347 | 347 | } |
348 | - if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) |
|
349 | - array_splice($this->_fd,$cc,0,array($item)); |
|
348 | + if($this->_fd && is_array($this->_fd) && count($this->_d)==1) |
|
349 | + array_splice($this->_fd, $cc, 0, array($item)); |
|
350 | 350 | else |
351 | 351 | $this->_fd=null; |
352 | 352 | } |
@@ -367,22 +367,22 @@ discard block |
||
367 | 367 | * @return integer index within the flattened list at which the item is being removed |
368 | 368 | * @throws TInvalidDataValueException If the item does not exist |
369 | 369 | */ |
370 | - public function remove($item,$priority=false) |
|
370 | + public function remove($item, $priority=false) |
|
371 | 371 | { |
372 | 372 | if($this->getReadOnly()) |
373 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
373 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
374 | 374 | |
375 | - if(($p=$this->priorityOf($item,true))!==false) |
|
375 | + if(($p=$this->priorityOf($item, true))!==false) |
|
376 | 376 | { |
377 | 377 | if($priority!==false) { |
378 | 378 | if($priority===null) |
379 | 379 | $priority=$this->getDefaultPriority(); |
380 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
380 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
381 | 381 | |
382 | 382 | if($p[0]!=$priority) |
383 | 383 | throw new TInvalidDataValueException('list_item_inexistent'); |
384 | 384 | } |
385 | - $this->removeAtIndexInPriority($p[1],$p[0]); |
|
385 | + $this->removeAtIndexInPriority($p[1], $p[0]); |
|
386 | 386 | return $p[2]; |
387 | 387 | } |
388 | 388 | else |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | public function removeAt($index) |
400 | 400 | { |
401 | 401 | if($this->getReadOnly()) |
402 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
402 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
403 | 403 | |
404 | 404 | if(($priority=$this->priorityAt($index, true))!==false) |
405 | - return $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
406 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
405 | + return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
406 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | public function removeAtIndexInPriority($index, $priority=null) |
418 | 418 | { |
419 | 419 | if($this->getReadOnly()) |
420 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
420 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
421 | 421 | |
422 | 422 | if($priority===null) |
423 | 423 | $priority=$this->getDefaultPriority(); |
424 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
424 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
425 | 425 | |
426 | - if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) |
|
426 | + if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
|
427 | 427 | throw new TInvalidDataValueException('list_item_inexistent'); |
428 | 428 | |
429 | 429 | // $value is an array of elements removed, only one |
430 | - $value=array_splice($this->_d[$priority],$index,1); |
|
430 | + $value=array_splice($this->_d[$priority], $index, 1); |
|
431 | 431 | $value=$value[0]; |
432 | 432 | |
433 | 433 | if(!count($this->_d[$priority])) |
@@ -444,12 +444,12 @@ discard block |
||
444 | 444 | public function clear() |
445 | 445 | { |
446 | 446 | if($this->getReadOnly()) |
447 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
447 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
448 | 448 | |
449 | - $d=array_reverse($this->_d,true); |
|
449 | + $d=array_reverse($this->_d, true); |
|
450 | 450 | foreach($this->_d as $priority=>$items) { |
451 | - for($index=count($items)-1;$index>=0;$index--) |
|
452 | - $this->removeAtIndexInPriority($index,$priority); |
|
451 | + for($index=count($items) - 1; $index >= 0; $index--) |
|
452 | + $this->removeAtIndexInPriority($index, $priority); |
|
453 | 453 | unset($this->_d[$priority]); |
454 | 454 | } |
455 | 455 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | */ |
461 | 461 | public function contains($item) |
462 | 462 | { |
463 | - return $this->indexOf($item)>=0; |
|
463 | + return $this->indexOf($item) >= 0; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | public function indexOf($item) |
471 | 471 | { |
472 | - if(($index=array_search($item,$this->flattenPriorities(),true))===false) |
|
472 | + if(($index=array_search($item, $this->flattenPriorities(), true))===false) |
|
473 | 473 | return -1; |
474 | 474 | else |
475 | 475 | return $index; |
@@ -484,16 +484,16 @@ discard block |
||
484 | 484 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
485 | 485 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
486 | 486 | */ |
487 | - public function priorityOf($item,$withindex = false) |
|
487 | + public function priorityOf($item, $withindex=false) |
|
488 | 488 | { |
489 | 489 | $this->sortPriorities(); |
490 | 490 | |
491 | - $absindex = 0; |
|
491 | + $absindex=0; |
|
492 | 492 | foreach($this->_d as $priority=>$items) { |
493 | - if(($index=array_search($item,$items,true))!==false) { |
|
493 | + if(($index=array_search($item, $items, true))!==false) { |
|
494 | 494 | $absindex+=$index; |
495 | - return $withindex?array($priority,$index,$absindex, |
|
496 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
495 | + return $withindex ? array($priority, $index, $absindex, |
|
496 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
497 | 497 | } else |
498 | 498 | $absindex+=count($items); |
499 | 499 | } |
@@ -510,19 +510,19 @@ discard block |
||
510 | 510 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
511 | 511 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
512 | 512 | */ |
513 | - public function priorityAt($index,$withindex = false) |
|
513 | + public function priorityAt($index, $withindex=false) |
|
514 | 514 | { |
515 | - if($index<0||$index>=$this->getCount()) |
|
516 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
515 | + if($index < 0 || $index >= $this->getCount()) |
|
516 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
517 | 517 | |
518 | 518 | $absindex=$index; |
519 | 519 | $this->sortPriorities(); |
520 | 520 | foreach($this->_d as $priority=>$items) { |
521 | - if($index>=($c=count($items))) |
|
521 | + if($index >= ($c=count($items))) |
|
522 | 522 | $index-=$c; |
523 | 523 | else |
524 | - return $withindex?array($priority,$index,$absindex, |
|
525 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
524 | + return $withindex ? array($priority, $index, $absindex, |
|
525 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
526 | 526 | } |
527 | 527 | return false; |
528 | 528 | } |
@@ -538,12 +538,12 @@ discard block |
||
538 | 538 | public function insertBefore($indexitem, $item) |
539 | 539 | { |
540 | 540 | if($this->getReadOnly()) |
541 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
541 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
542 | 542 | |
543 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
543 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
544 | 544 | throw new TInvalidDataValueException('list_item_inexistent'); |
545 | 545 | |
546 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
546 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
547 | 547 | |
548 | 548 | return $priority[2]; |
549 | 549 | } |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | public function insertAfter($indexitem, $item) |
560 | 560 | { |
561 | 561 | if($this->getReadOnly()) |
562 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
562 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
563 | 563 | |
564 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
564 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
565 | 565 | throw new TInvalidDataValueException('list_item_inexistent'); |
566 | 566 | |
567 | - $this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]); |
|
567 | + $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
|
568 | 568 | |
569 | - return $priority[2]+1; |
|
569 | + return $priority[2] + 1; |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
@@ -593,15 +593,15 @@ discard block |
||
593 | 593 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
594 | 594 | * The priorities are sorted so important priorities, lower numerics, are first. |
595 | 595 | */ |
596 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
596 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
597 | 597 | { |
598 | 598 | $this->sortPriorities(); |
599 | 599 | $items=array(); |
600 | 600 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
601 | 601 | { |
602 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
602 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
603 | 603 | break; |
604 | - $items=array_merge($items,$itemsatpriority); |
|
604 | + $items=array_merge($items, $itemsatpriority); |
|
605 | 605 | } |
606 | 606 | return $items; |
607 | 607 | } |
@@ -613,15 +613,15 @@ discard block |
||
613 | 613 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
614 | 614 | * The priorities are sorted so important priorities, lower numerics, are first. |
615 | 615 | */ |
616 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
616 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
617 | 617 | { |
618 | 618 | $this->sortPriorities(); |
619 | 619 | $items=array(); |
620 | 620 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
621 | 621 | { |
622 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
622 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
623 | 623 | continue; |
624 | - $items=array_merge($items,$itemsatpriority); |
|
624 | + $items=array_merge($items, $itemsatpriority); |
|
625 | 625 | } |
626 | 626 | return $items; |
627 | 627 | } |
@@ -637,15 +637,15 @@ discard block |
||
637 | 637 | { |
638 | 638 | if($data instanceof TPriorityList) |
639 | 639 | { |
640 | - if($this->getCount()>0) |
|
640 | + if($this->getCount() > 0) |
|
641 | 641 | $this->clear(); |
642 | 642 | foreach($data->getPriorities() as $priority) |
643 | 643 | { |
644 | 644 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
645 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
645 | + $this->insertAtIndexInPriority($item, $index, $priority); |
|
646 | 646 | } |
647 | - } else if(is_array($data)||$data instanceof Traversable) { |
|
648 | - if($this->getCount()>0) |
|
647 | + } else if(is_array($data) || $data instanceof Traversable) { |
|
648 | + if($this->getCount() > 0) |
|
649 | 649 | $this->clear(); |
650 | 650 | foreach($data as $key=>$item) |
651 | 651 | $this->add($item); |
@@ -668,10 +668,10 @@ discard block |
||
668 | 668 | foreach($data->getPriorities() as $priority) |
669 | 669 | { |
670 | 670 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
671 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
671 | + $this->insertAtIndexInPriority($item, false, $priority); |
|
672 | 672 | } |
673 | 673 | } |
674 | - else if(is_array($data)||$data instanceof Traversable) |
|
674 | + else if(is_array($data) || $data instanceof Traversable) |
|
675 | 675 | { |
676 | 676 | foreach($data as $priority=>$item) |
677 | 677 | $this->add($item); |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | */ |
690 | 690 | public function offsetExists($offset) |
691 | 691 | { |
692 | - return ($offset>=0&&$offset<$this->getCount()); |
|
692 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
@@ -715,18 +715,18 @@ discard block |
||
715 | 715 | * @param integer the offset to set element |
716 | 716 | * @param mixed the element value |
717 | 717 | */ |
718 | - public function offsetSet($offset,$item) |
|
718 | + public function offsetSet($offset, $item) |
|
719 | 719 | { |
720 | 720 | if($offset===null) |
721 | 721 | return $this->add($item); |
722 | 722 | if($offset===$this->getCount()) { |
723 | - $priority=$this->priorityAt($offset-1,true); |
|
723 | + $priority=$this->priorityAt($offset - 1, true); |
|
724 | 724 | $priority[1]++; |
725 | 725 | } else { |
726 | - $priority=$this->priorityAt($offset,true); |
|
727 | - $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
726 | + $priority=$this->priorityAt($offset, true); |
|
727 | + $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
728 | 728 | } |
729 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
729 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -384,8 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | $this->removeAtIndexInPriority($p[1],$p[0]); |
386 | 386 | return $p[2]; |
387 | - } |
|
388 | - else |
|
387 | + } else |
|
389 | 388 | throw new TInvalidDataValueException('list_item_inexistent'); |
390 | 389 | } |
391 | 390 | |
@@ -670,14 +669,12 @@ discard block |
||
670 | 669 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
671 | 670 | $this->insertAtIndexInPriority($item,false,$priority); |
672 | 671 | } |
673 | - } |
|
674 | - else if(is_array($data)||$data instanceof Traversable) |
|
672 | + } else if(is_array($data)||$data instanceof Traversable) |
|
675 | 673 | { |
676 | 674 | foreach($data as $priority=>$item) |
677 | 675 | $this->add($item); |
678 | 676 | |
679 | - } |
|
680 | - else if($data!==null) |
|
677 | + } else if($data!==null) |
|
681 | 678 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
682 | 679 | } |
683 | 680 |
@@ -114,6 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | /** |
116 | 116 | * @param boolean whether this list is read-only or not |
117 | + * @param boolean $value |
|
117 | 118 | */ |
118 | 119 | protected function setReadOnly($value) |
119 | 120 | { |
@@ -131,6 +132,7 @@ discard block |
||
131 | 132 | /** |
132 | 133 | * This must be called internally or when instantiated. |
133 | 134 | * @param numeric sets the default priority of inserted items without a specified priority |
135 | + * @param integer $value |
|
134 | 136 | */ |
135 | 137 | protected function setDefaultPriority($value) |
136 | 138 | { |
@@ -148,6 +150,7 @@ discard block |
||
148 | 150 | /** |
149 | 151 | * This must be called internally or when instantiated. |
150 | 152 | * @param integer The precision of numeric priorities. |
153 | + * @param integer $value |
|
151 | 154 | */ |
152 | 155 | protected function setPrecision($value) |
153 | 156 | { |
@@ -338,7 +341,7 @@ discard block |
||
338 | 341 | * @param mixed key |
339 | 342 | * @param mixed value |
340 | 343 | * @param numeric|null priority, default: null, filled in with default priority |
341 | - * @return numeric priority at which the pair was added |
|
344 | + * @return string priority at which the pair was added |
|
342 | 345 | * @throws TInvalidOperationException if the map is read-only |
343 | 346 | */ |
344 | 347 | public function add($key,$value,$priority=null) |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param integer the precision of the numeric priorities |
96 | 96 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
97 | 97 | */ |
98 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
98 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
99 | 99 | { |
100 | 100 | if($data!==null) |
101 | 101 | $this->copyFrom($data); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function setDefaultPriority($value) |
136 | 136 | { |
137 | - $this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p); |
|
137 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | return $this->_fd; |
185 | 185 | |
186 | 186 | $this->sortPriorities(); |
187 | - $this->_fd = array(); |
|
187 | + $this->_fd=array(); |
|
188 | 188 | foreach($this->_d as $priority => $itemsatpriority) |
189 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
189 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
190 | 190 | return $this->_fd; |
191 | 191 | } |
192 | 192 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | { |
219 | 219 | if($priority===null) |
220 | 220 | $priority=$this->getDefaultPriority(); |
221 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
221 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
222 | 222 | |
223 | - if(!isset($this->_d[$priority])||!is_array($this->_d[$priority])) |
|
223 | + if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
|
224 | 224 | return false; |
225 | 225 | return count($this->_d[$priority]); |
226 | 226 | } |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | * and numeric is a specific priority. default: false, any priority. |
253 | 253 | * @return mixed the element at the offset, null if no element is found at the offset |
254 | 254 | */ |
255 | - public function itemAt($key,$priority=false) |
|
255 | + public function itemAt($key, $priority=false) |
|
256 | 256 | { |
257 | - if($priority===false){ |
|
257 | + if($priority===false) { |
|
258 | 258 | $map=$this->flattenPriorities(); |
259 | - return isset($map[$key])?$map[$key]:null; |
|
259 | + return isset($map[$key]) ? $map[$key] : null; |
|
260 | 260 | } else { |
261 | 261 | if($priority===null) |
262 | 262 | $priority=$this->getDefaultPriority(); |
263 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
264 | - return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null; |
|
263 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
264 | + return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key])) ? $this->_d[$priority][$key] : null; |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | * @param numeric|null the priority. default: null, filled in with the default priority numeric. |
273 | 273 | * @return numeric old priority of the item |
274 | 274 | */ |
275 | - public function setPriorityAt($key,$priority=null) |
|
275 | + public function setPriorityAt($key, $priority=null) |
|
276 | 276 | { |
277 | 277 | if($priority===null) |
278 | 278 | $priority=$this->getDefaultPriority(); |
279 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
279 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
280 | 280 | |
281 | 281 | $oldpriority=$this->priorityAt($key); |
282 | - if($oldpriority!==false&&$oldpriority!=$priority) { |
|
283 | - $value=$this->remove($key,$oldpriority); |
|
284 | - $this->add($key,$value,$priority); |
|
282 | + if($oldpriority!==false && $oldpriority!=$priority) { |
|
283 | + $value=$this->remove($key, $oldpriority); |
|
284 | + $this->add($key, $value, $priority); |
|
285 | 285 | } |
286 | 286 | return $oldpriority; |
287 | 287 | } |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | { |
296 | 296 | if($priority===null) |
297 | 297 | $priority=$this->getDefaultPriority(); |
298 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
298 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
299 | 299 | |
300 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
300 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | { |
310 | 310 | $this->sortPriorities(); |
311 | 311 | foreach($this->_d as $priority=>$items) |
312 | - if(($index=array_search($item,$items,true))!==false) |
|
312 | + if(($index=array_search($item, $items, true))!==false) |
|
313 | 313 | return $priority; |
314 | 314 | return false; |
315 | 315 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | { |
324 | 324 | $this->sortPriorities(); |
325 | 325 | foreach($this->_d as $priority=>$items) |
326 | - if(array_key_exists($key,$items)) |
|
326 | + if(array_key_exists($key, $items)) |
|
327 | 327 | return $priority; |
328 | 328 | return false; |
329 | 329 | } |
@@ -341,16 +341,16 @@ discard block |
||
341 | 341 | * @return numeric priority at which the pair was added |
342 | 342 | * @throws TInvalidOperationException if the map is read-only |
343 | 343 | */ |
344 | - public function add($key,$value,$priority=null) |
|
344 | + public function add($key, $value, $priority=null) |
|
345 | 345 | { |
346 | 346 | if($priority===null) |
347 | 347 | $priority=$this->getDefaultPriority(); |
348 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
348 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
349 | 349 | |
350 | 350 | if(!$this->_r) |
351 | 351 | { |
352 | 352 | foreach($this->_d as $innerpriority=>$items) |
353 | - if(array_key_exists($key,$items)) |
|
353 | + if(array_key_exists($key, $items)) |
|
354 | 354 | { |
355 | 355 | unset($this->_d[$innerpriority][$key]); |
356 | 356 | $this->_c--; |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $this->_fd=null; |
368 | 368 | } |
369 | 369 | else |
370 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
370 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
371 | 371 | return $priority; |
372 | 372 | } |
373 | 373 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return mixed the removed value, null if no such key exists. |
384 | 384 | * @throws TInvalidOperationException if the map is read-only |
385 | 385 | */ |
386 | - public function remove($key,$priority=false) |
|
386 | + public function remove($key, $priority=false) |
|
387 | 387 | { |
388 | 388 | if(!$this->_r) |
389 | 389 | { |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | { |
395 | 395 | $this->sortPriorities(); |
396 | 396 | foreach($this->_d as $priority=>$items) |
397 | - if(array_key_exists($key,$items)) |
|
397 | + if(array_key_exists($key, $items)) |
|
398 | 398 | { |
399 | 399 | $value=$this->_d[$priority][$key]; |
400 | 400 | unset($this->_d[$priority][$key]); |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | } |
412 | 412 | else |
413 | 413 | { |
414 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
415 | - if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority]))) |
|
414 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
415 | + if(isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority]))) |
|
416 | 416 | { |
417 | 417 | $value=$this->_d[$priority][$key]; |
418 | 418 | unset($this->_d[$priority][$key]); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | } |
430 | 430 | } |
431 | 431 | else |
432 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
432 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | public function contains($key) |
450 | 450 | { |
451 | 451 | $map=$this->flattenPriorities(); |
452 | - return isset($map[$key])||array_key_exists($key,$map); |
|
452 | + return isset($map[$key]) || array_key_exists($key, $map); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -470,15 +470,15 @@ discard block |
||
470 | 470 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
471 | 471 | * The priorities are sorted so important priorities, lower numerics, are first. |
472 | 472 | */ |
473 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
473 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
474 | 474 | { |
475 | 475 | $this->sortPriorities(); |
476 | 476 | $items=array(); |
477 | 477 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
478 | 478 | { |
479 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
479 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
480 | 480 | break; |
481 | - $items=array_merge($items,$itemsatpriority); |
|
481 | + $items=array_merge($items, $itemsatpriority); |
|
482 | 482 | } |
483 | 483 | return $items; |
484 | 484 | } |
@@ -490,15 +490,15 @@ discard block |
||
490 | 490 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
491 | 491 | * The priorities are sorted so important priorities, lower numerics, are first. |
492 | 492 | */ |
493 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
493 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
494 | 494 | { |
495 | 495 | $this->sortPriorities(); |
496 | 496 | $items=array(); |
497 | 497 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
498 | 498 | { |
499 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
499 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
500 | 500 | continue; |
501 | - $items=array_merge($items,$itemsatpriority); |
|
501 | + $items=array_merge($items, $itemsatpriority); |
|
502 | 502 | } |
503 | 503 | return $items; |
504 | 504 | } |
@@ -514,20 +514,20 @@ discard block |
||
514 | 514 | { |
515 | 515 | if($data instanceof TPriorityMap) |
516 | 516 | { |
517 | - if($this->getCount()>0) |
|
517 | + if($this->getCount() > 0) |
|
518 | 518 | $this->clear(); |
519 | 519 | foreach($data->getPriorities() as $priority) { |
520 | 520 | foreach($data->itemsAtPriority($priority) as $key => $value) { |
521 | - $this->add($key,$value,$priority); |
|
521 | + $this->add($key, $value, $priority); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | } |
525 | - else if(is_array($data)||$data instanceof Traversable) |
|
525 | + else if(is_array($data) || $data instanceof Traversable) |
|
526 | 526 | { |
527 | - if($this->getCount()>0) |
|
527 | + if($this->getCount() > 0) |
|
528 | 528 | $this->clear(); |
529 | 529 | foreach($data as $key=>$value) |
530 | - $this->add($key,$value); |
|
530 | + $this->add($key, $value); |
|
531 | 531 | } |
532 | 532 | else if($data!==null) |
533 | 533 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | foreach($data->getPriorities() as $priority) |
548 | 548 | { |
549 | 549 | foreach($data->itemsAtPriority($priority) as $key => $value) |
550 | - $this->add($key,$value,$priority); |
|
550 | + $this->add($key, $value, $priority); |
|
551 | 551 | } |
552 | 552 | } |
553 | - else if(is_array($data)||$data instanceof Traversable) |
|
553 | + else if(is_array($data) || $data instanceof Traversable) |
|
554 | 554 | { |
555 | 555 | foreach($data as $key=>$value) |
556 | - $this->add($key,$value); |
|
556 | + $this->add($key, $value); |
|
557 | 557 | } |
558 | 558 | else if($data!==null) |
559 | 559 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | * @param integer the offset to set element |
588 | 588 | * @param mixed the element value |
589 | 589 | */ |
590 | - public function offsetSet($offset,$item) |
|
590 | + public function offsetSet($offset, $item) |
|
591 | 591 | { |
592 | - $this->add($offset,$item); |
|
592 | + $this->add($offset, $item); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -360,13 +360,11 @@ discard block |
||
360 | 360 | if(!isset($this->_d[$priority])) { |
361 | 361 | $this->_d[$priority]=array($key=>$value); |
362 | 362 | $this->_o=false; |
363 | - } |
|
364 | - else |
|
363 | + } else |
|
365 | 364 | $this->_d[$priority][$key]=$value; |
366 | 365 | $this->_c++; |
367 | 366 | $this->_fd=null; |
368 | - } |
|
369 | - else |
|
367 | + } else |
|
370 | 368 | throw new TInvalidOperationException('map_readonly',get_class($this)); |
371 | 369 | return $priority; |
372 | 370 | } |
@@ -408,8 +406,7 @@ discard block |
||
408 | 406 | return $value; |
409 | 407 | } |
410 | 408 | return null; |
411 | - } |
|
412 | - else |
|
409 | + } else |
|
413 | 410 | { |
414 | 411 | $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
415 | 412 | if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority]))) |
@@ -423,12 +420,10 @@ discard block |
||
423 | 420 | } |
424 | 421 | $this->_fd=null; |
425 | 422 | return $value; |
426 | - } |
|
427 | - else |
|
423 | + } else |
|
428 | 424 | return null; |
429 | 425 | } |
430 | - } |
|
431 | - else |
|
426 | + } else |
|
432 | 427 | throw new TInvalidOperationException('map_readonly',get_class($this)); |
433 | 428 | } |
434 | 429 | |
@@ -521,15 +516,13 @@ discard block |
||
521 | 516 | $this->add($key,$value,$priority); |
522 | 517 | } |
523 | 518 | } |
524 | - } |
|
525 | - else if(is_array($data)||$data instanceof Traversable) |
|
519 | + } else if(is_array($data)||$data instanceof Traversable) |
|
526 | 520 | { |
527 | 521 | if($this->getCount()>0) |
528 | 522 | $this->clear(); |
529 | 523 | foreach($data as $key=>$value) |
530 | 524 | $this->add($key,$value); |
531 | - } |
|
532 | - else if($data!==null) |
|
525 | + } else if($data!==null) |
|
533 | 526 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
534 | 527 | } |
535 | 528 | |
@@ -549,13 +542,11 @@ discard block |
||
549 | 542 | foreach($data->itemsAtPriority($priority) as $key => $value) |
550 | 543 | $this->add($key,$value,$priority); |
551 | 544 | } |
552 | - } |
|
553 | - else if(is_array($data)||$data instanceof Traversable) |
|
545 | + } else if(is_array($data)||$data instanceof Traversable) |
|
554 | 546 | { |
555 | 547 | foreach($data as $key=>$value) |
556 | 548 | $this->add($key,$value); |
557 | - } |
|
558 | - else if($data!==null) |
|
549 | + } else if($data!==null) |
|
559 | 550 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
560 | 551 | } |
561 | 552 |
@@ -67,6 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @param ICache application cache |
70 | + * @param ICache $value |
|
70 | 71 | */ |
71 | 72 | public function setCache($value) |
72 | 73 | { |
@@ -75,6 +76,7 @@ discard block |
||
75 | 76 | |
76 | 77 | /** |
77 | 78 | * @param TDbConnection default database connection |
79 | + * @param TDbConnection $conn |
|
78 | 80 | */ |
79 | 81 | public function setDbConnection($conn) |
80 | 82 | { |
@@ -90,6 +92,7 @@ discard block |
||
90 | 92 | } |
91 | 93 | |
92 | 94 | /** |
95 | + * @param TComponent $self |
|
93 | 96 | * @return TActiveRecordManager static instance of record manager. |
94 | 97 | */ |
95 | 98 | public static function getInstance($self=null) |
@@ -152,6 +155,7 @@ discard block |
||
152 | 155 | /** |
153 | 156 | * Define the way an active record finder react if an invalid magic-finder invoked |
154 | 157 | * @param TActiveRecordInvalidFinderResult |
158 | + * @param TActiveRecordInvalidFinderResult $value |
|
155 | 159 | * @since 3.1.5 |
156 | 160 | * @see getInvalidFinderResult |
157 | 161 | */ |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class TActiveRecordManager extends TComponent |
37 | 37 | { |
38 | - const DEFAULT_GATEWAY_CLASS = 'System.Data.ActiveRecord.TActiveRecordGateway'; |
|
38 | + const DEFAULT_GATEWAY_CLASS='System.Data.ActiveRecord.TActiveRecordGateway'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Defaults to {@link TActiveRecordManager::DEFAULT_GATEWAY_CLASS DEFAULT_GATEWAY_CLASS} |
42 | 42 | * @var string |
43 | 43 | */ |
44 | - private $_gatewayClass = self::DEFAULT_GATEWAY_CLASS; |
|
44 | + private $_gatewayClass=self::DEFAULT_GATEWAY_CLASS; |
|
45 | 45 | |
46 | 46 | private $_gateway; |
47 | 47 | private $_meta=array(); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @var TActiveRecordInvalidFinderResult |
56 | 56 | * @since 3.1.5 |
57 | 57 | */ |
58 | - private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null; |
|
58 | + private $_invalidFinderResult=TActiveRecordInvalidFinderResult::Null; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @return ICache application cache. |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if($self!==null) |
99 | 99 | $instance=$self; |
100 | 100 | else if($instance===null) |
101 | - $instance = new self; |
|
101 | + $instance=new self; |
|
102 | 102 | return $instance; |
103 | 103 | } |
104 | 104 | |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getRecordGateway() |
109 | 109 | { |
110 | - if($this->_gateway === null) { |
|
111 | - $this->_gateway = $this->createRecordGateway(); |
|
110 | + if($this->_gateway===null) { |
|
111 | + $this->_gateway=$this->createRecordGateway(); |
|
112 | 112 | } |
113 | 113 | return $this->_gateway; |
114 | 114 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function setGatewayClass($value) |
129 | 129 | { |
130 | - $this->_gateway = null; |
|
131 | - $this->_gatewayClass = (string)$value; |
|
130 | + $this->_gateway=null; |
|
131 | + $this->_gatewayClass=(string) $value; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -157,6 +157,6 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function setInvalidFinderResult($value) |
159 | 159 | { |
160 | - $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult'); |
|
160 | + $this->_invalidFinderResult=TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult'); |
|
161 | 161 | } |
162 | 162 | } |
@@ -100,6 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param TDbTableInfo table or view information. |
103 | + * @param TDbTableInfo $tableInfo |
|
103 | 104 | */ |
104 | 105 | protected function setTableInfo($tableInfo) |
105 | 106 | { |
@@ -110,6 +111,7 @@ discard block |
||
110 | 111 | /** |
111 | 112 | * Sets up the command builder for the given table. |
112 | 113 | * @param string table or view name. |
114 | + * @param string $tableName |
|
113 | 115 | */ |
114 | 116 | protected function setTableName($tableName) |
115 | 117 | { |
@@ -185,7 +187,7 @@ discard block |
||
185 | 187 | * Execute arbituary sql command with binding parameters. |
186 | 188 | * @param string SQL query string. |
187 | 189 | * @param array binding parameters, positional or named. |
188 | - * @return array query results. |
|
190 | + * @return TDbDataReader query results. |
|
189 | 191 | */ |
190 | 192 | public function findBySql($sql, $parameters=array()) |
191 | 193 | { |
@@ -222,6 +224,7 @@ discard block |
||
222 | 224 | * |
223 | 225 | * @param string|TSqlCriteria SQL condition or criteria object. |
224 | 226 | * @param mixed parameter values. |
227 | + * @param TActiveRecordCriteria $criteria |
|
225 | 228 | * @return array matching record object. |
226 | 229 | */ |
227 | 230 | public function find($criteria, $parameters=array()) |
@@ -235,6 +238,7 @@ discard block |
||
235 | 238 | * Accepts same parameters as find(), but returns TDbDataReader instead. |
236 | 239 | * @param string|TSqlCriteria SQL condition or criteria object. |
237 | 240 | * @param mixed parameter values. |
241 | + * @param TActiveRecordCriteria $criteria |
|
238 | 242 | * @return TDbDataReader matching records. |
239 | 243 | */ |
240 | 244 | public function findAll($criteria=null, $parameters=array()) |
@@ -297,6 +301,7 @@ discard block |
||
297 | 301 | * </code> |
298 | 302 | * @param string delete condition. |
299 | 303 | * @param array condition parameters. |
304 | + * @param TActiveRecordCriteria $criteria |
|
300 | 305 | * @return integer number of records deleted. |
301 | 306 | */ |
302 | 307 | public function deleteAll($criteria, $parameters=array()) |
@@ -385,7 +390,7 @@ discard block |
||
385 | 390 | * Inserts a new record into the table. Each array key must |
386 | 391 | * correspond to a column name in the table unless a null value is permitted. |
387 | 392 | * @param array new record data. |
388 | - * @return mixed last insert id if one column contains a serial or sequence, |
|
393 | + * @return string|boolean last insert id if one column contains a serial or sequence, |
|
389 | 394 | * otherwise true if command executes successfully and affected 1 or more rows. |
390 | 395 | */ |
391 | 396 | public function insert($data) |
@@ -394,7 +399,7 @@ discard block |
||
394 | 399 | } |
395 | 400 | |
396 | 401 | /** |
397 | - * @return mixed last insert id, null if none is found. |
|
402 | + * @return string|null last insert id, null if none is found. |
|
398 | 403 | */ |
399 | 404 | public function getLastInsertId() |
400 | 405 | { |
@@ -416,8 +416,7 @@ |
||
416 | 416 | { |
417 | 417 | $useArgs = !is_array($parameters) && is_array($args); |
418 | 418 | return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
419 | - } |
|
420 | - else if($criteria instanceof TSqlCriteria) |
|
419 | + } else if($criteria instanceof TSqlCriteria) |
|
421 | 420 | return $criteria; |
422 | 421 | else |
423 | 422 | throw new TDbException('dbtablegateway_invalid_criteria'); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string|TDbTableInfo table or view name or table information. |
88 | 88 | * @param TDbConnection database connection. |
89 | 89 | */ |
90 | - public function __construct($table,$connection) |
|
90 | + public function __construct($table, $connection) |
|
91 | 91 | { |
92 | 92 | $this->_connection=$connection; |
93 | 93 | if(is_string($table)) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function setTableInfo($tableInfo) |
105 | 105 | { |
106 | - $builder = $tableInfo->createCommandBuilder($this->getDbConnection()); |
|
106 | + $builder=$tableInfo->createCommandBuilder($this->getDbConnection()); |
|
107 | 107 | $this->initCommandBuilder($builder); |
108 | 108 | } |
109 | 109 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | protected function setTableName($tableName) |
115 | 115 | { |
116 | 116 | Prado::using('System.Data.Common.TDbMetaData'); |
117 | - $meta = TDbMetaData::getInstance($this->getDbConnection()); |
|
117 | + $meta=TDbMetaData::getInstance($this->getDbConnection()); |
|
118 | 118 | $this->initCommandBuilder($meta->createCommandBuilder($tableName)); |
119 | 119 | } |
120 | 120 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function initCommandBuilder($builder) |
135 | 135 | { |
136 | - $this->_command = new TDataGatewayCommand($builder); |
|
137 | - $this->_command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
138 | - $this->_command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
136 | + $this->_command=new TDataGatewayCommand($builder); |
|
137 | + $this->_command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
138 | + $this->_command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function findBySql($sql, $parameters=array()) |
191 | 191 | { |
192 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
193 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
192 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
193 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
194 | 194 | return $this->getCommand()->findBySql($criteria); |
195 | 195 | } |
196 | 196 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function findAllBySql($sql, $parameters=array()) |
204 | 204 | { |
205 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
206 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
205 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
206 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
207 | 207 | return $this->getCommand()->findAllBySql($criteria); |
208 | 208 | } |
209 | 209 | |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function find($criteria, $parameters=array()) |
228 | 228 | { |
229 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
230 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
229 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
230 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
231 | 231 | return $this->getCommand()->find($criteria); |
232 | 232 | } |
233 | 233 | |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function findAll($criteria=null, $parameters=array()) |
241 | 241 | { |
242 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
242 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
243 | 243 | if($criteria!==null) |
244 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
244 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
245 | 245 | return $this->getCommand()->findAll($criteria); |
246 | 246 | } |
247 | 247 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | public function findByPk($keys) |
261 | 261 | { |
262 | 262 | if(func_num_args() > 1) |
263 | - $keys = func_get_args(); |
|
263 | + $keys=func_get_args(); |
|
264 | 264 | return $this->getCommand()->findByPk($keys); |
265 | 265 | } |
266 | 266 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | public function findAllByPks($keys) |
285 | 285 | { |
286 | 286 | if(func_num_args() > 1) |
287 | - $keys = func_get_args(); |
|
287 | + $keys=func_get_args(); |
|
288 | 288 | return $this->getCommand()->findAllByPk($keys); |
289 | 289 | } |
290 | 290 | |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function deleteAll($criteria, $parameters=array()) |
303 | 303 | { |
304 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
305 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
304 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
305 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
306 | 306 | return $this->getCommand()->delete($criteria); |
307 | 307 | } |
308 | 308 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public function deleteByPk($keys) |
333 | 333 | { |
334 | 334 | if(func_num_args() > 1) |
335 | - $keys = func_get_args(); |
|
335 | + $keys=func_get_args(); |
|
336 | 336 | return $this->getCommand()->deleteByPk($keys); |
337 | 337 | } |
338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | public function deleteAllByPks($keys) |
343 | 343 | { |
344 | 344 | if(func_num_args() > 1) |
345 | - $keys = func_get_args(); |
|
345 | + $keys=func_get_args(); |
|
346 | 346 | return $this->deleteByPk($keys); |
347 | 347 | } |
348 | 348 | |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | * @param mixed parameter values. |
353 | 353 | * @return int number of records. |
354 | 354 | */ |
355 | - public function count($criteria=null,$parameters=array()) |
|
355 | + public function count($criteria=null, $parameters=array()) |
|
356 | 356 | { |
357 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
357 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
358 | 358 | if($criteria!==null) |
359 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
359 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
360 | 360 | return $this->getCommand()->count($criteria); |
361 | 361 | } |
362 | 362 | |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function update($data, $criteria, $parameters=array()) |
378 | 378 | { |
379 | - $args = func_num_args() > 2 ? array_slice(func_get_args(),2) : null; |
|
380 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
379 | + $args=func_num_args() > 2 ? array_slice(func_get_args(), 2) : null; |
|
380 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
381 | 381 | return $this->getCommand()->update($data, $criteria); |
382 | 382 | } |
383 | 383 | |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | { |
415 | 415 | if(is_string($criteria)) |
416 | 416 | { |
417 | - $useArgs = !is_array($parameters) && is_array($args); |
|
418 | - return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
|
417 | + $useArgs=!is_array($parameters) && is_array($args); |
|
418 | + return new TSqlCriteria($criteria, $useArgs ? $args : $parameters); |
|
419 | 419 | } |
420 | 420 | else if($criteria instanceof TSqlCriteria) |
421 | 421 | return $criteria; |
@@ -452,21 +452,21 @@ discard block |
||
452 | 452 | * @return mixed single record if method name starts with "findBy", 0 or more records |
453 | 453 | * if method name starts with "findAllBy" |
454 | 454 | */ |
455 | - public function __call($method,$args) |
|
455 | + public function __call($method, $args) |
|
456 | 456 | { |
457 | - $delete =false; |
|
458 | - if($findOne = substr(strtolower($method),0,6)==='findby') |
|
459 | - $condition = $method[6]==='_' ? substr($method,7) : substr($method,6); |
|
460 | - else if(substr(strtolower($method),0,9)==='findallby') |
|
461 | - $condition = $method[9]==='_' ? substr($method,10) : substr($method,9); |
|
462 | - else if($delete = substr(strtolower($method),0,8)==='deleteby') |
|
463 | - $condition = $method[8]==='_' ? substr($method,9) : substr($method,8); |
|
464 | - else if($delete = substr(strtolower($method),0,11)==='deleteallby') |
|
465 | - $condition = $method[11]==='_' ? substr($method,12) : substr($method,11); |
|
457 | + $delete=false; |
|
458 | + if($findOne=substr(strtolower($method), 0, 6)==='findby') |
|
459 | + $condition=$method[6]==='_' ? substr($method, 7) : substr($method, 6); |
|
460 | + else if(substr(strtolower($method), 0, 9)==='findallby') |
|
461 | + $condition=$method[9]==='_' ? substr($method, 10) : substr($method, 9); |
|
462 | + else if($delete=substr(strtolower($method), 0, 8)==='deleteby') |
|
463 | + $condition=$method[8]==='_' ? substr($method, 9) : substr($method, 8); |
|
464 | + else if($delete=substr(strtolower($method), 0, 11)==='deleteallby') |
|
465 | + $condition=$method[11]==='_' ? substr($method, 12) : substr($method, 11); |
|
466 | 466 | else |
467 | 467 | return null; |
468 | 468 | |
469 | - $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
469 | + $criteria=$this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
470 | 470 | if($delete) |
471 | 471 | return $this->deleteAll($criteria); |
472 | 472 | else |
@@ -129,6 +129,7 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * Register a mapped statement that will trigger a cache flush. |
131 | 131 | * @param TMappedStatement mapped statement that may flush the cache. |
132 | + * @param IMappedStatement $mappedStatement |
|
132 | 133 | */ |
133 | 134 | public function registerTriggerStatement($mappedStatement) |
134 | 135 | { |
@@ -145,6 +146,7 @@ discard block |
||
145 | 146 | |
146 | 147 | /** |
147 | 148 | * @param TSqlMapCacheKey|string cache key |
149 | + * @param string $key |
|
148 | 150 | * @return mixed cached value. |
149 | 151 | */ |
150 | 152 | public function get($key) |
@@ -163,6 +165,7 @@ discard block |
||
163 | 165 | /** |
164 | 166 | * @param TSqlMapCacheKey|string cache key |
165 | 167 | * @param mixed value to be cached. |
168 | + * @param string $key |
|
166 | 169 | */ |
167 | 170 | public function set($key, $value) |
168 | 171 | { |
@@ -174,7 +177,7 @@ discard block |
||
174 | 177 | } |
175 | 178 | |
176 | 179 | /** |
177 | - * @return float cache hit ratio. |
|
180 | + * @return integer cache hit ratio. |
|
178 | 181 | */ |
179 | 182 | public function getHitRatio() |
180 | 183 | { |
@@ -223,7 +226,7 @@ discard block |
||
223 | 226 | } |
224 | 227 | |
225 | 228 | /** |
226 | - * @param string serialized object |
|
229 | + * @param string string object |
|
227 | 230 | * @return string crc32 hash of the serialized object. |
228 | 231 | */ |
229 | 232 | protected function generateKey($string) |
@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | class TSqlMapCacheModel extends TComponent |
34 | 34 | { |
35 | 35 | private $_cache; |
36 | - private $_hits = 0; |
|
37 | - private $_requests = 0; |
|
36 | + private $_hits=0; |
|
37 | + private $_requests=0; |
|
38 | 38 | private $_id; |
39 | 39 | private $_implementation=TSqlMapCacheTypes::Basic; |
40 | - private $_properties = array(); |
|
41 | - private $_flushInterval = 0; |
|
40 | + private $_properties=array(); |
|
41 | + private $_flushInterval=0; |
|
42 | 42 | |
43 | - private static $_cacheTypes = array(); |
|
43 | + private static $_cacheTypes=array(); |
|
44 | 44 | |
45 | 45 | public static function registerCacheType($type, $className) |
46 | 46 | { |
47 | - self::$_cacheTypes[$type] = $className; |
|
47 | + self::$_cacheTypes[$type]=$className; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function setID($value) |
62 | 62 | { |
63 | - $this->_id = $value; |
|
63 | + $this->_id=$value; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setImplementation($value) |
78 | 78 | { |
79 | - if (isset(self::$_cacheTypes[$value])) |
|
80 | - $this->_implementation = $value; |
|
79 | + if(isset(self::$_cacheTypes[$value])) |
|
80 | + $this->_implementation=$value; |
|
81 | 81 | else |
82 | - $this->_implementation = TPropertyValue::ensureEnum($value,'TSqlMapCacheTypes'); |
|
82 | + $this->_implementation=TPropertyValue::ensureEnum($value, 'TSqlMapCacheTypes'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | public function initialize($cache=null) |
106 | 106 | { |
107 | 107 | if($cache===null) |
108 | - $this->_cache= Prado::createComponent($this->getImplementationClass(), $this); |
|
108 | + $this->_cache=Prado::createComponent($this->getImplementationClass(), $this); |
|
109 | 109 | else |
110 | 110 | $this->_cache=$cache; |
111 | 111 | } |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function getImplementationClass() |
117 | 117 | { |
118 | - $implementation = $this->_implementation; |
|
119 | - if (isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
118 | + $implementation=$this->_implementation; |
|
119 | + if(isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
120 | 120 | |
121 | - switch(TPropertyValue::ensureEnum($implementation,'TSqlMapCacheTypes')) |
|
121 | + switch(TPropertyValue::ensureEnum($implementation, 'TSqlMapCacheTypes')) |
|
122 | 122 | { |
123 | 123 | case TSqlMapCacheTypes::FIFO: return 'TSqlMapFifoCache'; |
124 | 124 | case TSqlMapCacheTypes::LRU : return 'TSqlMapLruCache'; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function registerTriggerStatement($mappedStatement) |
134 | 134 | { |
135 | - $mappedStatement->attachEventHandler('OnExecuteQuery',array($this, 'flush')); |
|
135 | + $mappedStatement->attachEventHandler('OnExecuteQuery', array($this, 'flush')); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | public function get($key) |
151 | 151 | { |
152 | 152 | if($key instanceof TSqlMapCacheKey) |
153 | - $key = $key->getHash(); |
|
153 | + $key=$key->getHash(); |
|
154 | 154 | |
155 | 155 | //if flush ? |
156 | - $value = $this->_cache->get($key); |
|
156 | + $value=$this->_cache->get($key); |
|
157 | 157 | $this->_requests++; |
158 | 158 | if($value!==null) |
159 | 159 | $this->_hits++; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function set($key, $value) |
168 | 168 | { |
169 | 169 | if($key instanceof TSqlMapCacheKey) |
170 | - $key = $key->getHash(); |
|
170 | + $key=$key->getHash(); |
|
171 | 171 | |
172 | 172 | if($value!==null) |
173 | 173 | $this->_cache->set($key, $value, $this->_flushInterval); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getHitRatio() |
180 | 180 | { |
181 | - if($this->_requests != 0) |
|
181 | + if($this->_requests!=0) |
|
182 | 182 | return $this->_hits / $this->_requests; |
183 | 183 | else |
184 | 184 | return 0; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function __construct($object) |
221 | 221 | { |
222 | - $this->_key = $this->generateKey(serialize($object)); |
|
222 | + $this->_key=$this->generateKey(serialize($object)); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function generateKey($string) |
230 | 230 | { |
231 | - return sprintf('%x',crc32($string)); |
|
231 | + return sprintf('%x', crc32($string)); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -205,6 +205,9 @@ |
||
205 | 205 | return $keyList; |
206 | 206 | } |
207 | 207 | |
208 | + /** |
|
209 | + * @param TList $keyList |
|
210 | + */ |
|
208 | 211 | protected function setKeyList($keyList) |
209 | 212 | { |
210 | 213 | $this->getCache()->set($this->getKeyListId(), $keyList); |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | { |
23 | 23 | protected $_keyList; |
24 | 24 | protected $_cache; |
25 | - protected $_cacheSize = 100; |
|
26 | - protected $_cacheModel = null; |
|
25 | + protected $_cacheSize=100; |
|
26 | + protected $_cacheModel=null; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Create a new cache with limited cache size. |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($cacheModel=null) |
33 | 33 | { |
34 | - $this->_cache = new TMap; |
|
35 | - $this->_keyList = new TList; |
|
34 | + $this->_cache=new TMap; |
|
35 | + $this->_keyList=new TList; |
|
36 | 36 | $this->_cacheModel=$cacheModel; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function setCacheSize($value) |
44 | 44 | { |
45 | - $this->_cacheSize=TPropertyValue::ensureInteger($value,100); |
|
45 | + $this->_cacheSize=TPropertyValue::ensureInteger($value, 100); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function delete($key) |
60 | 60 | { |
61 | - $object = $this->get($key); |
|
61 | + $object=$this->get($key); |
|
62 | 62 | $this->_cache->remove($key); |
63 | 63 | $this->_keyList->remove($key); |
64 | 64 | return $object; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * @throws TSqlMapException not implemented. |
78 | 78 | */ |
79 | - public function add($id,$value,$expire=0,$dependency=null) |
|
79 | + public function add($id, $value, $expire=0, $dependency=null) |
|
80 | 80 | { |
81 | 81 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
82 | 82 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param string cache key |
107 | 107 | * @param mixed value to cache. |
108 | 108 | */ |
109 | - public function set($key, $value,$expire=0,$dependency=null) |
|
109 | + public function set($key, $value, $expire=0, $dependency=null) |
|
110 | 110 | { |
111 | 111 | $this->_cache->add($key, $value); |
112 | 112 | $this->_keyList->add($key); |
113 | 113 | if($this->_keyList->getCount() > $this->_cacheSize) |
114 | 114 | { |
115 | - $oldestKey = $this->_keyList->removeAt(0); |
|
115 | + $oldestKey=$this->_keyList->removeAt(0); |
|
116 | 116 | $this->_cache->remove($oldestKey); |
117 | 117 | } |
118 | 118 | } |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | * @param string the key identifying the value to be cached |
148 | 148 | * @param mixed the value to be cached |
149 | 149 | */ |
150 | - public function set($key, $value,$expire=0,$dependency=null) |
|
150 | + public function set($key, $value, $expire=0, $dependency=null) |
|
151 | 151 | { |
152 | 152 | $this->_cache->add($key, $value); |
153 | 153 | $this->_keyList->add($key); |
154 | 154 | if($this->_keyList->getCount() > $this->_cacheSize) |
155 | 155 | { |
156 | - $oldestKey = $this->_keyList->removeAt(0); |
|
156 | + $oldestKey=$this->_keyList->removeAt(0); |
|
157 | 157 | $this->_cache->remove($oldestKey); |
158 | 158 | } |
159 | 159 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | protected function getKeyListId() |
188 | 188 | { |
189 | 189 | $id='keyList'; |
190 | - if ($this->_cacheModel instanceof TSqlMapCacheModel) |
|
190 | + if($this->_cacheModel instanceof TSqlMapCacheModel) |
|
191 | 191 | $id.='_'.$this->_cacheModel->getId(); |
192 | 192 | return $id; |
193 | 193 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function getKeyList() |
199 | 199 | { |
200 | - if (($keyList=$this->getCache()->get($this->getKeyListId()))===false) |
|
200 | + if(($keyList=$this->getCache()->get($this->getKeyListId()))===false) |
|
201 | 201 | { |
202 | 202 | $keyList=new TList(); |
203 | 203 | $this->getCache()->set($this->getKeyListId(), $keyList); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | $keyList=$this->getKeyList(); |
230 | 230 | $cache=$this->getCache(); |
231 | - foreach ($keyList as $key) |
|
231 | + foreach($keyList as $key) |
|
232 | 232 | { |
233 | 233 | $cache->delete($key); |
234 | 234 | } |
@@ -241,18 +241,18 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function get($key) |
243 | 243 | { |
244 | - $result = $this->getCache()->get($key); |
|
245 | - if ($result === false) |
|
244 | + $result=$this->getCache()->get($key); |
|
245 | + if($result===false) |
|
246 | 246 | { |
247 | 247 | // if the key has not been found in cache (e.g expired), remove from keylist |
248 | 248 | $keyList=$this->getKeyList(); |
249 | - if ($keyList->contains($key)) |
|
249 | + if($keyList->contains($key)) |
|
250 | 250 | { |
251 | 251 | $keyList->remove($key); |
252 | 252 | $this->setKeyList($keyList); |
253 | 253 | } |
254 | 254 | } |
255 | - return $result === false ? null : $result; |
|
255 | + return $result===false ? null : $result; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | * @param string the key identifying the value to be cached |
261 | 261 | * @param mixed the value to be cached |
262 | 262 | */ |
263 | - public function set($key, $value,$expire=0,$dependency=null) |
|
263 | + public function set($key, $value, $expire=0, $dependency=null) |
|
264 | 264 | { |
265 | - $this->getCache()->set($key, $value, $expire,$dependency); |
|
265 | + $this->getCache()->set($key, $value, $expire, $dependency); |
|
266 | 266 | $keyList=$this->getKeyList(); |
267 | - if (!$keyList->contains($key)) |
|
267 | + if(!$keyList->contains($key)) |
|
268 | 268 | { |
269 | 269 | $keyList->add($key); |
270 | 270 | $this->setKeyList($keyList); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | /** |
283 | 283 | * @throws TSqlMapException not implemented. |
284 | 284 | */ |
285 | - public function add($id,$value,$expire=0,$dependency=null) |
|
285 | + public function add($id, $value, $expire=0, $dependency=null) |
|
286 | 286 | { |
287 | 287 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
288 | 288 | } |
@@ -32,6 +32,9 @@ |
||
32 | 32 | */ |
33 | 33 | private $_manager; |
34 | 34 | |
35 | + /** |
|
36 | + * @param TSqlMapManager $manager |
|
37 | + */ |
|
35 | 38 | public function __construct($manager) |
36 | 39 | { |
37 | 40 | $this->_manager=$manager; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function queryForObject($statementName, $parameter=null, $result=null) |
69 | 69 | { |
70 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
70 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
71 | 71 | return $statement->executeQueryForObject($this->getDbConnection(), $parameter, $result); |
72 | 72 | } |
73 | 73 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function queryForList($statementName, $parameter=null, $result=null, $skip=-1, $max=-1) |
90 | 90 | { |
91 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
92 | - return $statement->executeQueryForList($this->getDbConnection(),$parameter, $result, $skip, $max); |
|
91 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
92 | + return $statement->executeQueryForList($this->getDbConnection(), $parameter, $result, $skip, $max); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function queryWithRowDelegate($statementName, $delegate, $parameter=null, $result=null, $skip=-1, $max=-1) |
111 | 111 | { |
112 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
112 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
113 | 113 | return $statement->executeQueryForList($this->getDbConnection(), $parameter, $result, $skip, $max, $delegate); |
114 | 114 | } |
115 | 115 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page=0) |
127 | 127 | { |
128 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
128 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
129 | 129 | return new TSqlMapPagedList($statement, $parameter, $pageSize, null, $page); |
130 | 130 | } |
131 | 131 | |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @param integer The number of the page to initially load into the list. |
145 | 145 | * @return TPagedList A PaginatedList of beans containing the rows. |
146 | 146 | */ |
147 | - public function queryForPagedListWithRowDelegate($statementName,$delegate, $parameter=null, $pageSize=10, $page=0) |
|
147 | + public function queryForPagedListWithRowDelegate($statementName, $delegate, $parameter=null, $pageSize=10, $page=0) |
|
148 | 148 | { |
149 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
150 | - return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate,$page); |
|
149 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
150 | + return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate, $page); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function queryForMap($statementName, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1) |
167 | 167 | { |
168 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
168 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
169 | 169 | return $statement->executeQueryForMap($this->getDbConnection(), $parameter, $keyProperty, $valueProperty, $skip, $max); |
170 | 170 | } |
171 | 171 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function queryForMapWithRowDelegate($statementName, $delegate, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1) |
186 | 186 | { |
187 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
187 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
188 | 188 | return $statement->executeQueryForMap($this->getDbConnection(), $parameter, $keyProperty, $valueProperty, $skip, $max, $delegate); |
189 | 189 | } |
190 | 190 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function insert($statementName, $parameter=null) |
208 | 208 | { |
209 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
209 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
210 | 210 | return $statement->executeInsert($this->getDbConnection(), $parameter); |
211 | 211 | } |
212 | 212 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function update($statementName, $parameter=null) |
227 | 227 | { |
228 | - $statement = $this->getSqlMapManager()->getMappedStatement($statementName); |
|
228 | + $statement=$this->getSqlMapManager()->getMappedStatement($statementName); |
|
229 | 229 | return $statement->executeUpdate($this->getDbConnection(), $parameter); |
230 | 230 | } |
231 | 231 |