@@ -310,7 +310,7 @@ |
||
310 | 310 | { |
311 | 311 | $source = $this->getSourceRecord(); |
312 | 312 | $builder = $this->getAssociationTableCommandBuilder(); |
313 | - for($i = 0;$i < $total;$i++) |
|
313 | + for($i = 0; $i < $total; $i++) |
|
314 | 314 | $success = $fkObjects[$i]->save() && $success; |
315 | 315 | return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success; |
316 | 316 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | get_class($record), self::TABLE_CONST); |
81 | 81 | return $value; |
82 | 82 | } |
83 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
83 | + elseif($class->hasMethod(self::TABLE_METHOD)) |
|
84 | 84 | { |
85 | 85 | $value = $record->{self::TABLE_METHOD}(); |
86 | 86 | if(empty($value)) |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | else |
362 | 362 | $values[$name] = $value; |
363 | 363 | } |
364 | - return [$values,$primary]; |
|
364 | + return [$values, $primary]; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo = false) |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | { |
248 | 248 | foreach($config['urls'] as $url) |
249 | 249 | { |
250 | - $class = isset($url['class'])?$url['class']:$defaultClass; |
|
251 | - $properties = isset($url['properties'])?$url['properties']:[]; |
|
250 | + $class = isset($url['class']) ? $url['class'] : $defaultClass; |
|
251 | + $properties = isset($url['properties']) ? $url['properties'] : []; |
|
252 | 252 | $this->buildUrlMapping($class, $properties, $url); |
253 | 253 | } |
254 | 254 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | if(is_string($key)) |
320 | 320 | $params[$key] = $value; |
321 | 321 | } |
322 | - if (!$pattern->getIsWildCardPattern()) |
|
322 | + if(!$pattern->getIsWildCardPattern()) |
|
323 | 323 | $params[$pattern->getServiceID()] = $pattern->getServiceParameter(); |
324 | 324 | return $params; |
325 | 325 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | if(is_string($value)) |
145 | 145 | return self::quoteString($value); |
146 | 146 | elseif(is_bool($value)) |
147 | - return $value?'true':'false'; |
|
147 | + return $value ? 'true' : 'false'; |
|
148 | 148 | elseif(is_array($value)) |
149 | 149 | { |
150 | 150 | $results = ''; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | elseif(is_object($value)) |
200 | - if ($value instanceof TJavaScriptLiteral) |
|
200 | + if($value instanceof TJavaScriptLiteral) |
|
201 | 201 | return $value->toJavaScriptLiteral(); |
202 | 202 | else |
203 | 203 | return self::encode(get_object_vars($value), $toMap); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public static function jsonEncode($value, $options = 0) |
216 | 216 | { |
217 | - if (($g = Prado::getApplication()->getGlobalization(false)) !== null && |
|
217 | + if(($g = Prado::getApplication()->getGlobalization(false)) !== null && |
|
218 | 218 | strtoupper($enc = $g->getCharset()) != 'UTF-8') { |
219 | 219 | self::convertToUtf8($value, $enc); |
220 | 220 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | private static function convertToUtf8(&$value, $sourceEncoding) { |
233 | 233 | if(is_string($value)) |
234 | 234 | $value = iconv($sourceEncoding, 'UTF-8', $value); |
235 | - elseif (is_array($value)) |
|
235 | + elseif(is_array($value)) |
|
236 | 236 | { |
237 | 237 | foreach($value as &$element) |
238 | 238 | self::convertToUtf8($element, $sourceEncoding); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | private static function checkJsonError() |
258 | 258 | { |
259 | - switch ($err = json_last_error()) |
|
259 | + switch($err = json_last_error()) |
|
260 | 260 | { |
261 | 261 | case JSON_ERROR_NONE: |
262 | 262 | return; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function setCacheControl($value) |
205 | 205 | { |
206 | - session_cache_limiter(TPropertyValue::ensureEnum($value, ['none','nocache','private','private_no_expire','public'])); |
|
206 | + session_cache_limiter(TPropertyValue::ensureEnum($value, ['none', 'nocache', 'private', 'private_no_expire', 'public'])); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function setContentType($type) |
213 | 213 | { |
214 | - if ($this->_contentTypeHeaderSent) |
|
214 | + if($this->_contentTypeHeaderSent) |
|
215 | 215 | throw new \Exception('Unable to alter content-type as it has been already sent'); |
216 | 216 | $this->_contentType = $type; |
217 | 217 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function setCharset($charset) |
239 | 239 | { |
240 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
240 | + $this->_charset = (strToLower($charset) === 'false') ? false : (string) $charset; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function setStatusCode($status, $reason = null) |
280 | 280 | { |
281 | - if ($this->_httpHeaderSent) |
|
281 | + if($this->_httpHeaderSent) |
|
282 | 282 | throw new \Exception('Unable to alter response as HTTP header already sent'); |
283 | 283 | $status = TPropertyValue::ensureInteger($status); |
284 | 284 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
285 | 285 | $this->_reason = self::$HTTP_STATUS_CODES[$status]; |
286 | - }else{ |
|
286 | + } else { |
|
287 | 287 | if($reason === null || $reason === '') { |
288 | 288 | throw new TInvalidDataValueException("response_status_reason_missing"); |
289 | 289 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function write($str) |
322 | 322 | { |
323 | 323 | // when starting output make sure we send the headers first |
324 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
324 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
325 | 325 | $this->ensureHeadersSent(); |
326 | 326 | echo $str; |
327 | 327 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $clientFileName = basename($clientFileName); |
373 | 373 | |
374 | 374 | if($fileSize === null || $fileSize < 0) |
375 | - $fileSize = ($content === null?filesize($fileName):strlen($content)); |
|
375 | + $fileSize = ($content === null ?filesize($fileName) : strlen($content)); |
|
376 | 376 | |
377 | 377 | $this->sendHttpHeader(); |
378 | 378 | if(is_array($headers)) |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); |
434 | 434 | if($url[0] === '/') |
435 | 435 | $url = $this->getRequest()->getBaseUrl() . $url; |
436 | - if ($this->_status >= 300 && $this->_status < 400) |
|
436 | + if($this->_status >= 300 && $this->_status < 400) |
|
437 | 437 | { |
438 | 438 | // The status code has been modified to a valid redirection status, send it |
439 | 439 | if($isIIS) |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | if($this->_bufferOutput) |
500 | 500 | { |
501 | 501 | // avoid forced send of http headers (ob_flush() does that) if there's no output yet |
502 | - if (ob_get_length() > 0) |
|
502 | + if(ob_get_length() > 0) |
|
503 | 503 | { |
504 | - if (!$continueBuffering) |
|
504 | + if(!$continueBuffering) |
|
505 | 505 | { |
506 | 506 | $this->_bufferOutput = false; |
507 | 507 | ob_end_flush(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | */ |
521 | 521 | protected function ensureHttpHeaderSent() |
522 | 522 | { |
523 | - if (!$this->_httpHeaderSent) |
|
523 | + if(!$this->_httpHeaderSent) |
|
524 | 524 | $this->sendHttpHeader(); |
525 | 525 | } |
526 | 526 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | */ |
544 | 544 | protected function ensureContentTypeHeaderSent() |
545 | 545 | { |
546 | - if (!$this->_contentTypeHeaderSent) |
|
546 | + if(!$this->_contentTypeHeaderSent) |
|
547 | 547 | $this->sendContentTypeHeader(); |
548 | 548 | } |
549 | 549 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | */ |
553 | 553 | protected function sendContentTypeHeader() |
554 | 554 | { |
555 | - $contentType = $this->_contentType === null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
555 | + $contentType = $this->_contentType === null ?self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
556 | 556 | $charset = $this->getCharset(); |
557 | 557 | if($charset === false) { |
558 | 558 | $this->appendHeader('Content-Type: ' . $contentType); |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | public function getContents() |
578 | 578 | { |
579 | 579 | Prado::trace("Retrieving output", 'Prado\Web\THttpResponse'); |
580 | - return $this->_bufferOutput?ob_get_contents():''; |
|
580 | + return $this->_bufferOutput ?ob_get_contents() : ''; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -100,7 +100,7 @@ |
||
100 | 100 | */ |
101 | 101 | public function _read($id) |
102 | 102 | { |
103 | - return (string)$this->_cache->get($this->calculateKey($id)); |
|
103 | + return (string) $this->_cache->get($this->calculateKey($id)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if(isset($_SERVER['REQUEST_URI'])) |
181 | 181 | $this->_requestUri = $_SERVER['REQUEST_URI']; |
182 | 182 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
183 | - $this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING'])?'':'?' . $_SERVER['QUERY_STRING']); |
|
183 | + $this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']); |
|
184 | 184 | |
185 | 185 | if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
186 | 186 | $this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function stripSlashes(&$data) |
216 | 216 | { |
217 | - return is_array($data)?array_map([$this,'stripSlashes'], $data):stripslashes($data); |
|
217 | + return is_array($data) ?array_map([$this, 'stripSlashes'], $data) : stripslashes($data); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | if($this->_url === null) |
226 | 226 | { |
227 | 227 | $secure = $this->getIsSecureConnection(); |
228 | - $url = $secure?'https://':'http://'; |
|
228 | + $url = $secure ? 'https://' : 'http://'; |
|
229 | 229 | if(empty($_SERVER['HTTP_HOST'])) |
230 | 230 | { |
231 | 231 | $url .= $_SERVER['SERVER_NAME']; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | { |
278 | 278 | $dependencies = null; |
279 | 279 | if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
280 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
280 | + if($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
281 | 281 | { |
282 | 282 | $fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
283 | 283 | $dependencies = new TFileCacheDependency($fn); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function getRequestType() |
404 | 404 | { |
405 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
405 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getQueryString() |
443 | 443 | { |
444 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
444 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function getHttpProtocolVersion() |
451 | 451 | { |
452 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
452 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -496,9 +496,9 @@ discard block |
||
496 | 496 | public function getBaseUrl($forceSecureConnection = null) |
497 | 497 | { |
498 | 498 | $url = $this->getUrl(); |
499 | - $scheme = ($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
499 | + $scheme = ($forceSecureConnection) ? "https" : (($forceSecureConnection === null) ? $url->getScheme() : 'http'); |
|
500 | 500 | $host = $url->getHost(); |
501 | - if (($port = $url->getPort())) $host .= ':' . $port; |
|
501 | + if(($port = $url->getPort())) $host .= ':' . $port; |
|
502 | 502 | return $scheme . '://' . $host; |
503 | 503 | } |
504 | 504 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
511 | 511 | return $_SERVER['ORIG_SCRIPT_NAME']; |
512 | 512 | |
513 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
513 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getApplicationFilePath() |
532 | 532 | { |
533 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
533 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function getServerName() |
540 | 540 | { |
541 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
541 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public function getServerPort() |
548 | 548 | { |
549 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
549 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | public function getUrlReferrer() |
556 | 556 | { |
557 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
557 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | */ |
564 | 564 | public function getServerSoftware() |
565 | 565 | { |
566 | - return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; |
|
566 | + return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | { |
577 | 577 | return get_browser(); |
578 | 578 | } |
579 | - catch(TPhpErrorException $e) |
|
579 | + catch (TPhpErrorException $e) |
|
580 | 580 | { |
581 | 581 | throw new TConfigurationException('httprequest_browscap_required'); |
582 | 582 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function getUserAgent() |
589 | 589 | { |
590 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
590 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function getUserHostAddress() |
597 | 597 | { |
598 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
598 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | */ |
604 | 604 | public function getUserHost() |
605 | 605 | { |
606 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
606 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | public function getAcceptTypes() |
613 | 613 | { |
614 | 614 | // TBD: break it into array?? |
615 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
615 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -732,11 +732,11 @@ discard block |
||
732 | 732 | */ |
733 | 733 | public function constructUrl($serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true) |
734 | 734 | { |
735 | - if ($this->_cookieOnly === null) |
|
736 | - $this->_cookieOnly = (int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
735 | + if($this->_cookieOnly === null) |
|
736 | + $this->_cookieOnly = (int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
737 | 737 | $url = $this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
738 | 738 | if(defined('SID') && SID != '' && !$this->_cookieOnly) |
739 | - return $url . (strpos($url, '?') === false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
739 | + return $url . (strpos($url, '?') === false ? '?' : ($encodeAmpersand ? '&' : '&')) . SID; |
|
740 | 740 | else |
741 | 741 | return $url; |
742 | 742 | } |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | protected function configureEvent($control, $name, $value, $contextControl) |
338 | 338 | { |
339 | 339 | if(strpos($value, '.') === false) |
340 | - $control->attachEventHandler($name, [$contextControl,'TemplateControl.' . $value]); |
|
340 | + $control->attachEventHandler($name, [$contextControl, 'TemplateControl.' . $value]); |
|
341 | 341 | else |
342 | - $control->attachEventHandler($name, [$contextControl,$value]); |
|
342 | + $control->attachEventHandler($name, [$contextControl, $value]); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | } |
391 | 391 | else |
392 | 392 | { |
393 | - if (substr($name, 0, 2) == 'js') |
|
394 | - if ($value and !($value instanceof TJavaScriptLiteral)) |
|
393 | + if(substr($name, 0, 2) == 'js') |
|
394 | + if($value and !($value instanceof TJavaScriptLiteral)) |
|
395 | 395 | $value = new TJavaScriptLiteral($value); |
396 | 396 | $setter = 'set' . $name; |
397 | 397 | $component->$setter($value); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $this->_directive = null; |
477 | 477 | try |
478 | 478 | { |
479 | - for($i = 0;$i < $n;++$i) |
|
479 | + for($i = 0; $i < $n; ++$i) |
|
480 | 480 | { |
481 | 481 | $match = &$matches[$i]; |
482 | 482 | $str = $match[0][0]; |
@@ -487,12 +487,12 @@ discard block |
||
487 | 487 | if($expectPropEnd) |
488 | 488 | continue; |
489 | 489 | if($matchStart > $textStart) |
490 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
490 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
491 | 491 | $textStart = $matchEnd + 1; |
492 | 492 | $type = $match[1][0]; |
493 | 493 | $attributes = $this->parseAttributes($match[2][0], $match[2][1]); |
494 | 494 | $class = $this->validateAttributes($type, $attributes); |
495 | - $tpl[$c++] = [$container,$class,$attributes]; |
|
495 | + $tpl[$c++] = [$container, $class, $attributes]; |
|
496 | 496 | if($str[strlen($str) - 2] !== '/') // open tag |
497 | 497 | { |
498 | 498 | $stack[] = $type; |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | if($expectPropEnd) |
505 | 505 | continue; |
506 | 506 | if($matchStart > $textStart) |
507 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
507 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
508 | 508 | $textStart = $matchEnd + 1; |
509 | 509 | $type = $match[1][0]; |
510 | 510 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | if($expectPropEnd) |
525 | 525 | continue; |
526 | 526 | if($matchStart > $textStart) |
527 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
527 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
528 | 528 | $textStart = $matchEnd + 1; |
529 | 529 | if(isset($tpl[0]) || $this->_directive !== null) |
530 | 530 | throw new TConfigurationException('template_directive_nonunique'); |
@@ -535,25 +535,25 @@ discard block |
||
535 | 535 | if($expectPropEnd) |
536 | 536 | continue; |
537 | 537 | if($matchStart > $textStart) |
538 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
538 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
539 | 539 | $textStart = $matchEnd + 1; |
540 | 540 | $literal = trim($match[5][0]); |
541 | 541 | if($str[2] === '=') // expression |
542 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,$literal]]; |
|
542 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, $literal]]; |
|
543 | 543 | elseif($str[2] === '%') // statements |
544 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_STATEMENTS,$literal]]; |
|
544 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_STATEMENTS, $literal]]; |
|
545 | 545 | elseif($str[2] === '#') |
546 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_DATABINDING,$literal]]; |
|
546 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_DATABINDING, $literal]]; |
|
547 | 547 | elseif($str[2] === '$') |
548 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"]]; |
|
548 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')"]]; |
|
549 | 549 | elseif($str[2] === '~') |
550 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"]]; |
|
550 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')"]]; |
|
551 | 551 | elseif($str[2] === '/') |
552 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]]; |
|
552 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]]; |
|
553 | 553 | elseif($str[2] === '[') |
554 | 554 | { |
555 | - $literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), ["'" => "\'","\\" => "\\\\"]); |
|
556 | - $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"]]; |
|
555 | + $literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), ["'" => "\'", "\\" => "\\\\"]); |
|
556 | + $tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')"]]; |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | elseif(strpos($str, '<prop:') === 0) // opening property |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | if($expectPropEnd) |
564 | 564 | continue; |
565 | 565 | if($matchStart > $textStart) |
566 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
566 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
567 | 567 | $textStart = $matchEnd + 1; |
568 | 568 | $prop = strtolower($match[6][0]); |
569 | 569 | $attrs = $this->parseAttributes($match[7][0], $match[7][1]); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | if(!$expectPropEnd) |
587 | 587 | { |
588 | 588 | if($matchStart > $textStart) |
589 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
589 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
590 | 590 | $textStart = $matchEnd + 1; |
591 | 591 | $expectPropEnd = true; |
592 | 592 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | if($expectPropEnd) |
633 | 633 | throw new TConfigurationException('template_comments_forbidden'); |
634 | 634 | if($matchStart > $textStart) |
635 | - $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
|
635 | + $tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)]; |
|
636 | 636 | $textStart = $matchEnd + 1; |
637 | 637 | } |
638 | 638 | else |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | throw new TConfigurationException('template_closingtag_expected', $tag, "nothing"); |
646 | 646 | } |
647 | 647 | if($textStart < strlen($input)) |
648 | - $tpl[$c++] = [$container,substr($input, $textStart)]; |
|
648 | + $tpl[$c++] = [$container, substr($input, $textStart)]; |
|
649 | 649 | } |
650 | - catch(\Exception $e) |
|
650 | + catch (\Exception $e) |
|
651 | 651 | { |
652 | 652 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
653 | 653 | throw $e; |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | if($parent !== null) |
673 | 673 | { |
674 | 674 | if(count($merged[1]) === 1 && is_string($merged[1][0])) |
675 | - $objects[$id - 1] = [$merged[0],$merged[1][0]]; |
|
675 | + $objects[$id - 1] = [$merged[0], $merged[1][0]]; |
|
676 | 676 | else |
677 | - $objects[$id - 1] = [$merged[0],new TCompositeLiteral($merged[1])]; |
|
677 | + $objects[$id - 1] = [$merged[0], new TCompositeLiteral($merged[1])]; |
|
678 | 678 | } |
679 | 679 | if(isset($object[2])) |
680 | 680 | { |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | else |
685 | 685 | { |
686 | 686 | $parent = $object[0]; |
687 | - $merged = [$parent,[$object[1]]]; |
|
687 | + $merged = [$parent, [$object[1]]]; |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | else |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | if($parent !== null) |
694 | 694 | { |
695 | 695 | if(count($merged[1]) === 1 && is_string($merged[1][0])) |
696 | - $objects[$id] = [$merged[0],$merged[1][0]]; |
|
696 | + $objects[$id] = [$merged[0], $merged[1][0]]; |
|
697 | 697 | else |
698 | - $objects[$id] = [$merged[0],new TCompositeLiteral($merged[1])]; |
|
698 | + $objects[$id] = [$merged[0], new TCompositeLiteral($merged[1])]; |
|
699 | 699 | } |
700 | 700 | $tpl = $objects; |
701 | 701 | return $objects; |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | $pattern = '/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
714 | 714 | $attributes = []; |
715 | 715 | $n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
716 | - for($i = 0;$i < $n;++$i) |
|
716 | + for($i = 0; $i < $n; ++$i) |
|
717 | 717 | { |
718 | 718 | $match = &$matches[$i]; |
719 | 719 | $name = strtolower($match[1][0]); |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | protected function parseTemplateProperty($content, $offset) |
742 | 742 | { |
743 | 743 | $line = $this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1; |
744 | - return [self::CONFIG_TEMPLATE,new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)]; |
|
744 | + return [self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)]; |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | $isDataBind = false; |
757 | 757 | $textStart = 0; |
758 | 758 | $expr = ''; |
759 | - for($i = 0;$i < $n;++$i) |
|
759 | + for($i = 0; $i < $n; ++$i) |
|
760 | 760 | { |
761 | 761 | $match = $matches[0][$i]; |
762 | 762 | $token = $match[0]; |
@@ -765,30 +765,30 @@ discard block |
||
765 | 765 | if($token[2] === '#') |
766 | 766 | $isDataBind = true; |
767 | 767 | if($offset > $textStart) |
768 | - $expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'"; |
|
768 | + $expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), ["'" => "\\'", "\\" => "\\\\"]) . "'"; |
|
769 | 769 | $expr .= '.(' . substr($token, 3, $length - 5) . ')'; |
770 | 770 | $textStart = $offset + $length; |
771 | 771 | } |
772 | 772 | $length = strlen($value); |
773 | 773 | if($length > $textStart) |
774 | - $expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'"; |
|
774 | + $expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), ["'" => "\\'", "\\" => "\\\\"]) . "'"; |
|
775 | 775 | if($isDataBind) |
776 | - return [self::CONFIG_DATABIND,ltrim($expr, '.')]; |
|
776 | + return [self::CONFIG_DATABIND, ltrim($expr, '.')]; |
|
777 | 777 | else |
778 | - return [self::CONFIG_EXPRESSION,ltrim($expr, '.')]; |
|
778 | + return [self::CONFIG_EXPRESSION, ltrim($expr, '.')]; |
|
779 | 779 | } |
780 | 780 | elseif(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value) |
781 | 781 | { |
782 | 782 | $value = $matches[1]; |
783 | 783 | if($value[2] === '~') |
784 | - return [self::CONFIG_ASSET,trim(substr($value, 3, strlen($value) - 5))]; |
|
784 | + return [self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))]; |
|
785 | 785 | elseif($value[2] === '[') |
786 | - return [self::CONFIG_LOCALIZATION,trim(substr($value, 3, strlen($value) - 6))]; |
|
786 | + return [self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))]; |
|
787 | 787 | elseif($value[2] === '$') |
788 | - return [self::CONFIG_PARAMETER,trim(substr($value, 3, strlen($value) - 5))]; |
|
788 | + return [self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))]; |
|
789 | 789 | elseif($value[2] === '/') { |
790 | 790 | $literal = trim(substr($value, 3, strlen($value) - 5)); |
791 | - return [self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]; |
|
791 | + return [self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]; |
|
792 | 792 | } |
793 | 793 | } |
794 | 794 | else |
@@ -825,9 +825,9 @@ discard block |
||
825 | 825 | else |
826 | 826 | { |
827 | 827 | // a simple property |
828 | - if (! ($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name))) |
|
828 | + if(!($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name))) |
|
829 | 829 | { |
830 | - if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name)) |
|
830 | + if($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name)) |
|
831 | 831 | throw new TConfigurationException('template_property_readonly', $type, $name); |
832 | 832 | else |
833 | 833 | throw new TConfigurationException('template_property_unknown', $type, $name); |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | |
898 | 898 | if(($n = count($this->_includedFiles)) > 0) // need to adjust error row number and file name |
899 | 899 | { |
900 | - for($i = $n - 1;$i >= 0;--$i) |
|
900 | + for($i = $n - 1; $i >= 0; --$i) |
|
901 | 901 | { |
902 | 902 | if($this->_includeAtLine[$i] <= $line) |
903 | 903 | { |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | { |
931 | 931 | if($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
932 | 932 | { |
933 | - for($i = 0;$i < $n;++$i) |
|
933 | + for($i = 0; $i < $n; ++$i) |
|
934 | 934 | { |
935 | 935 | $filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT); |
936 | 936 | if($filePath !== null && is_file($filePath)) |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | } |
943 | 943 | } |
944 | 944 | $base = 0; |
945 | - for($i = 0;$i < $n;++$i) |
|
945 | + for($i = 0; $i < $n; ++$i) |
|
946 | 946 | { |
947 | 947 | $ext = file_get_contents($this->_includedFiles[$i]); |
948 | 948 | $length = strlen($matches[$i][0][0]); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $timestamps[$fileName] = filemtime($fileName); |
105 | 105 | foreach($includedFiles as $includedFile) |
106 | 106 | $timestamps[$includedFile] = filemtime($includedFile); |
107 | - $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template,$timestamps]); |
|
107 | + $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template, $timestamps]); |
|
108 | 108 | return $template; |
109 | 109 | } |
110 | 110 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | protected function getLocalizedTemplate($filename) |
121 | 121 | { |
122 | 122 | if(($app = $this->getApplication()->getGlobalization(false)) === null) |
123 | - return is_file($filename)?$filename:null; |
|
123 | + return is_file($filename) ? $filename : null; |
|
124 | 124 | foreach($app->getLocalizedResource($filename) as $file) |
125 | 125 | { |
126 | 126 | if(($file = realpath($file)) !== false && is_file($file)) |