@@ -35,6 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * Returns a user instance according to auth data stored in a cookie. |
| 37 | 37 | * @param THttpCookie the cookie storing user authentication information |
| 38 | + * @param THttpCookie $cookie |
|
| 38 | 39 | * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data. |
| 39 | 40 | * @since 3.1.1 |
| 40 | 41 | */ |
@@ -42,7 +43,9 @@ discard block |
||
| 42 | 43 | /** |
| 43 | 44 | * Saves user auth data into a cookie. |
| 44 | 45 | * @param THttpCookie the cookie to receive the user auth data. |
| 46 | + * @param THttpCookie $cookie |
|
| 45 | 47 | * @since 3.1.1 |
| 48 | + * @return void |
|
| 46 | 49 | */ |
| 47 | 50 | public function saveUserToCookie($cookie); |
| 48 | 51 | /** |
@@ -51,6 +51,6 @@ |
||
| 51 | 51 | * @param string password |
| 52 | 52 | * @return boolean true if validation is successful, false otherwise. |
| 53 | 53 | */ |
| 54 | - public function validateUser($username,$password); |
|
| 54 | + public function validateUser($username, $password); |
|
| 55 | 55 | } |
| 56 | 56 | |
@@ -219,11 +219,17 @@ discard block |
||
| 219 | 219 | return 0; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | + /** |
|
| 223 | + * @param IUser $user |
|
| 224 | + */ |
|
| 222 | 225 | private function isUserMatched($user) |
| 223 | 226 | { |
| 224 | 227 | return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users)); |
| 225 | 228 | } |
| 226 | 229 | |
| 230 | + /** |
|
| 231 | + * @param IUser $user |
|
| 232 | + */ |
|
| 227 | 233 | private function isRoleMatched($user) |
| 228 | 234 | { |
| 229 | 235 | foreach($this->_roles as $role) |
@@ -256,6 +262,9 @@ discard block |
||
| 256 | 262 | * @param IUser the user to be authorized |
| 257 | 263 | * @param string verb, can be empty, 'post' or 'get'. |
| 258 | 264 | * @param string the request IP address |
| 265 | + * @param IUser $user |
|
| 266 | + * @param string $verb |
|
| 267 | + * @param string $ip |
|
| 259 | 268 | * @return boolean whether the user is allowed |
| 260 | 269 | */ |
| 261 | 270 | public function isUserAllowed($user,$verb,$ip) |
@@ -94,8 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $this->_everyone=true; |
| 96 | 96 | break; |
| 97 | - } |
|
| 98 | - else if($user==='?') |
|
| 97 | + } else if($user==='?') |
|
| 99 | 98 | $this->_guest=true; |
| 100 | 99 | else if($user==='@') |
| 101 | 100 | $this->_authenticated=true; |
@@ -269,8 +268,7 @@ discard block |
||
| 269 | 268 | return ($decision>0); |
| 270 | 269 | } |
| 271 | 270 | return true; |
| 272 | - } |
|
| 273 | - else |
|
| 271 | + } else |
|
| 274 | 272 | return false; |
| 275 | 273 | } |
| 276 | 274 | |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | * @param string verb, can be empty, 'get', or 'post' |
| 71 | 71 | * @param string IP rules (separated by comma, can contain wild card *) |
| 72 | 72 | */ |
| 73 | - public function __construct($action,$users,$roles,$verb='',$ipRules='') |
|
| 73 | + public function __construct($action, $users, $roles, $verb='', $ipRules='') |
|
| 74 | 74 | { |
| 75 | 75 | $action=strtolower(trim($action)); |
| 76 | 76 | if($action==='allow' || $action==='deny') |
| 77 | 77 | $this->_action=$action; |
| 78 | 78 | else |
| 79 | - throw new TInvalidDataValueException('authorizationrule_action_invalid',$action); |
|
| 79 | + throw new TInvalidDataValueException('authorizationrule_action_invalid', $action); |
|
| 80 | 80 | $this->_users=array(); |
| 81 | 81 | $this->_roles=array(); |
| 82 | 82 | $this->_ipRules=array(); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | if(trim($users)==='') |
| 88 | 88 | $users='*'; |
| 89 | - foreach(explode(',',$users) as $user) |
|
| 89 | + foreach(explode(',', $users) as $user) |
|
| 90 | 90 | { |
| 91 | 91 | if(($user=trim(strtolower($user)))!=='') |
| 92 | 92 | { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | if(trim($roles)==='') |
| 108 | 108 | $roles='*'; |
| 109 | - foreach(explode(',',$roles) as $role) |
|
| 109 | + foreach(explode(',', $roles) as $role) |
|
| 110 | 110 | { |
| 111 | 111 | if(($role=trim(strtolower($role)))!=='') |
| 112 | 112 | $this->_roles[]=$role; |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | if($verb==='*' || $verb==='get' || $verb==='post') |
| 118 | 118 | $this->_verb=$verb; |
| 119 | 119 | else |
| 120 | - throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb); |
|
| 120 | + throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb); |
|
| 121 | 121 | |
| 122 | 122 | if(trim($ipRules)==='') |
| 123 | 123 | $ipRules='*'; |
| 124 | - foreach(explode(',',$ipRules) as $ipRule) |
|
| 124 | + foreach(explode(',', $ipRules) as $ipRule) |
|
| 125 | 125 | { |
| 126 | 126 | if(($ipRule=trim($ipRule))!=='') |
| 127 | 127 | $this->_ipRules[]=$ipRule; |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param string the request IP address |
| 200 | 200 | * @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user |
| 201 | 201 | */ |
| 202 | - public function isUserAllowed(IUser $user,$verb,$ip) |
|
| 202 | + public function isUserAllowed(IUser $user, $verb, $ip) |
|
| 203 | 203 | { |
| 204 | 204 | if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
| 205 | - return ($this->_action==='allow')?1:-1; |
|
| 205 | + return ($this->_action==='allow') ? 1 : -1; |
|
| 206 | 206 | else |
| 207 | 207 | return 0; |
| 208 | 208 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | return 1; |
| 214 | 214 | foreach($this->_ipRules as $rule) |
| 215 | 215 | { |
| 216 | - if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) |
|
| 216 | + if($rule==='*' || $rule===$ip || (($pos=strpos($rule, '*'))!==false && strncmp($ip, $rule, $pos)===0)) |
|
| 217 | 217 | return 1; |
| 218 | 218 | } |
| 219 | 219 | return 0; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | private function isUserMatched($user) |
| 223 | 223 | { |
| 224 | - return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users)); |
|
| 224 | + return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()), $this->_users)); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | private function isRoleMatched($user) |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | private function isVerbMatched($verb) |
| 238 | 238 | { |
| 239 | - return ($this->_verb==='*' || strcasecmp($verb,$this->_verb)===0); |
|
| 239 | + return ($this->_verb==='*' || strcasecmp($verb, $this->_verb)===0); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | * @param string the request IP address |
| 259 | 259 | * @return boolean whether the user is allowed |
| 260 | 260 | */ |
| 261 | - public function isUserAllowed($user,$verb,$ip) |
|
| 261 | + public function isUserAllowed($user, $verb, $ip) |
|
| 262 | 262 | { |
| 263 | 263 | if($user instanceof IUser) |
| 264 | 264 | { |
| 265 | 265 | $verb=strtolower(trim($verb)); |
| 266 | 266 | foreach($this as $rule) |
| 267 | 267 | { |
| 268 | - if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0) |
|
| 269 | - return ($decision>0); |
|
| 268 | + if(($decision=$rule->isUserAllowed($user, $verb, $ip))!==0) |
|
| 269 | + return ($decision > 0); |
|
| 270 | 270 | } |
| 271 | 271 | return true; |
| 272 | 272 | } |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | * @param mixed new item |
| 283 | 283 | * @throws TInvalidDataTypeException if the item to be inserted is not a TAuthorizationRule object. |
| 284 | 284 | */ |
| 285 | - public function insertAt($index,$item) |
|
| 285 | + public function insertAt($index, $item) |
|
| 286 | 286 | { |
| 287 | 287 | if($item instanceof TAuthorizationRule) |
| 288 | - parent::insertAt($index,$item); |
|
| 288 | + parent::insertAt($index, $item); |
|
| 289 | 289 | else |
| 290 | 290 | throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required'); |
| 291 | 291 | } |
@@ -163,6 +163,7 @@ |
||
| 163 | 163 | /** |
| 164 | 164 | * Creates the DB connection. |
| 165 | 165 | * @param string the module ID for TDataSourceConfig |
| 166 | + * @param string $connectionID |
|
| 166 | 167 | * @return TDbConnection the created DB connection |
| 167 | 168 | * @throws TConfigurationException if module ID is invalid or empty |
| 168 | 169 | */ |
@@ -123,8 +123,7 @@ discard block |
||
| 123 | 123 | $user=Prado::createComponent($this->_userClass,$this); |
| 124 | 124 | $user->setIsGuest(true); |
| 125 | 125 | return $user; |
| 126 | - } |
|
| 127 | - else |
|
| 126 | + } else |
|
| 128 | 127 | return $this->_userFactory->createUser($username); |
| 129 | 128 | } |
| 130 | 129 | |
@@ -175,8 +174,7 @@ discard block |
||
| 175 | 174 | return $conn->getDbConnection(); |
| 176 | 175 | else |
| 177 | 176 | throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID); |
| 178 | - } |
|
| 179 | - else |
|
| 177 | + } else |
|
| 180 | 178 | throw new TConfigurationException('dbusermanager_connectionid_required'); |
| 181 | 179 | } |
| 182 | 180 | |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | if($this->_userClass==='') |
| 65 | 65 | throw new TConfigurationException('dbusermanager_userclass_required'); |
| 66 | - $this->_userFactory=Prado::createComponent($this->_userClass,$this); |
|
| 66 | + $this->_userFactory=Prado::createComponent($this->_userClass, $this); |
|
| 67 | 67 | if(!($this->_userFactory instanceof TDbUser)) |
| 68 | - throw new TInvalidDataTypeException('dbusermanager_userclass_invalid',$this->_userClass); |
|
| 68 | + throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | * @param string password |
| 107 | 107 | * @return boolean true if validation is successful, false otherwise. |
| 108 | 108 | */ |
| 109 | - public function validateUser($username,$password) |
|
| 109 | + public function validateUser($username, $password) |
|
| 110 | 110 | { |
| 111 | - return $this->_userFactory->validateUser($username,$password); |
|
| 111 | + return $this->_userFactory->validateUser($username, $password); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | if($username===null) |
| 122 | 122 | { |
| 123 | - $user=Prado::createComponent($this->_userClass,$this); |
|
| 123 | + $user=Prado::createComponent($this->_userClass, $this); |
|
| 124 | 124 | $user->setIsGuest(true); |
| 125 | 125 | return $user; |
| 126 | 126 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | if($conn instanceof TDataSourceConfig) |
| 175 | 175 | return $conn->getDbConnection(); |
| 176 | 176 | else |
| 177 | - throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID); |
|
| 177 | + throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID); |
|
| 178 | 178 | } |
| 179 | 179 | else |
| 180 | 180 | throw new TConfigurationException('dbusermanager_connectionid_required'); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param string password |
| 256 | 256 | * @return boolean whether the validation succeeds |
| 257 | 257 | */ |
| 258 | - abstract public function validateUser($username,$password); |
|
| 258 | + abstract public function validateUser($username, $password); |
|
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Creates a new user instance given the username. |
@@ -342,6 +342,7 @@ discard block |
||
| 342 | 342 | * to determine the application configuration file, |
| 343 | 343 | * application root path and the runtime path. |
| 344 | 344 | * @param string the application root path or the application configuration file |
| 345 | + * @param string $basePath |
|
| 345 | 346 | * @see setBasePath |
| 346 | 347 | * @see setRuntimePath |
| 347 | 348 | * @see setConfigurationFile |
@@ -440,6 +441,7 @@ discard block |
||
| 440 | 441 | * A global value is one that is persistent across users sessions and requests. |
| 441 | 442 | * @param string the name of the value to be returned |
| 442 | 443 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 444 | + * @param integer $defaultValue |
|
| 443 | 445 | * @return mixed the global value corresponding to $key |
| 444 | 446 | */ |
| 445 | 447 | public function getGlobalState($key,$defaultValue=null) |
@@ -456,6 +458,7 @@ discard block |
||
| 456 | 458 | * @param mixed the global value to be set |
| 457 | 459 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 458 | 460 | * @param boolean wheter to force an immediate GlobalState save. defaults to false |
| 461 | + * @param string $key |
|
| 459 | 462 | */ |
| 460 | 463 | public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
| 461 | 464 | { |
@@ -545,7 +548,7 @@ discard block |
||
| 545 | 548 | } |
| 546 | 549 | |
| 547 | 550 | /** |
| 548 | - * @return TApplicationMode application mode. Defaults to TApplicationMode::Debug. |
|
| 551 | + * @return string application mode. Defaults to TApplicationMode::Debug. |
|
| 549 | 552 | */ |
| 550 | 553 | public function getMode() |
| 551 | 554 | { |
@@ -570,6 +573,7 @@ discard block |
||
| 570 | 573 | |
| 571 | 574 | /** |
| 572 | 575 | * @param string the directory containing the application configuration file |
| 576 | + * @param string $value |
|
| 573 | 577 | */ |
| 574 | 578 | public function setBasePath($value) |
| 575 | 579 | { |
@@ -586,6 +590,7 @@ discard block |
||
| 586 | 590 | |
| 587 | 591 | /** |
| 588 | 592 | * @param string the application configuration file (absolute path) |
| 593 | + * @param string $value |
|
| 589 | 594 | */ |
| 590 | 595 | public function setConfigurationFile($value) |
| 591 | 596 | { |
@@ -602,6 +607,7 @@ discard block |
||
| 602 | 607 | |
| 603 | 608 | /** |
| 604 | 609 | * @param string the application configuration type. 'xml' and 'php' are valid values |
| 610 | + * @param string $value |
|
| 605 | 611 | */ |
| 606 | 612 | public function setConfigurationType($value) |
| 607 | 613 | { |
@@ -657,6 +663,7 @@ discard block |
||
| 657 | 663 | |
| 658 | 664 | /** |
| 659 | 665 | * @param string the directory storing cache data and application-level persistent data. (absolute path) |
| 666 | + * @param string $value |
|
| 660 | 667 | */ |
| 661 | 668 | public function setRuntimePath($value) |
| 662 | 669 | { |
@@ -677,6 +684,7 @@ discard block |
||
| 677 | 684 | |
| 678 | 685 | /** |
| 679 | 686 | * @param IService the currently requested service |
| 687 | + * @param IService $value |
|
| 680 | 688 | */ |
| 681 | 689 | public function setService($value) |
| 682 | 690 | { |
@@ -1126,6 +1134,7 @@ discard block |
||
| 1126 | 1134 | * This method is invoked when an exception is raised during the lifecycles |
| 1127 | 1135 | * of the application. |
| 1128 | 1136 | * @param mixed event parameter |
| 1137 | + * @param Exception $param |
|
| 1129 | 1138 | */ |
| 1130 | 1139 | public function onError($param) |
| 1131 | 1140 | { |
@@ -602,7 +602,7 @@ |
||
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | 604 | * @param string the application configuration type. 'xml' and 'php' are valid values |
| 605 | - */ |
|
| 605 | + */ |
|
| 606 | 606 | public function setConfigurationType($value) |
| 607 | 607 | { |
| 608 | 608 | $this->_configType = $value; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | /** |
| 134 | 134 | * Configuration file type, application.xml and config.xml |
| 135 | 135 | */ |
| 136 | - const CONFIG_TYPE_XML = 'xml'; |
|
| 136 | + const CONFIG_TYPE_XML='xml'; |
|
| 137 | 137 | /** |
| 138 | 138 | * Application configuration file name |
| 139 | 139 | */ |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | /** |
| 146 | 146 | * Configuration file type, application.php and config.php |
| 147 | 147 | */ |
| 148 | - const CONFIG_TYPE_PHP = 'php'; |
|
| 148 | + const CONFIG_TYPE_PHP='php'; |
|
| 149 | 149 | /** |
| 150 | 150 | * Runtime directory name |
| 151 | 151 | */ |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | /** |
| 299 | 299 | * @var string Customizable page service ID |
| 300 | 300 | */ |
| 301 | - private $_pageServiceID = self::PAGE_SERVICE_ID; |
|
| 301 | + private $_pageServiceID=self::PAGE_SERVICE_ID; |
|
| 302 | 302 | |
| 303 | 303 | /** |
| 304 | 304 | * Constructor. |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @param boolean whether to cache application configuration. Defaults to true. |
| 319 | 319 | * @throws TConfigurationException if configuration file cannot be read or the runtime path is invalid. |
| 320 | 320 | */ |
| 321 | - public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
| 321 | + public function __construct($basePath='protected', $cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
| 322 | 322 | { |
| 323 | 323 | // register application as a singleton |
| 324 | 324 | Prado::setApplication($this); |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | // generates unique ID by hashing the runtime path |
| 332 | 332 | $this->_uniqueID=md5($this->_runtimePath); |
| 333 | 333 | $this->_parameters=new TMap; |
| 334 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
| 334 | + $this->_services=array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
| 335 | 335 | |
| 336 | - Prado::setPathOfAlias('Application',$this->_basePath); |
|
| 336 | + Prado::setPathOfAlias('Application', $this->_basePath); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | // determine configuration path and file |
| 352 | 352 | if(empty($basePath) || ($basePath=realpath($basePath))===false) |
| 353 | - throw new TConfigurationException('application_basepath_invalid',$basePath); |
|
| 353 | + throw new TConfigurationException('application_basepath_invalid', $basePath); |
|
| 354 | 354 | if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) |
| 355 | 355 | $configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName(); |
| 356 | 356 | else if(is_file($basePath)) |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if(!is_dir($runtimePath)) |
| 372 | 372 | { |
| 373 | 373 | if(@mkdir($runtimePath)===false) |
| 374 | - throw new TConfigurationException('application_runtimepath_failed',$runtimePath); |
|
| 374 | + throw new TConfigurationException('application_runtimepath_failed', $runtimePath); |
|
| 375 | 375 | @chmod($runtimePath, PRADO_CHMOD); //make it deletable |
| 376 | 376 | } |
| 377 | 377 | $this->setConfigurationFile($configFile); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $this->setRuntimePath($runtimePath); |
| 381 | 381 | } |
| 382 | 382 | else |
| 383 | - throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
|
| 383 | + throw new TConfigurationException('application_runtimepath_invalid', $runtimePath); |
|
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
@@ -397,14 +397,14 @@ discard block |
||
| 397 | 397 | $n=count(self::$_steps); |
| 398 | 398 | $this->_step=0; |
| 399 | 399 | $this->_requestCompleted=false; |
| 400 | - while($this->_step<$n) |
|
| 400 | + while($this->_step < $n) |
|
| 401 | 401 | { |
| 402 | 402 | if($this->_mode===self::STATE_OFF) |
| 403 | - throw new THttpException(503,'application_unavailable'); |
|
| 403 | + throw new THttpException(503, 'application_unavailable'); |
|
| 404 | 404 | if($this->_requestCompleted) |
| 405 | 405 | break; |
| 406 | 406 | $method=self::$_steps[$this->_step]; |
| 407 | - Prado::trace("Executing $method()",'System.TApplication'); |
|
| 407 | + Prado::trace("Executing $method()", 'System.TApplication'); |
|
| 408 | 408 | $this->$method(); |
| 409 | 409 | $this->_step++; |
| 410 | 410 | } |
@@ -442,9 +442,9 @@ discard block |
||
| 442 | 442 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 443 | 443 | * @return mixed the global value corresponding to $key |
| 444 | 444 | */ |
| 445 | - public function getGlobalState($key,$defaultValue=null) |
|
| 445 | + public function getGlobalState($key, $defaultValue=null) |
|
| 446 | 446 | { |
| 447 | - return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
|
| 447 | + return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 458 | 458 | * @param boolean wheter to force an immediate GlobalState save. defaults to false |
| 459 | 459 | */ |
| 460 | - public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false) |
|
| 460 | + public function setGlobalState($key, $value, $defaultValue=null, $forceSave=false) |
|
| 461 | 461 | { |
| 462 | 462 | $this->_stateChanged=true; |
| 463 | 463 | if($value===$defaultValue) |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | public function setMode($value) |
| 559 | 559 | { |
| 560 | - $this->_mode=TPropertyValue::ensureEnum($value,'TApplicationMode'); |
|
| 560 | + $this->_mode=TPropertyValue::ensureEnum($value, 'TApplicationMode'); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | public function setConfigurationType($value) |
| 607 | 607 | { |
| 608 | - $this->_configType = $value; |
|
| 608 | + $this->_configType=$value; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | /** |
@@ -618,10 +618,10 @@ discard block |
||
| 618 | 618 | switch($this->_configType) |
| 619 | 619 | { |
| 620 | 620 | case TApplication::CONFIG_TYPE_PHP: |
| 621 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP; |
|
| 621 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_PHP; |
|
| 622 | 622 | break; |
| 623 | 623 | default: |
| 624 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_XML; |
|
| 624 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_XML; |
|
| 625 | 625 | } |
| 626 | 626 | } |
| 627 | 627 | return $this->_configFileExt; |
@@ -633,15 +633,15 @@ discard block |
||
| 633 | 633 | public function getConfigurationFileName() |
| 634 | 634 | { |
| 635 | 635 | static $fileName; |
| 636 | - if($fileName == null) |
|
| 636 | + if($fileName==null) |
|
| 637 | 637 | { |
| 638 | 638 | switch($this->_configType) |
| 639 | 639 | { |
| 640 | 640 | case TApplication::CONFIG_TYPE_PHP: |
| 641 | - $fileName = TApplication::CONFIG_FILE_PHP; |
|
| 641 | + $fileName=TApplication::CONFIG_FILE_PHP; |
|
| 642 | 642 | break; |
| 643 | 643 | default: |
| 644 | - $fileName = TApplication::CONFIG_FILE_XML; |
|
| 644 | + $fileName=TApplication::CONFIG_FILE_XML; |
|
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | 647 | return $fileName; |
@@ -689,10 +689,10 @@ discard block |
||
| 689 | 689 | * @param string ID of the module |
| 690 | 690 | * @param IModule module object or null if the module has not been loaded yet |
| 691 | 691 | */ |
| 692 | - public function setModule($id,IModule $module=null) |
|
| 692 | + public function setModule($id, IModule $module=null) |
|
| 693 | 693 | { |
| 694 | 694 | if(isset($this->_modules[$id])) |
| 695 | - throw new TConfigurationException('application_moduleid_duplicated',$id); |
|
| 695 | + throw new TConfigurationException('application_moduleid_duplicated', $id); |
|
| 696 | 696 | else |
| 697 | 697 | $this->_modules[$id]=$module; |
| 698 | 698 | } |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | // force loading of a lazy module |
| 709 | 709 | if($this->_modules[$id]===null) |
| 710 | 710 | { |
| 711 | - $module = $this->internalLoadModule($id, true); |
|
| 711 | + $module=$this->internalLoadModule($id, true); |
|
| 712 | 712 | $module[0]->init($module[1]); |
| 713 | 713 | } |
| 714 | 714 | |
@@ -957,37 +957,37 @@ discard block |
||
| 957 | 957 | list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id]; |
| 958 | 958 | if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force) |
| 959 | 959 | { |
| 960 | - Prado::trace("Postponed loading of lazy module $id ({$moduleClass})",'System.TApplication'); |
|
| 960 | + Prado::trace("Postponed loading of lazy module $id ({$moduleClass})", 'System.TApplication'); |
|
| 961 | 961 | $this->setModule($id, null); |
| 962 | 962 | return null; |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | - Prado::trace("Loading module $id ({$moduleClass})",'System.TApplication'); |
|
| 965 | + Prado::trace("Loading module $id ({$moduleClass})", 'System.TApplication'); |
|
| 966 | 966 | $module=Prado::createComponent($moduleClass); |
| 967 | 967 | foreach($initProperties as $name=>$value) |
| 968 | 968 | { |
| 969 | 969 | if($name==='lazy') continue; |
| 970 | - $module->setSubProperty($name,$value); |
|
| 970 | + $module->setSubProperty($name, $value); |
|
| 971 | 971 | } |
| 972 | - $this->setModule($id,$module); |
|
| 972 | + $this->setModule($id, $module); |
|
| 973 | 973 | // keep the key to avoid reuse of the old module id |
| 974 | 974 | $this->_lazyModules[$id]=null; |
| 975 | 975 | |
| 976 | - return array($module,$configElement); |
|
| 976 | + return array($module, $configElement); |
|
| 977 | 977 | } |
| 978 | 978 | /** |
| 979 | 979 | * Applies an application configuration. |
| 980 | 980 | * @param TApplicationConfiguration the configuration |
| 981 | 981 | * @param boolean whether the configuration is specified within a service. |
| 982 | 982 | */ |
| 983 | - public function applyConfiguration($config,$withinService=false) |
|
| 983 | + public function applyConfiguration($config, $withinService=false) |
|
| 984 | 984 | { |
| 985 | 985 | if($config->getIsEmpty()) |
| 986 | 986 | return; |
| 987 | 987 | |
| 988 | 988 | // set path aliases and using namespaces |
| 989 | 989 | foreach($config->getAliases() as $alias=>$path) |
| 990 | - Prado::setPathOfAlias($alias,$path); |
|
| 990 | + Prado::setPathOfAlias($alias, $path); |
|
| 991 | 991 | foreach($config->getUsings() as $using) |
| 992 | 992 | Prado::using($using); |
| 993 | 993 | |
@@ -995,11 +995,11 @@ discard block |
||
| 995 | 995 | if(!$withinService) |
| 996 | 996 | { |
| 997 | 997 | foreach($config->getProperties() as $name=>$value) |
| 998 | - $this->setSubProperty($name,$value); |
|
| 998 | + $this->setSubProperty($name, $value); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | if(empty($this->_services)) |
| 1002 | - $this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null)); |
|
| 1002 | + $this->_services=array($this->getPageServiceID()=>array('TPageService', array(), null)); |
|
| 1003 | 1003 | |
| 1004 | 1004 | // load parameters |
| 1005 | 1005 | foreach($config->getParameters() as $id=>$parameter) |
@@ -1008,11 +1008,11 @@ discard block |
||
| 1008 | 1008 | { |
| 1009 | 1009 | $component=Prado::createComponent($parameter[0]); |
| 1010 | 1010 | foreach($parameter[1] as $name=>$value) |
| 1011 | - $component->setSubProperty($name,$value); |
|
| 1012 | - $this->_parameters->add($id,$component); |
|
| 1011 | + $component->setSubProperty($name, $value); |
|
| 1012 | + $this->_parameters->add($id, $component); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | else |
| 1015 | - $this->_parameters->add($id,$parameter); |
|
| 1015 | + $this->_parameters->add($id, $parameter); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | // load and init modules specified in app config |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | if(!is_string($id)) |
| 1023 | 1023 | $id='_module'.count($this->_lazyModules); |
| 1024 | 1024 | $this->_lazyModules[$id]=$moduleConfig; |
| 1025 | - if($module = $this->internalLoadModule($id)) |
|
| 1025 | + if($module=$this->internalLoadModule($id)) |
|
| 1026 | 1026 | $modules[]=$module; |
| 1027 | 1027 | } |
| 1028 | 1028 | foreach($modules as $module) |
@@ -1039,12 +1039,12 @@ discard block |
||
| 1039 | 1039 | $condition=$this->evaluateExpression($condition); |
| 1040 | 1040 | if($condition) |
| 1041 | 1041 | { |
| 1042 | - if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 1043 | - throw new TConfigurationException('application_includefile_invalid',$filePath); |
|
| 1042 | + if(($path=Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 1043 | + throw new TConfigurationException('application_includefile_invalid', $filePath); |
|
| 1044 | 1044 | $cn=$this->getApplicationConfigurationClass(); |
| 1045 | 1045 | $c=new $cn; |
| 1046 | 1046 | $c->loadFromFile($path); |
| 1047 | - $this->applyConfiguration($c,$withinService); |
|
| 1047 | + $this->applyConfiguration($c, $withinService); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | } |
| 1050 | 1050 | } |
@@ -1060,21 +1060,21 @@ discard block |
||
| 1060 | 1060 | */ |
| 1061 | 1061 | protected function initApplication() |
| 1062 | 1062 | { |
| 1063 | - Prado::trace('Initializing application','System.TApplication'); |
|
| 1063 | + Prado::trace('Initializing application', 'System.TApplication'); |
|
| 1064 | 1064 | |
| 1065 | 1065 | if($this->_configFile!==null) |
| 1066 | 1066 | { |
| 1067 | - if($this->_cacheFile===null || @filemtime($this->_cacheFile)<filemtime($this->_configFile)) |
|
| 1067 | + if($this->_cacheFile===null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) |
|
| 1068 | 1068 | { |
| 1069 | 1069 | $config=new TApplicationConfiguration; |
| 1070 | 1070 | $config->loadFromFile($this->_configFile); |
| 1071 | 1071 | if($this->_cacheFile!==null) |
| 1072 | - file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
|
| 1072 | + file_put_contents($this->_cacheFile, serialize($config), LOCK_EX); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | else |
| 1075 | 1075 | $config=unserialize(file_get_contents($this->_cacheFile)); |
| 1076 | 1076 | |
| 1077 | - $this->applyConfiguration($config,false); |
|
| 1077 | + $this->applyConfiguration($config, false); |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) |
@@ -1093,32 +1093,32 @@ discard block |
||
| 1093 | 1093 | { |
| 1094 | 1094 | if(isset($this->_services[$serviceID])) |
| 1095 | 1095 | { |
| 1096 | - list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID]; |
|
| 1096 | + list($serviceClass, $initProperties, $configElement)=$this->_services[$serviceID]; |
|
| 1097 | 1097 | $service=Prado::createComponent($serviceClass); |
| 1098 | 1098 | if(!($service instanceof IService)) |
| 1099 | - throw new THttpException(500,'application_service_invalid',$serviceClass); |
|
| 1099 | + throw new THttpException(500, 'application_service_invalid', $serviceClass); |
|
| 1100 | 1100 | if(!$service->getEnabled()) |
| 1101 | - throw new THttpException(500,'application_service_unavailable',$serviceClass); |
|
| 1101 | + throw new THttpException(500, 'application_service_unavailable', $serviceClass); |
|
| 1102 | 1102 | $service->setID($serviceID); |
| 1103 | 1103 | $this->setService($service); |
| 1104 | 1104 | |
| 1105 | 1105 | foreach($initProperties as $name=>$value) |
| 1106 | - $service->setSubProperty($name,$value); |
|
| 1106 | + $service->setSubProperty($name, $value); |
|
| 1107 | 1107 | |
| 1108 | 1108 | if($configElement!==null) |
| 1109 | 1109 | { |
| 1110 | 1110 | $config=new TApplicationConfiguration; |
| 1111 | 1111 | if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) |
| 1112 | - $config->loadFromPhp($configElement,$this->getBasePath()); |
|
| 1112 | + $config->loadFromPhp($configElement, $this->getBasePath()); |
|
| 1113 | 1113 | else |
| 1114 | - $config->loadFromXml($configElement,$this->getBasePath()); |
|
| 1115 | - $this->applyConfiguration($config,true); |
|
| 1114 | + $config->loadFromXml($configElement, $this->getBasePath()); |
|
| 1115 | + $this->applyConfiguration($config, true); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | $service->init($configElement); |
| 1119 | 1119 | } |
| 1120 | 1120 | else |
| 1121 | - throw new THttpException(500,'application_service_unknown',$serviceID); |
|
| 1121 | + throw new THttpException(500, 'application_service_unknown', $serviceID); |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | /** |
@@ -1129,9 +1129,9 @@ discard block |
||
| 1129 | 1129 | */ |
| 1130 | 1130 | public function onError($param) |
| 1131 | 1131 | { |
| 1132 | - Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication'); |
|
| 1133 | - $this->raiseEvent('OnError',$this,$param); |
|
| 1134 | - $this->getErrorHandler()->handleError($this,$param); |
|
| 1132 | + Prado::log($param->getMessage(), TLogger::ERROR, 'System.TApplication'); |
|
| 1133 | + $this->raiseEvent('OnError', $this, $param); |
|
| 1134 | + $this->getErrorHandler()->handleError($this, $param); |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | /** |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | */ |
| 1144 | 1144 | public function onBeginRequest() |
| 1145 | 1145 | { |
| 1146 | - $this->raiseEvent('OnBeginRequest',$this,null); |
|
| 1146 | + $this->raiseEvent('OnBeginRequest', $this, null); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /** |
@@ -1152,7 +1152,7 @@ discard block |
||
| 1152 | 1152 | */ |
| 1153 | 1153 | public function onAuthentication() |
| 1154 | 1154 | { |
| 1155 | - $this->raiseEvent('OnAuthentication',$this,null); |
|
| 1155 | + $this->raiseEvent('OnAuthentication', $this, null); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | */ |
| 1162 | 1162 | public function onAuthenticationComplete() |
| 1163 | 1163 | { |
| 1164 | - $this->raiseEvent('OnAuthenticationComplete',$this,null); |
|
| 1164 | + $this->raiseEvent('OnAuthenticationComplete', $this, null); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | /** |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | */ |
| 1171 | 1171 | public function onAuthorization() |
| 1172 | 1172 | { |
| 1173 | - $this->raiseEvent('OnAuthorization',$this,null); |
|
| 1173 | + $this->raiseEvent('OnAuthorization', $this, null); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | /** |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | */ |
| 1180 | 1180 | public function onAuthorizationComplete() |
| 1181 | 1181 | { |
| 1182 | - $this->raiseEvent('OnAuthorizationComplete',$this,null); |
|
| 1182 | + $this->raiseEvent('OnAuthorizationComplete', $this, null); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | /** |
@@ -1189,7 +1189,7 @@ discard block |
||
| 1189 | 1189 | public function onLoadState() |
| 1190 | 1190 | { |
| 1191 | 1191 | $this->loadGlobals(); |
| 1192 | - $this->raiseEvent('OnLoadState',$this,null); |
|
| 1192 | + $this->raiseEvent('OnLoadState', $this, null); |
|
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | /** |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | */ |
| 1199 | 1199 | public function onLoadStateComplete() |
| 1200 | 1200 | { |
| 1201 | - $this->raiseEvent('OnLoadStateComplete',$this,null); |
|
| 1201 | + $this->raiseEvent('OnLoadStateComplete', $this, null); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | */ |
| 1208 | 1208 | public function onPreRunService() |
| 1209 | 1209 | { |
| 1210 | - $this->raiseEvent('OnPreRunService',$this,null); |
|
| 1210 | + $this->raiseEvent('OnPreRunService', $this, null); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | /** |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | */ |
| 1226 | 1226 | public function onSaveState() |
| 1227 | 1227 | { |
| 1228 | - $this->raiseEvent('OnSaveState',$this,null); |
|
| 1228 | + $this->raiseEvent('OnSaveState', $this, null); |
|
| 1229 | 1229 | $this->saveGlobals(); |
| 1230 | 1230 | } |
| 1231 | 1231 | |
@@ -1235,7 +1235,7 @@ discard block |
||
| 1235 | 1235 | */ |
| 1236 | 1236 | public function onSaveStateComplete() |
| 1237 | 1237 | { |
| 1238 | - $this->raiseEvent('OnSaveStateComplete',$this,null); |
|
| 1238 | + $this->raiseEvent('OnSaveStateComplete', $this, null); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | /** |
@@ -1244,14 +1244,14 @@ discard block |
||
| 1244 | 1244 | */ |
| 1245 | 1245 | public function onPreFlushOutput() |
| 1246 | 1246 | { |
| 1247 | - $this->raiseEvent('OnPreFlushOutput',$this,null); |
|
| 1247 | + $this->raiseEvent('OnPreFlushOutput', $this, null); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | 1250 | /** |
| 1251 | 1251 | * Flushes output to client side. |
| 1252 | 1252 | * @param boolean whether to continue buffering after flush if buffering was active |
| 1253 | 1253 | */ |
| 1254 | - public function flushOutput($continueBuffering = true) |
|
| 1254 | + public function flushOutput($continueBuffering=true) |
|
| 1255 | 1255 | { |
| 1256 | 1256 | $this->getResponse()->flush($continueBuffering); |
| 1257 | 1257 | } |
@@ -1263,8 +1263,8 @@ discard block |
||
| 1263 | 1263 | public function onEndRequest() |
| 1264 | 1264 | { |
| 1265 | 1265 | $this->flushOutput(false); // flush all remaining content in the buffer |
| 1266 | - $this->saveGlobals(); // save global state |
|
| 1267 | - $this->raiseEvent('OnEndRequest',$this,null); |
|
| 1266 | + $this->saveGlobals(); // save global state |
|
| 1267 | + $this->raiseEvent('OnEndRequest', $this, null); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | } |
| 1270 | 1270 | |
@@ -1344,14 +1344,14 @@ discard block |
||
| 1344 | 1344 | { |
| 1345 | 1345 | if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 1346 | 1346 | { |
| 1347 | - $fcontent = include $fname; |
|
| 1348 | - $this->loadFromPhp($fcontent,dirname($fname)); |
|
| 1347 | + $fcontent=include $fname; |
|
| 1348 | + $this->loadFromPhp($fcontent, dirname($fname)); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | else |
| 1351 | 1351 | { |
| 1352 | 1352 | $dom=new TXmlDocument; |
| 1353 | 1353 | $dom->loadFromFile($fname); |
| 1354 | - $this->loadFromXml($dom,dirname($fname)); |
|
| 1354 | + $this->loadFromXml($dom, dirname($fname)); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | } |
| 1357 | 1357 | |
@@ -1377,23 +1377,23 @@ discard block |
||
| 1377 | 1377 | { |
| 1378 | 1378 | $this->_properties[$name]=$value; |
| 1379 | 1379 | } |
| 1380 | - $this->_empty = false; |
|
| 1380 | + $this->_empty=false; |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | if(isset($config['paths']) && is_array($config['paths'])) |
| 1384 | - $this->loadPathsPhp($config['paths'],$configPath); |
|
| 1384 | + $this->loadPathsPhp($config['paths'], $configPath); |
|
| 1385 | 1385 | |
| 1386 | 1386 | if(isset($config['modules']) && is_array($config['modules'])) |
| 1387 | - $this->loadModulesPhp($config['modules'],$configPath); |
|
| 1387 | + $this->loadModulesPhp($config['modules'], $configPath); |
|
| 1388 | 1388 | |
| 1389 | 1389 | if(isset($config['services']) && is_array($config['services'])) |
| 1390 | - $this->loadServicesPhp($config['services'],$configPath); |
|
| 1390 | + $this->loadServicesPhp($config['services'], $configPath); |
|
| 1391 | 1391 | |
| 1392 | 1392 | if(isset($config['parameters']) && is_array($config['parameters'])) |
| 1393 | 1393 | $this->loadParametersPhp($config['parameters'], $configPath); |
| 1394 | 1394 | |
| 1395 | 1395 | if(isset($config['includes']) && is_array($config['includes'])) |
| 1396 | - $this->loadExternalXml($config['includes'],$configPath); |
|
| 1396 | + $this->loadExternalXml($config['includes'], $configPath); |
|
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | 1399 | /** |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | * @param TXmlElement the XML element |
| 1402 | 1402 | * @param string the context path (for specifying relative paths) |
| 1403 | 1403 | */ |
| 1404 | - public function loadFromXml($dom,$configPath) |
|
| 1404 | + public function loadFromXml($dom, $configPath) |
|
| 1405 | 1405 | { |
| 1406 | 1406 | // application properties |
| 1407 | 1407 | foreach($dom->getAttributes() as $name=>$value) |
@@ -1415,19 +1415,19 @@ discard block |
||
| 1415 | 1415 | switch($element->getTagName()) |
| 1416 | 1416 | { |
| 1417 | 1417 | case 'paths': |
| 1418 | - $this->loadPathsXml($element,$configPath); |
|
| 1418 | + $this->loadPathsXml($element, $configPath); |
|
| 1419 | 1419 | break; |
| 1420 | 1420 | case 'modules': |
| 1421 | - $this->loadModulesXml($element,$configPath); |
|
| 1421 | + $this->loadModulesXml($element, $configPath); |
|
| 1422 | 1422 | break; |
| 1423 | 1423 | case 'services': |
| 1424 | - $this->loadServicesXml($element,$configPath); |
|
| 1424 | + $this->loadServicesXml($element, $configPath); |
|
| 1425 | 1425 | break; |
| 1426 | 1426 | case 'parameters': |
| 1427 | - $this->loadParametersXml($element,$configPath); |
|
| 1427 | + $this->loadParametersXml($element, $configPath); |
|
| 1428 | 1428 | break; |
| 1429 | 1429 | case 'include': |
| 1430 | - $this->loadExternalXml($element,$configPath); |
|
| 1430 | + $this->loadExternalXml($element, $configPath); |
|
| 1431 | 1431 | break; |
| 1432 | 1432 | default: |
| 1433 | 1433 | //throw new TConfigurationException('appconfig_tag_invalid',$element->getTagName()); |
@@ -1447,15 +1447,15 @@ discard block |
||
| 1447 | 1447 | { |
| 1448 | 1448 | foreach($pathsNode['aliases'] as $id=>$path) |
| 1449 | 1449 | { |
| 1450 | - $path=str_replace('\\','/',$path); |
|
| 1451 | - if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) // if absolute path |
|
| 1450 | + $path=str_replace('\\', '/', $path); |
|
| 1451 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
| 1452 | 1452 | $p=realpath($path); |
| 1453 | 1453 | else |
| 1454 | 1454 | $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
| 1455 | 1455 | if($p===false || !is_dir($p)) |
| 1456 | - throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path); |
|
| 1456 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
| 1457 | 1457 | if(isset($this->_aliases[$id])) |
| 1458 | - throw new TConfigurationException('appconfig_alias_redefined',$id); |
|
| 1458 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
| 1459 | 1459 | $this->_aliases[$id]=$p; |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
@@ -1464,7 +1464,7 @@ discard block |
||
| 1464 | 1464 | { |
| 1465 | 1465 | foreach($pathsNode['using'] as $namespace) |
| 1466 | 1466 | { |
| 1467 | - $this->_usings[] = $namespace; |
|
| 1467 | + $this->_usings[]=$namespace; |
|
| 1468 | 1468 | } |
| 1469 | 1469 | } |
| 1470 | 1470 | } |
@@ -1474,7 +1474,7 @@ discard block |
||
| 1474 | 1474 | * @param TXmlElement the paths XML node |
| 1475 | 1475 | * @param string the context path (for specifying relative paths) |
| 1476 | 1476 | */ |
| 1477 | - protected function loadPathsXml($pathsNode,$configPath) |
|
| 1477 | + protected function loadPathsXml($pathsNode, $configPath) |
|
| 1478 | 1478 | { |
| 1479 | 1479 | foreach($pathsNode->getElements() as $element) |
| 1480 | 1480 | { |
@@ -1484,15 +1484,15 @@ discard block |
||
| 1484 | 1484 | { |
| 1485 | 1485 | if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null) |
| 1486 | 1486 | { |
| 1487 | - $path=str_replace('\\','/',$path); |
|
| 1488 | - if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) // if absolute path |
|
| 1487 | + $path=str_replace('\\', '/', $path); |
|
| 1488 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
| 1489 | 1489 | $p=realpath($path); |
| 1490 | 1490 | else |
| 1491 | 1491 | $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
| 1492 | 1492 | if($p===false || !is_dir($p)) |
| 1493 | - throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path); |
|
| 1493 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
| 1494 | 1494 | if(isset($this->_aliases[$id])) |
| 1495 | - throw new TConfigurationException('appconfig_alias_redefined',$id); |
|
| 1495 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
| 1496 | 1496 | $this->_aliases[$id]=$p; |
| 1497 | 1497 | } |
| 1498 | 1498 | else |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | break; |
| 1511 | 1511 | } |
| 1512 | 1512 | default: |
| 1513 | - throw new TConfigurationException('appconfig_paths_invalid',$element->getTagName()); |
|
| 1513 | + throw new TConfigurationException('appconfig_paths_invalid', $element->getTagName()); |
|
| 1514 | 1514 | } |
| 1515 | 1515 | } |
| 1516 | 1516 | } |
@@ -1525,17 +1525,17 @@ discard block |
||
| 1525 | 1525 | foreach($modulesNode as $id=>$module) |
| 1526 | 1526 | { |
| 1527 | 1527 | if(!isset($module['class'])) |
| 1528 | - throw new TConfigurationException('appconfig_moduletype_required',$id); |
|
| 1529 | - $type = $module['class']; |
|
| 1528 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
| 1529 | + $type=$module['class']; |
|
| 1530 | 1530 | unset($module['class']); |
| 1531 | - $properties = array(); |
|
| 1531 | + $properties=array(); |
|
| 1532 | 1532 | if(isset($module['properties'])) |
| 1533 | 1533 | { |
| 1534 | - $properties = $module['properties']; |
|
| 1534 | + $properties=$module['properties']; |
|
| 1535 | 1535 | unset($module['properties']); |
| 1536 | 1536 | } |
| 1537 | - $properties['id'] = $id; |
|
| 1538 | - $this->_modules[$id]=array($type,$properties,$module); |
|
| 1537 | + $properties['id']=$id; |
|
| 1538 | + $this->_modules[$id]=array($type, $properties, $module); |
|
| 1539 | 1539 | $this->_empty=false; |
| 1540 | 1540 | } |
| 1541 | 1541 | } |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | * @param TXmlElement the modules XML node |
| 1546 | 1546 | * @param string the context path (for specifying relative paths) |
| 1547 | 1547 | */ |
| 1548 | - protected function loadModulesXml($modulesNode,$configPath) |
|
| 1548 | + protected function loadModulesXml($modulesNode, $configPath) |
|
| 1549 | 1549 | { |
| 1550 | 1550 | foreach($modulesNode->getElements() as $element) |
| 1551 | 1551 | { |
@@ -1555,16 +1555,16 @@ discard block |
||
| 1555 | 1555 | $id=$properties->itemAt('id'); |
| 1556 | 1556 | $type=$properties->remove('class'); |
| 1557 | 1557 | if($type===null) |
| 1558 | - throw new TConfigurationException('appconfig_moduletype_required',$id); |
|
| 1558 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
| 1559 | 1559 | $element->setParent(null); |
| 1560 | 1560 | if($id===null) |
| 1561 | - $this->_modules[]=array($type,$properties->toArray(),$element); |
|
| 1561 | + $this->_modules[]=array($type, $properties->toArray(), $element); |
|
| 1562 | 1562 | else |
| 1563 | - $this->_modules[$id]=array($type,$properties->toArray(),$element); |
|
| 1563 | + $this->_modules[$id]=array($type, $properties->toArray(), $element); |
|
| 1564 | 1564 | $this->_empty=false; |
| 1565 | 1565 | } |
| 1566 | 1566 | else |
| 1567 | - throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName()); |
|
| 1567 | + throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
|
| 1568 | 1568 | } |
| 1569 | 1569 | } |
| 1570 | 1570 | |
@@ -1573,18 +1573,18 @@ discard block |
||
| 1573 | 1573 | * @param array the services PHP array |
| 1574 | 1574 | * @param string the context path (for specifying relative paths) |
| 1575 | 1575 | */ |
| 1576 | - protected function loadServicesPhp($servicesNode,$configPath) |
|
| 1576 | + protected function loadServicesPhp($servicesNode, $configPath) |
|
| 1577 | 1577 | { |
| 1578 | 1578 | foreach($servicesNode as $id => $service) |
| 1579 | 1579 | { |
| 1580 | 1580 | if(!isset($service['class'])) |
| 1581 | 1581 | throw new TConfigurationException('appconfig_servicetype_required'); |
| 1582 | - $type = $service['class']; |
|
| 1583 | - $properties = isset($service['properties']) ? $service['properties'] : array(); |
|
| 1582 | + $type=$service['class']; |
|
| 1583 | + $properties=isset($service['properties']) ? $service['properties'] : array(); |
|
| 1584 | 1584 | unset($service['properties']); |
| 1585 | - $properties['id'] = $id; |
|
| 1586 | - $this->_services[$id] = array($type,$properties,$service); |
|
| 1587 | - $this->_empty = false; |
|
| 1585 | + $properties['id']=$id; |
|
| 1586 | + $this->_services[$id]=array($type, $properties, $service); |
|
| 1587 | + $this->_empty=false; |
|
| 1588 | 1588 | } |
| 1589 | 1589 | } |
| 1590 | 1590 | |
@@ -1593,7 +1593,7 @@ discard block |
||
| 1593 | 1593 | * @param TXmlElement the services XML node |
| 1594 | 1594 | * @param string the context path (for specifying relative paths) |
| 1595 | 1595 | */ |
| 1596 | - protected function loadServicesXml($servicesNode,$configPath) |
|
| 1596 | + protected function loadServicesXml($servicesNode, $configPath) |
|
| 1597 | 1597 | { |
| 1598 | 1598 | foreach($servicesNode->getElements() as $element) |
| 1599 | 1599 | { |
@@ -1603,13 +1603,13 @@ discard block |
||
| 1603 | 1603 | if(($id=$properties->itemAt('id'))===null) |
| 1604 | 1604 | throw new TConfigurationException('appconfig_serviceid_required'); |
| 1605 | 1605 | if(($type=$properties->remove('class'))===null) |
| 1606 | - throw new TConfigurationException('appconfig_servicetype_required',$id); |
|
| 1606 | + throw new TConfigurationException('appconfig_servicetype_required', $id); |
|
| 1607 | 1607 | $element->setParent(null); |
| 1608 | - $this->_services[$id]=array($type,$properties->toArray(),$element); |
|
| 1608 | + $this->_services[$id]=array($type, $properties->toArray(), $element); |
|
| 1609 | 1609 | $this->_empty=false; |
| 1610 | 1610 | } |
| 1611 | 1611 | else |
| 1612 | - throw new TConfigurationException('appconfig_services_invalid',$element->getTagName()); |
|
| 1612 | + throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
|
| 1613 | 1613 | } |
| 1614 | 1614 | } |
| 1615 | 1615 | |
@@ -1618,7 +1618,7 @@ discard block |
||
| 1618 | 1618 | * @param array the parameters PHP array |
| 1619 | 1619 | * @param string the context path (for specifying relative paths) |
| 1620 | 1620 | */ |
| 1621 | - protected function loadParametersPhp($parametersNode,$configPath) |
|
| 1621 | + protected function loadParametersPhp($parametersNode, $configPath) |
|
| 1622 | 1622 | { |
| 1623 | 1623 | foreach($parametersNode as $id => $parameter) |
| 1624 | 1624 | { |
@@ -1626,16 +1626,16 @@ discard block |
||
| 1626 | 1626 | { |
| 1627 | 1627 | if(isset($parameter['class'])) |
| 1628 | 1628 | { |
| 1629 | - $type = $parameter['class']; |
|
| 1629 | + $type=$parameter['class']; |
|
| 1630 | 1630 | unset($parameter['class']); |
| 1631 | - $properties = isset($service['properties']) ? $service['properties'] : array(); |
|
| 1632 | - $properties['id'] = $id; |
|
| 1633 | - $this->_parameters[$id] = array($type,$properties); |
|
| 1631 | + $properties=isset($service['properties']) ? $service['properties'] : array(); |
|
| 1632 | + $properties['id']=$id; |
|
| 1633 | + $this->_parameters[$id]=array($type, $properties); |
|
| 1634 | 1634 | } |
| 1635 | 1635 | } |
| 1636 | 1636 | else |
| 1637 | 1637 | { |
| 1638 | - $this->_parameters[$id] = $parameter; |
|
| 1638 | + $this->_parameters[$id]=$parameter; |
|
| 1639 | 1639 | } |
| 1640 | 1640 | } |
| 1641 | 1641 | } |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | * @param TXmlElement the parameters XML node |
| 1646 | 1646 | * @param string the context path (for specifying relative paths) |
| 1647 | 1647 | */ |
| 1648 | - protected function loadParametersXml($parametersNode,$configPath) |
|
| 1648 | + protected function loadParametersXml($parametersNode, $configPath) |
|
| 1649 | 1649 | { |
| 1650 | 1650 | foreach($parametersNode->getElements() as $element) |
| 1651 | 1651 | { |
@@ -1662,11 +1662,11 @@ discard block |
||
| 1662 | 1662 | $this->_parameters[$id]=$value; |
| 1663 | 1663 | } |
| 1664 | 1664 | else |
| 1665 | - $this->_parameters[$id]=array($type,$properties->toArray()); |
|
| 1665 | + $this->_parameters[$id]=array($type, $properties->toArray()); |
|
| 1666 | 1666 | $this->_empty=false; |
| 1667 | 1667 | } |
| 1668 | 1668 | else |
| 1669 | - throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName()); |
|
| 1669 | + throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
|
| 1670 | 1670 | } |
| 1671 | 1671 | } |
| 1672 | 1672 | |
@@ -1675,14 +1675,14 @@ discard block |
||
| 1675 | 1675 | * @param array the application PHP array |
| 1676 | 1676 | * @param string the context path (for specifying relative paths) |
| 1677 | 1677 | */ |
| 1678 | - protected function loadExternalPhp($includeNode,$configPath) |
|
| 1678 | + protected function loadExternalPhp($includeNode, $configPath) |
|
| 1679 | 1679 | { |
| 1680 | 1680 | foreach($includeNode as $include) |
| 1681 | 1681 | { |
| 1682 | - $when = isset($include['when'])?true:false; |
|
| 1682 | + $when=isset($include['when']) ? true : false; |
|
| 1683 | 1683 | if(!isset($include['file'])) |
| 1684 | 1684 | throw new TConfigurationException('appconfig_includefile_required'); |
| 1685 | - $filePath = $include['file']; |
|
| 1685 | + $filePath=$include['file']; |
|
| 1686 | 1686 | if(isset($this->_includes[$filePath])) |
| 1687 | 1687 | $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
| 1688 | 1688 | else |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | * @param TXmlElement the application DOM element |
| 1697 | 1697 | * @param string the context path (for specifying relative paths) |
| 1698 | 1698 | */ |
| 1699 | - protected function loadExternalXml($includeNode,$configPath) |
|
| 1699 | + protected function loadExternalXml($includeNode, $configPath) |
|
| 1700 | 1700 | { |
| 1701 | 1701 | if(($when=$includeNode->getAttribute('when'))===null) |
| 1702 | 1702 | $when=true; |
@@ -1862,12 +1862,12 @@ discard block |
||
| 1862 | 1862 | if($cache->get(self::CACHE_NAME)===$content) |
| 1863 | 1863 | $saveFile=false; |
| 1864 | 1864 | else |
| 1865 | - $cache->set(self::CACHE_NAME,$content); |
|
| 1865 | + $cache->set(self::CACHE_NAME, $content); |
|
| 1866 | 1866 | } |
| 1867 | 1867 | if($saveFile) |
| 1868 | 1868 | { |
| 1869 | 1869 | $fileName=$this->getStateFilePath(); |
| 1870 | - file_put_contents($fileName,$content,LOCK_EX); |
|
| 1870 | + file_put_contents($fileName, $content, LOCK_EX); |
|
| 1871 | 1871 | } |
| 1872 | 1872 | } |
| 1873 | 1873 | |
@@ -357,8 +357,7 @@ discard block |
||
| 357 | 357 | { |
| 358 | 358 | $configFile=$basePath; |
| 359 | 359 | $basePath=dirname($configFile); |
| 360 | - } |
|
| 361 | - else |
|
| 360 | + } else |
|
| 362 | 361 | $configFile=null; |
| 363 | 362 | |
| 364 | 363 | // determine runtime path |
@@ -378,8 +377,7 @@ discard block |
||
| 378 | 377 | } |
| 379 | 378 | $this->setBasePath($basePath); |
| 380 | 379 | $this->setRuntimePath($runtimePath); |
| 381 | - } |
|
| 382 | - else |
|
| 380 | + } else |
|
| 383 | 381 | throw new TConfigurationException('application_runtimepath_invalid',$runtimePath); |
| 384 | 382 | |
| 385 | 383 | } |
@@ -408,8 +406,7 @@ discard block |
||
| 408 | 406 | $this->$method(); |
| 409 | 407 | $this->_step++; |
| 410 | 408 | } |
| 411 | - } |
|
| 412 | - catch(Exception $e) |
|
| 409 | + } catch(Exception $e) |
|
| 413 | 410 | { |
| 414 | 411 | $this->onError($e); |
| 415 | 412 | } |
@@ -1010,8 +1007,7 @@ discard block |
||
| 1010 | 1007 | foreach($parameter[1] as $name=>$value) |
| 1011 | 1008 | $component->setSubProperty($name,$value); |
| 1012 | 1009 | $this->_parameters->add($id,$component); |
| 1013 | - } |
|
| 1014 | - else |
|
| 1010 | + } else |
|
| 1015 | 1011 | $this->_parameters->add($id,$parameter); |
| 1016 | 1012 | } |
| 1017 | 1013 | |
@@ -1070,8 +1066,7 @@ discard block |
||
| 1070 | 1066 | $config->loadFromFile($this->_configFile); |
| 1071 | 1067 | if($this->_cacheFile!==null) |
| 1072 | 1068 | file_put_contents($this->_cacheFile,serialize($config),LOCK_EX); |
| 1073 | - } |
|
| 1074 | - else |
|
| 1069 | + } else |
|
| 1075 | 1070 | $config=unserialize(file_get_contents($this->_cacheFile)); |
| 1076 | 1071 | |
| 1077 | 1072 | $this->applyConfiguration($config,false); |
@@ -1116,8 +1111,7 @@ discard block |
||
| 1116 | 1111 | } |
| 1117 | 1112 | |
| 1118 | 1113 | $service->init($configElement); |
| 1119 | - } |
|
| 1120 | - else |
|
| 1114 | + } else |
|
| 1121 | 1115 | throw new THttpException(500,'application_service_unknown',$serviceID); |
| 1122 | 1116 | } |
| 1123 | 1117 | |
@@ -1346,8 +1340,7 @@ discard block |
||
| 1346 | 1340 | { |
| 1347 | 1341 | $fcontent = include $fname; |
| 1348 | 1342 | $this->loadFromPhp($fcontent,dirname($fname)); |
| 1349 | - } |
|
| 1350 | - else |
|
| 1343 | + } else |
|
| 1351 | 1344 | { |
| 1352 | 1345 | $dom=new TXmlDocument; |
| 1353 | 1346 | $dom->loadFromFile($fname); |
@@ -1494,8 +1487,7 @@ discard block |
||
| 1494 | 1487 | if(isset($this->_aliases[$id])) |
| 1495 | 1488 | throw new TConfigurationException('appconfig_alias_redefined',$id); |
| 1496 | 1489 | $this->_aliases[$id]=$p; |
| 1497 | - } |
|
| 1498 | - else |
|
| 1490 | + } else |
|
| 1499 | 1491 | throw new TConfigurationException('appconfig_alias_invalid'); |
| 1500 | 1492 | $this->_empty=false; |
| 1501 | 1493 | break; |
@@ -1562,8 +1554,7 @@ discard block |
||
| 1562 | 1554 | else |
| 1563 | 1555 | $this->_modules[$id]=array($type,$properties->toArray(),$element); |
| 1564 | 1556 | $this->_empty=false; |
| 1565 | - } |
|
| 1566 | - else |
|
| 1557 | + } else |
|
| 1567 | 1558 | throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName()); |
| 1568 | 1559 | } |
| 1569 | 1560 | } |
@@ -1607,8 +1598,7 @@ discard block |
||
| 1607 | 1598 | $element->setParent(null); |
| 1608 | 1599 | $this->_services[$id]=array($type,$properties->toArray(),$element); |
| 1609 | 1600 | $this->_empty=false; |
| 1610 | - } |
|
| 1611 | - else |
|
| 1601 | + } else |
|
| 1612 | 1602 | throw new TConfigurationException('appconfig_services_invalid',$element->getTagName()); |
| 1613 | 1603 | } |
| 1614 | 1604 | } |
@@ -1632,8 +1622,7 @@ discard block |
||
| 1632 | 1622 | $properties['id'] = $id; |
| 1633 | 1623 | $this->_parameters[$id] = array($type,$properties); |
| 1634 | 1624 | } |
| 1635 | - } |
|
| 1636 | - else |
|
| 1625 | + } else |
|
| 1637 | 1626 | { |
| 1638 | 1627 | $this->_parameters[$id] = $parameter; |
| 1639 | 1628 | } |
@@ -1660,12 +1649,10 @@ discard block |
||
| 1660 | 1649 | $this->_parameters[$id]=$element; |
| 1661 | 1650 | else |
| 1662 | 1651 | $this->_parameters[$id]=$value; |
| 1663 | - } |
|
| 1664 | - else |
|
| 1652 | + } else |
|
| 1665 | 1653 | $this->_parameters[$id]=array($type,$properties->toArray()); |
| 1666 | 1654 | $this->_empty=false; |
| 1667 | - } |
|
| 1668 | - else |
|
| 1655 | + } else |
|
| 1669 | 1656 | throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName()); |
| 1670 | 1657 | } |
| 1671 | 1658 | } |
@@ -49,6 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @param string id of this service |
| 52 | + * @param string $value |
|
| 52 | 53 | */ |
| 53 | 54 | public function setID($value) |
| 54 | 55 | { |
@@ -98,6 +98,7 @@ |
||
| 98 | 98 | * @param integer level filter |
| 99 | 99 | * @param array category filter |
| 100 | 100 | * @param array control filter |
| 101 | + * @param integer $levels |
|
| 101 | 102 | * @return array list of messages. Each array elements represents one message |
| 102 | 103 | * with the following structure: |
| 103 | 104 | * array( |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | * @param string category of the message |
| 64 | 64 | * @param string|TControl control of the message |
| 65 | 65 | */ |
| 66 | - public function log($message,$level,$category='Uncategorized', $ctl=null) |
|
| 66 | + public function log($message, $level, $category='Uncategorized', $ctl=null) |
|
| 67 | 67 | { |
| 68 | 68 | if($ctl) { |
| 69 | 69 | if($ctl instanceof TControl) |
| 70 | - $ctl = $ctl->ClientId; |
|
| 70 | + $ctl=$ctl->ClientId; |
|
| 71 | 71 | else if(!is_string($ctl)) |
| 72 | - $ctl = null; |
|
| 72 | + $ctl=null; |
|
| 73 | 73 | } else |
| 74 | - $ctl = null; |
|
| 75 | - $this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl); |
|
| 74 | + $ctl=null; |
|
| 75 | + $this->_logs[]=array($message, $level, $category, microtime(true), memory_get_usage(), $ctl); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * [4] => memory in bytes |
| 109 | 109 | * [5] => control client id |
| 110 | 110 | */ |
| 111 | - public function getLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
| 111 | + public function getLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
| 112 | 112 | { |
| 113 | 113 | $this->_levels=$levels; |
| 114 | 114 | $this->_categories=$categories; |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | $this->_timestamp=$timestamp; |
| 117 | 117 | if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp)) |
| 118 | 118 | return $this->_logs; |
| 119 | - $logs = $this->_logs; |
|
| 119 | + $logs=$this->_logs; |
|
| 120 | 120 | if(!empty($levels)) |
| 121 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) )); |
|
| 121 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByLevels')))); |
|
| 122 | 122 | if(!empty($categories)) |
| 123 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) )); |
|
| 123 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByCategories')))); |
|
| 124 | 124 | if(!empty($controls)) |
| 125 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) )); |
|
| 125 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByControl')))); |
|
| 126 | 126 | if(!is_null($timestamp)) |
| 127 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) )); |
|
| 127 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByTimeStamp')))); |
|
| 128 | 128 | return $logs; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param array category filter |
| 153 | 153 | * @param array control filter |
| 154 | 154 | */ |
| 155 | - public function deleteLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
| 155 | + public function deleteLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
| 156 | 156 | { |
| 157 | 157 | $this->_levels=$levels; |
| 158 | 158 | $this->_categories=$categories; |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | $this->_logs=array(); |
| 164 | 164 | return; |
| 165 | 165 | } |
| 166 | - $logs = $this->_logs; |
|
| 166 | + $logs=$this->_logs; |
|
| 167 | 167 | if(!empty($levels)) |
| 168 | - $logs = array_filter( array_filter($logs,array($this,'filterByLevels')) ); |
|
| 168 | + $logs=array_filter(array_filter($logs, array($this, 'filterByLevels'))); |
|
| 169 | 169 | if(!empty($categories)) |
| 170 | - $logs = array_filter( array_filter($logs,array($this,'filterByCategories')) ); |
|
| 170 | + $logs=array_filter(array_filter($logs, array($this, 'filterByCategories'))); |
|
| 171 | 171 | if(!empty($controls)) |
| 172 | - $logs = array_filter( array_filter($logs,array($this,'filterByControl')) ); |
|
| 172 | + $logs=array_filter(array_filter($logs, array($this, 'filterByControl'))); |
|
| 173 | 173 | if(!is_null($timestamp)) |
| 174 | - $logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ); |
|
| 175 | - $this->_logs = array_values( array_diff_key($this->_logs, $logs) ); |
|
| 174 | + $logs=array_filter(array_filter($logs, array($this, 'filterByTimeStamp'))); |
|
| 175 | + $this->_logs=array_values(array_diff_key($this->_logs, $logs)); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | foreach($this->_categories as $category) |
| 185 | 185 | { |
| 186 | 186 | // element 2 is the category |
| 187 | - if($value[2]===$category || strpos($value[2],$category.'.')===0) |
|
| 187 | + if($value[2]===$category || strpos($value[2], $category.'.')===0) |
|
| 188 | 188 | return $value; |
| 189 | 189 | } |
| 190 | 190 | return false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | // element 5 are the control client ids |
| 213 | 213 | foreach($this->_controls as $control) |
| 214 | 214 | { |
| 215 | - if($value[5]===$control || strpos($value[5],$control)===0) |
|
| 215 | + if($value[5]===$control || strpos($value[5], $control)===0) |
|
| 216 | 216 | return $value; |
| 217 | 217 | } |
| 218 | 218 | return false; |
@@ -105,6 +105,9 @@ |
||
| 105 | 105 | * @param string RPC server URL |
| 106 | 106 | * @param array payload data |
| 107 | 107 | * @param string request mime type |
| 108 | + * @param string $serverUrl |
|
| 109 | + * @param string $mimeType |
|
| 110 | + * @return string |
|
| 108 | 111 | */ |
| 109 | 112 | protected function performRequest($serverUrl, $payload, $mimeType) |
| 110 | 113 | { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @var boolean whether the request is a notification and therefore should not care about the result (default: false) |
| 57 | 57 | */ |
| 58 | - private $_isNotification = false; |
|
| 58 | + private $_isNotification=false; |
|
| 59 | 59 | |
| 60 | 60 | // magics |
| 61 | 61 | |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | * @param string url to RPC server |
| 64 | 64 | * @param boolean whether requests are considered to be notifications (completely ignoring the response) (default: false) |
| 65 | 65 | */ |
| 66 | - public function __construct($serverUrl, $isNotification = false) |
|
| 66 | + public function __construct($serverUrl, $isNotification=false) |
|
| 67 | 67 | { |
| 68 | - $this->_serverUrl = $serverUrl; |
|
| 69 | - $this->_isNotification = TPropertyValue::ensureBoolean($isNotification); |
|
| 68 | + $this->_serverUrl=$serverUrl; |
|
| 69 | + $this->_isNotification=TPropertyValue::ensureBoolean($isNotification); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // methods |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * @return TRpcClient instance |
| 77 | 77 | * @throws TApplicationException if an unsupported RPC client type was specified |
| 78 | 78 | */ |
| 79 | - public static function create($type, $serverUrl, $isNotification = false) |
|
| 79 | + public static function create($type, $serverUrl, $isNotification=false) |
|
| 80 | 80 | { |
| 81 | - if(($_handler = constant('TRpcClientTypesEnumerable::'.strtoupper($type))) === null) |
|
| 81 | + if(($_handler=constant('TRpcClientTypesEnumerable::'.strtoupper($type)))===null) |
|
| 82 | 82 | throw new TApplicationException('rpcclient_unsupported_handler'); |
| 83 | 83 | |
| 84 | 84 | return new $_handler($serverUrl, $isNotification); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function performRequest($serverUrl, $payload, $mimeType) |
| 110 | 110 | { |
| 111 | - if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false) |
|
| 111 | + if(($_response=@file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType)))===false) |
|
| 112 | 112 | throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")'); |
| 113 | 113 | |
| 114 | 114 | return $_response; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function setIsNotification($bool) |
| 131 | 131 | { |
| 132 | - $this->_isNotification = TPropertyValue::ensureBoolean($bool); |
|
| 132 | + $this->_isNotification=TPropertyValue::ensureBoolean($bool); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function setServerUrl($value) |
| 147 | 147 | { |
| 148 | - $this->_serverUrl = $value; |
|
| 148 | + $this->_serverUrl=$value; |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | class TRpcClientTypesEnumerable extends TEnumerable |
| 162 | 162 | { |
| 163 | - const JSON = 'TJsonRpcClient'; |
|
| 164 | - const XML = 'TXmlRpcClient'; |
|
| 163 | + const JSON='TJsonRpcClient'; |
|
| 164 | + const XML='TXmlRpcClient'; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param string error message |
| 198 | 198 | * @param integer error code (optional) |
| 199 | 199 | */ |
| 200 | - public function __construct($errorMessage, $errorCode = null) |
|
| 200 | + public function __construct($errorMessage, $errorCode=null) |
|
| 201 | 201 | { |
| 202 | 202 | $this->setErrorCode($errorCode); |
| 203 | 203 | |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | public function __call($method, $parameters) |
| 240 | 240 | { |
| 241 | 241 | // send request |
| 242 | - $_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json'); |
|
| 242 | + $_response=$this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json'); |
|
| 243 | 243 | |
| 244 | 244 | // skip response handling if the request was just a notification request |
| 245 | 245 | if($this->isNotification) |
| 246 | 246 | return true; |
| 247 | 247 | |
| 248 | 248 | // decode response |
| 249 | - if(($_response = json_decode($_response, true)) === null) |
|
| 249 | + if(($_response=json_decode($_response, true))===null) |
|
| 250 | 250 | throw new TRpcClientResponseException('Empty response received'); |
| 251 | 251 | |
| 252 | 252 | // handle error response |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | public function encodeRequest($method, $parameters) |
| 266 | 266 | { |
| 267 | 267 | static $_requestId; |
| 268 | - $_requestId = ($_requestId === null) ? 1 : $_requestId + 1; |
|
| 268 | + $_requestId=($_requestId===null) ? 1 : $_requestId + 1; |
|
| 269 | 269 | |
| 270 | 270 | return json_encode(array( |
| 271 | 271 | 'method' => $method, |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @param string url of the rpc server |
| 280 | 280 | * @param boolean whether the requests are considered to be notifications (completely ignoring the response) (default: false) |
| 281 | 281 | */ |
| 282 | - public static function create($type, $serverUrl, $isNotification = false) |
|
| 282 | + public static function create($type, $serverUrl, $isNotification=false) |
|
| 283 | 283 | { |
| 284 | 284 | return new self($serverUrl, $isNotification); |
| 285 | 285 | } |
@@ -317,14 +317,14 @@ discard block |
||
| 317 | 317 | public function __call($method, $parameters) |
| 318 | 318 | { |
| 319 | 319 | // send request |
| 320 | - $_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'text/xml'); |
|
| 320 | + $_response=$this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'text/xml'); |
|
| 321 | 321 | |
| 322 | 322 | // skip response handling if the request was just a notification request |
| 323 | 323 | if($this->isNotification) |
| 324 | 324 | return true; |
| 325 | 325 | |
| 326 | 326 | // decode response |
| 327 | - if(($_response = xmlrpc_decode($_response)) === null) |
|
| 327 | + if(($_response=xmlrpc_decode($_response))===null) |
|
| 328 | 328 | throw new TRpcClientResponseException('Empty response received'); |
| 329 | 329 | |
| 330 | 330 | // handle error response |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @param string url of the rpc server |
| 351 | 351 | * @param boolean whether the requests are considered to be notifications (completely ignoring the response) (default: false) |
| 352 | 352 | */ |
| 353 | - public static function create($type, $serverUrl, $isNotification = false) |
|
| 353 | + public static function create($type, $serverUrl, $isNotification=false) |
|
| 354 | 354 | { |
| 355 | 355 | return new self($serverUrl, $isNotification); |
| 356 | 356 | } |
@@ -55,6 +55,9 @@ |
||
| 55 | 55 | return self::$_output; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param integer $level |
|
| 60 | + */ |
|
| 58 | 61 | private static function dumpInternal($var,$level) |
| 59 | 62 | { |
| 60 | 63 | switch(gettype($var)) |
@@ -40,27 +40,27 @@ discard block |
||
| 40 | 40 | * @param integer maximum depth that the dumper should go into the variable. Defaults to 10. |
| 41 | 41 | * @return string the string representation of the variable |
| 42 | 42 | */ |
| 43 | - public static function dump($var,$depth=10,$highlight=false) |
|
| 43 | + public static function dump($var, $depth=10, $highlight=false) |
|
| 44 | 44 | { |
| 45 | 45 | self::$_output=''; |
| 46 | 46 | self::$_objects=array(); |
| 47 | 47 | self::$_depth=$depth; |
| 48 | - self::dumpInternal($var,0); |
|
| 48 | + self::dumpInternal($var, 0); |
|
| 49 | 49 | if($highlight) |
| 50 | 50 | { |
| 51 | - $result=highlight_string("<?php\n".self::$_output,true); |
|
| 52 | - return preg_replace('/<\\?php<br \\/>/','',$result,1); |
|
| 51 | + $result=highlight_string("<?php\n".self::$_output, true); |
|
| 52 | + return preg_replace('/<\\?php<br \\/>/', '', $result, 1); |
|
| 53 | 53 | } |
| 54 | 54 | else |
| 55 | 55 | return self::$_output; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private static function dumpInternal($var,$level) |
|
| 58 | + private static function dumpInternal($var, $level) |
|
| 59 | 59 | { |
| 60 | 60 | switch(gettype($var)) |
| 61 | 61 | { |
| 62 | 62 | case 'boolean': |
| 63 | - self::$_output.=$var?'true':'false'; |
|
| 63 | + self::$_output.=$var ? 'true' : 'false'; |
|
| 64 | 64 | break; |
| 65 | 65 | case 'integer': |
| 66 | 66 | self::$_output.="$var"; |
@@ -81,41 +81,41 @@ discard block |
||
| 81 | 81 | self::$_output.='{unknown}'; |
| 82 | 82 | break; |
| 83 | 83 | case 'array': |
| 84 | - if(self::$_depth<=$level) |
|
| 84 | + if(self::$_depth <= $level) |
|
| 85 | 85 | self::$_output.='array(...)'; |
| 86 | 86 | else if(empty($var)) |
| 87 | 87 | self::$_output.='array()'; |
| 88 | 88 | else |
| 89 | 89 | { |
| 90 | 90 | $keys=array_keys($var); |
| 91 | - $spaces=str_repeat(' ',$level*4); |
|
| 91 | + $spaces=str_repeat(' ', $level * 4); |
|
| 92 | 92 | self::$_output.="array\n".$spaces.'('; |
| 93 | 93 | foreach($keys as $key) |
| 94 | 94 | { |
| 95 | 95 | self::$_output.="\n".$spaces." [$key] => "; |
| 96 | - self::$_output.=self::dumpInternal($var[$key],$level+1); |
|
| 96 | + self::$_output.=self::dumpInternal($var[$key], $level + 1); |
|
| 97 | 97 | } |
| 98 | 98 | self::$_output.="\n".$spaces.')'; |
| 99 | 99 | } |
| 100 | 100 | break; |
| 101 | 101 | case 'object': |
| 102 | - if(($id=array_search($var,self::$_objects,true))!==false) |
|
| 103 | - self::$_output.=get_class($var).'#'.($id+1).'(...)'; |
|
| 104 | - else if(self::$_depth<=$level) |
|
| 102 | + if(($id=array_search($var, self::$_objects, true))!==false) |
|
| 103 | + self::$_output.=get_class($var).'#'.($id + 1).'(...)'; |
|
| 104 | + else if(self::$_depth <= $level) |
|
| 105 | 105 | self::$_output.=get_class($var).'(...)'; |
| 106 | 106 | else |
| 107 | 107 | { |
| 108 | - $id=array_push(self::$_objects,$var); |
|
| 108 | + $id=array_push(self::$_objects, $var); |
|
| 109 | 109 | $className=get_class($var); |
| 110 | - $members=(array)$var; |
|
| 110 | + $members=(array) $var; |
|
| 111 | 111 | $keys=array_keys($members); |
| 112 | - $spaces=str_repeat(' ',$level*4); |
|
| 112 | + $spaces=str_repeat(' ', $level * 4); |
|
| 113 | 113 | self::$_output.="$className#$id\n".$spaces.'('; |
| 114 | 114 | foreach($keys as $key) |
| 115 | 115 | { |
| 116 | - $keyDisplay=strtr(trim($key),array("\0"=>':')); |
|
| 116 | + $keyDisplay=strtr(trim($key), array("\0"=>':')); |
|
| 117 | 117 | self::$_output.="\n".$spaces." [$keyDisplay] => "; |
| 118 | - self::$_output.=self::dumpInternal($members[$key],$level+1); |
|
| 118 | + self::$_output.=self::dumpInternal($members[$key], $level + 1); |
|
| 119 | 119 | } |
| 120 | 120 | self::$_output.="\n".$spaces.')'; |
| 121 | 121 | } |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | { |
| 53 | 53 | $result=highlight_string("<?php\n".self::$_output,true); |
| 54 | 54 | return preg_replace('/<\\?php<br \\/>/','',$result,1); |
| 55 | - } |
|
| 56 | - else |
|
| 55 | + } else |
|
| 57 | 56 | return self::$_output; |
| 58 | 57 | } |
| 59 | 58 | |
@@ -73,6 +73,9 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param integer $d |
|
| 78 | + */ |
|
| 76 | 79 | protected function action($d) { |
| 77 | 80 | switch($d) { |
| 78 | 81 | case 1: |
@@ -132,6 +135,9 @@ discard block |
||
| 132 | 135 | } |
| 133 | 136 | } |
| 134 | 137 | |
| 138 | + /** |
|
| 139 | + * @return string |
|
| 140 | + */ |
|
| 135 | 141 | protected function get() { |
| 136 | 142 | $c = $this->lookAhead; |
| 137 | 143 | $this->lookAhead = null; |
@@ -156,6 +162,9 @@ discard block |
||
| 156 | 162 | return ' '; |
| 157 | 163 | } |
| 158 | 164 | |
| 165 | + /** |
|
| 166 | + * @param string $c |
|
| 167 | + */ |
|
| 159 | 168 | protected function isAlphaNum($c) { |
| 160 | 169 | return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
| 161 | 170 | } |
@@ -60,229 +60,229 @@ |
||
| 60 | 60 | // -- Public Static Methods -------------------------------------------------- |
| 61 | 61 | |
| 62 | 62 | public static function minify($js) { |
| 63 | - $jsmin = new JSMin($js); |
|
| 64 | - return $jsmin->min(); |
|
| 63 | + $jsmin = new JSMin($js); |
|
| 64 | + return $jsmin->min(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // -- Public Instance Methods ------------------------------------------------ |
| 68 | 68 | |
| 69 | 69 | public function __construct($input) { |
| 70 | - $this->input = str_replace("\r\n", "\n", $input); |
|
| 71 | - $this->inputLength = strlen($this->input); |
|
| 70 | + $this->input = str_replace("\r\n", "\n", $input); |
|
| 71 | + $this->inputLength = strlen($this->input); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
| 75 | 75 | |
| 76 | 76 | protected function action($d) { |
| 77 | - switch($d) { |
|
| 78 | - case 1: |
|
| 79 | - $this->output .= $this->a; |
|
| 80 | - |
|
| 81 | - case 2: |
|
| 82 | - $this->a = $this->b; |
|
| 83 | - |
|
| 84 | - if ($this->a === "'" || $this->a === '"') { |
|
| 85 | - for (;;) { |
|
| 86 | - $this->output .= $this->a; |
|
| 87 | - $this->a = $this->get(); |
|
| 88 | - |
|
| 89 | - if ($this->a === $this->b) { |
|
| 90 | - break; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if (ord($this->a) <= self::ORD_LF) { |
|
| 94 | - throw new JSMinException('Unterminated string literal.'); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($this->a === '\\') { |
|
| 98 | - $this->output .= $this->a; |
|
| 99 | - $this->a = $this->get(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - case 3: |
|
| 105 | - $this->b = $this->next(); |
|
| 106 | - |
|
| 107 | - if ($this->b === '/' && ( |
|
| 108 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 109 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 110 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 111 | - |
|
| 112 | - $this->output .= $this->a . $this->b; |
|
| 113 | - |
|
| 114 | - for (;;) { |
|
| 115 | - $this->a = $this->get(); |
|
| 116 | - |
|
| 117 | - if ($this->a === '/') { |
|
| 118 | - break; |
|
| 119 | - } elseif ($this->a === '\\') { |
|
| 120 | - $this->output .= $this->a; |
|
| 121 | - $this->a = $this->get(); |
|
| 122 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 123 | - throw new JSMinException('Unterminated regular expression '. |
|
| 124 | - 'literal.'); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $this->output .= $this->a; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $this->b = $this->next(); |
|
| 131 | - } |
|
| 132 | - } |
|
| 77 | + switch($d) { |
|
| 78 | + case 1: |
|
| 79 | + $this->output .= $this->a; |
|
| 80 | + |
|
| 81 | + case 2: |
|
| 82 | + $this->a = $this->b; |
|
| 83 | + |
|
| 84 | + if ($this->a === "'" || $this->a === '"') { |
|
| 85 | + for (;;) { |
|
| 86 | + $this->output .= $this->a; |
|
| 87 | + $this->a = $this->get(); |
|
| 88 | + |
|
| 89 | + if ($this->a === $this->b) { |
|
| 90 | + break; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if (ord($this->a) <= self::ORD_LF) { |
|
| 94 | + throw new JSMinException('Unterminated string literal.'); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($this->a === '\\') { |
|
| 98 | + $this->output .= $this->a; |
|
| 99 | + $this->a = $this->get(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + case 3: |
|
| 105 | + $this->b = $this->next(); |
|
| 106 | + |
|
| 107 | + if ($this->b === '/' && ( |
|
| 108 | + $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 109 | + $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 110 | + $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 111 | + |
|
| 112 | + $this->output .= $this->a . $this->b; |
|
| 113 | + |
|
| 114 | + for (;;) { |
|
| 115 | + $this->a = $this->get(); |
|
| 116 | + |
|
| 117 | + if ($this->a === '/') { |
|
| 118 | + break; |
|
| 119 | + } elseif ($this->a === '\\') { |
|
| 120 | + $this->output .= $this->a; |
|
| 121 | + $this->a = $this->get(); |
|
| 122 | + } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 123 | + throw new JSMinException('Unterminated regular expression '. |
|
| 124 | + 'literal.'); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $this->output .= $this->a; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $this->b = $this->next(); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | protected function get() { |
| 136 | - $c = $this->lookAhead; |
|
| 137 | - $this->lookAhead = null; |
|
| 138 | - |
|
| 139 | - if ($c === null) { |
|
| 140 | - if ($this->inputIndex < $this->inputLength) { |
|
| 141 | - $c = $this->input[$this->inputIndex]; |
|
| 142 | - $this->inputIndex += 1; |
|
| 143 | - } else { |
|
| 144 | - $c = null; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - if ($c === "\r") { |
|
| 149 | - return "\n"; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 153 | - return $c; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return ' '; |
|
| 136 | + $c = $this->lookAhead; |
|
| 137 | + $this->lookAhead = null; |
|
| 138 | + |
|
| 139 | + if ($c === null) { |
|
| 140 | + if ($this->inputIndex < $this->inputLength) { |
|
| 141 | + $c = $this->input[$this->inputIndex]; |
|
| 142 | + $this->inputIndex += 1; |
|
| 143 | + } else { |
|
| 144 | + $c = null; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + if ($c === "\r") { |
|
| 149 | + return "\n"; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 153 | + return $c; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return ' '; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | protected function isAlphaNum($c) { |
| 160 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 160 | + return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | protected function min() { |
| 164 | - $this->a = "\n"; |
|
| 165 | - $this->action(3); |
|
| 166 | - |
|
| 167 | - while ($this->a !== null) { |
|
| 168 | - switch ($this->a) { |
|
| 169 | - case ' ': |
|
| 170 | - if ($this->isAlphaNum($this->b)) { |
|
| 171 | - $this->action(1); |
|
| 172 | - } else { |
|
| 173 | - $this->action(2); |
|
| 174 | - } |
|
| 175 | - break; |
|
| 176 | - |
|
| 177 | - case "\n": |
|
| 178 | - switch ($this->b) { |
|
| 179 | - case '{': |
|
| 180 | - case '[': |
|
| 181 | - case '(': |
|
| 182 | - case '+': |
|
| 183 | - case '-': |
|
| 184 | - $this->action(1); |
|
| 185 | - break; |
|
| 186 | - |
|
| 187 | - case ' ': |
|
| 188 | - $this->action(3); |
|
| 189 | - break; |
|
| 190 | - |
|
| 191 | - default: |
|
| 192 | - if ($this->isAlphaNum($this->b)) { |
|
| 193 | - $this->action(1); |
|
| 194 | - } |
|
| 195 | - else { |
|
| 196 | - $this->action(2); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - |
|
| 201 | - default: |
|
| 202 | - switch ($this->b) { |
|
| 203 | - case ' ': |
|
| 204 | - if ($this->isAlphaNum($this->a)) { |
|
| 205 | - $this->action(1); |
|
| 206 | - break; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - $this->action(3); |
|
| 210 | - break; |
|
| 211 | - |
|
| 212 | - case "\n": |
|
| 213 | - switch ($this->a) { |
|
| 214 | - case '}': |
|
| 215 | - case ']': |
|
| 216 | - case ')': |
|
| 217 | - case '+': |
|
| 218 | - case '-': |
|
| 219 | - case '"': |
|
| 220 | - case "'": |
|
| 221 | - $this->action(1); |
|
| 222 | - break; |
|
| 223 | - |
|
| 224 | - default: |
|
| 225 | - if ($this->isAlphaNum($this->a)) { |
|
| 226 | - $this->action(1); |
|
| 227 | - } |
|
| 228 | - else { |
|
| 229 | - $this->action(3); |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - break; |
|
| 233 | - |
|
| 234 | - default: |
|
| 235 | - $this->action(1); |
|
| 236 | - break; |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $this->output; |
|
| 164 | + $this->a = "\n"; |
|
| 165 | + $this->action(3); |
|
| 166 | + |
|
| 167 | + while ($this->a !== null) { |
|
| 168 | + switch ($this->a) { |
|
| 169 | + case ' ': |
|
| 170 | + if ($this->isAlphaNum($this->b)) { |
|
| 171 | + $this->action(1); |
|
| 172 | + } else { |
|
| 173 | + $this->action(2); |
|
| 174 | + } |
|
| 175 | + break; |
|
| 176 | + |
|
| 177 | + case "\n": |
|
| 178 | + switch ($this->b) { |
|
| 179 | + case '{': |
|
| 180 | + case '[': |
|
| 181 | + case '(': |
|
| 182 | + case '+': |
|
| 183 | + case '-': |
|
| 184 | + $this->action(1); |
|
| 185 | + break; |
|
| 186 | + |
|
| 187 | + case ' ': |
|
| 188 | + $this->action(3); |
|
| 189 | + break; |
|
| 190 | + |
|
| 191 | + default: |
|
| 192 | + if ($this->isAlphaNum($this->b)) { |
|
| 193 | + $this->action(1); |
|
| 194 | + } |
|
| 195 | + else { |
|
| 196 | + $this->action(2); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + |
|
| 201 | + default: |
|
| 202 | + switch ($this->b) { |
|
| 203 | + case ' ': |
|
| 204 | + if ($this->isAlphaNum($this->a)) { |
|
| 205 | + $this->action(1); |
|
| 206 | + break; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + $this->action(3); |
|
| 210 | + break; |
|
| 211 | + |
|
| 212 | + case "\n": |
|
| 213 | + switch ($this->a) { |
|
| 214 | + case '}': |
|
| 215 | + case ']': |
|
| 216 | + case ')': |
|
| 217 | + case '+': |
|
| 218 | + case '-': |
|
| 219 | + case '"': |
|
| 220 | + case "'": |
|
| 221 | + $this->action(1); |
|
| 222 | + break; |
|
| 223 | + |
|
| 224 | + default: |
|
| 225 | + if ($this->isAlphaNum($this->a)) { |
|
| 226 | + $this->action(1); |
|
| 227 | + } |
|
| 228 | + else { |
|
| 229 | + $this->action(3); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + break; |
|
| 233 | + |
|
| 234 | + default: |
|
| 235 | + $this->action(1); |
|
| 236 | + break; |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $this->output; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | protected function next() { |
| 245 | - $c = $this->get(); |
|
| 246 | - |
|
| 247 | - if ($c === '/') { |
|
| 248 | - switch($this->peek()) { |
|
| 249 | - case '/': |
|
| 250 | - for (;;) { |
|
| 251 | - $c = $this->get(); |
|
| 252 | - |
|
| 253 | - if (ord($c) <= self::ORD_LF) { |
|
| 254 | - return $c; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - case '*': |
|
| 259 | - $this->get(); |
|
| 260 | - |
|
| 261 | - for (;;) { |
|
| 262 | - switch($this->get()) { |
|
| 263 | - case '*': |
|
| 264 | - if ($this->peek() === '/') { |
|
| 265 | - $this->get(); |
|
| 266 | - return ' '; |
|
| 267 | - } |
|
| 268 | - break; |
|
| 269 | - |
|
| 270 | - case null: |
|
| 271 | - throw new JSMinException('Unterminated comment.'); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - default: |
|
| 276 | - return $c; |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - return $c; |
|
| 245 | + $c = $this->get(); |
|
| 246 | + |
|
| 247 | + if ($c === '/') { |
|
| 248 | + switch($this->peek()) { |
|
| 249 | + case '/': |
|
| 250 | + for (;;) { |
|
| 251 | + $c = $this->get(); |
|
| 252 | + |
|
| 253 | + if (ord($c) <= self::ORD_LF) { |
|
| 254 | + return $c; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + case '*': |
|
| 259 | + $this->get(); |
|
| 260 | + |
|
| 261 | + for (;;) { |
|
| 262 | + switch($this->get()) { |
|
| 263 | + case '*': |
|
| 264 | + if ($this->peek() === '/') { |
|
| 265 | + $this->get(); |
|
| 266 | + return ' '; |
|
| 267 | + } |
|
| 268 | + break; |
|
| 269 | + |
|
| 270 | + case null: |
|
| 271 | + throw new JSMinException('Unterminated comment.'); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + default: |
|
| 276 | + return $c; |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + return $c; |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | protected function peek() { |
| 284 | - $this->lookAhead = $this->get(); |
|
| 285 | - return $this->lookAhead; |
|
| 284 | + $this->lookAhead = $this->get(); |
|
| 285 | + return $this->lookAhead; |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | default: |
| 192 | 192 | if ($this->isAlphaNum($this->b)) { |
| 193 | 193 | $this->action(1); |
| 194 | - } |
|
| 195 | - else { |
|
| 194 | + } else { |
|
| 196 | 195 | $this->action(2); |
| 197 | 196 | } |
| 198 | 197 | } |
@@ -224,8 +223,7 @@ discard block |
||
| 224 | 223 | default: |
| 225 | 224 | if ($this->isAlphaNum($this->a)) { |
| 226 | 225 | $this->action(1); |
| 227 | - } |
|
| 228 | - else { |
|
| 226 | + } else { |
|
| 229 | 227 | $this->action(3); |
| 230 | 228 | } |
| 231 | 229 | } |
@@ -46,29 +46,29 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | 48 | class JSMin { |
| 49 | - const ORD_LF = 10; |
|
| 50 | - const ORD_SPACE = 32; |
|
| 49 | + const ORD_LF=10; |
|
| 50 | + const ORD_SPACE=32; |
|
| 51 | 51 | |
| 52 | - protected $a = ''; |
|
| 53 | - protected $b = ''; |
|
| 54 | - protected $input = ''; |
|
| 55 | - protected $inputIndex = 0; |
|
| 56 | - protected $inputLength = 0; |
|
| 57 | - protected $lookAhead = null; |
|
| 58 | - protected $output = ''; |
|
| 52 | + protected $a=''; |
|
| 53 | + protected $b=''; |
|
| 54 | + protected $input=''; |
|
| 55 | + protected $inputIndex=0; |
|
| 56 | + protected $inputLength=0; |
|
| 57 | + protected $lookAhead=null; |
|
| 58 | + protected $output=''; |
|
| 59 | 59 | |
| 60 | 60 | // -- Public Static Methods -------------------------------------------------- |
| 61 | 61 | |
| 62 | 62 | public static function minify($js) { |
| 63 | - $jsmin = new JSMin($js); |
|
| 63 | + $jsmin=new JSMin($js); |
|
| 64 | 64 | return $jsmin->min(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // -- Public Instance Methods ------------------------------------------------ |
| 68 | 68 | |
| 69 | 69 | public function __construct($input) { |
| 70 | - $this->input = str_replace("\r\n", "\n", $input); |
|
| 71 | - $this->inputLength = strlen($this->input); |
|
| 70 | + $this->input=str_replace("\r\n", "\n", $input); |
|
| 71 | + $this->inputLength=strlen($this->input); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
@@ -76,80 +76,80 @@ discard block |
||
| 76 | 76 | protected function action($d) { |
| 77 | 77 | switch($d) { |
| 78 | 78 | case 1: |
| 79 | - $this->output .= $this->a; |
|
| 79 | + $this->output.=$this->a; |
|
| 80 | 80 | |
| 81 | 81 | case 2: |
| 82 | - $this->a = $this->b; |
|
| 82 | + $this->a=$this->b; |
|
| 83 | 83 | |
| 84 | - if ($this->a === "'" || $this->a === '"') { |
|
| 85 | - for (;;) { |
|
| 86 | - $this->output .= $this->a; |
|
| 87 | - $this->a = $this->get(); |
|
| 84 | + if($this->a==="'" || $this->a==='"') { |
|
| 85 | + for(;;) { |
|
| 86 | + $this->output.=$this->a; |
|
| 87 | + $this->a=$this->get(); |
|
| 88 | 88 | |
| 89 | - if ($this->a === $this->b) { |
|
| 89 | + if($this->a===$this->b) { |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if (ord($this->a) <= self::ORD_LF) { |
|
| 93 | + if(ord($this->a) <= self::ORD_LF) { |
|
| 94 | 94 | throw new JSMinException('Unterminated string literal.'); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if ($this->a === '\\') { |
|
| 98 | - $this->output .= $this->a; |
|
| 99 | - $this->a = $this->get(); |
|
| 97 | + if($this->a==='\\') { |
|
| 98 | + $this->output.=$this->a; |
|
| 99 | + $this->a=$this->get(); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | case 3: |
| 105 | - $this->b = $this->next(); |
|
| 105 | + $this->b=$this->next(); |
|
| 106 | 106 | |
| 107 | - if ($this->b === '/' && ( |
|
| 108 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 109 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 110 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 107 | + if($this->b==='/' && ( |
|
| 108 | + $this->a==='(' || $this->a===',' || $this->a==='=' || |
|
| 109 | + $this->a===':' || $this->a==='[' || $this->a==='!' || |
|
| 110 | + $this->a==='&' || $this->a==='|' || $this->a==='?')) { |
|
| 111 | 111 | |
| 112 | - $this->output .= $this->a . $this->b; |
|
| 112 | + $this->output.=$this->a.$this->b; |
|
| 113 | 113 | |
| 114 | - for (;;) { |
|
| 115 | - $this->a = $this->get(); |
|
| 114 | + for(;;) { |
|
| 115 | + $this->a=$this->get(); |
|
| 116 | 116 | |
| 117 | - if ($this->a === '/') { |
|
| 117 | + if($this->a==='/') { |
|
| 118 | 118 | break; |
| 119 | - } elseif ($this->a === '\\') { |
|
| 120 | - $this->output .= $this->a; |
|
| 121 | - $this->a = $this->get(); |
|
| 122 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 119 | + } elseif($this->a==='\\') { |
|
| 120 | + $this->output.=$this->a; |
|
| 121 | + $this->a=$this->get(); |
|
| 122 | + } elseif(ord($this->a) <= self::ORD_LF) { |
|
| 123 | 123 | throw new JSMinException('Unterminated regular expression '. |
| 124 | 124 | 'literal.'); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $this->output .= $this->a; |
|
| 127 | + $this->output.=$this->a; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $this->b = $this->next(); |
|
| 130 | + $this->b=$this->next(); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | protected function get() { |
| 136 | - $c = $this->lookAhead; |
|
| 137 | - $this->lookAhead = null; |
|
| 136 | + $c=$this->lookAhead; |
|
| 137 | + $this->lookAhead=null; |
|
| 138 | 138 | |
| 139 | - if ($c === null) { |
|
| 140 | - if ($this->inputIndex < $this->inputLength) { |
|
| 141 | - $c = $this->input[$this->inputIndex]; |
|
| 142 | - $this->inputIndex += 1; |
|
| 139 | + if($c===null) { |
|
| 140 | + if($this->inputIndex < $this->inputLength) { |
|
| 141 | + $c=$this->input[$this->inputIndex]; |
|
| 142 | + $this->inputIndex+=1; |
|
| 143 | 143 | } else { |
| 144 | - $c = null; |
|
| 144 | + $c=null; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if ($c === "\r") { |
|
| 148 | + if($c==="\r") { |
|
| 149 | 149 | return "\n"; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 152 | + if($c===null || $c==="\n" || ord($c) >= self::ORD_SPACE) { |
|
| 153 | 153 | return $c; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | protected function isAlphaNum($c) { |
| 160 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 160 | + return ord($c) > 126 || $c==='\\' || preg_match('/^[\w\$]$/', $c)===1; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | protected function min() { |
| 164 | - $this->a = "\n"; |
|
| 164 | + $this->a="\n"; |
|
| 165 | 165 | $this->action(3); |
| 166 | 166 | |
| 167 | - while ($this->a !== null) { |
|
| 168 | - switch ($this->a) { |
|
| 167 | + while($this->a!==null) { |
|
| 168 | + switch($this->a) { |
|
| 169 | 169 | case ' ': |
| 170 | - if ($this->isAlphaNum($this->b)) { |
|
| 170 | + if($this->isAlphaNum($this->b)) { |
|
| 171 | 171 | $this->action(1); |
| 172 | 172 | } else { |
| 173 | 173 | $this->action(2); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | break; |
| 176 | 176 | |
| 177 | 177 | case "\n": |
| 178 | - switch ($this->b) { |
|
| 178 | + switch($this->b) { |
|
| 179 | 179 | case '{': |
| 180 | 180 | case '[': |
| 181 | 181 | case '(': |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | break; |
| 190 | 190 | |
| 191 | 191 | default: |
| 192 | - if ($this->isAlphaNum($this->b)) { |
|
| 192 | + if($this->isAlphaNum($this->b)) { |
|
| 193 | 193 | $this->action(1); |
| 194 | 194 | } |
| 195 | 195 | else { |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | break; |
| 200 | 200 | |
| 201 | 201 | default: |
| 202 | - switch ($this->b) { |
|
| 202 | + switch($this->b) { |
|
| 203 | 203 | case ' ': |
| 204 | - if ($this->isAlphaNum($this->a)) { |
|
| 204 | + if($this->isAlphaNum($this->a)) { |
|
| 205 | 205 | $this->action(1); |
| 206 | 206 | break; |
| 207 | 207 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | break; |
| 211 | 211 | |
| 212 | 212 | case "\n": |
| 213 | - switch ($this->a) { |
|
| 213 | + switch($this->a) { |
|
| 214 | 214 | case '}': |
| 215 | 215 | case ']': |
| 216 | 216 | case ')': |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | break; |
| 223 | 223 | |
| 224 | 224 | default: |
| 225 | - if ($this->isAlphaNum($this->a)) { |
|
| 225 | + if($this->isAlphaNum($this->a)) { |
|
| 226 | 226 | $this->action(1); |
| 227 | 227 | } |
| 228 | 228 | else { |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | protected function next() { |
| 245 | - $c = $this->get(); |
|
| 245 | + $c=$this->get(); |
|
| 246 | 246 | |
| 247 | - if ($c === '/') { |
|
| 247 | + if($c==='/') { |
|
| 248 | 248 | switch($this->peek()) { |
| 249 | 249 | case '/': |
| 250 | - for (;;) { |
|
| 251 | - $c = $this->get(); |
|
| 250 | + for(;;) { |
|
| 251 | + $c=$this->get(); |
|
| 252 | 252 | |
| 253 | - if (ord($c) <= self::ORD_LF) { |
|
| 253 | + if(ord($c) <= self::ORD_LF) { |
|
| 254 | 254 | return $c; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | case '*': |
| 259 | 259 | $this->get(); |
| 260 | 260 | |
| 261 | - for (;;) { |
|
| 261 | + for(;;) { |
|
| 262 | 262 | switch($this->get()) { |
| 263 | 263 | case '*': |
| 264 | - if ($this->peek() === '/') { |
|
| 264 | + if($this->peek()==='/') { |
|
| 265 | 265 | $this->get(); |
| 266 | 266 | return ' '; |
| 267 | 267 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | protected function peek() { |
| 284 | - $this->lookAhead = $this->get(); |
|
| 284 | + $this->lookAhead=$this->get(); |
|
| 285 | 285 | return $this->lookAhead; |
| 286 | 286 | } |
| 287 | 287 | } |