@@ -73,7 +73,7 @@ |
||
73 | 73 | */ |
74 | 74 | public function __construct($style=null) |
75 | 75 | { |
76 | - parent::__construct(); |
|
76 | + parent::__construct(); |
|
77 | 77 | if($style!==null) |
78 | 78 | $this->copyFrom($style); |
79 | 79 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
231 | - * @return TDisplayStyle display style |
|
231 | + * @return string display style |
|
232 | 232 | */ |
233 | 233 | public function getDisplayStyle() |
234 | 234 | { |
@@ -285,6 +285,7 @@ discard block |
||
285 | 285 | * Sets custom style fields from a string. |
286 | 286 | * Custom style fields will be overwritten by style fields explicitly defined. |
287 | 287 | * @param string the custom style of the control |
288 | + * @param string $value |
|
288 | 289 | */ |
289 | 290 | public function setCustomStyle($value) |
290 | 291 | { |
@@ -304,6 +305,8 @@ discard block |
||
304 | 305 | * Style fields set by this method will overwrite those set by {@link setCustomStyle}. |
305 | 306 | * @param string style field name |
306 | 307 | * @param string style field value |
308 | + * @param string $name |
|
309 | + * @param string $value |
|
307 | 310 | */ |
308 | 311 | public function setStyleField($name,$value) |
309 | 312 | { |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | protected function _getZappableSleepProps(&$exprops) |
54 | 54 | { |
55 | 55 | parent::_getZappableSleepProps($exprops); |
56 | - if ($this->_fields===array()) |
|
57 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_fields"; |
|
56 | + if($this->_fields===array()) |
|
57 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_fields"; |
|
58 | 58 | if($this->_font===null) |
59 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_font"; |
|
59 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_font"; |
|
60 | 60 | if($this->_class===null) |
61 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_class"; |
|
62 | - if ($this->_customStyle===null) |
|
63 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_customStyle"; |
|
64 | - if ($this->_displayStyle==='Fixed') |
|
65 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_displayStyle"; |
|
61 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_class"; |
|
62 | + if($this->_customStyle===null) |
|
63 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_customStyle"; |
|
64 | + if($this->_displayStyle==='Fixed') |
|
65 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_displayStyle"; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function __clone() |
83 | 83 | { |
84 | 84 | if($this->_font!==null) |
85 | - $this->_font = clone($this->_font); |
|
85 | + $this->_font=clone($this->_font); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function getBackColor() |
92 | 92 | { |
93 | - return isset($this->_fields['background-color'])?$this->_fields['background-color']:''; |
|
93 | + return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : ''; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getBorderColor() |
111 | 111 | { |
112 | - return isset($this->_fields['border-color'])?$this->_fields['border-color']:''; |
|
112 | + return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : ''; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function getBorderStyle() |
130 | 130 | { |
131 | - return isset($this->_fields['border-style'])?$this->_fields['border-style']:''; |
|
131 | + return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : ''; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function getBorderWidth() |
150 | 150 | { |
151 | - return isset($this->_fields['border-width'])?$this->_fields['border-width']:''; |
|
151 | + return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : ''; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getCssClass() |
169 | 169 | { |
170 | - return $this->_class===null?'':$this->_class; |
|
170 | + return $this->_class===null ? '' : $this->_class; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function hasFont() |
203 | 203 | { |
204 | - return $this->_font !== null; |
|
204 | + return $this->_font!==null; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -209,20 +209,20 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function setDisplayStyle($value) |
211 | 211 | { |
212 | - $this->_displayStyle = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); |
|
212 | + $this->_displayStyle=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); |
|
213 | 213 | switch($this->_displayStyle) |
214 | 214 | { |
215 | 215 | case TDisplayStyle::None: |
216 | - $this->_fields['display'] = 'none'; |
|
216 | + $this->_fields['display']='none'; |
|
217 | 217 | break; |
218 | 218 | case TDisplayStyle::Dynamic: |
219 | - $this->_fields['display'] = ''; //remove the display property |
|
219 | + $this->_fields['display']=''; //remove the display property |
|
220 | 220 | break; |
221 | 221 | case TDisplayStyle::Fixed: |
222 | - $this->_fields['visibility'] = 'visible'; |
|
222 | + $this->_fields['visibility']='visible'; |
|
223 | 223 | break; |
224 | 224 | case TDisplayStyle::Hidden: |
225 | - $this->_fields['visibility'] = 'hidden'; |
|
225 | + $this->_fields['visibility']='hidden'; |
|
226 | 226 | break; |
227 | 227 | } |
228 | 228 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function getForeColor() |
242 | 242 | { |
243 | - return isset($this->_fields['color'])?$this->_fields['color']:''; |
|
243 | + return isset($this->_fields['color']) ? $this->_fields['color'] : ''; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public function getHeight() |
261 | 261 | { |
262 | - return isset($this->_fields['height'])?$this->_fields['height']:''; |
|
262 | + return isset($this->_fields['height']) ? $this->_fields['height'] : ''; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function getCustomStyle() |
280 | 280 | { |
281 | - return $this->_customStyle===null?'':$this->_customStyle; |
|
281 | + return $this->_customStyle===null ? '' : $this->_customStyle; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function getStyleField($name) |
298 | 298 | { |
299 | - return isset($this->_fields[$name])?$this->_fields[$name]:''; |
|
299 | + return isset($this->_fields[$name]) ? $this->_fields[$name] : ''; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @param string style field name |
306 | 306 | * @param string style field value |
307 | 307 | */ |
308 | - public function setStyleField($name,$value) |
|
308 | + public function setStyleField($name, $value) |
|
309 | 309 | { |
310 | 310 | $this->_fields[$name]=$value; |
311 | 311 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function getWidth() |
334 | 334 | { |
335 | - return isset($this->_fields['width'])?$this->_fields['width']:''; |
|
335 | + return isset($this->_fields['width']) ? $this->_fields['width'] : ''; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | { |
365 | 365 | if($style instanceof TStyle) |
366 | 366 | { |
367 | - $this->_fields=array_merge($this->_fields,$style->_fields); |
|
367 | + $this->_fields=array_merge($this->_fields, $style->_fields); |
|
368 | 368 | if($style->_class!==null) |
369 | 369 | $this->_class=$style->_class; |
370 | 370 | if($style->_customStyle!==null) |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | { |
385 | 385 | if($style instanceof TStyle) |
386 | 386 | { |
387 | - $this->_fields=array_merge($style->_fields,$this->_fields); |
|
387 | + $this->_fields=array_merge($style->_fields, $this->_fields); |
|
388 | 388 | if($this->_class===null) |
389 | 389 | $this->_class=$style->_class; |
390 | 390 | if($this->_customStyle===null) |
@@ -402,18 +402,18 @@ discard block |
||
402 | 402 | { |
403 | 403 | if($this->_customStyle!==null) |
404 | 404 | { |
405 | - foreach(explode(';',$this->_customStyle) as $style) |
|
405 | + foreach(explode(';', $this->_customStyle) as $style) |
|
406 | 406 | { |
407 | - $arr=explode(':',$style,2); |
|
407 | + $arr=explode(':', $style, 2); |
|
408 | 408 | if(isset($arr[1]) && trim($arr[0])!=='') |
409 | - $writer->addStyleAttribute(trim($arr[0]),trim($arr[1])); |
|
409 | + $writer->addStyleAttribute(trim($arr[0]), trim($arr[1])); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | $writer->addStyleAttributes($this->_fields); |
413 | 413 | if($this->_font!==null) |
414 | 414 | $this->_font->addAttributesToRender($writer); |
415 | 415 | if($this->_class!==null) |
416 | - $writer->addAttribute('class',$this->_class); |
|
416 | + $writer->addAttribute('class', $this->_class); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @param string a key identifying a value to be cached |
112 | - * @return sring a key generated from the provided key which ensures the uniqueness across applications |
|
112 | + * @return string a key generated from the provided key which ensures the uniqueness across applications |
|
113 | 113 | */ |
114 | 114 | protected function generateUniqueKey($key) |
115 | 115 | { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param mixed the value to be cached |
144 | 144 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
145 | 145 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid. |
146 | - * @return boolean true if the value is successfully stored into cache, false otherwise |
|
146 | + * @return null|boolean true if the value is successfully stored into cache, false otherwise |
|
147 | 147 | */ |
148 | 148 | public function set($id,$value,$expire=0,$dependency=null) |
149 | 149 | { |
@@ -201,6 +201,7 @@ discard block |
||
201 | 201 | * in {@link get()} already. So only the implementation of data retrieval |
202 | 202 | * is needed. |
203 | 203 | * @param string a unique key identifying the cached value |
204 | + * @param string $key |
|
204 | 205 | * @return string the value stored in cache, false if the value is not in the cache or expired. |
205 | 206 | */ |
206 | 207 | abstract protected function getValue($key); |
@@ -215,6 +216,8 @@ discard block |
||
215 | 216 | * @param string the key identifying the value to be cached |
216 | 217 | * @param string the value to be cached |
217 | 218 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
219 | + * @param string $key |
|
220 | + * @param integer $expire |
|
218 | 221 | * @return boolean true if the value is successfully stored into cache, false otherwise |
219 | 222 | */ |
220 | 223 | abstract protected function setValue($key,$value,$expire); |
@@ -229,6 +232,8 @@ discard block |
||
229 | 232 | * @param string the key identifying the value to be cached |
230 | 233 | * @param string the value to be cached |
231 | 234 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
235 | + * @param string $key |
|
236 | + * @param integer $expire |
|
232 | 237 | * @return boolean true if the value is successfully stored into cache, false otherwise |
233 | 238 | */ |
234 | 239 | abstract protected function addValue($key,$value,$expire); |
@@ -237,6 +242,7 @@ discard block |
||
237 | 242 | * Deletes a value with the specified key from cache |
238 | 243 | * This method should be implemented by child classes to delete the data from actual cache storage. |
239 | 244 | * @param string the key of the value to be deleted |
245 | + * @param string $key |
|
240 | 246 | * @return boolean if no error happens during deletion |
241 | 247 | */ |
242 | 248 | abstract protected function deleteValue($key); |
@@ -280,7 +286,7 @@ discard block |
||
280 | 286 | * Deletes the value with the specified key from cache |
281 | 287 | * This method is required by the interface \ArrayAccess. |
282 | 288 | * @param string the key of the value to be deleted |
283 | - * @return boolean if no error happens during deletion |
|
289 | + * @return boolean|null if no error happens during deletion |
|
284 | 290 | */ |
285 | 291 | public function offsetUnset($id) |
286 | 292 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | if($this->getApplication()->getCache()===null) |
68 | 68 | $this->getApplication()->setCache($this); |
69 | 69 | else |
70 | - throw new TConfigurationException('cache_primary_duplicated',get_class($this)); |
|
70 | + throw new TConfigurationException('cache_primary_duplicated', get_class($this)); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid. |
146 | 146 | * @return boolean true if the value is successfully stored into cache, false otherwise |
147 | 147 | */ |
148 | - public function set($id,$value,$expire=0,$dependency=null) |
|
148 | + public function set($id, $value, $expire=0, $dependency=null) |
|
149 | 149 | { |
150 | - if(empty($value) && $expire === 0) |
|
150 | + if(empty($value) && $expire===0) |
|
151 | 151 | $this->delete($id); |
152 | 152 | else |
153 | 153 | { |
154 | - $data=array($value,$dependency); |
|
155 | - return $this->setValue($this->generateUniqueKey($id),$data,$expire); |
|
154 | + $data=array($value, $dependency); |
|
155 | + return $this->setValue($this->generateUniqueKey($id), $data, $expire); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid. |
166 | 166 | * @return boolean true if the value is successfully stored into cache, false otherwise |
167 | 167 | */ |
168 | - public function add($id,$value,$expire=0,$dependency=null) |
|
168 | + public function add($id, $value, $expire=0, $dependency=null) |
|
169 | 169 | { |
170 | - if(empty($value) && $expire === 0) |
|
170 | + if(empty($value) && $expire===0) |
|
171 | 171 | return false; |
172 | - $data=array($value,$dependency); |
|
173 | - return $this->addValue($this->generateUniqueKey($id),$data,$expire); |
|
172 | + $data=array($value, $dependency); |
|
173 | + return $this->addValue($this->generateUniqueKey($id), $data, $expire); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
218 | 218 | * @return boolean true if the value is successfully stored into cache, false otherwise |
219 | 219 | */ |
220 | - abstract protected function setValue($key,$value,$expire); |
|
220 | + abstract protected function setValue($key, $value, $expire); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Stores a value identified by a key into cache if the cache does not contain this key. |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
232 | 232 | * @return boolean true if the value is successfully stored into cache, false otherwise |
233 | 233 | */ |
234 | - abstract protected function addValue($key,$value,$expire); |
|
234 | + abstract protected function addValue($key, $value, $expire); |
|
235 | 235 | |
236 | 236 | /** |
237 | 237 | * Deletes a value with the specified key from cache |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function offsetExists($id) |
251 | 251 | { |
252 | - return $this->get($id) !== false; |
|
252 | + return $this->get($id)!==false; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -123,6 +123,7 @@ discard block |
||
123 | 123 | * By default, it always returns true, meaning the file should be checked. |
124 | 124 | * You may override this method to check only certain files. |
125 | 125 | * @param string the name of the file that may be checked for dependency. |
126 | + * @param string $fileName |
|
126 | 127 | * @return boolean whether this file should be checked. |
127 | 128 | */ |
128 | 129 | protected function validateFile($fileName) |
@@ -136,6 +137,7 @@ discard block |
||
136 | 137 | * By default, it always returns true, meaning the subdirectory should be checked. |
137 | 138 | * You may override this method to check only certain subdirectories. |
138 | 139 | * @param string the name of the subdirectory that may be checked for dependency. |
140 | + * @param string $directory |
|
139 | 141 | * @return boolean whether this subdirectory should be checked. |
140 | 142 | */ |
141 | 143 | protected function validateDirectory($directory) |
@@ -149,6 +151,7 @@ discard block |
||
149 | 151 | * {@link setRecursiveCheck RecursiveCheck} is set true. |
150 | 152 | * @param string the directory name |
151 | 153 | * @param int level of the recursion |
154 | + * @param string $directory |
|
152 | 155 | * @return array list of file modification time indexed by the file path |
153 | 156 | */ |
154 | 157 | protected function generateTimestamps($directory,$level=0) |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function setDirectory($directory) |
64 | 64 | { |
65 | 65 | if(($path=realpath($directory))===false || !is_dir($path)) |
66 | - throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory); |
|
66 | + throw new TInvalidDataValueException('directorycachedependency_directory_invalid', $directory); |
|
67 | 67 | $this->_directory=$path; |
68 | 68 | $this->_timestamps=$this->generateTimestamps($path); |
69 | 69 | } |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * @param int level of the recursion |
152 | 152 | * @return array list of file modification time indexed by the file path |
153 | 153 | */ |
154 | - protected function generateTimestamps($directory,$level=0) |
|
154 | + protected function generateTimestamps($directory, $level=0) |
|
155 | 155 | { |
156 | 156 | if(($dir=opendir($directory))===false) |
157 | - throw new TIOException('directorycachedependency_directory_invalid',$directory); |
|
157 | + throw new TIOException('directorycachedependency_directory_invalid', $directory); |
|
158 | 158 | $timestamps=array(); |
159 | 159 | while(($file=readdir($dir))!==false) |
160 | 160 | { |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | continue; |
164 | 164 | else if(is_dir($path)) |
165 | 165 | { |
166 | - if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
|
167 | - $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
|
166 | + if(($this->_recursiveLevel < 0 || $level < $this->_recursiveLevel) && $this->validateDirectory($path)) |
|
167 | + $timestamps=array_merge($this->generateTimestamps($path, $level + 1)); |
|
168 | 168 | } |
169 | 169 | else if($this->validateFile($path)) |
170 | 170 | $timestamps[$path]=filemtime($path); |
@@ -532,8 +532,7 @@ |
||
532 | 532 | { |
533 | 533 | if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
534 | 534 | $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
535 | - } |
|
536 | - else if($this->validateFile($path)) |
|
535 | + } else if($this->validateFile($path)) |
|
537 | 536 | $timestamps[$path]=filemtime($path); |
538 | 537 | } |
539 | 538 | closedir($dir); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * @return Iterator iterator |
|
51 | + * @return TDummyDataSourceIterator iterator |
|
52 | 52 | */ |
53 | 53 | public function getIterator() |
54 | 54 | { |
@@ -68,6 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @param mixed original data source |
71 | + * @param \Traversable $value |
|
71 | 72 | */ |
72 | 73 | public function setDataSource($value) |
73 | 74 | { |
@@ -93,6 +94,7 @@ discard block |
||
93 | 94 | |
94 | 95 | /** |
95 | 96 | * @param integer number of items in each page |
97 | + * @param integer $value |
|
96 | 98 | */ |
97 | 99 | public function setPageSize($value) |
98 | 100 | { |
@@ -112,6 +114,7 @@ discard block |
||
112 | 114 | |
113 | 115 | /** |
114 | 116 | * @param integer current page index |
117 | + * @param integer $value |
|
115 | 118 | */ |
116 | 119 | public function setCurrentPageIndex($value) |
117 | 120 | { |
@@ -130,6 +133,7 @@ discard block |
||
130 | 133 | |
131 | 134 | /** |
132 | 135 | * @param boolean whether to allow paging |
136 | + * @param boolean $value |
|
133 | 137 | */ |
134 | 138 | public function setAllowPaging($value) |
135 | 139 | { |
@@ -146,6 +150,7 @@ discard block |
||
146 | 150 | |
147 | 151 | /** |
148 | 152 | * @param boolean whether to allow custom paging |
153 | + * @param boolean $value |
|
149 | 154 | */ |
150 | 155 | public function setAllowCustomPaging($value) |
151 | 156 | { |
@@ -162,6 +167,7 @@ discard block |
||
162 | 167 | |
163 | 168 | /** |
164 | 169 | * @param integer user-assigned number of items in data source |
170 | + * @param integer $value |
|
165 | 171 | */ |
166 | 172 | public function setVirtualItemCount($value) |
167 | 173 | { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function setPageSize($value) |
98 | 98 | { |
99 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
99 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
100 | 100 | $this->_pageSize=$value; |
101 | 101 | else |
102 | 102 | throw new TInvalidDataValueException('pageddatasource_pagesize_invalid'); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function setCurrentPageIndex($value) |
117 | 117 | { |
118 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
118 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
119 | 119 | $value=0; |
120 | 120 | $this->_currentPageIndex=$value; |
121 | 121 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function setVirtualItemCount($value) |
167 | 167 | { |
168 | - if(($value=TPropertyValue::ensureInteger($value))>=0) |
|
168 | + if(($value=TPropertyValue::ensureInteger($value)) >= 0) |
|
169 | 169 | $this->_virtualCount=$value; |
170 | 170 | else |
171 | 171 | throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid'); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if(!$this->_allowPaging) |
182 | 182 | return $this->getDataSourceCount(); |
183 | 183 | if(!$this->_allowCustomPaging && $this->getIsLastPage()) |
184 | - return $this->getDataSourceCount()-$this->getFirstIndexInPage(); |
|
184 | + return $this->getDataSourceCount() - $this->getFirstIndexInPage(); |
|
185 | 185 | return $this->_pageSize; |
186 | 186 | } |
187 | 187 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | if($this->_dataSource===null) |
204 | 204 | return 0; |
205 | 205 | $count=$this->getDataSourceCount(); |
206 | - if(!$this->_allowPaging || $count<=0) |
|
206 | + if(!$this->_allowPaging || $count <= 0) |
|
207 | 207 | return 1; |
208 | - return (int)(($count+$this->_pageSize-1)/$this->_pageSize); |
|
208 | + return (int) (($count + $this->_pageSize - 1) / $this->_pageSize); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | public function getIsLastPage() |
226 | 226 | { |
227 | 227 | if($this->_allowPaging) |
228 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
228 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
229 | 229 | else |
230 | 230 | return true; |
231 | 231 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | public function getFirstIndexInPage() |
238 | 238 | { |
239 | 239 | if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging) |
240 | - return $this->_currentPageIndex*$this->_pageSize; |
|
240 | + return $this->_currentPageIndex * $this->_pageSize; |
|
241 | 241 | else |
242 | 242 | return 0; |
243 | 243 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | public function getIterator() |
262 | 262 | { |
263 | 263 | if($this->_dataSource instanceof TList) |
264 | - return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
264 | + return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
265 | 265 | else if($this->_dataSource instanceof TMap) |
266 | - return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
266 | + return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
267 | 267 | else |
268 | 268 | return null; |
269 | 269 | } |
@@ -35,6 +35,8 @@ |
||
35 | 35 | * @param TList the data to be iterated through |
36 | 36 | * @param integer start index |
37 | 37 | * @param integer number of items to be iterated through |
38 | + * @param integer $startIndex |
|
39 | + * @param integer $count |
|
38 | 40 | */ |
39 | 41 | public function __construct(TList $list,$startIndex,$count) |
40 | 42 | { |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param integer start index |
37 | 37 | * @param integer number of items to be iterated through |
38 | 38 | */ |
39 | - public function __construct(TList $list,$startIndex,$count) |
|
39 | + public function __construct(TList $list, $startIndex, $count) |
|
40 | 40 | { |
41 | 41 | $this->_list=$list; |
42 | 42 | $this->_index=0; |
43 | 43 | $this->_startIndex=$startIndex; |
44 | - if($startIndex+$count>$list->getCount()) |
|
45 | - $this->_count=$list->getCount()-$startIndex; |
|
44 | + if($startIndex + $count > $list->getCount()) |
|
45 | + $this->_count=$list->getCount() - $startIndex; |
|
46 | 46 | else |
47 | 47 | $this->_count=$count; |
48 | 48 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function current() |
75 | 75 | { |
76 | - return $this->_list->itemAt($this->_startIndex+$this->_index); |
|
76 | + return $this->_list->itemAt($this->_startIndex + $this->_index); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -92,6 +92,6 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function valid() |
94 | 94 | { |
95 | - return $this->_index<$this->_count; |
|
95 | + return $this->_index < $this->_count; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -28,6 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * Constructor. |
30 | 30 | * @param integer old page index |
31 | + * @param integer $oldPage |
|
31 | 32 | */ |
32 | 33 | public function __construct($oldPage) |
33 | 34 | { |
@@ -34,6 +34,8 @@ |
||
34 | 34 | /** |
35 | 35 | * Constructor. |
36 | 36 | * @param array the data to be iterated through |
37 | + * @param integer $startIndex |
|
38 | + * @param integer $count |
|
37 | 39 | */ |
38 | 40 | public function __construct(TMap $map,$startIndex,$count) |
39 | 41 | { |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | * Constructor. |
36 | 36 | * @param array the data to be iterated through |
37 | 37 | */ |
38 | - public function __construct(TMap $map,$startIndex,$count) |
|
38 | + public function __construct(TMap $map, $startIndex, $count) |
|
39 | 39 | { |
40 | 40 | $this->_map=$map; |
41 | 41 | $this->_index=0; |
42 | 42 | $this->_startIndex=$startIndex; |
43 | - if($startIndex+$count>$map->getCount()) |
|
44 | - $this->_count=$map->getCount()-$startIndex; |
|
43 | + if($startIndex + $count > $map->getCount()) |
|
44 | + $this->_count=$map->getCount() - $startIndex; |
|
45 | 45 | else |
46 | 46 | $this->_count=$count; |
47 | 47 | $this->_iterator=$map->getIterator(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | public function rewind() |
55 | 55 | { |
56 | 56 | $this->_iterator->rewind(); |
57 | - for($i=0;$i<$this->_startIndex;++$i) |
|
57 | + for($i=0; $i < $this->_startIndex; ++$i) |
|
58 | 58 | $this->_iterator->next(); |
59 | 59 | $this->_index=0; |
60 | 60 | } |
@@ -96,6 +96,6 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function valid() |
98 | 98 | { |
99 | - return $this->_index<$this->_count; |
|
99 | + return $this->_index < $this->_count; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | \ No newline at end of file |
@@ -143,6 +143,7 @@ discard block |
||
143 | 143 | /** |
144 | 144 | * This must be called internally or when instantiated. |
145 | 145 | * @param numeric sets the default priority of inserted items without a specified priority |
146 | + * @param integer $value |
|
146 | 147 | */ |
147 | 148 | protected function setDefaultPriority($value) |
148 | 149 | { |
@@ -160,6 +161,7 @@ discard block |
||
160 | 161 | /** |
161 | 162 | * This must be called internally or when instantiated. |
162 | 163 | * @param integer The precision of numeric priorities. |
164 | + * @param integer $value |
|
163 | 165 | */ |
164 | 166 | protected function setPrecision($value) |
165 | 167 | { |
@@ -169,7 +171,7 @@ discard block |
||
169 | 171 | /** |
170 | 172 | * Returns an iterator for traversing the items in the list. |
171 | 173 | * This method is required by the interface \IteratorAggregate. |
172 | - * @return Iterator an iterator for traversing the items in the list. |
|
174 | + * @return \ArrayIterator an iterator for traversing the items in the list. |
|
173 | 175 | */ |
174 | 176 | public function getIterator() |
175 | 177 | { |
@@ -596,6 +598,7 @@ discard block |
||
596 | 598 | * Combines the map elements which have a priority below the parameter value |
597 | 599 | * @param numeric the cut-off priority. All items of priority less than this are returned. |
598 | 600 | * @param boolean whether or not the input cut-off priority is inclusive. Default: false, not inclusive. |
601 | + * @param integer $priority |
|
599 | 602 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
600 | 603 | * The priorities are sorted so important priorities, lower numerics, are first. |
601 | 604 | */ |
@@ -616,6 +619,7 @@ discard block |
||
616 | 619 | * Combines the map elements which have a priority above the parameter value |
617 | 620 | * @param numeric the cut-off priority. All items of priority greater than this are returned. |
618 | 621 | * @param boolean whether or not the input cut-off priority is inclusive. Default: true, inclusive. |
622 | + * @param integer $priority |
|
619 | 623 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
620 | 624 | * The priorities are sorted so important priorities, lower numerics, are first. |
621 | 625 | */ |
@@ -390,8 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | $this->removeAtIndexInPriority($p[1],$p[0]); |
392 | 392 | return $p[2]; |
393 | - } |
|
394 | - else |
|
393 | + } else |
|
395 | 394 | throw new TInvalidDataValueException('list_item_inexistent'); |
396 | 395 | } |
397 | 396 | |
@@ -676,14 +675,12 @@ discard block |
||
676 | 675 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
677 | 676 | $this->insertAtIndexInPriority($item,false,$priority); |
678 | 677 | } |
679 | - } |
|
680 | - else if(is_array($data)||$data instanceof \Traversable) |
|
678 | + } else if(is_array($data)||$data instanceof \Traversable) |
|
681 | 679 | { |
682 | 680 | foreach($data as $priority=>$item) |
683 | 681 | $this->add($item); |
684 | 682 | |
685 | - } |
|
686 | - else if($data!==null) |
|
683 | + } else if($data!==null) |
|
687 | 684 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
688 | 685 | } |
689 | 686 |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param integer the precision of the numeric priorities |
88 | 88 | * @throws TInvalidDataTypeException If data is not null and is neither an array nor an iterator. |
89 | 89 | */ |
90 | - public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8) |
|
90 | + public function __construct($data=null, $readOnly=false, $defaultPriority=10, $precision=8) |
|
91 | 91 | { |
92 | 92 | parent::__construct(); |
93 | 93 | if($data!==null) |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | if($priority===null) |
127 | 127 | $priority=$this->getDefaultPriority(); |
128 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
128 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
129 | 129 | |
130 | 130 | if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) |
131 | 131 | return false; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function setDefaultPriority($value) |
148 | 148 | { |
149 | - $this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p); |
|
149 | + $this->_dp=(string) round(TPropertyValue::ensureFloat($value), $this->_p); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function sortPriorities() { |
194 | 194 | if(!$this->_o) { |
195 | - ksort($this->_d,SORT_NUMERIC); |
|
195 | + ksort($this->_d, SORT_NUMERIC); |
|
196 | 196 | $this->_o=true; |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $this->sortPriorities(); |
209 | 209 | $this->_fd=array(); |
210 | 210 | foreach($this->_d as $priority => $itemsatpriority) |
211 | - $this->_fd=array_merge($this->_fd,$itemsatpriority); |
|
211 | + $this->_fd=array_merge($this->_fd, $itemsatpriority); |
|
212 | 212 | return $this->_fd; |
213 | 213 | } |
214 | 214 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function itemAt($index) |
224 | 224 | { |
225 | - if($index>=0&&$index<$this->getCount()) { |
|
225 | + if($index >= 0 && $index < $this->getCount()) { |
|
226 | 226 | $arr=$this->flattenPriorities(); |
227 | 227 | return $arr[$index]; |
228 | 228 | } else |
229 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
229 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | { |
239 | 239 | if($priority===null) |
240 | 240 | $priority=$this->getDefaultPriority(); |
241 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
241 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
242 | 242 | |
243 | - return isset($this->_d[$priority])?$this->_d[$priority]:null; |
|
243 | + return isset($this->_d[$priority]) ? $this->_d[$priority] : null; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | * @param numeric the priority which to index. no parameter or null will result in the default priority |
250 | 250 | * @return mixed the element at the offset, false if no element is found at the offset |
251 | 251 | */ |
252 | - public function itemAtIndexInPriority($index,$priority=null) |
|
252 | + public function itemAtIndexInPriority($index, $priority=null) |
|
253 | 253 | { |
254 | 254 | if($priority===null) |
255 | 255 | $priority=$this->getDefaultPriority(); |
256 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
256 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
257 | 257 | |
258 | - return !isset($this->_d[$priority])?false:( |
|
259 | - isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false |
|
258 | + return !isset($this->_d[$priority]) ?false:( |
|
259 | + isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false |
|
260 | 260 | ); |
261 | 261 | } |
262 | 262 | |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @return int the index within the flattened array |
269 | 269 | * @throws TInvalidOperationException if the map is read-only |
270 | 270 | */ |
271 | - public function add($item,$priority=null) |
|
271 | + public function add($item, $priority=null) |
|
272 | 272 | { |
273 | 273 | if($this->getReadOnly()) |
274 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
274 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
275 | 275 | |
276 | - return $this->insertAtIndexInPriority($item,false,$priority,true); |
|
276 | + return $this->insertAtIndexInPriority($item, false, $priority, true); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -284,15 +284,15 @@ discard block |
||
284 | 284 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
285 | 285 | * @throws TInvalidOperationException if the list is read-only |
286 | 286 | */ |
287 | - public function insertAt($index,$item) |
|
287 | + public function insertAt($index, $item) |
|
288 | 288 | { |
289 | 289 | if($this->getReadOnly()) |
290 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
290 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
291 | 291 | |
292 | - if(($priority=$this->priorityAt($index,true))!==false) |
|
293 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
292 | + if(($priority=$this->priorityAt($index, true))!==false) |
|
293 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
294 | 294 | else |
295 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
295 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -305,54 +305,54 @@ discard block |
||
305 | 305 | * @throws TInvalidDataValueException If the index specified exceeds the bound |
306 | 306 | * @throws TInvalidOperationException if the list is read-only |
307 | 307 | */ |
308 | - public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false) |
|
308 | + public function insertAtIndexInPriority($item, $index=false, $priority=null, $preserveCache=false) |
|
309 | 309 | { |
310 | 310 | if($this->getReadOnly()) |
311 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
311 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
312 | 312 | |
313 | 313 | if($priority===null) |
314 | 314 | $priority=$this->getDefaultPriority(); |
315 | - $priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
315 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
316 | 316 | |
317 | 317 | if($preserveCache) { |
318 | 318 | $this->sortPriorities(); |
319 | 319 | $cc=0; |
320 | 320 | foreach($this->_d as $prioritykey=>$items) |
321 | - if($prioritykey>=$priority) |
|
321 | + if($prioritykey >= $priority) |
|
322 | 322 | break; |
323 | 323 | else |
324 | 324 | $cc+=count($items); |
325 | 325 | |
326 | - if($index===false&&isset($this->_d[$priority])) { |
|
326 | + if($index===false && isset($this->_d[$priority])) { |
|
327 | 327 | $c=count($this->_d[$priority]); |
328 | 328 | $c+=$cc; |
329 | 329 | $this->_d[$priority][]=$item; |
330 | 330 | } else if(isset($this->_d[$priority])) { |
331 | - $c=$index+$cc; |
|
332 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
331 | + $c=$index + $cc; |
|
332 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
333 | 333 | } else { |
334 | - $c = $cc; |
|
335 | - $this->_o = false; |
|
334 | + $c=$cc; |
|
335 | + $this->_o=false; |
|
336 | 336 | $this->_d[$priority]=array($item); |
337 | 337 | } |
338 | 338 | |
339 | - if($this->_fd&&is_array($this->_fd)) // if there is a flattened array cache |
|
340 | - array_splice($this->_fd,$c,0,array($item)); |
|
339 | + if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache |
|
340 | + array_splice($this->_fd, $c, 0, array($item)); |
|
341 | 341 | } else { |
342 | 342 | $c=null; |
343 | - if($index===false&&isset($this->_d[$priority])) { |
|
343 | + if($index===false && isset($this->_d[$priority])) { |
|
344 | 344 | $cc=count($this->_d[$priority]); |
345 | 345 | $this->_d[$priority][]=$item; |
346 | 346 | } else if(isset($this->_d[$priority])) { |
347 | 347 | $cc=$index; |
348 | - array_splice($this->_d[$priority],$index,0,array($item)); |
|
348 | + array_splice($this->_d[$priority], $index, 0, array($item)); |
|
349 | 349 | } else { |
350 | 350 | $cc=0; |
351 | 351 | $this->_o=false; |
352 | 352 | $this->_d[$priority]=array($item); |
353 | 353 | } |
354 | - if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) |
|
355 | - array_splice($this->_fd,$cc,0,array($item)); |
|
354 | + if($this->_fd && is_array($this->_fd) && count($this->_d)==1) |
|
355 | + array_splice($this->_fd, $cc, 0, array($item)); |
|
356 | 356 | else |
357 | 357 | $this->_fd=null; |
358 | 358 | } |
@@ -373,22 +373,22 @@ discard block |
||
373 | 373 | * @return integer index within the flattened list at which the item is being removed |
374 | 374 | * @throws TInvalidDataValueException If the item does not exist |
375 | 375 | */ |
376 | - public function remove($item,$priority=false) |
|
376 | + public function remove($item, $priority=false) |
|
377 | 377 | { |
378 | 378 | if($this->getReadOnly()) |
379 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
379 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
380 | 380 | |
381 | - if(($p=$this->priorityOf($item,true))!==false) |
|
381 | + if(($p=$this->priorityOf($item, true))!==false) |
|
382 | 382 | { |
383 | 383 | if($priority!==false) { |
384 | 384 | if($priority===null) |
385 | 385 | $priority=$this->getDefaultPriority(); |
386 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
386 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
387 | 387 | |
388 | 388 | if($p[0]!=$priority) |
389 | 389 | throw new TInvalidDataValueException('list_item_inexistent'); |
390 | 390 | } |
391 | - $this->removeAtIndexInPriority($p[1],$p[0]); |
|
391 | + $this->removeAtIndexInPriority($p[1], $p[0]); |
|
392 | 392 | return $p[2]; |
393 | 393 | } |
394 | 394 | else |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | public function removeAt($index) |
406 | 406 | { |
407 | 407 | if($this->getReadOnly()) |
408 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
408 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
409 | 409 | |
410 | 410 | if(($priority=$this->priorityAt($index, true))!==false) |
411 | - return $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
412 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
411 | + return $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
412 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -423,17 +423,17 @@ discard block |
||
423 | 423 | public function removeAtIndexInPriority($index, $priority=null) |
424 | 424 | { |
425 | 425 | if($this->getReadOnly()) |
426 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
426 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
427 | 427 | |
428 | 428 | if($priority===null) |
429 | 429 | $priority=$this->getDefaultPriority(); |
430 | - $priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p); |
|
430 | + $priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p); |
|
431 | 431 | |
432 | - if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) |
|
432 | + if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) |
|
433 | 433 | throw new TInvalidDataValueException('list_item_inexistent'); |
434 | 434 | |
435 | 435 | // $value is an array of elements removed, only one |
436 | - $value=array_splice($this->_d[$priority],$index,1); |
|
436 | + $value=array_splice($this->_d[$priority], $index, 1); |
|
437 | 437 | $value=$value[0]; |
438 | 438 | |
439 | 439 | if(!count($this->_d[$priority])) |
@@ -450,11 +450,11 @@ discard block |
||
450 | 450 | public function clear() |
451 | 451 | { |
452 | 452 | if($this->getReadOnly()) |
453 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
453 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
454 | 454 | |
455 | 455 | foreach($this->_d as $priority=>$items) { |
456 | - for($index=count($items)-1;$index>=0;$index--) |
|
457 | - $this->removeAtIndexInPriority($index,$priority); |
|
456 | + for($index=count($items) - 1; $index >= 0; $index--) |
|
457 | + $this->removeAtIndexInPriority($index, $priority); |
|
458 | 458 | unset($this->_d[$priority]); |
459 | 459 | } |
460 | 460 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function contains($item) |
467 | 467 | { |
468 | - return $this->indexOf($item)>=0; |
|
468 | + return $this->indexOf($item) >= 0; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | */ |
475 | 475 | public function indexOf($item) |
476 | 476 | { |
477 | - if(($index=array_search($item,$this->flattenPriorities(),true))===false) |
|
477 | + if(($index=array_search($item, $this->flattenPriorities(), true))===false) |
|
478 | 478 | return -1; |
479 | 479 | else |
480 | 480 | return $index; |
@@ -489,16 +489,16 @@ discard block |
||
489 | 489 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
490 | 490 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
491 | 491 | */ |
492 | - public function priorityOf($item,$withindex = false) |
|
492 | + public function priorityOf($item, $withindex=false) |
|
493 | 493 | { |
494 | 494 | $this->sortPriorities(); |
495 | 495 | |
496 | - $absindex = 0; |
|
496 | + $absindex=0; |
|
497 | 497 | foreach($this->_d as $priority=>$items) { |
498 | - if(($index=array_search($item,$items,true))!==false) { |
|
498 | + if(($index=array_search($item, $items, true))!==false) { |
|
499 | 499 | $absindex+=$index; |
500 | - return $withindex?array($priority,$index,$absindex, |
|
501 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
500 | + return $withindex ? array($priority, $index, $absindex, |
|
501 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
502 | 502 | } else |
503 | 503 | $absindex+=count($items); |
504 | 504 | } |
@@ -515,19 +515,19 @@ discard block |
||
515 | 515 | * if withindex is true, an array is returned of [0 => $priority, 1 => $priorityIndex, 2 => flattenedIndex, |
516 | 516 | * 'priority' => $priority, 'index' => $priorityIndex, 'absindex' => flattenedIndex] |
517 | 517 | */ |
518 | - public function priorityAt($index,$withindex = false) |
|
518 | + public function priorityAt($index, $withindex=false) |
|
519 | 519 | { |
520 | - if($index<0||$index>=$this->getCount()) |
|
521 | - throw new TInvalidDataValueException('list_index_invalid',$index); |
|
520 | + if($index < 0 || $index >= $this->getCount()) |
|
521 | + throw new TInvalidDataValueException('list_index_invalid', $index); |
|
522 | 522 | |
523 | 523 | $absindex=$index; |
524 | 524 | $this->sortPriorities(); |
525 | 525 | foreach($this->_d as $priority=>$items) { |
526 | - if($index>=($c=count($items))) |
|
526 | + if($index >= ($c=count($items))) |
|
527 | 527 | $index-=$c; |
528 | 528 | else |
529 | - return $withindex?array($priority,$index,$absindex, |
|
530 | - 'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority; |
|
529 | + return $withindex ? array($priority, $index, $absindex, |
|
530 | + 'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority; |
|
531 | 531 | } |
532 | 532 | return false; |
533 | 533 | } |
@@ -543,12 +543,12 @@ discard block |
||
543 | 543 | public function insertBefore($indexitem, $item) |
544 | 544 | { |
545 | 545 | if($this->getReadOnly()) |
546 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
546 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
547 | 547 | |
548 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
548 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
549 | 549 | throw new TInvalidDataValueException('list_item_inexistent'); |
550 | 550 | |
551 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
551 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
552 | 552 | |
553 | 553 | return $priority[2]; |
554 | 554 | } |
@@ -564,14 +564,14 @@ discard block |
||
564 | 564 | public function insertAfter($indexitem, $item) |
565 | 565 | { |
566 | 566 | if($this->getReadOnly()) |
567 | - throw new TInvalidOperationException('list_readonly',get_class($this)); |
|
567 | + throw new TInvalidOperationException('list_readonly', get_class($this)); |
|
568 | 568 | |
569 | - if(($priority=$this->priorityOf($indexitem,true))===false) |
|
569 | + if(($priority=$this->priorityOf($indexitem, true))===false) |
|
570 | 570 | throw new TInvalidDataValueException('list_item_inexistent'); |
571 | 571 | |
572 | - $this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]); |
|
572 | + $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]); |
|
573 | 573 | |
574 | - return $priority[2]+1; |
|
574 | + return $priority[2] + 1; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | * @return array the array of priorities keys with values of arrays of items that are below a specified priority. |
599 | 599 | * The priorities are sorted so important priorities, lower numerics, are first. |
600 | 600 | */ |
601 | - public function toArrayBelowPriority($priority,$inclusive=false) |
|
601 | + public function toArrayBelowPriority($priority, $inclusive=false) |
|
602 | 602 | { |
603 | 603 | $this->sortPriorities(); |
604 | 604 | $items=array(); |
605 | 605 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
606 | 606 | { |
607 | - if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) |
|
607 | + if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) |
|
608 | 608 | break; |
609 | - $items=array_merge($items,$itemsatpriority); |
|
609 | + $items=array_merge($items, $itemsatpriority); |
|
610 | 610 | } |
611 | 611 | return $items; |
612 | 612 | } |
@@ -618,15 +618,15 @@ discard block |
||
618 | 618 | * @return array the array of priorities keys with values of arrays of items that are above a specified priority. |
619 | 619 | * The priorities are sorted so important priorities, lower numerics, are first. |
620 | 620 | */ |
621 | - public function toArrayAbovePriority($priority,$inclusive=true) |
|
621 | + public function toArrayAbovePriority($priority, $inclusive=true) |
|
622 | 622 | { |
623 | 623 | $this->sortPriorities(); |
624 | 624 | $items=array(); |
625 | 625 | foreach($this->_d as $itemspriority=>$itemsatpriority) |
626 | 626 | { |
627 | - if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) |
|
627 | + if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) |
|
628 | 628 | continue; |
629 | - $items=array_merge($items,$itemsatpriority); |
|
629 | + $items=array_merge($items, $itemsatpriority); |
|
630 | 630 | } |
631 | 631 | return $items; |
632 | 632 | } |
@@ -642,15 +642,15 @@ discard block |
||
642 | 642 | { |
643 | 643 | if($data instanceof TPriorityList) |
644 | 644 | { |
645 | - if($this->getCount()>0) |
|
645 | + if($this->getCount() > 0) |
|
646 | 646 | $this->clear(); |
647 | 647 | foreach($data->getPriorities() as $priority) |
648 | 648 | { |
649 | 649 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
650 | - $this->insertAtIndexInPriority($item,$index,$priority); |
|
650 | + $this->insertAtIndexInPriority($item, $index, $priority); |
|
651 | 651 | } |
652 | - } else if(is_array($data)||$data instanceof \Traversable) { |
|
653 | - if($this->getCount()>0) |
|
652 | + } else if(is_array($data) || $data instanceof \Traversable) { |
|
653 | + if($this->getCount() > 0) |
|
654 | 654 | $this->clear(); |
655 | 655 | foreach($data as $key=>$item) |
656 | 656 | $this->add($item); |
@@ -673,10 +673,10 @@ discard block |
||
673 | 673 | foreach($data->getPriorities() as $priority) |
674 | 674 | { |
675 | 675 | foreach($data->itemsAtPriority($priority) as $index=>$item) |
676 | - $this->insertAtIndexInPriority($item,false,$priority); |
|
676 | + $this->insertAtIndexInPriority($item, false, $priority); |
|
677 | 677 | } |
678 | 678 | } |
679 | - else if(is_array($data)||$data instanceof \Traversable) |
|
679 | + else if(is_array($data) || $data instanceof \Traversable) |
|
680 | 680 | { |
681 | 681 | foreach($data as $priority=>$item) |
682 | 682 | $this->add($item); |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | */ |
695 | 695 | public function offsetExists($offset) |
696 | 696 | { |
697 | - return ($offset>=0&&$offset<$this->getCount()); |
|
697 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -720,18 +720,18 @@ discard block |
||
720 | 720 | * @param integer the offset to set element |
721 | 721 | * @param mixed the element value |
722 | 722 | */ |
723 | - public function offsetSet($offset,$item) |
|
723 | + public function offsetSet($offset, $item) |
|
724 | 724 | { |
725 | 725 | if($offset===null) |
726 | 726 | return $this->add($item); |
727 | 727 | if($offset===$this->getCount()) { |
728 | - $priority=$this->priorityAt($offset-1,true); |
|
728 | + $priority=$this->priorityAt($offset - 1, true); |
|
729 | 729 | $priority[1]++; |
730 | 730 | } else { |
731 | - $priority=$this->priorityAt($offset,true); |
|
732 | - $this->removeAtIndexInPriority($priority[1],$priority[0]); |
|
731 | + $priority=$this->priorityAt($offset, true); |
|
732 | + $this->removeAtIndexInPriority($priority[1], $priority[0]); |
|
733 | 733 | } |
734 | - $this->insertAtIndexInPriority($item,$priority[1],$priority[0]); |
|
734 | + $this->insertAtIndexInPriority($item, $priority[1], $priority[0]); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |