@@ -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 |
@@ -233,8 +233,7 @@ discard block |
||
233 | 233 | $newid=substr($id,$pos+1); |
234 | 234 | if ($control!==null) |
235 | 235 | $control=$control->$newid; |
236 | - } |
|
237 | - else |
|
236 | + } else |
|
238 | 237 | { |
239 | 238 | // TCheckBoxList overrides findControl() with a fake implementation |
240 | 239 | // but accepts a second parameter to use the standard one |
@@ -296,8 +295,7 @@ discard block |
||
296 | 295 | { |
297 | 296 | $group=$this->getValidationGroup(); |
298 | 297 | return $this->getPage()->getValidators($group)->getCount()>0; |
299 | - } |
|
300 | - else |
|
298 | + } else |
|
301 | 299 | return false; |
302 | 300 | } |
303 | 301 |
@@ -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]); |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param string path of the asset that is relative to the directory containing the specified class file. |
94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
95 | + * @param string $assetPath |
|
95 | 96 | * @return string URL to the asset path. |
96 | 97 | */ |
97 | 98 | public function publishAsset($assetPath,$className=null) |
@@ -106,6 +107,7 @@ discard block |
||
106 | 107 | /** |
107 | 108 | * Publishes a file or directory and returns its URL. |
108 | 109 | * @param string absolute path of the file or directory to be published |
110 | + * @param string $fullPath |
|
109 | 111 | * @return string URL to the published file or directory |
110 | 112 | */ |
111 | 113 | public function publishFilePath($fullPath, $checkTimestamp=false) |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
95 | 95 | * @return string URL to the asset path. |
96 | 96 | */ |
97 | - public function publishAsset($assetPath,$className=null) |
|
97 | + public function publishAsset($assetPath, $className=null) |
|
98 | 98 | { |
99 | 99 | if($className===null) |
100 | 100 | $className=get_class($this); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * </code> |
407 | 407 | * to be executed when listen is called. All attached behaviors are notified through dyListen. |
408 | 408 | * |
409 | - * @return numeric the number of global events that were registered to the global event registry |
|
409 | + * @return null|integer the number of global events that were registered to the global event registry |
|
410 | 410 | */ |
411 | 411 | public function listen() { |
412 | 412 | if($this->_listeningenabled) |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * </code> |
441 | 441 | * to be executed when listen is called. All attached behaviors are notified through dyUnlisten. |
442 | 442 | * |
443 | - * @return numeric the number of global events that were unregistered from the global event registry |
|
443 | + * @return null|integer the number of global events that were unregistered from the global event registry |
|
444 | 444 | */ |
445 | 445 | public function unlisten() { |
446 | 446 | if(!$this->_listeningenabled) |
@@ -774,6 +774,7 @@ discard block |
||
774 | 774 | * A property is defined if there is a getter or setter method |
775 | 775 | * defined in the class. Note, property names are case-insensitive. |
776 | 776 | * @param string the property name |
777 | + * @param string $name |
|
777 | 778 | * @return boolean whether the property is defined |
778 | 779 | */ |
779 | 780 | public function hasProperty($name) |
@@ -2100,6 +2101,9 @@ discard block |
||
2100 | 2101 | $this->reflect(); |
2101 | 2102 | } |
2102 | 2103 | |
2104 | + /** |
|
2105 | + * @param ReflectionMethod $method |
|
2106 | + */ |
|
2103 | 2107 | private function isPropertyMethod($method) |
2104 | 2108 | { |
2105 | 2109 | $methodName=$method->getName(); |
@@ -2108,6 +2112,9 @@ discard block |
||
2108 | 2112 | && isset($methodName[3]); |
2109 | 2113 | } |
2110 | 2114 | |
2115 | + /** |
|
2116 | + * @param ReflectionMethod $method |
|
2117 | + */ |
|
2111 | 2118 | private function isEventMethod($method) |
2112 | 2119 | { |
2113 | 2120 | $methodName=$method->getName(); |
@@ -2254,11 +2261,14 @@ discard block |
||
2254 | 2261 | /** |
2255 | 2262 | * Attaches the behavior object to the component. |
2256 | 2263 | * @param CComponent the component that this behavior is to be attached to. |
2264 | + * @param TComponent $component |
|
2265 | + * @return void |
|
2257 | 2266 | */ |
2258 | 2267 | public function attach($component); |
2259 | 2268 | /** |
2260 | 2269 | * Detaches the behavior object from the component. |
2261 | 2270 | * @param CComponent the component that this behavior is to be detached from. |
2271 | + * @return void |
|
2262 | 2272 | */ |
2263 | 2273 | public function detach($component); |
2264 | 2274 | } |
@@ -2283,6 +2293,8 @@ discard block |
||
2283 | 2293 | public function getEnabled(); |
2284 | 2294 | /** |
2285 | 2295 | * @param boolean whether this behavior is enabled |
2296 | + * @param boolean $value |
|
2297 | + * @return void |
|
2286 | 2298 | */ |
2287 | 2299 | public function setEnabled($value); |
2288 | 2300 | } |
@@ -533,8 +533,7 @@ discard block |
||
533 | 533 | } |
534 | 534 | if($callchain->getCount()>0) |
535 | 535 | return call_user_func_array(array($callchain,'call'),$args); |
536 | - } |
|
537 | - else |
|
536 | + } else |
|
538 | 537 | { |
539 | 538 | foreach($this->_m->toArray() as $behavior) |
540 | 539 | { |
@@ -588,29 +587,25 @@ discard block |
||
588 | 587 | { |
589 | 588 | // getting a property |
590 | 589 | return $this->$getter(); |
591 | - } |
|
592 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
590 | + } else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
593 | 591 | { |
594 | 592 | // getting a javascript property |
595 | 593 | return (string)$this->$jsgetter(); |
596 | - } |
|
597 | - else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
594 | + } else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
598 | 595 | { |
599 | 596 | // getting an event (handler list) |
600 | 597 | $name=strtolower($name); |
601 | 598 | if(!isset($this->_e[$name])) |
602 | 599 | $this->_e[$name]=new TPriorityList; |
603 | 600 | return $this->_e[$name]; |
604 | - } |
|
605 | - else if(strncasecmp($name,'fx',2)===0) |
|
601 | + } else if(strncasecmp($name,'fx',2)===0) |
|
606 | 602 | { |
607 | 603 | // getting a global event (handler list) |
608 | 604 | $name=strtolower($name); |
609 | 605 | if(!isset(self::$_ue[$name])) |
610 | 606 | self::$_ue[$name]=new TPriorityList; |
611 | 607 | return self::$_ue[$name]; |
612 | - } |
|
613 | - else if($this->_behaviorsenabled) |
|
608 | + } else if($this->_behaviorsenabled) |
|
614 | 609 | { |
615 | 610 | // getting a behavior property/event (handler list) |
616 | 611 | if(isset($this->_m[$name])) |
@@ -650,18 +645,15 @@ discard block |
||
650 | 645 | if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) |
651 | 646 | $value = new TJavaScriptLiteral($value); |
652 | 647 | return $this->$setter($value); |
653 | - } |
|
654 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
648 | + } else if(method_exists($this,$jssetter='setjs'.$name)) |
|
655 | 649 | { |
656 | 650 | if($value&&!($value instanceof TJavaScriptString)) |
657 | 651 | $value=new TJavaScriptString($value); |
658 | 652 | return $this->$jssetter($value); |
659 | - } |
|
660 | - else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
653 | + } else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
661 | 654 | { |
662 | 655 | return $this->attachEventHandler($name,$value); |
663 | - } |
|
664 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
656 | + } else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
665 | 657 | { |
666 | 658 | $sets=0; |
667 | 659 | foreach($this->_m->toArray() as $behavior) |
@@ -679,8 +671,7 @@ discard block |
||
679 | 671 | if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
680 | 672 | { |
681 | 673 | throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
682 | - } |
|
683 | - else |
|
674 | + } else |
|
684 | 675 | { |
685 | 676 | throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
686 | 677 | } |
@@ -708,13 +699,11 @@ discard block |
||
708 | 699 | { |
709 | 700 | $name=strtolower($name); |
710 | 701 | return isset($this->_e[$name])&&$this->_e[$name]->getCount(); |
711 | - } |
|
712 | - else if(strncasecmp($name,'fx',2)===0) |
|
702 | + } else if(strncasecmp($name,'fx',2)===0) |
|
713 | 703 | { |
714 | 704 | $name=strtolower($name); |
715 | 705 | return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount(); |
716 | - } |
|
717 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
706 | + } else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
718 | 707 | { |
719 | 708 | if(isset($this->_m[$name])) |
720 | 709 | return true; |
@@ -724,8 +713,7 @@ discard block |
||
724 | 713 | return isset($behavior->$name); |
725 | 714 | } |
726 | 715 | |
727 | - } |
|
728 | - else |
|
716 | + } else |
|
729 | 717 | return false; |
730 | 718 | } |
731 | 719 | |
@@ -939,15 +927,13 @@ discard block |
||
939 | 927 | if(!isset($this->_e[$name])) |
940 | 928 | $this->_e[$name]=new TPriorityList; |
941 | 929 | return $this->_e[$name]; |
942 | - } |
|
943 | - else if(strncasecmp($name,'fx',2)===0) |
|
930 | + } else if(strncasecmp($name,'fx',2)===0) |
|
944 | 931 | { |
945 | 932 | $name=strtolower($name); |
946 | 933 | if(!isset(self::$_ue[$name])) |
947 | 934 | self::$_ue[$name]=new TPriorityList; |
948 | 935 | return self::$_ue[$name]; |
949 | - } |
|
950 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
936 | + } else if($this->_m!==null&&$this->_behaviorsenabled) |
|
951 | 937 | { |
952 | 938 | foreach($this->_m->toArray() as $behavior) |
953 | 939 | { |
@@ -1026,8 +1012,7 @@ discard block |
||
1026 | 1012 | { |
1027 | 1013 | $this->getEventHandlers($name)->remove($handler,$priority); |
1028 | 1014 | return true; |
1029 | - } |
|
1030 | - catch(Exception $e) |
|
1015 | + } catch(Exception $e) |
|
1031 | 1016 | { |
1032 | 1017 | } |
1033 | 1018 | } |
@@ -1150,14 +1135,11 @@ discard block |
||
1150 | 1135 | $response=$object->__dycall($name,array($sender,$param,$name)); |
1151 | 1136 | else |
1152 | 1137 | $response=$object->$method($sender,$param,$name); |
1153 | - } |
|
1154 | - else |
|
1138 | + } else |
|
1155 | 1139 | throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler); |
1156 | - } |
|
1157 | - else |
|
1140 | + } else |
|
1158 | 1141 | $response=call_user_func($handler,$sender,$param,$name); |
1159 | - } |
|
1160 | - else if(is_callable($handler,true)) |
|
1142 | + } else if(is_callable($handler,true)) |
|
1161 | 1143 | { |
1162 | 1144 | list($object,$method)=$handler; |
1163 | 1145 | if(is_string($object)) |
@@ -1175,12 +1157,10 @@ discard block |
||
1175 | 1157 | $response=$object->__dycall($name,array($sender,$param,$name)); |
1176 | 1158 | else |
1177 | 1159 | $response=$object->$method($sender,$param,$name); |
1178 | - } |
|
1179 | - else |
|
1160 | + } else |
|
1180 | 1161 | throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]); |
1181 | 1162 | } |
1182 | - } |
|
1183 | - else |
|
1163 | + } else |
|
1184 | 1164 | throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler)); |
1185 | 1165 | |
1186 | 1166 | $this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response); |
@@ -1197,8 +1177,7 @@ discard block |
||
1197 | 1177 | $param=$response; |
1198 | 1178 | |
1199 | 1179 | } |
1200 | - } |
|
1201 | - else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1180 | + } else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1202 | 1181 | throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
1203 | 1182 | |
1204 | 1183 | if($responsetype&TEventResults::EVENT_RESULT_FILTER) |
@@ -1234,8 +1213,7 @@ discard block |
||
1234 | 1213 | if(eval("\$result=$expression;")===false) |
1235 | 1214 | throw new Exception(''); |
1236 | 1215 | return $result; |
1237 | - } |
|
1238 | - catch(Exception $e) |
|
1216 | + } catch(Exception $e) |
|
1239 | 1217 | { |
1240 | 1218 | throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); |
1241 | 1219 | } |
@@ -1269,8 +1247,7 @@ discard block |
||
1269 | 1247 | $content=ob_get_contents(); |
1270 | 1248 | ob_end_clean(); |
1271 | 1249 | return $content; |
1272 | - } |
|
1273 | - catch(Exception $e) |
|
1250 | + } catch(Exception $e) |
|
1274 | 1251 | { |
1275 | 1252 | throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); |
1276 | 1253 | } |
@@ -1972,11 +1949,9 @@ discard block |
||
1972 | 1949 | { |
1973 | 1950 | eval('$array=array'.$value.';'); |
1974 | 1951 | return $array; |
1975 | - } |
|
1976 | - else |
|
1952 | + } else |
|
1977 | 1953 | return $len>0?array($value):array(); |
1978 | - } |
|
1979 | - else |
|
1954 | + } else |
|
1980 | 1955 | return (array)$value; |
1981 | 1956 | } |
1982 | 1957 | |
@@ -2019,8 +1994,7 @@ discard block |
||
2019 | 1994 | throw new TInvalidDataValueException( |
2020 | 1995 | 'propertyvalue_enumvalue_invalid',$value, |
2021 | 1996 | implode(' | ',$types[$enums]->getConstants())); |
2022 | - } |
|
2023 | - else if(!is_array($enums)) |
|
1997 | + } else if(!is_array($enums)) |
|
2024 | 1998 | { |
2025 | 1999 | $enums=func_get_args(); |
2026 | 2000 | array_shift($enums); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * that start with 'fx' are filtered in. |
374 | 374 | */ |
375 | 375 | private function filter_prado_fx($name) { |
376 | - return strncasecmp($name,'fx',2)===0; |
|
376 | + return strncasecmp($name, 'fx', 2)===0; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | * @param boolean optional should the names be all lowercase true/false |
384 | 384 | * @return array array of strings being the class hierarchy of $this. |
385 | 385 | */ |
386 | - public function getClassHierarchy($lowercase = false) |
|
386 | + public function getClassHierarchy($lowercase=false) |
|
387 | 387 | { |
388 | 388 | $class=get_class($this); |
389 | 389 | $classes=array($class); |
390 | - while($class=get_parent_class($class)){array_unshift($classes,$class);} |
|
390 | + while($class=get_parent_class($class)) {array_unshift($classes, $class); } |
|
391 | 391 | if($lowercase) |
392 | - return array_map('strtolower',$classes); |
|
392 | + return array_map('strtolower', $classes); |
|
393 | 393 | return $classes; |
394 | 394 | } |
395 | 395 | |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | if($this->_listeningenabled) |
413 | 413 | return; |
414 | 414 | |
415 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
415 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
416 | 416 | |
417 | 417 | foreach($fx as $func) |
418 | - $this->attachEventHandler($func,array($this,$func)); |
|
418 | + $this->attachEventHandler($func, array($this, $func)); |
|
419 | 419 | |
420 | - if(is_a($this,'IDynamicMethods')) { |
|
421 | - $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
422 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
420 | + if(is_a($this, 'IDynamicMethods')) { |
|
421 | + $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
422 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | $this->_listeningenabled=true; |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | if(!$this->_listeningenabled) |
447 | 447 | return; |
448 | 448 | |
449 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
449 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
450 | 450 | |
451 | 451 | foreach($fx as $func) |
452 | - $this->detachEventHandler($func,array($this,$func)); |
|
452 | + $this->detachEventHandler($func, array($this, $func)); |
|
453 | 453 | |
454 | - if(is_a($this,'IDynamicMethods')) { |
|
455 | - $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
456 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
454 | + if(is_a($this, 'IDynamicMethods')) { |
|
455 | + $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
456 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $this->_listeningenabled=false; |
@@ -498,66 +498,66 @@ discard block |
||
498 | 498 | */ |
499 | 499 | public function __call($method, $args) |
500 | 500 | { |
501 | - $getset=substr($method,0,3); |
|
502 | - if(($getset=='get')||($getset=='set')) |
|
501 | + $getset=substr($method, 0, 3); |
|
502 | + if(($getset=='get') || ($getset=='set')) |
|
503 | 503 | { |
504 | - $propname=substr($method,3); |
|
504 | + $propname=substr($method, 3); |
|
505 | 505 | $jsmethod=$getset.'js'.$propname; |
506 | - if(method_exists($this,$jsmethod)) |
|
506 | + if(method_exists($this, $jsmethod)) |
|
507 | 507 | { |
508 | - if(count($args)>0) |
|
509 | - if($args[0]&&!($args[0] instanceof TJavaScriptString)) |
|
508 | + if(count($args) > 0) |
|
509 | + if($args[0] && !($args[0] instanceof TJavaScriptString)) |
|
510 | 510 | $args[0]=new TJavaScriptString($args[0]); |
511 | - return call_user_func_array(array($this,$jsmethod),$args); |
|
511 | + return call_user_func_array(array($this, $jsmethod), $args); |
|
512 | 512 | } |
513 | 513 | |
514 | - if (($getset=='set')&&method_exists($this,'getjs'.$propname)) |
|
515 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$method); |
|
514 | + if(($getset=='set') && method_exists($this, 'getjs'.$propname)) |
|
515 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $method); |
|
516 | 516 | } |
517 | 517 | |
518 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
518 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
519 | 519 | { |
520 | - if(strncasecmp($method,'dy',2)===0) |
|
520 | + if(strncasecmp($method, 'dy', 2)===0) |
|
521 | 521 | { |
522 | 522 | $callchain=new TCallChain($method); |
523 | 523 | foreach($this->_m->toArray() as $behavior) |
524 | 524 | { |
525 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&(method_exists($behavior,$method)||($behavior instanceof IDynamicMethods))) |
|
525 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) |
|
526 | 526 | { |
527 | 527 | $behavior_args=$args; |
528 | 528 | if($behavior instanceof IClassBehavior) |
529 | - array_unshift($behavior_args,$this); |
|
530 | - $callchain->addCall(array($behavior,$method),$behavior_args); |
|
529 | + array_unshift($behavior_args, $this); |
|
530 | + $callchain->addCall(array($behavior, $method), $behavior_args); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | } |
534 | - if($callchain->getCount()>0) |
|
535 | - return call_user_func_array(array($callchain,'call'),$args); |
|
534 | + if($callchain->getCount() > 0) |
|
535 | + return call_user_func_array(array($callchain, 'call'), $args); |
|
536 | 536 | } |
537 | 537 | else |
538 | 538 | { |
539 | 539 | foreach($this->_m->toArray() as $behavior) |
540 | 540 | { |
541 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&method_exists($behavior,$method)) |
|
541 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method)) |
|
542 | 542 | { |
543 | 543 | if($behavior instanceof IClassBehavior) |
544 | - array_unshift($args,$this); |
|
545 | - return call_user_func_array(array($behavior,$method),$args); |
|
544 | + array_unshift($args, $this); |
|
545 | + return call_user_func_array(array($behavior, $method), $args); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | - if(strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
551 | + if(strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
552 | 552 | { |
553 | 553 | if($this instanceof IDynamicMethods) |
554 | - return $this->__dycall($method,$args); |
|
555 | - return isset($args[0])?$args[0]:null; |
|
554 | + return $this->__dycall($method, $args); |
|
555 | + return isset($args[0]) ? $args[0] : null; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // don't thrown an exception for __magicMethods() or any other weird methods natively implemented by php |
559 | - if (!method_exists($this, $method)) { |
|
560 | - throw new TApplicationException('component_method_undefined',get_class($this),$method); |
|
559 | + if(!method_exists($this, $method)) { |
|
560 | + throw new TApplicationException('component_method_undefined', get_class($this), $method); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | |
@@ -587,17 +587,17 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function __get($name) |
589 | 589 | { |
590 | - if(method_exists($this,$getter='get'.$name)) |
|
590 | + if(method_exists($this, $getter='get'.$name)) |
|
591 | 591 | { |
592 | 592 | // getting a property |
593 | 593 | return $this->$getter(); |
594 | 594 | } |
595 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
595 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
596 | 596 | { |
597 | 597 | // getting a javascript property |
598 | - return (string)$this->$jsgetter(); |
|
598 | + return (string) $this->$jsgetter(); |
|
599 | 599 | } |
600 | - else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
600 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
601 | 601 | { |
602 | 602 | // getting an event (handler list) |
603 | 603 | $name=strtolower($name); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $this->_e[$name]=new TPriorityList; |
606 | 606 | return $this->_e[$name]; |
607 | 607 | } |
608 | - else if(strncasecmp($name,'fx',2)===0) |
|
608 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
609 | 609 | { |
610 | 610 | // getting a global event (handler list) |
611 | 611 | $name=strtolower($name); |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | { |
623 | 623 | foreach($this->_m->toArray() as $behavior) |
624 | 624 | { |
625 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
626 | - (property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name))) |
|
625 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
626 | + (property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name))) |
|
627 | 627 | return $behavior->$name; |
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
631 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
@@ -646,31 +646,31 @@ discard block |
||
646 | 646 | * @param mixed the property value or event handler |
647 | 647 | * @throws TInvalidOperationException If the property is not defined or read-only. |
648 | 648 | */ |
649 | - public function __set($name,$value) |
|
649 | + public function __set($name, $value) |
|
650 | 650 | { |
651 | - if(method_exists($this,$setter='set'.$name)) |
|
651 | + if(method_exists($this, $setter='set'.$name)) |
|
652 | 652 | { |
653 | - if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) |
|
654 | - $value = new TJavaScriptLiteral($value); |
|
653 | + if(strncasecmp($name, 'js', 2)===0 && $value && !($value instanceof TJavaScriptLiteral)) |
|
654 | + $value=new TJavaScriptLiteral($value); |
|
655 | 655 | return $this->$setter($value); |
656 | 656 | } |
657 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
657 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
658 | 658 | { |
659 | - if($value&&!($value instanceof TJavaScriptString)) |
|
659 | + if($value && !($value instanceof TJavaScriptString)) |
|
660 | 660 | $value=new TJavaScriptString($value); |
661 | 661 | return $this->$jssetter($value); |
662 | 662 | } |
663 | - else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
663 | + else if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0) |
|
664 | 664 | { |
665 | - return $this->attachEventHandler($name,$value); |
|
665 | + return $this->attachEventHandler($name, $value); |
|
666 | 666 | } |
667 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
667 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
668 | 668 | { |
669 | 669 | $sets=0; |
670 | 670 | foreach($this->_m->toArray() as $behavior) |
671 | 671 | { |
672 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
673 | - (property_exists($behavior,$name)||$behavior->canSetProperty($name)||$behavior->hasEvent($name))) { |
|
672 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
673 | + (property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) { |
|
674 | 674 | $behavior->$name=$value; |
675 | 675 | $sets++; |
676 | 676 | } |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | |
680 | 680 | } |
681 | 681 | |
682 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
682 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
683 | 683 | { |
684 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
684 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
685 | 685 | } |
686 | 686 | else |
687 | 687 | { |
688 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
688 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -703,27 +703,27 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function __isset($name) |
705 | 705 | { |
706 | - if(method_exists($this,$getter='get'.$name)) |
|
706 | + if(method_exists($this, $getter='get'.$name)) |
|
707 | 707 | return $this->$getter()!==null; |
708 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
708 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
709 | 709 | return $this->$jsgetter()!==null; |
710 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
710 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
711 | 711 | { |
712 | 712 | $name=strtolower($name); |
713 | - return isset($this->_e[$name])&&$this->_e[$name]->getCount(); |
|
713 | + return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
|
714 | 714 | } |
715 | - else if(strncasecmp($name,'fx',2)===0) |
|
715 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
716 | 716 | { |
717 | 717 | $name=strtolower($name); |
718 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount(); |
|
718 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
|
719 | 719 | } |
720 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
720 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
721 | 721 | { |
722 | 722 | if(isset($this->_m[$name])) |
723 | 723 | return true; |
724 | 724 | foreach($this->_m->toArray() as $behavior) |
725 | 725 | { |
726 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) |
|
726 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) |
|
727 | 727 | return isset($behavior->$name); |
728 | 728 | } |
729 | 729 | |
@@ -744,15 +744,15 @@ discard block |
||
744 | 744 | */ |
745 | 745 | public function __unset($name) |
746 | 746 | { |
747 | - if(method_exists($this,$setter='set'.$name)) |
|
747 | + if(method_exists($this, $setter='set'.$name)) |
|
748 | 748 | $this->$setter(null); |
749 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
749 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
750 | 750 | $this->$jssetter(null); |
751 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
751 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
752 | 752 | $this->_e[strtolower($name)]->clear(); |
753 | - else if(strncasecmp($name,'fx',2)===0) |
|
753 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
754 | 754 | $this->getEventHandlers($name)->remove(array($this, $name)); |
755 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
755 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
756 | 756 | { |
757 | 757 | if(isset($this->_m[$name])) |
758 | 758 | $this->detachBehavior($name); |
@@ -760,16 +760,16 @@ discard block |
||
760 | 760 | $unset=0; |
761 | 761 | foreach($this->_m->toArray() as $behavior) |
762 | 762 | { |
763 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) { |
|
763 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
764 | 764 | unset($behavior->$name); |
765 | 765 | $unset++; |
766 | 766 | } |
767 | 767 | } |
768 | - if(!$unset&&method_exists($this,'get'.$name)) |
|
769 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
768 | + if(!$unset && method_exists($this, 'get'.$name)) |
|
769 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
770 | 770 | } |
771 | - } else if(method_exists($this,'get'.$name)) |
|
772 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
771 | + } else if(method_exists($this, 'get'.$name)) |
|
772 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | */ |
782 | 782 | public function hasProperty($name) |
783 | 783 | { |
784 | - return $this->canGetProperty($name)||$this->canSetProperty($name); |
|
784 | + return $this->canGetProperty($name) || $this->canSetProperty($name); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
@@ -795,13 +795,13 @@ discard block |
||
795 | 795 | */ |
796 | 796 | public function canGetProperty($name) |
797 | 797 | { |
798 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
798 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
799 | 799 | return true; |
800 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
800 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
801 | 801 | { |
802 | 802 | foreach($this->_m->toArray() as $behavior) |
803 | 803 | { |
804 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name)) |
|
804 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name)) |
|
805 | 805 | return true; |
806 | 806 | } |
807 | 807 | } |
@@ -819,13 +819,13 @@ discard block |
||
819 | 819 | */ |
820 | 820 | public function canSetProperty($name) |
821 | 821 | { |
822 | - if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name)) |
|
822 | + if(method_exists($this, 'set'.$name) || method_exists($this, 'setjs'.$name)) |
|
823 | 823 | return true; |
824 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
824 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
825 | 825 | { |
826 | 826 | foreach($this->_m->toArray() as $behavior) |
827 | 827 | { |
828 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name)) |
|
828 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name)) |
|
829 | 829 | return true; |
830 | 830 | } |
831 | 831 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | public function getSubProperty($path) |
846 | 846 | { |
847 | 847 | $object=$this; |
848 | - foreach(explode('.',$path) as $property) |
|
848 | + foreach(explode('.', $path) as $property) |
|
849 | 849 | $object=$object->$property; |
850 | 850 | return $object; |
851 | 851 | } |
@@ -860,15 +860,15 @@ discard block |
||
860 | 860 | * @param string property path |
861 | 861 | * @param mixed the property path value |
862 | 862 | */ |
863 | - public function setSubProperty($path,$value) |
|
863 | + public function setSubProperty($path, $value) |
|
864 | 864 | { |
865 | 865 | $object=$this; |
866 | - if(($pos=strrpos($path,'.'))===false) |
|
866 | + if(($pos=strrpos($path, '.'))===false) |
|
867 | 867 | $property=$path; |
868 | 868 | else |
869 | 869 | { |
870 | - $object=$this->getSubProperty(substr($path,0,$pos)); |
|
871 | - $property=substr($path,$pos+1); |
|
870 | + $object=$this->getSubProperty(substr($path, 0, $pos)); |
|
871 | + $property=substr($path, $pos + 1); |
|
872 | 872 | } |
873 | 873 | $object->$property=$value; |
874 | 874 | } |
@@ -887,14 +887,14 @@ discard block |
||
887 | 887 | */ |
888 | 888 | public function hasEvent($name) |
889 | 889 | { |
890 | - if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0) |
|
890 | + if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0 || strncasecmp($name, 'dy', 2)===0) |
|
891 | 891 | return true; |
892 | 892 | |
893 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
893 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
894 | 894 | { |
895 | 895 | foreach($this->_m->toArray() as $behavior) |
896 | 896 | { |
897 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
897 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
898 | 898 | return true; |
899 | 899 | } |
900 | 900 | } |
@@ -911,16 +911,16 @@ discard block |
||
911 | 911 | public function hasEventHandler($name) |
912 | 912 | { |
913 | 913 | $name=strtolower($name); |
914 | - if(strncasecmp($name,'fx',2)===0) |
|
915 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0; |
|
914 | + if(strncasecmp($name, 'fx', 2)===0) |
|
915 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0; |
|
916 | 916 | else |
917 | 917 | { |
918 | - if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0) |
|
918 | + if(isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) |
|
919 | 919 | return true; |
920 | - else if($this->_m!==null&&$this->_behaviorsenabled) { |
|
920 | + else if($this->_m!==null && $this->_behaviorsenabled) { |
|
921 | 921 | foreach($this->_m->toArray() as $behavior) |
922 | 922 | { |
923 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name)) |
|
923 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) |
|
924 | 924 | return true; |
925 | 925 | } |
926 | 926 | } |
@@ -936,29 +936,29 @@ discard block |
||
936 | 936 | */ |
937 | 937 | public function getEventHandlers($name) |
938 | 938 | { |
939 | - if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
939 | + if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
940 | 940 | { |
941 | 941 | $name=strtolower($name); |
942 | 942 | if(!isset($this->_e[$name])) |
943 | 943 | $this->_e[$name]=new TPriorityList; |
944 | 944 | return $this->_e[$name]; |
945 | 945 | } |
946 | - else if(strncasecmp($name,'fx',2)===0) |
|
946 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
947 | 947 | { |
948 | 948 | $name=strtolower($name); |
949 | 949 | if(!isset(self::$_ue[$name])) |
950 | 950 | self::$_ue[$name]=new TPriorityList; |
951 | 951 | return self::$_ue[$name]; |
952 | 952 | } |
953 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
953 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
954 | 954 | { |
955 | 955 | foreach($this->_m->toArray() as $behavior) |
956 | 956 | { |
957 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
957 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
958 | 958 | return $behavior->getEventHandlers($name); |
959 | 959 | } |
960 | 960 | } |
961 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
961 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -1006,9 +1006,9 @@ discard block |
||
1006 | 1006 | * default priority of 10.0 within {@link TPriorityList} |
1007 | 1007 | * @throws TInvalidOperationException if the event does not exist |
1008 | 1008 | */ |
1009 | - public function attachEventHandler($name,$handler,$priority=null) |
|
1009 | + public function attachEventHandler($name, $handler, $priority=null) |
|
1010 | 1010 | { |
1011 | - $this->getEventHandlers($name)->add($handler,$priority); |
|
1011 | + $this->getEventHandlers($name)->add($handler, $priority); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1021,13 +1021,13 @@ discard block |
||
1021 | 1021 | * to an item of any priority within {@link TPriorityList}; null means the default priority |
1022 | 1022 | * @return boolean if the removal is successful |
1023 | 1023 | */ |
1024 | - public function detachEventHandler($name,$handler,$priority=false) |
|
1024 | + public function detachEventHandler($name, $handler, $priority=false) |
|
1025 | 1025 | { |
1026 | 1026 | if($this->hasEventHandler($name)) |
1027 | 1027 | { |
1028 | 1028 | try |
1029 | 1029 | { |
1030 | - $this->getEventHandlers($name)->remove($handler,$priority); |
|
1030 | + $this->getEventHandlers($name)->remove($handler, $priority); |
|
1031 | 1031 | return true; |
1032 | 1032 | } |
1033 | 1033 | catch(Exception $e) |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | * @throws TInvalidOperationException if the event is undefined |
1110 | 1110 | * @throws TInvalidDataValueException If an event handler is invalid |
1111 | 1111 | */ |
1112 | - public function raiseEvent($name,$sender,$param,$responsetype=null,$postfunction=null) |
|
1112 | + public function raiseEvent($name, $sender, $param, $responsetype=null, $postfunction=null) |
|
1113 | 1113 | { |
1114 | 1114 | $p=$param; |
1115 | 1115 | if(is_callable($responsetype)) |
@@ -1124,90 +1124,90 @@ discard block |
||
1124 | 1124 | $name=strtolower($name); |
1125 | 1125 | $responses=array(); |
1126 | 1126 | |
1127 | - $name=$this->dyPreRaiseEvent($name,$sender,$param,$responsetype,$postfunction); |
|
1127 | + $name=$this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
|
1128 | 1128 | |
1129 | - if($this->hasEventHandler($name)||$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1129 | + if($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1130 | 1130 | { |
1131 | 1131 | $handlers=$this->getEventHandlers($name); |
1132 | 1132 | $handlerArray=$handlers->toArray(); |
1133 | - if(strncasecmp($name,'fx',2)===0&&$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1133 | + if(strncasecmp($name, 'fx', 2)===0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1134 | 1134 | { |
1135 | 1135 | $globalhandlers=$this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
1136 | - $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0),$handlerArray,$globalhandlers->toArrayAbovePriority(0)); |
|
1136 | + $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
|
1137 | 1137 | } |
1138 | 1138 | $response=null; |
1139 | 1139 | foreach($handlerArray as $handler) |
1140 | 1140 | { |
1141 | - if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false) |
|
1141 | + if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name)===false) |
|
1142 | 1142 | continue; |
1143 | 1143 | |
1144 | 1144 | if(is_string($handler)) |
1145 | 1145 | { |
1146 | - if(($pos=strrpos($handler,'.'))!==false) |
|
1146 | + if(($pos=strrpos($handler, '.'))!==false) |
|
1147 | 1147 | { |
1148 | - $object=$this->getSubProperty(substr($handler,0,$pos)); |
|
1149 | - $method=substr($handler,$pos+1); |
|
1150 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
1148 | + $object=$this->getSubProperty(substr($handler, 0, $pos)); |
|
1149 | + $method=substr($handler, $pos + 1); |
|
1150 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
1151 | 1151 | { |
1152 | 1152 | if($method=='__dycall') |
1153 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
1153 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
1154 | 1154 | else |
1155 | - $response=$object->$method($sender,$param,$name); |
|
1155 | + $response=$object->$method($sender, $param, $name); |
|
1156 | 1156 | } |
1157 | 1157 | else |
1158 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler); |
|
1158 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler); |
|
1159 | 1159 | } |
1160 | 1160 | else |
1161 | - $response=call_user_func($handler,$sender,$param,$name); |
|
1161 | + $response=call_user_func($handler, $sender, $param, $name); |
|
1162 | 1162 | } |
1163 | - else if(is_callable($handler,true)) |
|
1163 | + else if(is_callable($handler, true)) |
|
1164 | 1164 | { |
1165 | - list($object,$method)=$handler; |
|
1165 | + list($object, $method)=$handler; |
|
1166 | 1166 | if(is_string($object)) |
1167 | - $response=call_user_func($handler,$sender,$param,$name); |
|
1167 | + $response=call_user_func($handler, $sender, $param, $name); |
|
1168 | 1168 | else |
1169 | 1169 | { |
1170 | - if(($pos=strrpos($method,'.'))!==false) |
|
1170 | + if(($pos=strrpos($method, '.'))!==false) |
|
1171 | 1171 | { |
1172 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
1173 | - $method=substr($method,$pos+1); |
|
1172 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
1173 | + $method=substr($method, $pos + 1); |
|
1174 | 1174 | } |
1175 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
1175 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
1176 | 1176 | { |
1177 | 1177 | if($method=='__dycall') |
1178 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
1178 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
1179 | 1179 | else |
1180 | - $response=$object->$method($sender,$param,$name); |
|
1180 | + $response=$object->$method($sender, $param, $name); |
|
1181 | 1181 | } |
1182 | 1182 | else |
1183 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]); |
|
1183 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]); |
|
1184 | 1184 | } |
1185 | 1185 | } |
1186 | 1186 | else |
1187 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler)); |
|
1187 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, gettype($handler)); |
|
1188 | 1188 | |
1189 | - $this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response); |
|
1189 | + $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
|
1190 | 1190 | |
1191 | 1191 | if($postfunction) |
1192 | - $response=call_user_func_array($postfunction,array($sender,$param,$this,$response)); |
|
1192 | + $response=call_user_func_array($postfunction, array($sender, $param, $this, $response)); |
|
1193 | 1193 | |
1194 | - if($responsetype&TEventResults::EVENT_RESULT_ALL) |
|
1195 | - $responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response); |
|
1194 | + if($responsetype & TEventResults::EVENT_RESULT_ALL) |
|
1195 | + $responses[]=array('sender'=>$sender, 'param'=>$param, 'response'=>$response); |
|
1196 | 1196 | else |
1197 | 1197 | $responses[]=$response; |
1198 | 1198 | |
1199 | - if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
1199 | + if($response!==null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
1200 | 1200 | $param=$response; |
1201 | 1201 | |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | - else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1205 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
1204 | + else if(strncasecmp($name, 'on', 2)===0 && !$this->hasEvent($name)) |
|
1205 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
1206 | 1206 | |
1207 | - if($responsetype&TEventResults::EVENT_RESULT_FILTER) |
|
1207 | + if($responsetype & TEventResults::EVENT_RESULT_FILTER) |
|
1208 | 1208 | $responses=array_filter($responses); |
1209 | 1209 | |
1210 | - $responses=$this->dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction); |
|
1210 | + $responses=$this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction); |
|
1211 | 1211 | |
1212 | 1212 | return $responses; |
1213 | 1213 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | } |
1241 | 1241 | catch(Exception $e) |
1242 | 1242 | { |
1243 | - throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
1243 | + throw new TInvalidOperationException('component_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
1244 | 1244 | } |
1245 | 1245 | } |
1246 | 1246 | |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | } |
1276 | 1276 | catch(Exception $e) |
1277 | 1277 | { |
1278 | - throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); |
|
1278 | + throw new TInvalidOperationException('component_statements_invalid', get_class($this), $statements, $e->getMessage()); |
|
1279 | 1279 | } |
1280 | 1280 | } |
1281 | 1281 | |
@@ -1335,9 +1335,9 @@ discard block |
||
1335 | 1335 | * @param $param TClassBehaviorEventParameter |
1336 | 1336 | * @since 3.2.3 |
1337 | 1337 | */ |
1338 | - public function fxAttachClassBehavior($sender,$param) { |
|
1339 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
1340 | - return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority()); |
|
1338 | + public function fxAttachClassBehavior($sender, $param) { |
|
1339 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
1340 | + return $this->attachBehavior($param->getName(), $param->getBehavior(), $param->getPriority()); |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | |
@@ -1349,9 +1349,9 @@ discard block |
||
1349 | 1349 | * @param $param TClassBehaviorEventParameter |
1350 | 1350 | * @since 3.2.3 |
1351 | 1351 | */ |
1352 | - public function fxDetachClassBehavior($sender,$param) { |
|
1353 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
1354 | - return $this->detachBehavior($param->getName(),$param->getPriority()); |
|
1352 | + public function fxDetachClassBehavior($sender, $param) { |
|
1353 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
1354 | + return $this->detachBehavior($param->getName(), $param->getPriority()); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | |
@@ -1373,8 +1373,8 @@ discard block |
||
1373 | 1373 | * @throws TInvalidOperationException if the class behavior is already defined |
1374 | 1374 | * @since 3.2.3 |
1375 | 1375 | */ |
1376 | - public static function attachClassBehavior($name,$behavior,$class=null,$priority=null) { |
|
1377 | - if(!$class&&function_exists('get_called_class')) |
|
1376 | + public static function attachClassBehavior($name, $behavior, $class=null, $priority=null) { |
|
1377 | + if(!$class && function_exists('get_called_class')) |
|
1378 | 1378 | $class=get_called_class(); |
1379 | 1379 | if(!$class) |
1380 | 1380 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1387,11 +1387,11 @@ discard block |
||
1387 | 1387 | if(empty(self::$_um[$class])) |
1388 | 1388 | self::$_um[$class]=array(); |
1389 | 1389 | if(isset(self::$_um[$class][$name])) |
1390 | - throw new TInvalidOperationException('component_class_behavior_defined',$class,$name); |
|
1391 | - $param=new TClassBehaviorEventParameter($class,$name,$behavior,$priority); |
|
1392 | - self::$_um[$class]=array($name=>$param)+self::$_um[$class]; |
|
1393 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
1394 | - return $behaviorObject->raiseEvent('fxAttachClassBehavior',null,$param); |
|
1390 | + throw new TInvalidOperationException('component_class_behavior_defined', $class, $name); |
|
1391 | + $param=new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
|
1392 | + self::$_um[$class]=array($name=>$param) + self::$_um[$class]; |
|
1393 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
1394 | + return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param); |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | * not supplied as a parameter. |
1408 | 1408 | * @since 3.2.3 |
1409 | 1409 | */ |
1410 | - public static function detachClassBehavior($name,$class=null,$priority=false) { |
|
1411 | - if(!$class&&function_exists('get_called_class')) |
|
1410 | + public static function detachClassBehavior($name, $class=null, $priority=false) { |
|
1411 | + if(!$class && function_exists('get_called_class')) |
|
1412 | 1412 | $class=get_called_class(); |
1413 | 1413 | if(!$class) |
1414 | 1414 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1416,13 +1416,13 @@ discard block |
||
1416 | 1416 | $class=strtolower($class); |
1417 | 1417 | if(!is_string($name)) |
1418 | 1418 | $name=get_class($name); |
1419 | - if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name])) |
|
1419 | + if(empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) |
|
1420 | 1420 | return false; |
1421 | 1421 | $param=self::$_um[$class][$name]; |
1422 | 1422 | $behavior=$param->getBehavior(); |
1423 | 1423 | unset(self::$_um[$class][$name]); |
1424 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
1425 | - return $behaviorObject->raiseEvent('fxDetachClassBehavior',null,$param); |
|
1424 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
1425 | + return $behaviorObject->raiseEvent('fxDetachClassBehavior', null, $param); |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | */ |
1435 | 1435 | public function asa($behaviorname) |
1436 | 1436 | { |
1437 | - return isset($this->_m[$behaviorname])?$this->_m[$behaviorname]:null; |
|
1437 | + return isset($this->_m[$behaviorname]) ? $this->_m[$behaviorname] : null; |
|
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | /** |
@@ -1460,15 +1460,15 @@ discard block |
||
1460 | 1460 | { |
1461 | 1461 | if($this instanceof $class) |
1462 | 1462 | return true; |
1463 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
1464 | - foreach($this->_m->toArray() as $behavior){ |
|
1465 | - if(($behavior instanceof IBehavior)&&!$behavior->getEnabled()) |
|
1463 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
1464 | + foreach($this->_m->toArray() as $behavior) { |
|
1465 | + if(($behavior instanceof IBehavior) && !$behavior->getEnabled()) |
|
1466 | 1466 | continue; |
1467 | 1467 | |
1468 | - $check = null; |
|
1469 | - if(($behavior->isa('IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this)) |
|
1468 | + $check=null; |
|
1469 | + if(($behavior->isa('IInstanceCheck')) && $check=$behavior->isinstanceof($class, $this)) |
|
1470 | 1470 | return true; |
1471 | - if($check===null&&($behavior->isa($class))) |
|
1471 | + if($check===null && ($behavior->isa($class))) |
|
1472 | 1472 | return true; |
1473 | 1473 | } |
1474 | 1474 | return false; |
@@ -1486,9 +1486,9 @@ discard block |
||
1486 | 1486 | { |
1487 | 1487 | foreach($behaviors as $name=>$behavior) |
1488 | 1488 | if($behavior instanceof TClassBehaviorEventParameter) |
1489 | - $this->attachBehavior($behavior->getName(),$behavior->getBehavior(),$behavior->getPriority()); |
|
1489 | + $this->attachBehavior($behavior->getName(), $behavior->getBehavior(), $behavior->getPriority()); |
|
1490 | 1490 | else |
1491 | - $this->attachBehavior($name,$behavior); |
|
1491 | + $this->attachBehavior($name, $behavior); |
|
1492 | 1492 | } |
1493 | 1493 | |
1494 | 1494 | /** |
@@ -1505,9 +1505,9 @@ discard block |
||
1505 | 1505 | { |
1506 | 1506 | foreach($behaviors as $name=>$behavior) |
1507 | 1507 | if($behavior instanceof TClassBehaviorEventParameter) |
1508 | - $this->detachBehavior($behavior->getName(),$behavior->getPriority()); |
|
1508 | + $this->detachBehavior($behavior->getName(), $behavior->getPriority()); |
|
1509 | 1509 | else |
1510 | - $this->detachBehavior(is_string($behavior)?$behavior:$name); |
|
1510 | + $this->detachBehavior(is_string($behavior) ? $behavior : $name); |
|
1511 | 1511 | } |
1512 | 1512 | } |
1513 | 1513 | |
@@ -1545,19 +1545,19 @@ discard block |
||
1545 | 1545 | * @return IBehavior the behavior object |
1546 | 1546 | * @since 3.2.3 |
1547 | 1547 | */ |
1548 | - public function attachBehavior($name,$behavior,$priority=null) |
|
1548 | + public function attachBehavior($name, $behavior, $priority=null) |
|
1549 | 1549 | { |
1550 | 1550 | if(is_string($behavior)) |
1551 | 1551 | $behavior=Prado::createComponent($behavior); |
1552 | 1552 | if(!($behavior instanceof IBaseBehavior)) |
1553 | - throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior)); |
|
1553 | + throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior)); |
|
1554 | 1554 | if($behavior instanceof IBehavior) |
1555 | 1555 | $behavior->setEnabled(true); |
1556 | 1556 | if($this->_m===null) |
1557 | 1557 | $this->_m=new TPriorityMap; |
1558 | 1558 | $behavior->attach($this); |
1559 | - $this->dyAttachBehavior($name,$behavior); |
|
1560 | - $this->_m->add($name,$behavior,$priority); |
|
1559 | + $this->dyAttachBehavior($name, $behavior); |
|
1560 | + $this->_m->add($name, $behavior, $priority); |
|
1561 | 1561 | return $behavior; |
1562 | 1562 | } |
1563 | 1563 | |
@@ -1578,14 +1578,14 @@ discard block |
||
1578 | 1578 | * @return IBehavior the detached behavior. Null if the behavior does not exist. |
1579 | 1579 | * @since 3.2.3 |
1580 | 1580 | */ |
1581 | - public function detachBehavior($name,$priority=false) |
|
1581 | + public function detachBehavior($name, $priority=false) |
|
1582 | 1582 | { |
1583 | - if($this->_m!=null&&isset($this->_m[$name])) |
|
1583 | + if($this->_m!=null && isset($this->_m[$name])) |
|
1584 | 1584 | { |
1585 | 1585 | $this->_m[$name]->detach($this); |
1586 | 1586 | $behavior=$this->_m->itemAt($name); |
1587 | - $this->_m->remove($name,$priority); |
|
1588 | - $this->dyDetachBehavior($name,$behavior); |
|
1587 | + $this->_m->remove($name, $priority); |
|
1588 | + $this->dyDetachBehavior($name, $behavior); |
|
1589 | 1589 | return $behavior; |
1590 | 1590 | } |
1591 | 1591 | } |
@@ -1661,10 +1661,10 @@ discard block |
||
1661 | 1661 | */ |
1662 | 1662 | public function enableBehavior($name) |
1663 | 1663 | { |
1664 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
1664 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
1665 | 1665 | if($this->_m[$name] instanceof IBehavior) { |
1666 | 1666 | $this->_m[$name]->setEnabled(true); |
1667 | - $this->dyEnableBehavior($name,$this->_m[$name]); |
|
1667 | + $this->dyEnableBehavior($name, $this->_m[$name]); |
|
1668 | 1668 | return true; |
1669 | 1669 | } |
1670 | 1670 | return false; |
@@ -1689,10 +1689,10 @@ discard block |
||
1689 | 1689 | */ |
1690 | 1690 | public function disableBehavior($name) |
1691 | 1691 | { |
1692 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
1692 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
1693 | 1693 | if($this->_m[$name] instanceof IBehavior) { |
1694 | 1694 | $this->_m[$name]->setEnabled(false); |
1695 | - $this->dyDisableBehavior($name,$this->_m[$name]); |
|
1695 | + $this->dyDisableBehavior($name, $this->_m[$name]); |
|
1696 | 1696 | return true; |
1697 | 1697 | } |
1698 | 1698 | return false; |
@@ -1707,9 +1707,9 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | public function __sleep() |
1709 | 1709 | { |
1710 | - $a = (array)$this; |
|
1711 | - $a = array_keys($a); |
|
1712 | - $exprops = array(); |
|
1710 | + $a=(array) $this; |
|
1711 | + $a=array_keys($a); |
|
1712 | + $exprops=array(); |
|
1713 | 1713 | $this->_getZappableSleepProps($exprops); |
1714 | 1714 | return array_diff($a, $exprops); |
1715 | 1715 | } |
@@ -1723,13 +1723,13 @@ discard block |
||
1723 | 1723 | protected function _getZappableSleepProps(&$exprops) |
1724 | 1724 | { |
1725 | 1725 | if($this->_listeningenabled===false) |
1726 | - $exprops[] = "\0TComponent\0_listeningenabled"; |
|
1726 | + $exprops[]="\0TComponent\0_listeningenabled"; |
|
1727 | 1727 | if($this->_behaviorsenabled===true) |
1728 | - $exprops[] = "\0TComponent\0_behaviorsenabled"; |
|
1729 | - if ($this->_e===array()) |
|
1730 | - $exprops[] = "\0TComponent\0_e"; |
|
1731 | - if ($this->_m===null) |
|
1732 | - $exprops[] = "\0TComponent\0_m"; |
|
1728 | + $exprops[]="\0TComponent\0_behaviorsenabled"; |
|
1729 | + if($this->_e===array()) |
|
1730 | + $exprops[]="\0TComponent\0_e"; |
|
1731 | + if($this->_m===null) |
|
1732 | + $exprops[]="\0TComponent\0_m"; |
|
1733 | 1733 | } |
1734 | 1734 | } |
1735 | 1735 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | */ |
1746 | 1746 | interface IDynamicMethods |
1747 | 1747 | { |
1748 | - public function __dycall($method,$args); |
|
1748 | + public function __dycall($method, $args); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | * @param string $name the name of the behavior |
1773 | 1773 | * @param object $behavior this is the behavior to implement the class behavior |
1774 | 1774 | */ |
1775 | - public function __construct($class,$name,$behavior,$priority) |
|
1775 | + public function __construct($class, $name, $behavior, $priority) |
|
1776 | 1776 | { |
1777 | 1777 | $this->_class=$class; |
1778 | 1778 | $this->_name=$name; |
@@ -1913,10 +1913,10 @@ discard block |
||
1913 | 1913 | */ |
1914 | 1914 | public static function ensureBoolean($value) |
1915 | 1915 | { |
1916 | - if (is_string($value)) |
|
1917 | - return strcasecmp($value,'true')==0 || $value!=0; |
|
1916 | + if(is_string($value)) |
|
1917 | + return strcasecmp($value, 'true')==0 || $value!=0; |
|
1918 | 1918 | else |
1919 | - return (boolean)$value; |
|
1919 | + return (boolean) $value; |
|
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | /** |
@@ -1928,12 +1928,12 @@ discard block |
||
1928 | 1928 | */ |
1929 | 1929 | public static function ensureString($value) |
1930 | 1930 | { |
1931 | - if (TJavaScript::isJsLiteral($value)) |
|
1931 | + if(TJavaScript::isJsLiteral($value)) |
|
1932 | 1932 | return $value; |
1933 | - if (is_bool($value)) |
|
1934 | - return $value?'true':'false'; |
|
1933 | + if(is_bool($value)) |
|
1934 | + return $value ? 'true' : 'false'; |
|
1935 | 1935 | else |
1936 | - return (string)$value; |
|
1936 | + return (string) $value; |
|
1937 | 1937 | } |
1938 | 1938 | |
1939 | 1939 | /** |
@@ -1943,7 +1943,7 @@ discard block |
||
1943 | 1943 | */ |
1944 | 1944 | public static function ensureInteger($value) |
1945 | 1945 | { |
1946 | - return (integer)$value; |
|
1946 | + return (integer) $value; |
|
1947 | 1947 | } |
1948 | 1948 | |
1949 | 1949 | /** |
@@ -1953,7 +1953,7 @@ discard block |
||
1953 | 1953 | */ |
1954 | 1954 | public static function ensureFloat($value) |
1955 | 1955 | { |
1956 | - return (float)$value; |
|
1956 | + return (float) $value; |
|
1957 | 1957 | } |
1958 | 1958 | |
1959 | 1959 | /** |
@@ -1969,18 +1969,18 @@ discard block |
||
1969 | 1969 | { |
1970 | 1970 | if(is_string($value)) |
1971 | 1971 | { |
1972 | - $value = trim($value); |
|
1973 | - $len = strlen($value); |
|
1974 | - if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')') |
|
1972 | + $value=trim($value); |
|
1973 | + $len=strlen($value); |
|
1974 | + if($len >= 2 && $value[0]=='(' && $value[$len - 1]==')') |
|
1975 | 1975 | { |
1976 | 1976 | eval('$array=array'.$value.';'); |
1977 | 1977 | return $array; |
1978 | 1978 | } |
1979 | 1979 | else |
1980 | - return $len>0?array($value):array(); |
|
1980 | + return $len > 0 ? array($value) : array(); |
|
1981 | 1981 | } |
1982 | 1982 | else |
1983 | - return (array)$value; |
|
1983 | + return (array) $value; |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | /** |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | */ |
1991 | 1991 | public static function ensureObject($value) |
1992 | 1992 | { |
1993 | - return (object)$value; |
|
1993 | + return (object) $value; |
|
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | /** |
@@ -2009,7 +2009,7 @@ discard block |
||
2009 | 2009 | * @return string the valid enumeration value |
2010 | 2010 | * @throws TInvalidDataValueException if the original value is not in the string array. |
2011 | 2011 | */ |
2012 | - public static function ensureEnum($value,$enums) |
|
2012 | + public static function ensureEnum($value, $enums) |
|
2013 | 2013 | { |
2014 | 2014 | static $types=array(); |
2015 | 2015 | if(func_num_args()===2 && is_string($enums)) |
@@ -2020,18 +2020,18 @@ discard block |
||
2020 | 2020 | return $value; |
2021 | 2021 | else |
2022 | 2022 | throw new TInvalidDataValueException( |
2023 | - 'propertyvalue_enumvalue_invalid',$value, |
|
2024 | - implode(' | ',$types[$enums]->getConstants())); |
|
2023 | + 'propertyvalue_enumvalue_invalid', $value, |
|
2024 | + implode(' | ', $types[$enums]->getConstants())); |
|
2025 | 2025 | } |
2026 | 2026 | else if(!is_array($enums)) |
2027 | 2027 | { |
2028 | 2028 | $enums=func_get_args(); |
2029 | 2029 | array_shift($enums); |
2030 | 2030 | } |
2031 | - if(in_array($value,$enums,true)) |
|
2031 | + if(in_array($value, $enums, true)) |
|
2032 | 2032 | return $value; |
2033 | 2033 | else |
2034 | - throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums)); |
|
2034 | + throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid', $value, implode(' | ', $enums)); |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | /** |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | */ |
2042 | 2042 | public static function ensureNullIfEmpty($value) |
2043 | 2043 | { |
2044 | - return empty($value)?null:$value; |
|
2044 | + return empty($value) ? null : $value; |
|
2045 | 2045 | } |
2046 | 2046 | } |
2047 | 2047 | |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | */ |
2095 | 2095 | public function __construct($component) |
2096 | 2096 | { |
2097 | - if(is_string($component) && class_exists($component,false)) |
|
2097 | + if(is_string($component) && class_exists($component, false)) |
|
2098 | 2098 | $this->_className=$component; |
2099 | 2099 | else if(is_object($component)) |
2100 | 2100 | $this->_className=get_class($component); |
@@ -2107,14 +2107,14 @@ discard block |
||
2107 | 2107 | { |
2108 | 2108 | $methodName=$method->getName(); |
2109 | 2109 | return $method->getNumberOfRequiredParameters()===0 |
2110 | - && strncasecmp($methodName,'get',3)===0 |
|
2110 | + && strncasecmp($methodName, 'get', 3)===0 |
|
2111 | 2111 | && isset($methodName[3]); |
2112 | 2112 | } |
2113 | 2113 | |
2114 | 2114 | private function isEventMethod($method) |
2115 | 2115 | { |
2116 | 2116 | $methodName=$method->getName(); |
2117 | - return strncasecmp($methodName,'on',2)===0 |
|
2117 | + return strncasecmp($methodName, 'on', 2)===0 |
|
2118 | 2118 | && isset($methodName[2]); |
2119 | 2119 | } |
2120 | 2120 | |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | $properties=array(); |
2125 | 2125 | $events=array(); |
2126 | 2126 | $methods=array(); |
2127 | - $isComponent=is_subclass_of($this->_className,'TComponent') || strcasecmp($this->_className,'TComponent')===0; |
|
2127 | + $isComponent=is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent')===0; |
|
2128 | 2128 | foreach($class->getMethods() as $method) |
2129 | 2129 | { |
2130 | 2130 | if($method->isPublic() || $method->isProtected()) |
@@ -2133,14 +2133,14 @@ discard block |
||
2133 | 2133 | if(!$method->isStatic() && $isComponent) |
2134 | 2134 | { |
2135 | 2135 | if($this->isPropertyMethod($method)) |
2136 | - $properties[substr($methodName,3)]=$method; |
|
2136 | + $properties[substr($methodName, 3)]=$method; |
|
2137 | 2137 | else if($this->isEventMethod($method)) |
2138 | 2138 | { |
2139 | 2139 | $methodName[0]='O'; |
2140 | 2140 | $events[$methodName]=$method; |
2141 | 2141 | } |
2142 | 2142 | } |
2143 | - if(strncmp($methodName,'__',2)!==0) |
|
2143 | + if(strncmp($methodName, '__', 2)!==0) |
|
2144 | 2144 | $methods[$methodName]=$method; |
2145 | 2145 | } |
2146 | 2146 | } |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | protected function determinePropertyType($method) |
2191 | 2191 | { |
2192 | 2192 | $comment=$method->getDocComment(); |
2193 | - if(preg_match('/@return\\s+(.*?)\\s+/',$comment,$matches)) |
|
2193 | + if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches)) |
|
2194 | 2194 | return $matches[1]; |
2195 | 2195 | else |
2196 | 2196 | return '{unknown}'; |
@@ -2348,7 +2348,7 @@ discard block |
||
2348 | 2348 | * @return boolean|null if the this or the instance is of type class. When null, no information could be derived and |
2349 | 2349 | * the default mechanisms take over. |
2350 | 2350 | */ |
2351 | - public function isinstanceof($class,$instance=null); |
|
2351 | + public function isinstanceof($class, $instance=null); |
|
2352 | 2352 | } |
2353 | 2353 | |
2354 | 2354 | /** |
@@ -2378,12 +2378,12 @@ discard block |
||
2378 | 2378 | |
2379 | 2379 | public function __construct($s) |
2380 | 2380 | { |
2381 | - $this->_s = $s; |
|
2381 | + $this->_s=$s; |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | public function __toString() |
2385 | 2385 | { |
2386 | - return (string)$this->_s; |
|
2386 | + return (string) $this->_s; |
|
2387 | 2387 | } |
2388 | 2388 | |
2389 | 2389 | public function toJavaScriptLiteral() |
@@ -2403,7 +2403,7 @@ discard block |
||
2403 | 2403 | { |
2404 | 2404 | public function toJavaScriptLiteral() |
2405 | 2405 | { |
2406 | - return TJavaScript::jsonEncode((string)$this->_s,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2406 | + return TJavaScript::jsonEncode((string) $this->_s, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2407 | 2407 | } |
2408 | 2408 | } |
2409 | 2409 |