@@ -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 |
@@ -136,6 +136,7 @@ discard block |
||
136 | 136 | * @param mixed Name of the PHP variable to bind to the SQL statement parameter |
137 | 137 | * @param int SQL data type of the parameter |
138 | 138 | * @param int length of the data type |
139 | + * @param string $name |
|
139 | 140 | * @see http://www.php.net/manual/en/function.PDOStatement-bindParam.php |
140 | 141 | */ |
141 | 142 | public function bindParameter($name, &$value, $dataType=null, $length=null) |
@@ -157,6 +158,7 @@ discard block |
||
157 | 158 | * placeholders, this will be the 1-indexed position of the parameter. |
158 | 159 | * @param mixed The value to bind to the parameter |
159 | 160 | * @param int SQL data type of the parameter |
161 | + * @param string $name |
|
160 | 162 | * @see http://www.php.net/manual/en/function.PDOStatement-bindValue.php |
161 | 163 | */ |
162 | 164 | public function bindValue($name, $value, $dataType=null) |
@@ -109,8 +109,7 @@ discard block |
||
109 | 109 | try |
110 | 110 | { |
111 | 111 | $this->_statement=$this->getConnection()->getPdoInstance()->prepare($this->getText()); |
112 | - } |
|
113 | - catch(Exception $e) |
|
112 | + } catch(Exception $e) |
|
114 | 113 | { |
115 | 114 | throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText()); |
116 | 115 | } |
@@ -186,11 +185,9 @@ discard block |
||
186 | 185 | { |
187 | 186 | $this->_statement->execute(); |
188 | 187 | return $this->_statement->rowCount(); |
189 | - } |
|
190 | - else |
|
188 | + } else |
|
191 | 189 | return $this->getConnection()->getPdoInstance()->exec($this->getText()); |
192 | - } |
|
193 | - catch(Exception $e) |
|
190 | + } catch(Exception $e) |
|
194 | 191 | { |
195 | 192 | throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText()); |
196 | 193 | } |
@@ -223,8 +220,7 @@ discard block |
||
223 | 220 | else |
224 | 221 | $this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText()); |
225 | 222 | return new TDbDataReader($this); |
226 | - } |
|
227 | - catch(Exception $e) |
|
223 | + } catch(Exception $e) |
|
228 | 224 | { |
229 | 225 | throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
230 | 226 | } |
@@ -250,8 +246,7 @@ discard block |
||
250 | 246 | $result=$this->_statement->fetch($fetchAssociative ? PDO::FETCH_ASSOC : PDO::FETCH_NUM); |
251 | 247 | $this->_statement->closeCursor(); |
252 | 248 | return $result; |
253 | - } |
|
254 | - catch(Exception $e) |
|
249 | + } catch(Exception $e) |
|
255 | 250 | { |
256 | 251 | throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
257 | 252 | } |
@@ -279,8 +274,7 @@ discard block |
||
279 | 274 | return stream_get_contents($result); |
280 | 275 | else |
281 | 276 | return $result; |
282 | - } |
|
283 | - catch(Exception $e) |
|
277 | + } catch(Exception $e) |
|
284 | 278 | { |
285 | 279 | throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
286 | 280 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param TDbConnection the database connection |
46 | 46 | * @param string the SQL statement to be executed |
47 | 47 | */ |
48 | - public function __construct(TDbConnection $connection,$text) |
|
48 | + public function __construct(TDbConnection $connection, $text) |
|
49 | 49 | { |
50 | 50 | $this->_connection=$connection; |
51 | 51 | $this->setText($text); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __sleep() |
58 | 58 | { |
59 | - return array_diff(parent::__sleep(),array("\0TDbCommand\0_statement")); |
|
59 | + return array_diff(parent::__sleep(), array("\0TDbCommand\0_statement")); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | catch(Exception $e) |
114 | 114 | { |
115 | - throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText()); |
|
115 | + throw new TDbException('dbcommand_prepare_failed', $e->getMessage(), $this->getText()); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | { |
143 | 143 | $this->prepare(); |
144 | 144 | if($dataType===null) |
145 | - $this->_statement->bindParam($name,$value); |
|
145 | + $this->_statement->bindParam($name, $value); |
|
146 | 146 | else if($length===null) |
147 | - $this->_statement->bindParam($name,$value,$dataType); |
|
147 | + $this->_statement->bindParam($name, $value, $dataType); |
|
148 | 148 | else |
149 | - $this->_statement->bindParam($name,$value,$dataType,$length); |
|
149 | + $this->_statement->bindParam($name, $value, $dataType, $length); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | { |
164 | 164 | $this->prepare(); |
165 | 165 | if($dataType===null) |
166 | - $this->_statement->bindValue($name,$value); |
|
166 | + $this->_statement->bindValue($name, $value); |
|
167 | 167 | else |
168 | - $this->_statement->bindValue($name,$value,$dataType); |
|
168 | + $this->_statement->bindValue($name, $value, $dataType); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | catch(Exception $e) |
194 | 194 | { |
195 | - throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
195 | + throw new TDbException('dbcommand_execute_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | catch(Exception $e) |
228 | 228 | { |
229 | - throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
229 | + throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | } |
254 | 254 | catch(Exception $e) |
255 | 255 | { |
256 | - throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
256 | + throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | catch(Exception $e) |
284 | 284 | { |
285 | - throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); |
|
285 | + throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText()); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TDbCommand class file |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Data |
|
10 | - */ |
|
3 | + * TDbCommand class file |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Data |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * TDbCommand class. |
@@ -58,6 +58,7 @@ |
||
58 | 58 | * should match the case of the column, as returned by the driver. |
59 | 59 | * @param mixed Name of the PHP variable to which the column will be bound. |
60 | 60 | * @param int Data type of the parameter |
61 | + * @param integer $column |
|
61 | 62 | * @see http://www.php.net/manual/en/function.PDOStatement-bindColumn.php |
62 | 63 | */ |
63 | 64 | public function bindColumn($column, &$value, $dataType=null) |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | public function bindColumn($column, &$value, $dataType=null) |
64 | 64 | { |
65 | 65 | if($dataType===null) |
66 | - $this->_statement->bindColumn($column,$value); |
|
66 | + $this->_statement->bindColumn($column, $value); |
|
67 | 67 | else |
68 | - $this->_statement->bindColumn($column,$value,$dataType); |
|
68 | + $this->_statement->bindColumn($column, $value, $dataType); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function setFetchMode($mode) |
75 | 75 | { |
76 | 76 | $params=func_get_args(); |
77 | - call_user_func_array(array($this->_statement,'setFetchMode'),$params); |
|
77 | + call_user_func_array(array($this->_statement, 'setFetchMode'), $params); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created |
103 | 103 | * @return mixed|false the populated object, false if no more row of data available |
104 | 104 | */ |
105 | - public function readObject($className,$fields) |
|
105 | + public function readObject($className, $fields) |
|
106 | 106 | { |
107 | - return $this->_statement->fetchObject($className,$fields); |
|
107 | + return $this->_statement->fetchObject($className, $fields); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function rewind() |
173 | 173 | { |
174 | - if($this->_index<0) |
|
174 | + if($this->_index < 0) |
|
175 | 175 | { |
176 | 176 | $this->_row=$this->_statement->fetch(); |
177 | 177 | $this->_index=0; |
@@ -109,6 +109,7 @@ discard block |
||
109 | 109 | * It terminates the application immediately after the error is displayed. |
110 | 110 | * @param mixed sender of the event |
111 | 111 | * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance) |
112 | + * @param null|TApplication $sender |
|
112 | 113 | */ |
113 | 114 | public function handleError($sender,$param) |
114 | 115 | { |
@@ -171,6 +172,7 @@ discard block |
||
171 | 172 | * mode will be displayed to the client user. |
172 | 173 | * @param integer response status code |
173 | 174 | * @param Exception exception instance |
175 | + * @param integer $statusCode |
|
174 | 176 | */ |
175 | 177 | protected function handleExternalError($statusCode,$exception) |
176 | 178 | { |
@@ -363,6 +365,9 @@ discard block |
||
363 | 365 | return $result; |
364 | 366 | } |
365 | 367 | |
368 | + /** |
|
369 | + * @param string $pattern |
|
370 | + */ |
|
366 | 371 | private function getPropertyAccessTrace($trace,$pattern) |
367 | 372 | { |
368 | 373 | $result=null; |
@@ -395,6 +400,9 @@ discard block |
||
395 | 400 | return $source; |
396 | 401 | } |
397 | 402 | |
403 | + /** |
|
404 | + * @param string $message |
|
405 | + */ |
|
398 | 406 | private function addLink($message) |
399 | 407 | { |
400 | 408 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
@@ -219,8 +219,7 @@ discard block |
||
219 | 219 | echo "<body><h1>Recursive Error</h1>\n"; |
220 | 220 | echo "<pre>".$exception->__toString()."</pre>\n"; |
221 | 221 | echo "</body></html>"; |
222 | - } |
|
223 | - else |
|
222 | + } else |
|
224 | 223 | { |
225 | 224 | error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
226 | 225 | header('HTTP/1.0 500 Internal Error'); |
@@ -251,15 +250,13 @@ discard block |
||
251 | 250 | if($fileName==='') |
252 | 251 | $fileName='---embedded template---'; |
253 | 252 | $errorLine=$exception->getLineNumber(); |
254 | - } |
|
255 | - else |
|
253 | + } else |
|
256 | 254 | { |
257 | 255 | if(($trace=$this->getExactTrace($exception))!==null) |
258 | 256 | { |
259 | 257 | $fileName=$trace['file']; |
260 | 258 | $errorLine=$trace['line']; |
261 | - } |
|
262 | - else |
|
259 | + } else |
|
263 | 260 | { |
264 | 261 | $fileName=$exception->getFile(); |
265 | 262 | $errorLine=$exception->getLine(); |
@@ -350,8 +347,7 @@ discard block |
||
350 | 347 | $result=$trace[0]; |
351 | 348 | elseif(isset($trace[1])) |
352 | 349 | $result=$trace[1]; |
353 | - } |
|
354 | - else if($exception instanceof TInvalidOperationException) |
|
350 | + } else if($exception instanceof TInvalidOperationException) |
|
355 | 351 | { |
356 | 352 | // in case of getter or setter error, find out the exact file and row |
357 | 353 | if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
@@ -388,8 +384,7 @@ discard block |
||
388 | 384 | { |
389 | 385 | $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
390 | 386 | $source.="<div class=\"error\">".$line."</div>"; |
391 | - } |
|
392 | - else |
|
387 | + } else |
|
393 | 388 | $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
394 | 389 | } |
395 | 390 | return $source; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
99 | 99 | $this->_templatePath=$templatePath; |
100 | 100 | else |
101 | - throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
|
101 | + throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param mixed sender of the event |
111 | 111 | * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance) |
112 | 112 | */ |
113 | - public function handleError($sender,$param) |
|
113 | + public function handleError($sender, $param) |
|
114 | 114 | { |
115 | 115 | static $handling=false; |
116 | 116 | // We need to restore error and exception handlers, |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | if(!headers_sent()) |
130 | 130 | header('Content-Type: text/html; charset=UTF-8'); |
131 | 131 | if($param instanceof THttpException) |
132 | - $this->handleExternalError($param->getStatusCode(),$param); |
|
132 | + $this->handleExternalError($param->getStatusCode(), $param); |
|
133 | 133 | else if($this->getApplication()->getMode()===TApplicationMode::Debug) |
134 | 134 | $this->displayException($param); |
135 | 135 | else |
136 | - $this->handleExternalError(500,$param); |
|
136 | + $this->handleExternalError(500, $param); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -146,21 +146,21 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected static function hideSecurityRelated($value, $exception=null) |
148 | 148 | { |
149 | - $aRpl = array(); |
|
150 | - if($exception !== null && $exception instanceof Exception) |
|
149 | + $aRpl=array(); |
|
150 | + if($exception!==null && $exception instanceof Exception) |
|
151 | 151 | { |
152 | - $aTrace = $exception->getTrace(); |
|
152 | + $aTrace=$exception->getTrace(); |
|
153 | 153 | foreach($aTrace as $item) |
154 | 154 | { |
155 | 155 | if(isset($item['file'])) |
156 | - $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
|
156 | + $aRpl[dirname($item['file']).DIRECTORY_SEPARATOR]='<hidden>'.DIRECTORY_SEPARATOR; |
|
157 | 157 | } |
158 | 158 | } |
159 | - $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
|
160 | - $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
|
161 | - $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
|
159 | + $aRpl[$_SERVER['DOCUMENT_ROOT']]='${DocumentRoot}'; |
|
160 | + $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])]='${DocumentRoot}'; |
|
161 | + $aRpl[PRADO_DIR.DIRECTORY_SEPARATOR]='${PradoFramework}'.DIRECTORY_SEPARATOR; |
|
162 | 162 | if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
163 | - $aRpl = array_reverse($aRpl, true); |
|
163 | + $aRpl=array_reverse($aRpl, true); |
|
164 | 164 | |
165 | 165 | return str_replace(array_keys($aRpl), $aRpl, $value); |
166 | 166 | } |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | * @param integer response status code |
173 | 173 | * @param Exception exception instance |
174 | 174 | */ |
175 | - protected function handleExternalError($statusCode,$exception) |
|
175 | + protected function handleExternalError($statusCode, $exception) |
|
176 | 176 | { |
177 | 177 | if(!($exception instanceof THttpException)) |
178 | 178 | error_log($exception->__toString()); |
179 | 179 | |
180 | - $content=$this->getErrorTemplate($statusCode,$exception); |
|
180 | + $content=$this->getErrorTemplate($statusCode, $exception); |
|
181 | 181 | |
182 | - $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
182 | + $serverAdmin=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
183 | 183 | |
184 | - $isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug; |
|
184 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
185 | 185 | |
186 | - $errorMessage = $exception->getMessage(); |
|
186 | + $errorMessage=$exception->getMessage(); |
|
187 | 187 | if($isDebug) |
188 | 188 | $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
189 | 189 | else |
190 | 190 | { |
191 | 191 | $version=''; |
192 | - $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
|
192 | + $errorMessage=self::hideSecurityRelated($errorMessage, $exception); |
|
193 | 193 | } |
194 | 194 | $tokens=array( |
195 | 195 | '%%StatusCode%%' => "$statusCode", |
196 | 196 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
197 | 197 | '%%ServerAdmin%%' => $serverAdmin, |
198 | 198 | '%%Version%%' => $version, |
199 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
199 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
200 | 200 | ); |
201 | 201 | |
202 | 202 | $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null); |
203 | 203 | |
204 | - echo strtr($content,$tokens); |
|
204 | + echo strtr($content, $tokens); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | if($exception instanceof TTemplateException) |
247 | 247 | { |
248 | 248 | $fileName=$exception->getTemplateFile(); |
249 | - $lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName); |
|
250 | - $source=$this->getSourceCode($lines,$exception->getLineNumber()); |
|
249 | + $lines=empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
250 | + $source=$this->getSourceCode($lines, $exception->getLineNumber()); |
|
251 | 251 | if($fileName==='') |
252 | 252 | $fileName='---embedded template---'; |
253 | 253 | $errorLine=$exception->getLineNumber(); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $fileName=$exception->getFile(); |
265 | 265 | $errorLine=$exception->getLine(); |
266 | 266 | } |
267 | - $source=$this->getSourceCode(@file($fileName),$errorLine); |
|
267 | + $source=$this->getSourceCode(@file($fileName), $errorLine); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | '%%SourceCode%%' => $source, |
280 | 280 | '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), |
281 | 281 | '%%Version%%' => $version, |
282 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
282 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
283 | 283 | ); |
284 | 284 | |
285 | 285 | $content=$this->getExceptionTemplate($exception); |
286 | 286 | |
287 | - echo strtr($content,$tokens); |
|
287 | + echo strtr($content, $tokens); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param Exception the exception to be displayed |
322 | 322 | * @return string the template content |
323 | 323 | */ |
324 | - protected function getErrorTemplate($statusCode,$exception) |
|
324 | + protected function getErrorTemplate($statusCode, $exception) |
|
325 | 325 | { |
326 | 326 | $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
327 | 327 | $lang=Prado::getPreferredLanguage(); |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | else if($exception instanceof TInvalidOperationException) |
355 | 355 | { |
356 | 356 | // in case of getter or setter error, find out the exact file and row |
357 | - if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
|
358 | - $result=$this->getPropertyAccessTrace($trace,'__set'); |
|
357 | + if(($result=$this->getPropertyAccessTrace($trace, '__get'))===null) |
|
358 | + $result=$this->getPropertyAccessTrace($trace, '__set'); |
|
359 | 359 | } |
360 | - if($result!==null && strpos($result['file'],': eval()\'d code')!==false) |
|
360 | + if($result!==null && strpos($result['file'], ': eval()\'d code')!==false) |
|
361 | 361 | return null; |
362 | 362 | |
363 | 363 | return $result; |
364 | 364 | } |
365 | 365 | |
366 | - private function getPropertyAccessTrace($trace,$pattern) |
|
366 | + private function getPropertyAccessTrace($trace, $pattern) |
|
367 | 367 | { |
368 | 368 | $result=null; |
369 | 369 | foreach($trace as $t) |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | return $result; |
377 | 377 | } |
378 | 378 | |
379 | - private function getSourceCode($lines,$errorLine) |
|
379 | + private function getSourceCode($lines, $errorLine) |
|
380 | 380 | { |
381 | - $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; |
|
382 | - $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); |
|
381 | + $beginLine=$errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
382 | + $endLine=$errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
383 | 383 | |
384 | 384 | $source=''; |
385 | - for($i=$beginLine;$i<$endLine;++$i) |
|
385 | + for($i=$beginLine; $i < $endLine; ++$i) |
|
386 | 386 | { |
387 | - if($i===$errorLine-1) |
|
387 | + if($i===$errorLine - 1) |
|
388 | 388 | { |
389 | - $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
389 | + $line=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
390 | 390 | $source.="<div class=\"error\">".$line."</div>"; |
391 | 391 | } |
392 | 392 | else |
393 | - $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
393 | + $source.=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
394 | 394 | } |
395 | 395 | return $source; |
396 | 396 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | private function addLink($message) |
399 | 399 | { |
400 | 400 | $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
401 | - return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message); |
|
401 | + return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 |
@@ -393,6 +393,8 @@ |
||
393 | 393 | * in the message file. If so, the message in the preferred language |
394 | 394 | * will be used as the error message. Any rest parameters will be used |
395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
396 | + * @param integer $statusCode |
|
397 | + * @param string $errorMessage |
|
396 | 398 | */ |
397 | 399 | public function __construct($statusCode,$errorMessage) |
398 | 400 | { |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | array_shift($args); |
51 | 51 | $n=count($args); |
52 | 52 | $tokens=array(); |
53 | - for($i=0;$i<$n;++$i) |
|
53 | + for($i=0; $i < $n; ++$i) |
|
54 | 54 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
55 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
55 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | $msgFile=$this->getErrorMessageFile(); |
66 | 66 | |
67 | 67 | // Cache messages |
68 | - if (!isset(self::$_messageCache[$msgFile])) |
|
68 | + if(!isset(self::$_messageCache[$msgFile])) |
|
69 | 69 | { |
70 | 70 | if(($entries=@file($msgFile))!==false) |
71 | 71 | { |
72 | 72 | foreach($entries as $entry) |
73 | 73 | { |
74 | - @list($code,$message)=explode('=',$entry,2); |
|
74 | + @list($code, $message)=explode('=', $entry, 2); |
|
75 | 75 | self::$_messageCache[$msgFile][trim($code)]=trim($message); |
76 | 76 | } |
77 | 77 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param string error file |
339 | 339 | * @param integer error line number |
340 | 340 | */ |
341 | - public function __construct($errno,$errstr,$errfile,$errline) |
|
341 | + public function __construct($errno, $errstr, $errfile, $errline) |
|
342 | 342 | { |
343 | 343 | static $errorTypes=array( |
344 | 344 | E_ERROR => "Error", |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | E_USER_NOTICE => "User Notice", |
355 | 355 | E_STRICT => "Runtime Notice" |
356 | 356 | ); |
357 | - $errorType=isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; |
|
357 | + $errorType=isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error'; |
|
358 | 358 | parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); |
359 | 359 | } |
360 | 360 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * will be used as the error message. Any rest parameters will be used |
395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
396 | 396 | */ |
397 | - public function __construct($statusCode,$errorMessage) |
|
397 | + public function __construct($statusCode, $errorMessage) |
|
398 | 398 | { |
399 | 399 | $this->_statusCode=$statusCode; |
400 | 400 | $this->setErrorCode($errorMessage); |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | array_shift($args); |
405 | 405 | $n=count($args); |
406 | 406 | $tokens=array(); |
407 | - for($i=0;$i<$n;++$i) |
|
407 | + for($i=0; $i < $n; ++$i) |
|
408 | 408 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
409 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
409 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -165,6 +165,9 @@ discard block |
||
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | + /** |
|
169 | + * @param string $set |
|
170 | + */ |
|
168 | 171 | protected function isValidSetNotation($number, $set) |
169 | 172 | { |
170 | 173 | $str = '$result = '.str_replace('n', '$number', $set).';'; |
@@ -208,6 +211,7 @@ discard block |
||
208 | 211 | * string that satisfied the set within the choices. |
209 | 212 | * @param string the choices string. |
210 | 213 | * @param float the number to test. |
214 | + * @param double $number |
|
211 | 215 | * @return string the choosen string. |
212 | 216 | */ |
213 | 217 | public function format($string, $number) |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | * The pattern to validate a set notation |
83 | 83 | * @var string |
84 | 84 | */ |
85 | - protected $validate = '/[\(\[\{]|[-Inf\d:\s]+|,|[\+Inf\d\s:\?\-=!><%\|&\(\)]+|[\)\]\}]/ms'; |
|
85 | + protected $validate='/[\(\[\{]|[-Inf\d:\s]+|,|[\+Inf\d\s:\?\-=!><%\|&\(\)]+|[\)\]\}]/ms'; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * The pattern to parse the formatting string. |
89 | 89 | * @var string |
90 | 90 | */ |
91 | - protected $parse = '/\s*\|?([\(\[\{]([-Inf\d:\s]+,?[\+Inf\d\s:\?\-=!><%\|&\(\)]*)+[\)\]\}])\s*/'; |
|
91 | + protected $parse='/\s*\|?([\(\[\{]([-Inf\d:\s]+,?[\+Inf\d\s:\?\-=!><%\|&\(\)]*)+[\)\]\}])\s*/'; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * The value for positive infinity. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function __construct() |
104 | 104 | { |
105 | - $this->inf = -log(0); |
|
105 | + $this->inf=-log(0); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | function isValid($number, $set) |
116 | 116 | { |
117 | - $n = preg_match_all($this->validate,$set,$matches,PREG_SET_ORDER); |
|
117 | + $n=preg_match_all($this->validate, $set, $matches, PREG_SET_ORDER); |
|
118 | 118 | |
119 | 119 | if($n < 3) throw new Exception("Invalid set \"{$set}\""); |
120 | 120 | |
@@ -123,42 +123,42 @@ discard block |
||
123 | 123 | return $this->isValidSetNotation($number, $def[1]); |
124 | 124 | } |
125 | 125 | |
126 | - $leftBracket = $matches[0][0]; |
|
127 | - $rightBracket = $matches[$n-1][0]; |
|
126 | + $leftBracket=$matches[0][0]; |
|
127 | + $rightBracket=$matches[$n - 1][0]; |
|
128 | 128 | |
129 | - $i = 0; |
|
130 | - $elements = array(); |
|
129 | + $i=0; |
|
130 | + $elements=array(); |
|
131 | 131 | foreach($matches as $match) |
132 | 132 | { |
133 | - $string = $match[0]; |
|
134 | - if($i != 0 && $i != $n-1 && $string !== ',') |
|
133 | + $string=$match[0]; |
|
134 | + if($i!=0 && $i!=$n - 1 && $string!==',') |
|
135 | 135 | { |
136 | - if($string == '-Inf') |
|
137 | - $elements[] = -1*$this->inf; |
|
138 | - else if ($string == '+Inf' || $string == 'Inf') |
|
139 | - $elements[] = $this->inf; |
|
136 | + if($string=='-Inf') |
|
137 | + $elements[]=-1 * $this->inf; |
|
138 | + else if($string=='+Inf' || $string=='Inf') |
|
139 | + $elements[]=$this->inf; |
|
140 | 140 | else |
141 | - $elements[] = floatval($string); |
|
141 | + $elements[]=floatval($string); |
|
142 | 142 | } |
143 | 143 | $i++; |
144 | 144 | } |
145 | - $total = count($elements); |
|
146 | - $number = floatval($number); |
|
145 | + $total=count($elements); |
|
146 | + $number=floatval($number); |
|
147 | 147 | |
148 | - if($leftBracket == '{' && $rightBracket == '}') |
|
148 | + if($leftBracket=='{' && $rightBracket=='}') |
|
149 | 149 | return in_array($number, $elements); |
150 | 150 | |
151 | - $left = false; |
|
152 | - if($leftBracket == '[') |
|
153 | - $left = $number >= $elements[0]; |
|
154 | - else if ($leftBracket == '(') |
|
155 | - $left = $number > $elements[0]; |
|
151 | + $left=false; |
|
152 | + if($leftBracket=='[') |
|
153 | + $left=$number >= $elements[0]; |
|
154 | + else if($leftBracket=='(') |
|
155 | + $left=$number > $elements[0]; |
|
156 | 156 | |
157 | - $right = false; |
|
157 | + $right=false; |
|
158 | 158 | if($rightBracket==']') |
159 | - $right = $number <= $elements[$total-1]; |
|
160 | - else if($rightBracket == ')') |
|
161 | - $right = $number < $elements[$total-1]; |
|
159 | + $right=$number <= $elements[$total - 1]; |
|
160 | + else if($rightBracket==')') |
|
161 | + $right=$number < $elements[$total - 1]; |
|
162 | 162 | |
163 | 163 | if($left && $right) return true; |
164 | 164 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | protected function isValidSetNotation($number, $set) |
169 | 169 | { |
170 | - $str = '$result = '.str_replace('n', '$number', $set).';'; |
|
170 | + $str='$result = '.str_replace('n', '$number', $set).';'; |
|
171 | 171 | try |
172 | 172 | { |
173 | 173 | eval($str); |
@@ -187,18 +187,18 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function parse($string) |
189 | 189 | { |
190 | - $n = preg_match_all($this->parse,$string,$matches, PREG_OFFSET_CAPTURE); |
|
191 | - $sets = array(); |
|
190 | + $n=preg_match_all($this->parse, $string, $matches, PREG_OFFSET_CAPTURE); |
|
191 | + $sets=array(); |
|
192 | 192 | foreach($matches[1] as $match) |
193 | - $sets[] = $match[0]; |
|
194 | - $offset = $matches[0]; |
|
195 | - $strings = array(); |
|
196 | - for($i = 0; $i < $n; $i++) |
|
193 | + $sets[]=$match[0]; |
|
194 | + $offset=$matches[0]; |
|
195 | + $strings=array(); |
|
196 | + for($i=0; $i < $n; $i++) |
|
197 | 197 | { |
198 | - $len = strlen($offset[$i][0]); |
|
199 | - $begin = $i == 0? $len : $offset[$i][1] + $len; |
|
200 | - $end = $i == $n-1 ? strlen($string) : $offset[$i+1][1]; |
|
201 | - $strings[] = substr($string, $begin, $end - $begin); |
|
198 | + $len=strlen($offset[$i][0]); |
|
199 | + $begin=$i==0 ? $len : $offset[$i][1] + $len; |
|
200 | + $end=$i==$n - 1 ? strlen($string) : $offset[$i + 1][1]; |
|
201 | + $strings[]=substr($string, $begin, $end - $begin); |
|
202 | 202 | } |
203 | 203 | return array($sets, $strings); |
204 | 204 | } |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function format($string, $number) |
214 | 214 | { |
215 | - list($sets, $strings) = $this->parse($string); |
|
216 | - $total = count($sets); |
|
217 | - for($i = 0; $i < $total; $i++) |
|
215 | + list($sets, $strings)=$this->parse($string); |
|
216 | + $total=count($sets); |
|
217 | + for($i=0; $i < $total; $i++) |
|
218 | 218 | { |
219 | 219 | if($this->isValid($number, $sets[$i])) |
220 | 220 | return $strings[$i]; |
@@ -164,8 +164,7 @@ |
||
164 | 164 | try |
165 | 165 | { |
166 | 166 | $highlighter=Text_Highlighter::factory($this->getLanguage()); |
167 | - } |
|
168 | - catch(Exception $e) |
|
167 | + } catch(Exception $e) |
|
169 | 168 | { |
170 | 169 | $highlighter=false; |
171 | 170 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * @return string default culture |
|
93 | + * @return boolean default culture |
|
94 | 94 | */ |
95 | 95 | public function getTranslateDefaultCulture() |
96 | 96 | { |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | * Default character set is 'UTF-8'. |
30 | 30 | * @var string |
31 | 31 | */ |
32 | - private $_defaultCharset = 'UTF-8'; |
|
32 | + private $_defaultCharset='UTF-8'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Default culture is 'en'. |
36 | 36 | * @var string |
37 | 37 | */ |
38 | - private $_defaultCulture = 'en'; |
|
38 | + private $_defaultCulture='en'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * The current charset. |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | if($config!==null) |
78 | 78 | { |
79 | 79 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
80 | - $translation = isset($config['translate'])?$config['translate']:null; |
|
80 | + $translation=isset($config['translate']) ? $config['translate'] : null; |
|
81 | 81 | else |
82 | 82 | { |
83 | - $t = $config->getElementByTagName('translation'); |
|
84 | - $translation = ($t)?$t->getAttributes():null; |
|
83 | + $t=$config->getElementByTagName('translation'); |
|
84 | + $translation=($t) ? $t->getAttributes() : null; |
|
85 | 85 | } |
86 | 86 | if($translation) |
87 | 87 | $this->setTranslationConfiguration($translation); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function setTranslateDefaultCulture($value) |
104 | 104 | { |
105 | - $this->_translateDefaultCulture = TPropertyValue::ensureBoolean($value); |
|
105 | + $this->_translateDefaultCulture=TPropertyValue::ensureBoolean($value); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function setDefaultCulture($culture) |
120 | 120 | { |
121 | - $this->_defaultCulture = str_replace('-','_',$culture); |
|
121 | + $this->_defaultCulture=str_replace('-', '_', $culture); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function setDefaultCharset($charset) |
136 | 136 | { |
137 | - $this->_defaultCharset = $charset; |
|
137 | + $this->_defaultCharset=$charset; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function setCulture($culture) |
152 | 152 | { |
153 | - $this->_culture = str_replace('-','_',$culture); |
|
153 | + $this->_culture=str_replace('-', '_', $culture); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function setCharset($charset) |
168 | 168 | { |
169 | - $this->_charset = $charset; |
|
169 | + $this->_charset=$charset; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function getTranslationConfiguration() |
176 | 176 | { |
177 | - return (!$this->_translateDefaultCulture && ($this->getDefaultCulture() == $this->getCulture())) |
|
177 | + return (!$this->_translateDefaultCulture && ($this->getDefaultCulture()==$this->getCulture())) |
|
178 | 178 | ? null |
179 | 179 | : $this->_translation; |
180 | 180 | } |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function setTranslationConfiguration($config) |
198 | 198 | { |
199 | - if($config['type'] == 'XLIFF' || $config['type'] == 'gettext') |
|
199 | + if($config['type']=='XLIFF' || $config['type']=='gettext') |
|
200 | 200 | { |
201 | 201 | if($config['source']) |
202 | 202 | { |
203 | - $config['source'] = Prado::getPathOfNamespace($config['source']); |
|
203 | + $config['source']=Prado::getPathOfNamespace($config['source']); |
|
204 | 204 | if(!is_dir($config['source'])) |
205 | 205 | { |
206 | 206 | if(@mkdir($config['source'])===false) |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | if($config['cache']) |
218 | 218 | { |
219 | - $config['cache'] = $this->getApplication()->getRunTimePath().'/i18n'; |
|
219 | + $config['cache']=$this->getApplication()->getRunTimePath().'/i18n'; |
|
220 | 220 | if(!is_dir($config['cache'])) |
221 | 221 | { |
222 | 222 | if(@mkdir($config['cache'])===false) |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | chmod($config['cache'], PRADO_CHMOD); //make it deletable |
226 | 226 | } |
227 | 227 | } |
228 | - $this->_translation = $config; |
|
228 | + $this->_translation=$config; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function setTranslationCatalogue($value) |
243 | 243 | { |
244 | - $this->_translation['catalogue'] = $value; |
|
244 | + $this->_translation['catalogue']=$value; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function getCultureVariants($culture=null) |
254 | 254 | { |
255 | - if($culture===null) $culture = $this->getCulture(); |
|
256 | - $variants = explode('_', $culture); |
|
257 | - $result = array(); |
|
255 | + if($culture===null) $culture=$this->getCulture(); |
|
256 | + $variants=explode('_', $culture); |
|
257 | + $result=array(); |
|
258 | 258 | for(; count($variants) > 0; array_pop($variants)) |
259 | - $result[] = implode('_', $variants); |
|
259 | + $result[]=implode('_', $variants); |
|
260 | 260 | return $result; |
261 | 261 | } |
262 | 262 | |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | * @param string culture string, null to use current culture |
280 | 280 | * @return array list of possible localized resource files. |
281 | 281 | */ |
282 | - public function getLocalizedResource($file,$culture=null) |
|
282 | + public function getLocalizedResource($file, $culture=null) |
|
283 | 283 | { |
284 | - $files = array(); |
|
285 | - $variants = $this->getCultureVariants($culture); |
|
286 | - $path = pathinfo($file); |
|
284 | + $files=array(); |
|
285 | + $variants=$this->getCultureVariants($culture); |
|
286 | + $path=pathinfo($file); |
|
287 | 287 | foreach($variants as $variant) |
288 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
289 | - $filename = substr($path['basename'],0,strrpos($path['basename'],'.')); |
|
288 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename']; |
|
289 | + $filename=substr($path['basename'], 0, strrpos($path['basename'], '.')); |
|
290 | 290 | foreach($variants as $variant) |
291 | - $files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
292 | - $files[] = $file; |
|
291 | + $files[]=$path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension']; |
|
292 | + $files[]=$file; |
|
293 | 293 | return $files; |
294 | 294 | } |
295 | 295 |
@@ -158,8 +158,7 @@ |
||
158 | 158 | $e->setAttribute('maxOccurs','unbounded'); |
159 | 159 | $sequence->appendChild($e); |
160 | 160 | $complexType->appendChild($sequence); |
161 | - } |
|
162 | - else |
|
161 | + } else |
|
163 | 162 | { |
164 | 163 | $all = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all'); |
165 | 164 | foreach($elements as $elem) |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * @return mixed the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'. |
|
185 | + * @return string the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'. |
|
186 | 186 | */ |
187 | 187 | public function getCryptAlgorithm() |
188 | 188 | { |
@@ -201,6 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Encrypts data with {@link getEncryptionKey EncryptionKey}. |
203 | 203 | * @param string data to be encrypted. |
204 | + * @param string $data |
|
204 | 205 | * @return string the encrypted data |
205 | 206 | * @throws TNotSupportedException if PHP Mcrypt extension is not loaded |
206 | 207 | */ |
@@ -220,6 +221,7 @@ discard block |
||
220 | 221 | /** |
221 | 222 | * Decrypts data with {@link getEncryptionKey EncryptionKey}. |
222 | 223 | * @param string data to be decrypted. |
224 | + * @param string $data |
|
223 | 225 | * @return string the decrypted data |
224 | 226 | * @throws TNotSupportedException if PHP Mcrypt extension is not loaded |
225 | 227 | */ |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class TSecurityManager extends TModule |
42 | 42 | { |
43 | - const STATE_VALIDATION_KEY = 'prado:securitymanager:validationkey'; |
|
44 | - const STATE_ENCRYPTION_KEY = 'prado:securitymanager:encryptionkey'; |
|
43 | + const STATE_VALIDATION_KEY='prado:securitymanager:validationkey'; |
|
44 | + const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey'; |
|
45 | 45 | |
46 | - private $_validationKey = null; |
|
47 | - private $_encryptionKey = null; |
|
48 | - private $_hashAlgorithm = 'sha1'; |
|
49 | - private $_cryptAlgorithm = 'rijndael-256'; |
|
46 | + private $_validationKey=null; |
|
47 | + private $_encryptionKey=null; |
|
48 | + private $_hashAlgorithm='sha1'; |
|
49 | + private $_cryptAlgorithm='rijndael-256'; |
|
50 | 50 | private $_mbstring; |
51 | 51 | |
52 | 52 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function generateRandomKey() |
67 | 67 | { |
68 | - return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand()); |
|
68 | + return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getValidationKey() |
76 | 76 | { |
77 | - if(null === $this->_validationKey) { |
|
78 | - if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
79 | - $this->_validationKey = $this->generateRandomKey(); |
|
77 | + if(null===$this->_validationKey) { |
|
78 | + if(null===($this->_validationKey=$this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
79 | + $this->_validationKey=$this->generateRandomKey(); |
|
80 | 80 | $this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true); |
81 | 81 | } |
82 | 82 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setValidationKey($value) |
91 | 91 | { |
92 | - if('' === $value) |
|
92 | + if(''===$value) |
|
93 | 93 | throw new TInvalidDataValueException('securitymanager_validationkey_invalid'); |
94 | 94 | |
95 | - $this->_validationKey = $value; |
|
95 | + $this->_validationKey=$value; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function getEncryptionKey() |
103 | 103 | { |
104 | - if(null === $this->_encryptionKey) { |
|
105 | - if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
106 | - $this->_encryptionKey = $this->generateRandomKey(); |
|
104 | + if(null===$this->_encryptionKey) { |
|
105 | + if(null===($this->_encryptionKey=$this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
106 | + $this->_encryptionKey=$this->generateRandomKey(); |
|
107 | 107 | $this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true); |
108 | 108 | } |
109 | 109 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function setEncryptionKey($value) |
118 | 118 | { |
119 | - if('' === $value) |
|
119 | + if(''===$value) |
|
120 | 120 | throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid'); |
121 | 121 | |
122 | - $this->_encryptionKey = $value; |
|
122 | + $this->_encryptionKey=$value; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function setValidation($value) |
149 | 149 | { |
150 | - $this->_hashAlgorithm = TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode'); |
|
150 | + $this->_hashAlgorithm=TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function setHashAlgorithm($value) |
157 | 157 | { |
158 | - $this->_hashAlgorithm = TPropertyValue::ensureString($value); |
|
158 | + $this->_hashAlgorithm=TPropertyValue::ensureString($value); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function setEncryption($value) |
180 | 180 | { |
181 | - $this->_cryptAlgorithm = $value; |
|
181 | + $this->_cryptAlgorithm=$value; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function setCryptAlgorithm($value) |
197 | 197 | { |
198 | - $this->_cryptAlgorithm = $value; |
|
198 | + $this->_cryptAlgorithm=$value; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | public function encrypt($data) |
208 | 208 | { |
209 | 209 | $module=$this->openCryptModule(); |
210 | - $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
210 | + $key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
211 | 211 | srand(); |
212 | - $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
|
212 | + $iv=mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND); |
|
213 | 213 | mcrypt_generic_init($module, $key, $iv); |
214 | - $encrypted = $iv.mcrypt_generic($module, $data); |
|
214 | + $encrypted=$iv.mcrypt_generic($module, $data); |
|
215 | 215 | mcrypt_generic_deinit($module); |
216 | 216 | mcrypt_module_close($module); |
217 | 217 | return $encrypted; |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | public function decrypt($data) |
227 | 227 | { |
228 | 228 | $module=$this->openCryptModule(); |
229 | - $key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
230 | - $ivSize = mcrypt_enc_get_iv_size($module); |
|
231 | - $iv = $this->substr($data, 0, $ivSize); |
|
229 | + $key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module)); |
|
230 | + $ivSize=mcrypt_enc_get_iv_size($module); |
|
231 | + $iv=$this->substr($data, 0, $ivSize); |
|
232 | 232 | mcrypt_generic_init($module, $key, $iv); |
233 | - $decrypted = mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data))); |
|
233 | + $decrypted=mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data))); |
|
234 | 234 | mcrypt_generic_deinit($module); |
235 | 235 | mcrypt_module_close($module); |
236 | 236 | return $decrypted; |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | if(extension_loaded('mcrypt')) |
247 | 247 | { |
248 | 248 | if(is_array($this->_cryptAlgorithm)) |
249 | - $module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm); |
|
249 | + $module=@call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm); |
|
250 | 250 | else |
251 | - $module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,''); |
|
251 | + $module=@mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, ''); |
|
252 | 252 | |
253 | 253 | if($module===false) |
254 | 254 | throw new TNotSupportedException('securitymanager_mcryptextension_initfailed'); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function hashData($data) |
268 | 268 | { |
269 | - $hmac = $this->computeHMAC($data); |
|
269 | + $hmac=$this->computeHMAC($data); |
|
270 | 270 | return $hmac.$data; |
271 | 271 | } |
272 | 272 | |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | if($this->strlen($data) < $len) |
285 | 285 | return false; |
286 | 286 | |
287 | - $hmac = $this->substr($data, 0, $len); |
|
287 | + $hmac=$this->substr($data, 0, $len); |
|
288 | 288 | $data2=$this->substr($data, $len, $this->strlen($data)); |
289 | - return $hmac === $this->computeHMAC($data2) ? $data2 : false; |
|
289 | + return $hmac===$this->computeHMAC($data2) ? $data2 : false; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,22 +296,22 @@ discard block |
||
296 | 296 | */ |
297 | 297 | protected function computeHMAC($data) |
298 | 298 | { |
299 | - $key = $this->getValidationKey(); |
|
299 | + $key=$this->getValidationKey(); |
|
300 | 300 | |
301 | 301 | if(function_exists('hash_hmac')) |
302 | 302 | return hash_hmac($this->_hashAlgorithm, $data, $key); |
303 | 303 | |
304 | - if(!strcasecmp($this->_hashAlgorithm,'sha1')) |
|
304 | + if(!strcasecmp($this->_hashAlgorithm, 'sha1')) |
|
305 | 305 | { |
306 | - $pack = 'H40'; |
|
307 | - $func = 'sha1'; |
|
306 | + $pack='H40'; |
|
307 | + $func='sha1'; |
|
308 | 308 | } else { |
309 | - $pack = 'H32'; |
|
310 | - $func = 'md5'; |
|
309 | + $pack='H32'; |
|
310 | + $func='md5'; |
|
311 | 311 | } |
312 | 312 | |
313 | - $key = str_pad($func($key), 64, chr(0)); |
|
314 | - return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)) . pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)) . $data))); |
|
313 | + $key=str_pad($func($key), 64, chr(0)); |
|
314 | + return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)).pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)).$data))); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | private function strlen($string) |
324 | 324 | { |
325 | - return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string); |
|
325 | + return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * @param int $length the desired portion length |
334 | 334 | * @return string the extracted part of string, or FALSE on failure or an empty string. |
335 | 335 | */ |
336 | - private function substr($string,$start,$length) |
|
336 | + private function substr($string, $start, $length) |
|
337 | 337 | { |
338 | - return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length); |
|
338 | + return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
@@ -357,6 +357,6 @@ discard block |
||
357 | 357 | */ |
358 | 358 | class TSecurityManagerValidationMode extends TEnumerable |
359 | 359 | { |
360 | - const MD5 = 'MD5'; |
|
361 | - const SHA1 = 'SHA1'; |
|
360 | + const MD5='MD5'; |
|
361 | + const SHA1='SHA1'; |
|
362 | 362 | } |
@@ -73,6 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string username |
76 | + * @param string $value |
|
76 | 77 | */ |
77 | 78 | public function setName($value) |
78 | 79 | { |
@@ -89,6 +90,7 @@ discard block |
||
89 | 90 | |
90 | 91 | /** |
91 | 92 | * @param boolean if the user is a guest |
93 | + * @param boolean $value |
|
92 | 94 | */ |
93 | 95 | public function setIsGuest($value) |
94 | 96 | { |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | * |
171 | 173 | * @param string variable name |
172 | 174 | * @param mixed default value |
175 | + * @param string $key |
|
173 | 176 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 177 | * @see setState |
175 | 178 | */ |
@@ -190,6 +193,7 @@ discard block |
||
190 | 193 | * @param string variable name |
191 | 194 | * @param mixed variable value |
192 | 195 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
196 | + * @param string $key |
|
193 | 197 | * @see getState |
194 | 198 | */ |
195 | 199 | protected function setState($key,$value,$defaultValue=null) |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getName() |
70 | 70 | { |
71 | - return $this->getState('Name',''); |
|
71 | + return $this->getState('Name', ''); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setName($value) |
78 | 78 | { |
79 | - $this->setState('Name',$value,''); |
|
79 | + $this->setState('Name', $value, ''); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getIsGuest() |
86 | 86 | { |
87 | - return $this->getState('IsGuest',true); |
|
87 | + return $this->getState('IsGuest', true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->setName($this->_manager->getGuestName()); |
98 | 98 | $this->setRoles(array()); |
99 | 99 | } |
100 | - $this->setState('IsGuest',$isGuest); |
|
100 | + $this->setState('IsGuest', $isGuest); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getRoles() |
107 | 107 | { |
108 | - return $this->getState('Roles',array()); |
|
108 | + return $this->getState('Roles', array()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function setRoles($value) |
115 | 115 | { |
116 | 116 | if(is_array($value)) |
117 | - $this->setState('Roles',$value,array()); |
|
117 | + $this->setState('Roles', $value, array()); |
|
118 | 118 | else |
119 | 119 | { |
120 | 120 | $roles=array(); |
121 | - foreach(explode(',',$value) as $role) |
|
121 | + foreach(explode(',', $value) as $role) |
|
122 | 122 | { |
123 | 123 | if(($role=trim($role))!=='') |
124 | 124 | $roles[]=$role; |
125 | 125 | } |
126 | - $this->setState('Roles',$roles,array()); |
|
126 | + $this->setState('Roles', $roles, array()); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function isInRole($role) |
135 | 135 | { |
136 | 136 | foreach($this->getRoles() as $r) |
137 | - if(strcasecmp($role,$r)===0) |
|
137 | + if(strcasecmp($role, $r)===0) |
|
138 | 138 | return true; |
139 | 139 | return false; |
140 | 140 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 174 | * @see setState |
175 | 175 | */ |
176 | - protected function getState($key,$defaultValue=null) |
|
176 | + protected function getState($key, $defaultValue=null) |
|
177 | 177 | { |
178 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
178 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
193 | 193 | * @see getState |
194 | 194 | */ |
195 | - protected function setState($key,$value,$defaultValue=null) |
|
195 | + protected function setState($key, $value, $defaultValue=null) |
|
196 | 196 | { |
197 | 197 | if($value===$defaultValue) |
198 | 198 | unset($this->_state[$key]); |