GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b130b6...8a2f54 )
by gyeong-won
07:36
created
modules/spamfilter/spamfilter.admin.controller.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -98,6 +98,7 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * @brief Delete IP
100 100
 	 * Remove the IP address which was previously registered as a spammers
101
+	 * @param string $ipaddress
101 102
 	 */
102 103
 	function deleteIP($ipaddress)
103 104
 	{
@@ -111,6 +112,7 @@  discard block
 block discarded – undo
111 112
 	/**
112 113
 	 * @brief Register the spam word
113 114
 	 * The post, which contains the newly registered spam word, should be considered as a spam
115
+	 * @param string $word_list
114 116
 	 */
115 117
 	function insertWord($word_list)
116 118
 	{
@@ -141,6 +143,7 @@  discard block
 block discarded – undo
141 143
 	/**
142 144
 	 * @brief Remove the spam word
143 145
 	 * Remove the word which was previously registered as a spam word
146
+	 * @param string $word
144 147
 	 */
145 148
 	function deleteWord($word)
146 149
 	{
Please login to merge, or discard this patch.
Braces   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,12 +20,18 @@  discard block
 block discarded – undo
20 20
 		$argsConfig = Context::gets('limits','check_trackback');
21 21
 		$flag = Context::get('flag');
22 22
 		//interval, limit_count
23
-		if($argsConfig->check_trackback!='Y') $argsConfig->check_trackback = 'N';
24
-		if($argsConfig->limits!='Y') $argsConfig->limits = 'N';
23
+		if($argsConfig->check_trackback!='Y') {
24
+			$argsConfig->check_trackback = 'N';
25
+		}
26
+		if($argsConfig->limits!='Y') {
27
+			$argsConfig->limits = 'N';
28
+		}
25 29
 		// Create and insert the module Controller object
26 30
 		$oModuleController = getController('module');
27 31
 		$moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter',$argsConfig);
28
-		if(!$moduleConfigOutput->toBool()) return $moduleConfigOutput;
32
+		if(!$moduleConfigOutput->toBool()) {
33
+			return $moduleConfigOutput;
34
+		}
29 35
 
30 36
 		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminConfigBlock');
31 37
 		$this->setRedirectUrl($returnUrl);
@@ -39,9 +45,13 @@  discard block
 block discarded – undo
39 45
 		if($ipaddress_list)
40 46
 		{
41 47
 			$output = $oSpamfilterController->insertIP($ipaddress_list);
42
-			if(!$output->toBool() && !$output->get('fail_list')) return $output;
48
+			if(!$output->toBool() && !$output->get('fail_list')) {
49
+				return $output;
50
+			}
43 51
 
44
-			if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
52
+			if($output->get('fail_list')) {
53
+				$message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
54
+			}
45 55
 			$this->setMessage(Context::getLang('success_registed').$message_fail);
46 56
 		}
47 57
 
@@ -57,9 +67,13 @@  discard block
 block discarded – undo
57 67
 		if($word_list)
58 68
 		{
59 69
 			$output = $this->insertWord($word_list);
60
-			if(!$output->toBool() && !$output->get('fail_list')) return $output;
70
+			if(!$output->toBool() && !$output->get('fail_list')) {
71
+				return $output;
72
+			}
61 73
 
62
-			if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
74
+			if($output->get('fail_list')) {
75
+				$message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
76
+			}
63 77
 			$this->setMessage(Context::getLang('success_registed').$message_fail);
64 78
 		}
65 79
 
@@ -73,7 +87,9 @@  discard block
 block discarded – undo
73 87
 	function procSpamfilterAdminDeleteDeniedIP()
74 88
 	{
75 89
 		$ipAddressList = Context::get('ipaddress');
76
-		if($ipAddressList) $this->deleteIP($ipAddressList);
90
+		if($ipAddressList) {
91
+			$this->deleteIP($ipAddressList);
92
+		}
77 93
 
78 94
 		$this->setMessage(Context::getLang('success_deleted'));
79 95
 
@@ -101,7 +117,9 @@  discard block
 block discarded – undo
101 117
 	 */
102 118
 	function deleteIP($ipaddress)
103 119
 	{
104
-		if(!$ipaddress) return;
120
+		if(!$ipaddress) {
121
+			return;
122
+		}
105 123
 
106 124
 		$args = new stdClass;
107 125
 		$args->ipaddress = $ipaddress;
@@ -130,9 +148,13 @@  discard block
 block discarded – undo
130 148
 		foreach($word_list as $word)
131 149
 		{
132 150
 			$args = new stdClass;
133
-			if(trim($word)) $args->word = $word;
151
+			if(trim($word)) {
152
+				$args->word = $word;
153
+			}
134 154
 			$output = executeQuery('spamfilter.insertDeniedWord', $args);
135
-			if(!$output->toBool()) $fail_word .= $word.'<br />';
155
+			if(!$output->toBool()) {
156
+				$fail_word .= $word.'<br />';
157
+			}
136 158
 		}
137 159
 		$output->add('fail_list',$fail_word);
138 160
 		return $output;
@@ -144,7 +166,9 @@  discard block
 block discarded – undo
144 166
 	 */
145 167
 	function deleteWord($word)
146 168
 	{
147
-		if(!$word) return;
169
+		if(!$word) {
170
+			return;
171
+		}
148 172
 		$args = new stdClass;
149 173
 		$args->word = $word;
150 174
 		return executeQuery('spamfilter.deleteDeniedWord', $args);
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
 	function procSpamfilterAdminInsertConfig()
18 18
 	{
19 19
 		// Get the default information
20
-		$argsConfig = Context::gets('limits','check_trackback');
20
+		$argsConfig = Context::gets('limits', 'check_trackback');
21 21
 		$flag = Context::get('flag');
22 22
 		//interval, limit_count
23
-		if($argsConfig->check_trackback!='Y') $argsConfig->check_trackback = 'N';
24
-		if($argsConfig->limits!='Y') $argsConfig->limits = 'N';
23
+		if ($argsConfig->check_trackback != 'Y') $argsConfig->check_trackback = 'N';
24
+		if ($argsConfig->limits != 'Y') $argsConfig->limits = 'N';
25 25
 		// Create and insert the module Controller object
26 26
 		$oModuleController = getController('module');
27
-		$moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter',$argsConfig);
28
-		if(!$moduleConfigOutput->toBool()) return $moduleConfigOutput;
27
+		$moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter', $argsConfig);
28
+		if (!$moduleConfigOutput->toBool()) return $moduleConfigOutput;
29 29
 
30 30
 		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminConfigBlock');
31 31
 		$this->setRedirectUrl($returnUrl);
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 		//스팸IP  추가
37 37
 		$ipaddress_list = Context::get('ipaddress_list');
38 38
 		$oSpamfilterController = getController('spamfilter');
39
-		if($ipaddress_list)
39
+		if ($ipaddress_list)
40 40
 		{
41 41
 			$output = $oSpamfilterController->insertIP($ipaddress_list);
42
-			if(!$output->toBool() && !$output->get('fail_list')) return $output;
42
+			if (!$output->toBool() && !$output->get('fail_list')) return $output;
43 43
 
44
-			if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
44
+			if ($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'), $output->get('fail_list')).'</em>';
45 45
 			$this->setMessage(Context::getLang('success_registed').$message_fail);
46 46
 		}
47 47
 
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 	{
55 55
 		//스팸 키워드 추가
56 56
 		$word_list = Context::get('word_list');
57
-		if($word_list)
57
+		if ($word_list)
58 58
 		{
59 59
 			$output = $this->insertWord($word_list);
60
-			if(!$output->toBool() && !$output->get('fail_list')) return $output;
60
+			if (!$output->toBool() && !$output->get('fail_list')) return $output;
61 61
 
62
-			if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
62
+			if ($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'), $output->get('fail_list')).'</em>';
63 63
 			$this->setMessage(Context::getLang('success_registed').$message_fail);
64 64
 		}
65 65
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	function procSpamfilterAdminDeleteDeniedIP()
74 74
 	{
75 75
 		$ipAddressList = Context::get('ipaddress');
76
-		if($ipAddressList) $this->deleteIP($ipAddressList);
76
+		if ($ipAddressList) $this->deleteIP($ipAddressList);
77 77
 
78 78
 		$this->setMessage(Context::getLang('success_deleted'));
79 79
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$this->setMessage(Context::getLang('success_deleted'));
93 93
 
94
-		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList','active','word');
94
+		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList', 'active', 'word');
95 95
 		return $this->setRedirectUrl($returnUrl);
96 96
 	}
97 97
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	function deleteIP($ipaddress)
103 103
 	{
104
-		if(!$ipaddress) return;
104
+		if (!$ipaddress) return;
105 105
 
106 106
 		$args = new stdClass;
107 107
 		$args->ipaddress = $ipaddress;
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
 	function insertWord($word_list)
116 116
 	{
117 117
 
118
-		$word_list = str_replace("\r","",$word_list);
119
-		$word_list = explode("\n",$word_list);
118
+		$word_list = str_replace("\r", "", $word_list);
119
+		$word_list = explode("\n", $word_list);
120 120
 
121
-		foreach($word_list as $word)
121
+		foreach ($word_list as $word)
122 122
 		{
123
-			if(!preg_match("/^(.{2,40}[\r\n]+)*.{2,40}$/", $word))
123
+			if (!preg_match("/^(.{2,40}[\r\n]+)*.{2,40}$/", $word))
124 124
 			{
125 125
 				return new BaseObject(-1, 'msg_invalid');
126 126
 			}
127 127
 		}
128 128
 
129 129
 		$fail_word = '';
130
-		foreach($word_list as $word)
130
+		foreach ($word_list as $word)
131 131
 		{
132 132
 			$args = new stdClass;
133
-			if(trim($word)) $args->word = $word;
133
+			if (trim($word)) $args->word = $word;
134 134
 			$output = executeQuery('spamfilter.insertDeniedWord', $args);
135
-			if(!$output->toBool()) $fail_word .= $word.'<br />';
135
+			if (!$output->toBool()) $fail_word .= $word.'<br />';
136 136
 		}
137
-		$output->add('fail_list',$fail_word);
137
+		$output->add('fail_list', $fail_word);
138 138
 		return $output;
139 139
 	}
140 140
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	function deleteWord($word)
146 146
 	{
147
-		if(!$word) return;
147
+		if (!$word) return;
148 148
 		$args = new stdClass;
149 149
 		$args->word = $word;
150 150
 		return executeQuery('spamfilter.deleteDeniedWord', $args);
Please login to merge, or discard this patch.
modules/spamfilter/spamfilter.controller.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -161,6 +161,8 @@
 block discarded – undo
161 161
 	/**
162 162
 	 * @brief IP registration
163 163
 	 * The registered IP address is considered as a spammer
164
+	 * @param string $ipaddress_list
165
+	 * @param string $description
164 166
 	 */
165 167
 	function insertIP($ipaddress_list, $description = null)
166 168
 	{
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -27,39 +27,39 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	function triggerInsertDocument(&$obj)
29 29
 	{
30
-		if($_SESSION['avoid_log']) return new BaseObject();
30
+		if ($_SESSION['avoid_log']) return new BaseObject();
31 31
 		// Check the login status, login information, and permission
32 32
 		$is_logged = Context::get('is_logged');
33 33
 		$logged_info = Context::get('logged_info');
34 34
 		$grant = Context::get('grant');
35 35
 		// In case logged in, check if it is an administrator
36
-		if($is_logged)
36
+		if ($is_logged)
37 37
 		{
38
-			if($logged_info->is_admin == 'Y') return new BaseObject();
39
-			if($grant->manager) return new BaseObject();
38
+			if ($logged_info->is_admin == 'Y') return new BaseObject();
39
+			if ($grant->manager) return new BaseObject();
40 40
 		}
41 41
 
42 42
 		$oFilterModel = getModel('spamfilter');
43 43
 		// Check if the IP is prohibited
44 44
 		$output = $oFilterModel->isDeniedIP();
45
-		if(!$output->toBool()) return $output;
45
+		if (!$output->toBool()) return $output;
46 46
 		// Check if there is a ban on the word
47 47
 		$text = '';
48
-		if($is_logged)
48
+		if ($is_logged)
49 49
 		{
50
-			$text = $obj->title . ' ' . $obj->content . ' ' . $obj->tags;
50
+			$text = $obj->title.' '.$obj->content.' '.$obj->tags;
51 51
 		}
52 52
 		else
53 53
 		{
54
-			$text = $obj->title . ' ' . $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage . ' ' . $obj->tags;	
54
+			$text = $obj->title.' '.$obj->content.' '.$obj->nick_name.' '.$obj->homepage.' '.$obj->tags;	
55 55
 		}
56 56
 		$output = $oFilterModel->isDeniedWord($text);
57
-		if(!$output->toBool()) return $output;
57
+		if (!$output->toBool()) return $output;
58 58
 		// Check the specified time beside the modificaiton time
59
-		if($obj->document_srl == 0)
59
+		if ($obj->document_srl == 0)
60 60
 		{
61 61
 			$output = $oFilterModel->checkLimited();
62
-			if(!$output->toBool()) return $output;
62
+			if (!$output->toBool()) return $output;
63 63
 		}
64 64
 		// Save a log
65 65
 		$this->insertLog();
@@ -72,39 +72,39 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	function triggerInsertComment(&$obj)
74 74
 	{
75
-		if($_SESSION['avoid_log']) return new BaseObject();
75
+		if ($_SESSION['avoid_log']) return new BaseObject();
76 76
 		// Check the login status, login information, and permission
77 77
 		$is_logged = Context::get('is_logged');
78 78
 		$logged_info = Context::get('logged_info');
79 79
 		$grant = Context::get('grant');
80 80
 		// In case logged in, check if it is an administrator
81
-		if($is_logged)
81
+		if ($is_logged)
82 82
 		{
83
-			if($logged_info->is_admin == 'Y') return new BaseObject();
84
-			if($grant->manager) return new BaseObject();
83
+			if ($logged_info->is_admin == 'Y') return new BaseObject();
84
+			if ($grant->manager) return new BaseObject();
85 85
 		}
86 86
 
87 87
 		$oFilterModel = getModel('spamfilter');
88 88
 		// Check if the IP is prohibited
89 89
 		$output = $oFilterModel->isDeniedIP();
90
-		if(!$output->toBool()) return $output;
90
+		if (!$output->toBool()) return $output;
91 91
 		// Check if there is a ban on the word
92 92
 		$text = '';
93
-		if($is_logged)
93
+		if ($is_logged)
94 94
 		{
95 95
 			$text = $obj->content;
96 96
 		}
97 97
 		else
98 98
 		{
99
-			$text = $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage;	
99
+			$text = $obj->content.' '.$obj->nick_name.' '.$obj->homepage;	
100 100
 		}
101 101
 		$output = $oFilterModel->isDeniedWord($text);
102
-		if(!$output->toBool()) return $output;
102
+		if (!$output->toBool()) return $output;
103 103
 		// If the specified time check is not modified
104
-		if(!$obj->__isupdate)
104
+		if (!$obj->__isupdate)
105 105
 		{
106 106
 			$output = $oFilterModel->checkLimited();
107
-			if(!$output->toBool()) return $output;
107
+			if (!$output->toBool()) return $output;
108 108
 		}
109 109
 		unset($obj->__isupdate);
110 110
 		// Save a log
@@ -118,32 +118,32 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	function triggerInsertTrackback(&$obj)
120 120
 	{
121
-		if($_SESSION['avoid_log']) return new BaseObject();
121
+		if ($_SESSION['avoid_log']) return new BaseObject();
122 122
 
123 123
 		$oFilterModel = getModel('spamfilter');
124 124
 		// Confirm if the trackbacks have been added more than once to your document
125 125
 		$output = $oFilterModel->isInsertedTrackback($obj->document_srl);
126
-		if(!$output->toBool()) return $output;
126
+		if (!$output->toBool()) return $output;
127 127
 
128 128
 		// Check if the IP is prohibited
129 129
 		$output = $oFilterModel->isDeniedIP();
130
-		if(!$output->toBool()) return $output;
130
+		if (!$output->toBool()) return $output;
131 131
 		// Check if there is a ban on the word
132
-		$text = $obj->blog_name . ' ' . $obj->title . ' ' . $obj->excerpt . ' ' . $obj->url;
132
+		$text = $obj->blog_name.' '.$obj->title.' '.$obj->excerpt.' '.$obj->url;
133 133
 		$output = $oFilterModel->isDeniedWord($text);
134
-		if(!$output->toBool()) return $output;
134
+		if (!$output->toBool()) return $output;
135 135
 		// Start Filtering
136 136
 		$oTrackbackModel = getModel('trackback');
137 137
 		$oTrackbackController = getController('trackback');
138 138
 
139
-		list($ipA,$ipB,$ipC,$ipD) = explode('.',$_SERVER['REMOTE_ADDR']);
139
+		list($ipA, $ipB, $ipC, $ipD) = explode('.', $_SERVER['REMOTE_ADDR']);
140 140
 		$ipaddress = $ipA.'.'.$ipB.'.'.$ipC;
141 141
 		// In case the title and the blog name are indentical, investigate the IP address of the last 6 hours, delete and ban it.
142
-		if($obj->title == $obj->excerpt)
142
+		if ($obj->title == $obj->excerpt)
143 143
 		{
144
-			$oTrackbackController->deleteTrackbackSender(60*60*6, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt);
144
+			$oTrackbackController->deleteTrackbackSender(60 * 60 * 6, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt);
145 145
 			$this->insertIP($ipaddress.'.*', 'AUTO-DENIED : trackback.insertTrackback');
146
-			return new BaseObject(-1,'msg_alert_trackback_denied');
146
+			return new BaseObject(-1, 'msg_alert_trackback_denied');
147 147
 		}
148 148
 		// If trackbacks have been registered by one C-class IP address more than once for the last 30 minutes, ban the IP address and delete all the posts
149 149
 		/* 호스팅 환경을 감안하여 일단 이 부분은 동작하지 않도록 주석 처리
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 	function insertIP($ipaddress_list, $description = null)
166 166
 	{
167 167
 		$regExr = "/^((\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?)*\s*$/";
168
-		if(!preg_match($regExr,$ipaddress_list)) return new BaseObject(-1, 'msg_invalid');
169
-		$ipaddress_list = str_replace("\r","",$ipaddress_list);
170
-		$ipaddress_list = explode("\n",$ipaddress_list);
171
-		foreach($ipaddress_list as $ipaddressValue)
168
+		if (!preg_match($regExr, $ipaddress_list)) return new BaseObject(-1, 'msg_invalid');
169
+		$ipaddress_list = str_replace("\r", "", $ipaddress_list);
170
+		$ipaddress_list = explode("\n", $ipaddress_list);
171
+		foreach ($ipaddress_list as $ipaddressValue)
172 172
 		{
173 173
 			$args = new stdClass();
174
-			preg_match("/(\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?/",$ipaddressValue,$matches);
175
-			if($ipaddress=trim($matches[1]))
174
+			preg_match("/(\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?/", $ipaddressValue, $matches);
175
+			if ($ipaddress = trim($matches[1]))
176 176
 			{
177 177
 				$args->ipaddress = $ipaddress;
178
-				if(!$description && $matches[4]) $args->description = $matches[4];
178
+				if (!$description && $matches[4]) $args->description = $matches[4];
179 179
 				else $args->description = $description;
180 180
 			}
181 181
 			$output = executeQuery('spamfilter.insertDeniedIP', $args);
182
-			if(!$output->toBool()) $fail_list .= $ipaddress.'<br/>';
182
+			if (!$output->toBool()) $fail_list .= $ipaddress.'<br/>';
183 183
 		}
184 184
 
185
-		$output->add('fail_list',$fail_list);
185
+		$output->add('fail_list', $fail_list);
186 186
 		return $output;
187 187
 	}
188 188
 
@@ -191,22 +191,22 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	function triggerSendMessage(&$obj)
193 193
 	{
194
-		if($_SESSION['avoid_log']) return new BaseObject();
194
+		if ($_SESSION['avoid_log']) return new BaseObject();
195 195
 
196 196
 		$logged_info = Context::get('logged_info');
197
-		if($logged_info->is_admin == 'Y') return new BaseObject();
197
+		if ($logged_info->is_admin == 'Y') return new BaseObject();
198 198
 
199 199
 		$oFilterModel = getModel('spamfilter');
200 200
 		// Check if the IP is prohibited
201 201
 		$output = $oFilterModel->isDeniedIP();
202
-		if(!$output->toBool()) return $output;
202
+		if (!$output->toBool()) return $output;
203 203
 		// Check if there is a ban on the word
204
-		$text = $obj->title . ' ' . $obj->content;
204
+		$text = $obj->title.' '.$obj->content;
205 205
 		$output = $oFilterModel->isDeniedWord($text);
206
-		if(!$output->toBool()) return $output;
206
+		if (!$output->toBool()) return $output;
207 207
 		// Check the specified time
208 208
 		$output = $oFilterModel->checkLimited(TRUE);
209
-		if(!$output->toBool()) return $output;
209
+		if (!$output->toBool()) return $output;
210 210
 		// Save a log
211 211
 		$this->insertLog();
212 212
 
Please login to merge, or discard this patch.
Braces   +76 added lines, -29 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	function triggerInsertDocument(&$obj)
29 29
 	{
30
-		if($_SESSION['avoid_log']) return new BaseObject();
30
+		if($_SESSION['avoid_log']) {
31
+			return new BaseObject();
32
+		}
31 33
 		// Check the login status, login information, and permission
32 34
 		$is_logged = Context::get('is_logged');
33 35
 		$logged_info = Context::get('logged_info');
@@ -35,31 +37,40 @@  discard block
 block discarded – undo
35 37
 		// In case logged in, check if it is an administrator
36 38
 		if($is_logged)
37 39
 		{
38
-			if($logged_info->is_admin == 'Y') return new BaseObject();
39
-			if($grant->manager) return new BaseObject();
40
+			if($logged_info->is_admin == 'Y') {
41
+				return new BaseObject();
42
+			}
43
+			if($grant->manager) {
44
+				return new BaseObject();
45
+			}
40 46
 		}
41 47
 
42 48
 		$oFilterModel = getModel('spamfilter');
43 49
 		// Check if the IP is prohibited
44 50
 		$output = $oFilterModel->isDeniedIP();
45
-		if(!$output->toBool()) return $output;
51
+		if(!$output->toBool()) {
52
+			return $output;
53
+		}
46 54
 		// Check if there is a ban on the word
47 55
 		$text = '';
48 56
 		if($is_logged)
49 57
 		{
50 58
 			$text = $obj->title . ' ' . $obj->content . ' ' . $obj->tags;
51
-		}
52
-		else
59
+		} else
53 60
 		{
54 61
 			$text = $obj->title . ' ' . $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage . ' ' . $obj->tags;	
55 62
 		}
56 63
 		$output = $oFilterModel->isDeniedWord($text);
57
-		if(!$output->toBool()) return $output;
64
+		if(!$output->toBool()) {
65
+			return $output;
66
+		}
58 67
 		// Check the specified time beside the modificaiton time
59 68
 		if($obj->document_srl == 0)
60 69
 		{
61 70
 			$output = $oFilterModel->checkLimited();
62
-			if(!$output->toBool()) return $output;
71
+			if(!$output->toBool()) {
72
+				return $output;
73
+			}
63 74
 		}
64 75
 		// Save a log
65 76
 		$this->insertLog();
@@ -72,7 +83,9 @@  discard block
 block discarded – undo
72 83
 	 */
73 84
 	function triggerInsertComment(&$obj)
74 85
 	{
75
-		if($_SESSION['avoid_log']) return new BaseObject();
86
+		if($_SESSION['avoid_log']) {
87
+			return new BaseObject();
88
+		}
76 89
 		// Check the login status, login information, and permission
77 90
 		$is_logged = Context::get('is_logged');
78 91
 		$logged_info = Context::get('logged_info');
@@ -80,31 +93,40 @@  discard block
 block discarded – undo
80 93
 		// In case logged in, check if it is an administrator
81 94
 		if($is_logged)
82 95
 		{
83
-			if($logged_info->is_admin == 'Y') return new BaseObject();
84
-			if($grant->manager) return new BaseObject();
96
+			if($logged_info->is_admin == 'Y') {
97
+				return new BaseObject();
98
+			}
99
+			if($grant->manager) {
100
+				return new BaseObject();
101
+			}
85 102
 		}
86 103
 
87 104
 		$oFilterModel = getModel('spamfilter');
88 105
 		// Check if the IP is prohibited
89 106
 		$output = $oFilterModel->isDeniedIP();
90
-		if(!$output->toBool()) return $output;
107
+		if(!$output->toBool()) {
108
+			return $output;
109
+		}
91 110
 		// Check if there is a ban on the word
92 111
 		$text = '';
93 112
 		if($is_logged)
94 113
 		{
95 114
 			$text = $obj->content;
96
-		}
97
-		else
115
+		} else
98 116
 		{
99 117
 			$text = $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage;	
100 118
 		}
101 119
 		$output = $oFilterModel->isDeniedWord($text);
102
-		if(!$output->toBool()) return $output;
120
+		if(!$output->toBool()) {
121
+			return $output;
122
+		}
103 123
 		// If the specified time check is not modified
104 124
 		if(!$obj->__isupdate)
105 125
 		{
106 126
 			$output = $oFilterModel->checkLimited();
107
-			if(!$output->toBool()) return $output;
127
+			if(!$output->toBool()) {
128
+				return $output;
129
+			}
108 130
 		}
109 131
 		unset($obj->__isupdate);
110 132
 		// Save a log
@@ -118,20 +140,28 @@  discard block
 block discarded – undo
118 140
 	 */
119 141
 	function triggerInsertTrackback(&$obj)
120 142
 	{
121
-		if($_SESSION['avoid_log']) return new BaseObject();
143
+		if($_SESSION['avoid_log']) {
144
+			return new BaseObject();
145
+		}
122 146
 
123 147
 		$oFilterModel = getModel('spamfilter');
124 148
 		// Confirm if the trackbacks have been added more than once to your document
125 149
 		$output = $oFilterModel->isInsertedTrackback($obj->document_srl);
126
-		if(!$output->toBool()) return $output;
150
+		if(!$output->toBool()) {
151
+			return $output;
152
+		}
127 153
 
128 154
 		// Check if the IP is prohibited
129 155
 		$output = $oFilterModel->isDeniedIP();
130
-		if(!$output->toBool()) return $output;
156
+		if(!$output->toBool()) {
157
+			return $output;
158
+		}
131 159
 		// Check if there is a ban on the word
132 160
 		$text = $obj->blog_name . ' ' . $obj->title . ' ' . $obj->excerpt . ' ' . $obj->url;
133 161
 		$output = $oFilterModel->isDeniedWord($text);
134
-		if(!$output->toBool()) return $output;
162
+		if(!$output->toBool()) {
163
+			return $output;
164
+		}
135 165
 		// Start Filtering
136 166
 		$oTrackbackModel = getModel('trackback');
137 167
 		$oTrackbackController = getController('trackback');
@@ -165,7 +195,9 @@  discard block
 block discarded – undo
165 195
 	function insertIP($ipaddress_list, $description = null)
166 196
 	{
167 197
 		$regExr = "/^((\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?)*\s*$/";
168
-		if(!preg_match($regExr,$ipaddress_list)) return new BaseObject(-1, 'msg_invalid');
198
+		if(!preg_match($regExr,$ipaddress_list)) {
199
+			return new BaseObject(-1, 'msg_invalid');
200
+		}
169 201
 		$ipaddress_list = str_replace("\r","",$ipaddress_list);
170 202
 		$ipaddress_list = explode("\n",$ipaddress_list);
171 203
 		foreach($ipaddress_list as $ipaddressValue)
@@ -175,11 +207,16 @@  discard block
 block discarded – undo
175 207
 			if($ipaddress=trim($matches[1]))
176 208
 			{
177 209
 				$args->ipaddress = $ipaddress;
178
-				if(!$description && $matches[4]) $args->description = $matches[4];
179
-				else $args->description = $description;
210
+				if(!$description && $matches[4]) {
211
+					$args->description = $matches[4];
212
+				} else {
213
+					$args->description = $description;
214
+				}
180 215
 			}
181 216
 			$output = executeQuery('spamfilter.insertDeniedIP', $args);
182
-			if(!$output->toBool()) $fail_list .= $ipaddress.'<br/>';
217
+			if(!$output->toBool()) {
218
+				$fail_list .= $ipaddress.'<br/>';
219
+			}
183 220
 		}
184 221
 
185 222
 		$output->add('fail_list',$fail_list);
@@ -191,22 +228,32 @@  discard block
 block discarded – undo
191 228
 	 */
192 229
 	function triggerSendMessage(&$obj)
193 230
 	{
194
-		if($_SESSION['avoid_log']) return new BaseObject();
231
+		if($_SESSION['avoid_log']) {
232
+			return new BaseObject();
233
+		}
195 234
 
196 235
 		$logged_info = Context::get('logged_info');
197
-		if($logged_info->is_admin == 'Y') return new BaseObject();
236
+		if($logged_info->is_admin == 'Y') {
237
+			return new BaseObject();
238
+		}
198 239
 
199 240
 		$oFilterModel = getModel('spamfilter');
200 241
 		// Check if the IP is prohibited
201 242
 		$output = $oFilterModel->isDeniedIP();
202
-		if(!$output->toBool()) return $output;
243
+		if(!$output->toBool()) {
244
+			return $output;
245
+		}
203 246
 		// Check if there is a ban on the word
204 247
 		$text = $obj->title . ' ' . $obj->content;
205 248
 		$output = $oFilterModel->isDeniedWord($text);
206
-		if(!$output->toBool()) return $output;
249
+		if(!$output->toBool()) {
250
+			return $output;
251
+		}
207 252
 		// Check the specified time
208 253
 		$output = $oFilterModel->checkLimited(TRUE);
209
-		if(!$output->toBool()) return $output;
254
+		if(!$output->toBool()) {
255
+			return $output;
256
+		}
210 257
 		// Save a log
211 258
 		$this->insertLog();
212 259
 
Please login to merge, or discard this patch.
modules/tag/tag.model.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -49,6 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 	/**
51 51
 	 * @brief document_srl the import tag
52
+	 * @param stdClass $obj
52 53
 	 */
53 54
 	function getDocumentSrlByTag($obj)
54 55
 	{
@@ -70,6 +71,7 @@  discard block
 block discarded – undo
70 71
 
71 72
 	/**
72 73
 	 * @brief document used in the import tag
74
+	 * @param stdClass $obj
73 75
 	 */
74 76
 	function getDocumentsTagList($obj)
75 77
 	{
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	function getTagList($obj)
22 22
 	{
23
-		if($obj->mid)
23
+		if ($obj->mid)
24 24
 		{
25 25
 			$oModuleModel = getModel('module');
26 26
 			$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
 		// Module_srl passed the array may be a check whether the array
31 31
 		$args = new stdClass;
32
-		if(is_array($obj->module_srl))
32
+		if (is_array($obj->module_srl))
33 33
 		{
34 34
 			$args->module_srl = implode(',', $obj->module_srl);
35 35
 		}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$args->count = $obj->sort_index;
43 43
 
44 44
 		$output = executeQueryArray('tag.getTagList', $args);
45
-		if(!$output->toBool()) return $output;
45
+		if (!$output->toBool()) return $output;
46 46
 
47 47
 		return $output;
48 48
 	}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	function getDocumentSrlByTag($obj)
54 54
 	{
55 55
 		$args = new stdClass;
56
-		if(is_array($obj->module_srl))
56
+		if (is_array($obj->module_srl))
57 57
 		{
58 58
 			$args->module_srl = implode(',', $obj->module_srl);
59 59
 		}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	function getDocumentsTagList($obj)
75 75
 	{
76 76
 		$args = new stdClass;
77
-		if(is_array($obj->document_srl))
77
+		if (is_array($obj->document_srl))
78 78
 		{
79 79
 			$args->document_srl = implode(',', $obj->document_srl);
80 80
 		}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		}
85 85
 
86 86
 		$output = executeQueryArray('tag.getDocumentsTagList', $args);
87
-		if(!$output->toBool()) return $output;
87
+		if (!$output->toBool()) return $output;
88 88
 
89 89
 		return $output;
90 90
 	}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	function getTagWithUsedList($obj)
96 96
 	{
97 97
 		$args = new stdClass;
98
-		if(is_array($obj->module_srl))
98
+		if (is_array($obj->module_srl))
99 99
 		{
100 100
 			$args->module_srl = implode(',', $obj->module_srl);
101 101
 		}
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 		$output = $this->getDocumentSrlByTag($args);
109 109
 		$document_srl = array();
110 110
 
111
-		if($output->data)
111
+		if ($output->data)
112 112
 		{
113
-			foreach($output->data as $k => $v) $document_srl[] = $v->document_srl;
113
+			foreach ($output->data as $k => $v) $document_srl[] = $v->document_srl;
114 114
 		}
115 115
 		unset($args);
116 116
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
 		if(is_array($obj->module_srl))
33 33
 		{
34 34
 			$args->module_srl = implode(',', $obj->module_srl);
35
-		}
36
-		else
35
+		} else
37 36
 		{
38 37
 			$args->module_srl = $obj->module_srl;
39 38
 		}
@@ -42,7 +41,9 @@  discard block
 block discarded – undo
42 41
 		$args->count = $obj->sort_index;
43 42
 
44 43
 		$output = executeQueryArray('tag.getTagList', $args);
45
-		if(!$output->toBool()) return $output;
44
+		if(!$output->toBool()) {
45
+			return $output;
46
+		}
46 47
 
47 48
 		return $output;
48 49
 	}
@@ -56,8 +57,7 @@  discard block
 block discarded – undo
56 57
 		if(is_array($obj->module_srl))
57 58
 		{
58 59
 			$args->module_srl = implode(',', $obj->module_srl);
59
-		}
60
-		else
60
+		} else
61 61
 		{
62 62
 			$args->module_srl = $obj->module_srl;
63 63
 		}
@@ -77,14 +77,15 @@  discard block
 block discarded – undo
77 77
 		if(is_array($obj->document_srl))
78 78
 		{
79 79
 			$args->document_srl = implode(',', $obj->document_srl);
80
-		}
81
-		else
80
+		} else
82 81
 		{
83 82
 			$args->document_srl = $obj->document_srl;
84 83
 		}
85 84
 
86 85
 		$output = executeQueryArray('tag.getDocumentsTagList', $args);
87
-		if(!$output->toBool()) return $output;
86
+		if(!$output->toBool()) {
87
+			return $output;
88
+		}
88 89
 
89 90
 		return $output;
90 91
 	}
@@ -98,8 +99,7 @@  discard block
 block discarded – undo
98 99
 		if(is_array($obj->module_srl))
99 100
 		{
100 101
 			$args->module_srl = implode(',', $obj->module_srl);
101
-		}
102
-		else
102
+		} else
103 103
 		{
104 104
 			$args->module_srl = $obj->module_srl;
105 105
 		}
@@ -110,7 +110,9 @@  discard block
 block discarded – undo
110 110
 
111 111
 		if($output->data)
112 112
 		{
113
-			foreach($output->data as $k => $v) $document_srl[] = $v->document_srl;
113
+			foreach($output->data as $k => $v) {
114
+				$document_srl[] = $v->document_srl;
115
+			}
114 116
 		}
115 117
 		unset($args);
116 118
 
Please login to merge, or discard this patch.
tools/dbxml_validator/tests/xmlQueriesTest.php 4 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -27,6 +27,11 @@  discard block
 block discarded – undo
27 27
  
28 28
     // recursive glob
29 29
     // On Windows glob() is case-sensitive.
30
+
31
+    /**
32
+     * @param string $sDir
33
+     * @param integer $nFlags
34
+     */
30 35
     public function globr($sDir, $sPattern, $nFlags = NULL) 
31 36
     { 
32 37
 	// Get the list of all matching files currently in the 
@@ -129,6 +134,9 @@  discard block
 block discarded – undo
129 134
 	$this->markTestIncomplete('XML Schema Language files should be fixed first.');
130 135
     }
131 136
 
137
+    /**
138
+     * @param integer $err_code
139
+     */
132 140
     public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133 141
     {
134 142
 	$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
@@ -166,6 +174,9 @@  discard block
 block discarded – undo
166 174
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS);
167 175
     }
168 176
 
177
+    /**
178
+     * @param string $dir_name
179
+     */
169 180
     public function getDirFilesList($dir_name)
170 181
     {
171 182
 	$output = array();
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@  discard block
 block discarded – undo
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4 4
 if (!defined('__DIR__'))
5
-    define('__DIR__', realpath(dirname(__FILE__))); 
5
+	define('__DIR__', realpath(dirname(__FILE__))); 
6 6
 
7 7
 /** The tests here are meant only for the built-in checks in validator.php, 
8 8
     and not for the entire syntax expressed by the .xsd files. */
9 9
 class XmlQueriesTest extends PHPUnit_Framework_TestCase
10 10
 {
11
-    // taken from validator.php
11
+	// taken from validator.php
12 12
 
13
-    const RETCODE_VALIDATOR_INTERNAL = 60;
14
-    const RETCODE_GENERIC_XML_SYNTAX = 50;
15
-    const RETCODE_QUERY_ELEMENT = 40;
16
-    const RETCODE_XSD_VALIDATION = 30;
17
-    const RETCODE_BUILTIN_CHECKS =    20;
18
-    const RETCODE_DB_SCHEMA_MATCH =10;	// no schema match is currently implemented.
19
-    const RETCODE_SUCCESS = 0;
13
+	const RETCODE_VALIDATOR_INTERNAL = 60;
14
+	const RETCODE_GENERIC_XML_SYNTAX = 50;
15
+	const RETCODE_QUERY_ELEMENT = 40;
16
+	const RETCODE_XSD_VALIDATION = 30;
17
+	const RETCODE_BUILTIN_CHECKS =    20;
18
+	const RETCODE_DB_SCHEMA_MATCH =10;	// no schema match is currently implemented.
19
+	const RETCODE_SUCCESS = 0;
20 20
 
21
-    public $validator_cmd;
21
+	public $validator_cmd;
22 22
 
23
-    public function setUp()
24
-    {
23
+	public function setUp()
24
+	{
25 25
 	 $this->validator_cmd = "php " . escapeshellarg(__DIR__ . '/../validate.php') . " ";
26
-    }
26
+	}
27 27
  
28
-    // recursive glob
29
-    // On Windows glob() is case-sensitive.
30
-    public function globr($sDir, $sPattern, $nFlags = NULL) 
31
-    { 
28
+	// recursive glob
29
+	// On Windows glob() is case-sensitive.
30
+	public function globr($sDir, $sPattern, $nFlags = NULL) 
31
+	{ 
32 32
 	// Get the list of all matching files currently in the 
33 33
 	// directory. 
34 34
 
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
 
42 42
 	foreach ($aDirs as $sSubDir) 
43 43
 	{ 
44
-	    if ($sSubDir != '.' && $sSubDir != '..')
45
-	    {
44
+		if ($sSubDir != '.' && $sSubDir != '..')
45
+		{
46 46
 		$aSubFiles = $this->globr($sSubDir, $sPattern, $nFlags); 
47 47
 		$aFiles = array_merge($aFiles, $aSubFiles); 
48
-	    }
48
+		}
49 49
 	} 
50 50
 
51 51
 	// return merged array with all (recursive) files
52 52
 	return $aFiles; 
53
-    } 
53
+	} 
54 54
 
55
-    /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
56
-    public function invoke_testReleasedXMLLangFiles
55
+	/** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
56
+	public function invoke_testReleasedXMLLangFiles
57 57
 	(
58
-	    $released_files,
59
-	    $expected_return_code,
60
-	    $validator_args = ''
58
+		$released_files,
59
+		$expected_return_code,
60
+		$validator_args = ''
61 61
 	)
62
-    {
62
+	{
63 63
 	// this file is in tools/dbxml_validator/tests
64 64
 	$xe_dir = __DIR__ . '/../../..';
65 65
 
@@ -70,67 +70,67 @@  discard block
 block discarded – undo
70 70
 	$xml_files = array();
71 71
 
72 72
 	foreach ($released_files as $released_file_mask)
73
-	    $xml_files =
73
+		$xml_files =
74 74
 		array_merge
75 75
 		(
76
-		    $xml_files,
77
-		    $this->globr
76
+			$xml_files,
77
+			$this->globr
78 78
 			(
79
-			    $xe_dir,
80
-			    $released_file_mask,
81
-			    GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
79
+				$xe_dir,
80
+				$released_file_mask,
81
+				GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
82 82
 			)
83 83
 		);
84 84
 
85 85
 	while ($cnt < count($xml_files))
86 86
 	{
87
-	    $cmd = $this->validator_cmd . $validator_args;
87
+		$cmd = $this->validator_cmd . $validator_args;
88 88
 
89
-	    // Validate 50 files at once
90
-	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
89
+		// Validate 50 files at once
90
+		foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
91 91
 		$cmd .= " " . escapeshellarg($xml_file);
92 92
 
93
-	    exec($cmd . ' 2>&1', $validator_output, $return_code);
93
+		exec($cmd . ' 2>&1', $validator_output, $return_code);
94 94
 
95
-	    $output_text = trim(trim(implode("\n", $validator_output)), "\n");
95
+		$output_text = trim(trim(implode("\n", $validator_output)), "\n");
96 96
 
97
-	    // Validator should not crash/exit-with-an-error.
98
-	    $this->assertLessThanOrEqual
97
+		// Validator should not crash/exit-with-an-error.
98
+		$this->assertLessThanOrEqual
99 99
 		(
100
-		    $expected_return_code,
101
-		    $return_code,
102
-		    "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
100
+			$expected_return_code,
101
+			$return_code,
102
+			"{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
103 103
 		);
104 104
 
105
-	    $cnt += 50;
105
+		$cnt += 50;
106
+	}
106 107
 	}
107
-    }
108 108
 
109
-    public function testReleasedXMLQueryLangFiles()
110
-    {
109
+	public function testReleasedXMLQueryLangFiles()
110
+	{
111 111
 	$this->invoke_testReleasedXMLLangFiles
112
-	    (
112
+		(
113 113
 		array('queries/*.xml', 'xml_query/*.xml'),
114 114
 		self::RETCODE_QUERY_ELEMENT
115
-	    );
115
+		);
116 116
 
117 117
 	$this->markTestIncomplete('XML Query Language files should be fixed first.');
118
-    }
118
+	}
119 119
 
120
-    public function testReleasedXMLSchemaLangFiles()
121
-    {
120
+	public function testReleasedXMLSchemaLangFiles()
121
+	{
122 122
 	$this->invoke_testReleasedXMLLangFiles
123
-	    (
123
+		(
124 124
 		array('schemas/*.xml'),
125 125
 		self::RETCODE_BUILTIN_CHECKS,
126 126
 		' --schema-language'
127
-	    );
127
+		);
128 128
 
129 129
 	$this->markTestIncomplete('XML Schema Language files should be fixed first.');
130
-    }
130
+	}
131 131
 
132
-    public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133
-    {
132
+	public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133
+	{
134 134
 	$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
135 135
 	$validator_output = array();
136 136
 	$return_code = 0;
@@ -141,88 +141,88 @@  discard block
 block discarded – undo
141 141
 
142 142
 	// Validator should not crash/exit-with-an-error.
143 143
 	$this->assertEquals
144
-	    (
144
+		(
145 145
 		$err_code,
146 146
 		$return_code,
147 147
 		"{$cmd}\n{$output_text}\nValidator returned code {$return_code}."
148
-	    );
148
+		);
149 149
 
150 150
 	// Validator should output some error on the test files
151 151
 	$basefilename = basename($filename);
152 152
 	$this->assertNotEmpty($output_text, "Error reporting failed for {$basefilename} validation.");
153 153
 
154
-    }
154
+	}
155 155
 
156
-    public function testInvalidQueryId()
157
-    {
156
+	public function testInvalidQueryId()
157
+	{
158 158
 	return $this->invoke_testInvalidXmlFiles(__DIR__.'/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT);
159
-    }
159
+	}
160 160
 
161
-    /**
162
-     * @dataProvider getFilesList
163
-     */
164
-    public function testInvalidXMLQueryFiles($filename)
165
-    {
161
+	/**
162
+	 * @dataProvider getFilesList
163
+	 */
164
+	public function testInvalidXMLQueryFiles($filename)
165
+	{
166 166
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS);
167
-    }
167
+	}
168 168
 
169
-    public function getDirFilesList($dir_name)
170
-    {
169
+	public function getDirFilesList($dir_name)
170
+	{
171 171
 	$output = array();
172 172
 
173 173
 	$dir = opendir(__DIR__ . '/' . $dir_name);
174 174
 
175 175
 	if ($dir)
176 176
 	{
177
-	    $entry = readdir($dir);
177
+		$entry = readdir($dir);
178 178
 
179
-	    while ($entry !== FALSE)
180
-	    {
179
+		while ($entry !== FALSE)
180
+		{
181 181
 		$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
182 182
 
183 183
 		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
184
-		    $output[] = array($fname);
184
+			$output[] = array($fname);
185 185
 
186 186
 		$entry = readdir($dir);
187
-	    }
187
+		}
188 188
 
189
-	    closedir($dir);
189
+		closedir($dir);
190 190
 	}
191 191
 	else
192
-	    $this->assertFalse(TRUE);
192
+		$this->assertFalse(TRUE);
193 193
 
194
-        return $output;
195
-    }
194
+		return $output;
195
+	}
196 196
 
197
-    public function getFilesList()
198
-    {
197
+	public function getFilesList()
198
+	{
199 199
 	return $this->getDirFilesList('data');
200
-    }
200
+	}
201 201
 
202
-    public function getSchemaFilesList()
203
-    {
202
+	public function getSchemaFilesList()
203
+	{
204 204
 	return $this->getDirFilesList('data/schema');
205
-    }
205
+	}
206 206
 
207
-    public function getSchemaWarningFilesList()
208
-    {
207
+	public function getSchemaWarningFilesList()
208
+	{
209 209
 	return $this->getDirFilesList('data/schema/warnings');
210
-    }
210
+	}
211 211
 
212
-    /**
213
-     * @dataProvider getSchemaFilesList
214
-     */
215
-    public function testInvalidXMLSchemaFiles($filename)
216
-    {
212
+	/**
213
+	 * @dataProvider getSchemaFilesList
214
+	 */
215
+	public function testInvalidXMLSchemaFiles($filename)
216
+	{
217 217
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS, '--schema-language');
218
-    }
218
+	}
219 219
 
220
-    /**
221
-     * @dataProvider getSchemaWarningFilesList
222
-     */
223
-    public function testWarningXMLSchemaFiles($filename)
224
-    {
220
+	/**
221
+	 * @dataProvider getSchemaWarningFilesList
222
+	 */
223
+	public function testWarningXMLSchemaFiles($filename)
224
+	{
225 225
 	return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_SUCCESS, '--schema-language');
226
-    }
226
+	}
227 227
 }
228 228
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,8 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if (!defined('__DIR__'))
5
-    define('__DIR__', realpath(dirname(__FILE__))); 
4
+if (!defined('__DIR__')) {
5
+    define('__DIR__', realpath(dirname(__FILE__)));
6
+}
6 7
 
7 8
 /** The tests here are meant only for the built-in checks in validator.php, 
8 9
     and not for the entire syntax expressed by the .xsd files. */
@@ -69,8 +70,8 @@  discard block
 block discarded – undo
69 70
 	$cmd = $this->validator_cmd;
70 71
 	$xml_files = array();
71 72
 
72
-	foreach ($released_files as $released_file_mask)
73
-	    $xml_files =
73
+	foreach ($released_files as $released_file_mask) {
74
+		    $xml_files =
74 75
 		array_merge
75 76
 		(
76 77
 		    $xml_files,
@@ -80,15 +81,17 @@  discard block
 block discarded – undo
80 81
 			    $released_file_mask,
81 82
 			    GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
82 83
 			)
83
-		);
84
+		);
85
+	}
84 86
 
85 87
 	while ($cnt < count($xml_files))
86 88
 	{
87 89
 	    $cmd = $this->validator_cmd . $validator_args;
88 90
 
89 91
 	    // Validate 50 files at once
90
-	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
91
-		$cmd .= " " . escapeshellarg($xml_file);
92
+	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file) {
93
+	    		$cmd .= " " . escapeshellarg($xml_file);
94
+	    }
92 95
 
93 96
 	    exec($cmd . ' 2>&1', $validator_output, $return_code);
94 97
 
@@ -180,16 +183,17 @@  discard block
 block discarded – undo
180 183
 	    {
181 184
 		$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
182 185
 
183
-		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
184
-		    $output[] = array($fname);
186
+		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml') {
187
+				    $output[] = array($fname);
188
+		}
185 189
 
186 190
 		$entry = readdir($dir);
187 191
 	    }
188 192
 
189 193
 	    closedir($dir);
190
-	}
191
-	else
192
-	    $this->assertFalse(TRUE);
194
+	} else {
195
+		    $this->assertFalse(TRUE);
196
+	}
193 197
 
194 198
         return $output;
195 199
     }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -27 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     const RETCODE_GENERIC_XML_SYNTAX = 50;
15 15
     const RETCODE_QUERY_ELEMENT = 40;
16 16
     const RETCODE_XSD_VALIDATION = 30;
17
-    const RETCODE_BUILTIN_CHECKS =    20;
18
-    const RETCODE_DB_SCHEMA_MATCH =10;	// no schema match is currently implemented.
17
+    const RETCODE_BUILTIN_CHECKS = 20;
18
+    const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented.
19 19
     const RETCODE_SUCCESS = 0;
20 20
 
21 21
     public $validator_cmd;
22 22
 
23 23
     public function setUp()
24 24
     {
25
-	 $this->validator_cmd = "php " . escapeshellarg(__DIR__ . '/../validate.php') . " ";
25
+	 $this->validator_cmd = "php ".escapeshellarg(__DIR__.'/../validate.php')." ";
26 26
     }
27 27
  
28 28
     // recursive glob
@@ -53,17 +53,16 @@  discard block
 block discarded – undo
53 53
     } 
54 54
 
55 55
     /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
56
-    public function invoke_testReleasedXMLLangFiles
57
-	(
56
+    public function invoke_testReleasedXMLLangFiles(
58 57
 	    $released_files,
59 58
 	    $expected_return_code,
60 59
 	    $validator_args = ''
61 60
 	)
62 61
     {
63 62
 	// this file is in tools/dbxml_validator/tests
64
-	$xe_dir = __DIR__ . '/../../..';
63
+	$xe_dir = __DIR__.'/../../..';
65 64
 
66
-	$this->assertTrue(file_exists($xe_dir . '/index.php'), 'XE directory not found');
65
+	$this->assertTrue(file_exists($xe_dir.'/index.php'), 'XE directory not found');
67 66
 
68 67
 	$cnt = 0;
69 68
 	$cmd = $this->validator_cmd;
@@ -71,11 +70,9 @@  discard block
 block discarded – undo
71 70
 
72 71
 	foreach ($released_files as $released_file_mask)
73 72
 	    $xml_files =
74
-		array_merge
75
-		(
73
+		array_merge(
76 74
 		    $xml_files,
77
-		    $this->globr
78
-			(
75
+		    $this->globr(
79 76
 			    $xe_dir,
80 77
 			    $released_file_mask,
81 78
 			    GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
@@ -84,19 +81,18 @@  discard block
 block discarded – undo
84 81
 
85 82
 	while ($cnt < count($xml_files))
86 83
 	{
87
-	    $cmd = $this->validator_cmd . $validator_args;
84
+	    $cmd = $this->validator_cmd.$validator_args;
88 85
 
89 86
 	    // Validate 50 files at once
90 87
 	    foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
91
-		$cmd .= " " . escapeshellarg($xml_file);
88
+		$cmd .= " ".escapeshellarg($xml_file);
92 89
 
93
-	    exec($cmd . ' 2>&1', $validator_output, $return_code);
90
+	    exec($cmd.' 2>&1', $validator_output, $return_code);
94 91
 
95 92
 	    $output_text = trim(trim(implode("\n", $validator_output)), "\n");
96 93
 
97 94
 	    // Validator should not crash/exit-with-an-error.
98
-	    $this->assertLessThanOrEqual
99
-		(
95
+	    $this->assertLessThanOrEqual(
100 96
 		    $expected_return_code,
101 97
 		    $return_code,
102 98
 		    "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
@@ -108,8 +104,7 @@  discard block
 block discarded – undo
108 104
 
109 105
     public function testReleasedXMLQueryLangFiles()
110 106
     {
111
-	$this->invoke_testReleasedXMLLangFiles
112
-	    (
107
+	$this->invoke_testReleasedXMLLangFiles(
113 108
 		array('queries/*.xml', 'xml_query/*.xml'),
114 109
 		self::RETCODE_QUERY_ELEMENT
115 110
 	    );
@@ -119,8 +114,7 @@  discard block
 block discarded – undo
119 114
 
120 115
     public function testReleasedXMLSchemaLangFiles()
121 116
     {
122
-	$this->invoke_testReleasedXMLLangFiles
123
-	    (
117
+	$this->invoke_testReleasedXMLLangFiles(
124 118
 		array('schemas/*.xml'),
125 119
 		self::RETCODE_BUILTIN_CHECKS,
126 120
 		' --schema-language'
@@ -131,17 +125,16 @@  discard block
 block discarded – undo
131 125
 
132 126
     public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
133 127
     {
134
-	$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
128
+	$cmd = $this->validator_cmd.' '.$args.' '.escapeshellarg($filename);
135 129
 	$validator_output = array();
136 130
 	$return_code = 0;
137 131
 
138
-	exec($cmd . '2>&1', $validator_output, $return_code);
132
+	exec($cmd.'2>&1', $validator_output, $return_code);
139 133
 
140 134
 	$output_text = trim(trim(implode("\n", $validator_output)), "\n");
141 135
 
142 136
 	// Validator should not crash/exit-with-an-error.
143
-	$this->assertEquals
144
-	    (
137
+	$this->assertEquals(
145 138
 		$err_code,
146 139
 		$return_code,
147 140
 		"{$cmd}\n{$output_text}\nValidator returned code {$return_code}."
@@ -170,7 +163,7 @@  discard block
 block discarded – undo
170 163
     {
171 164
 	$output = array();
172 165
 
173
-	$dir = opendir(__DIR__ . '/' . $dir_name);
166
+	$dir = opendir(__DIR__.'/'.$dir_name);
174 167
 
175 168
 	if ($dir)
176 169
 	{
@@ -178,9 +171,9 @@  discard block
 block discarded – undo
178 171
 
179 172
 	    while ($entry !== FALSE)
180 173
 	    {
181
-		$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
174
+		$fname = __DIR__.'/'.$dir_name.'/'.$entry;
182 175
 
183
-		if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
176
+		if (!is_dir($fname) && $entry != 'wrongQueryId.xml')
184 177
 		    $output[] = array($fname);
185 178
 
186 179
 		$entry = readdir($dir);
Please login to merge, or discard this patch.
tools/dbxml_validator/validate.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  @return
174 174
  @param $xml_file
175 175
  @param $node
176
- @param $child_tag
176
+ @param string $child_tag
177 177
  */
178 178
 function checkDuplicateDescendants($xml_file, $node, $child_tag)
179 179
 {
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 	messages.
200 200
  @param $node
201 201
 	The XML node with the children to be checked.
202
- @param $child_tags
202
+ @param string[] $child_tags
203 203
 	Array with tag names for the children elements
204
- @param $attr_tags
204
+ @param string[] $attr_tags
205 205
 	Array with names of attributes to be checked. If multiple attributes
206 206
 	are given, than the first one that is present on a child is included
207 207
 	in the check.
208
- @param $key
208
+ @param boolean $key
209 209
 	True if child elements are required to expose at least one of the 
210 210
 	attribute. False if only the child nodes with some of the
211 211
 	attributes present are to be checked.
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 	@return
490 490
 	@param $xml_file
491 491
 	@param $container_element
492
-	@param $child_tag
492
+	@param string $child_tag
493 493
 */
494 494
 function checkVarContentsValidation
495 495
 	(
Please login to merge, or discard this patch.
Indentation   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		@param $line_no
91 91
 		@param $message
92 92
 		@access
93
-	*/
93
+	 */
94 94
 	public function __construct($file, $line_no, $message)
95 95
 	{
96 96
 		parent::__construct("{$file}({$line_no}):\n\t$message");
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	@developer
113 113
 	@return
114 114
 	@access
115
-	*/
115
+	 */
116 116
 	public function __destruct()
117 117
 	{
118 118
 		libxml_clear_errors();
@@ -834,8 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
 	@brief
836 836
 	@developer
837
-
838
-	*/
837
+	 */
839 838
 	class RestoreWorkDir
840 839
 	{
841 840
 		protected $dirname;
@@ -845,7 +844,7 @@  discard block
 block discarded – undo
845 844
 			@developer
846 845
 			@return
847 846
 			@access
848
-			*/
847
+		 */
849 848
 		public function __destruct()
850 849
 		{
851 850
 			try
@@ -868,7 +867,7 @@  discard block
 block discarded – undo
868 867
 			@developer
869 868
 			@return
870 869
 			@access
871
-			*/
870
+		 */
872 871
 		public function __construct()
873 872
 		{
874 873
 			$this->dirname = getcwd();
@@ -1113,7 +1112,7 @@  discard block
 block discarded – undo
1113 1112
 		@return
1114 1113
 		@access
1115 1114
 		@param $val
1116
-	*/
1115
+	 */
1117 1116
 	public function code($val = -1)
1118 1117
 	{
1119 1118
 		if($val == -1)
@@ -1135,7 +1134,7 @@  discard block
 block discarded – undo
1135 1134
 		@return
1136 1135
 		@access
1137 1136
 		@param $val
1138
-	*/
1137
+	 */
1139 1138
 	public function push($val)
1140 1139
 	{
1141 1140
 		$this->save = $this->exit_code;
@@ -1147,7 +1146,7 @@  discard block
 block discarded – undo
1147 1146
 		@developer
1148 1147
 		@access
1149 1148
 		@return
1150
-	*/
1149
+	 */
1151 1150
 	public function pop()
1152 1151
 	{
1153 1152
 		$this->exit_code = $this->save;
@@ -1160,7 +1159,7 @@  discard block
 block discarded – undo
1160 1159
 		@return
1161 1160
 		@access
1162 1161
 		@param $val
1163
-	*/
1162
+	 */
1164 1163
 	public function __construct($val = 0)
1165 1164
 	{
1166 1165
 		$this->save = self::RETCODE_VALIDATOR_INTERNAL;
@@ -1181,7 +1180,7 @@  discard block
 block discarded – undo
1181 1180
 		@developer
1182 1181
 		@access
1183 1182
 		@return
1184
-	*/
1183
+	 */
1185 1184
 	public function __destruct()
1186 1185
 	{
1187 1186
 		if($this->file_name)
@@ -1196,7 +1195,7 @@  discard block
 block discarded – undo
1196 1195
 		@access
1197 1196
 		@return
1198 1197
 		@param $file_name
1199
-	*/
1198
+	 */
1200 1199
 	public function __construct($file_name)
1201 1200
 	{
1202 1201
 		$this->file_name = $file_name;
@@ -1439,7 +1438,7 @@  discard block
 block discarded – undo
1439 1438
 
1440 1439
 			@brief
1441 1440
 			@developer
1442
-		*/
1441
+		 */
1443 1442
 		class Context
1444 1443
 		{
1445 1444
 			protected static $db_info = NULL;
@@ -1449,7 +1448,7 @@  discard block
 block discarded – undo
1449 1448
 				@developer
1450 1449
 				@return
1451 1450
 				@access
1452
-			*/
1451
+			 */
1453 1452
 			public static function isInstalled()
1454 1453
 			{
1455 1454
 				return TRUE;
@@ -1460,7 +1459,7 @@  discard block
 block discarded – undo
1460 1459
 				@developer
1461 1460
 				@return
1462 1461
 				@access
1463
-			*/
1462
+			 */
1464 1463
 			public static function getLangType()
1465 1464
 			{
1466 1465
 				return 'en';
@@ -1471,7 +1470,7 @@  discard block
 block discarded – undo
1471 1470
 				@developer
1472 1471
 				@return
1473 1472
 				@access
1474
-			*/
1473
+			 */
1475 1474
 			public static function getLang()
1476 1475
 			{
1477 1476
 				return 'en';
@@ -1482,7 +1481,7 @@  discard block
 block discarded – undo
1482 1481
 				@developer
1483 1482
 				@return
1484 1483
 				@access
1485
-			*/
1484
+			 */
1486 1485
 			public static function getDBType()
1487 1486
 			{
1488 1487
 				if(self::$db_info)
@@ -1501,7 +1500,7 @@  discard block
 block discarded – undo
1501 1500
 				@return
1502 1501
 				@access
1503 1502
 				@param $db_info
1504
-			*/
1503
+			 */
1505 1504
 			public static function setDBInfo($db_info)
1506 1505
 			{
1507 1506
 				self::$db_info = $db_info;
@@ -1512,7 +1511,7 @@  discard block
 block discarded – undo
1512 1511
 				@developer
1513 1512
 				@return
1514 1513
 				@access
1515
-			*/
1514
+			 */
1516 1515
 			public static function getDBInfo()
1517 1516
 			{
1518 1517
 				return self::$db_info;
@@ -1524,7 +1523,7 @@  discard block
 block discarded – undo
1524 1523
 				@return
1525 1524
 				@access
1526 1525
 				@param $str
1527
-			*/
1526
+			 */
1528 1527
 			public static function convertEncodingStr($str)
1529 1528
 			{
1530 1529
 				return $str;
@@ -1535,7 +1534,7 @@  discard block
 block discarded – undo
1535 1534
 				@developer
1536 1535
 				@return
1537 1536
 				@access
1538
-			*/
1537
+			 */
1539 1538
 			public static function setNoDBInfo()
1540 1539
 			{
1541 1540
 				$db_info = (object)NULL;
@@ -1562,7 +1561,7 @@  discard block
 block discarded – undo
1562 1561
 				@developer
1563 1562
 				@access
1564 1563
 				@return
1565
-			*/
1564
+			 */
1566 1565
 			public static function setMysqlDBInfo()
1567 1566
 			{
1568 1567
 				$db_info = (object)NULL;
@@ -1604,7 +1603,7 @@  discard block
 block discarded – undo
1604 1603
 				@developer
1605 1604
 				@return
1606 1605
 				@access
1607
-			*/
1606
+			 */
1608 1607
 			public static function setMysqliDBInfo()
1609 1608
 			{
1610 1609
 				$db_info = (object)NULL;
@@ -1646,7 +1645,7 @@  discard block
 block discarded – undo
1646 1645
 				@developer
1647 1646
 				@return
1648 1647
 				@access
1649
-			*/
1648
+			 */
1650 1649
 			public static function setCubridDBInfo()
1651 1650
 			{
1652 1651
 				$db_info = (object)NULL;
@@ -1688,7 +1687,7 @@  discard block
 block discarded – undo
1688 1687
 				@developer
1689 1688
 				@return
1690 1689
 				@access
1691
-			*/
1690
+			 */
1692 1691
 			public static function setMssqlDBInfo()
1693 1692
 			{
1694 1693
 				$db_info = (object)NULL;
@@ -1729,7 +1728,7 @@  discard block
 block discarded – undo
1729 1728
 		/**
1730 1729
 			@brief
1731 1730
 			@developer
1732
-		*/
1731
+		 */
1733 1732
 		class Any_prop_obj_base
1734 1733
 		{
1735 1734
 			/**
@@ -1738,7 +1737,7 @@  discard block
 block discarded – undo
1738 1737
 				@return
1739 1738
 				@param $property
1740 1739
 				@access
1741
-			*/
1740
+			 */
1742 1741
 			public function __get($property)
1743 1742
 			{
1744 1743
 				return NULL;
@@ -1748,7 +1747,7 @@  discard block
 block discarded – undo
1748 1747
 		/**
1749 1748
 			@brief
1750 1749
 			@developer
1751
-			*/
1750
+		 */
1752 1751
 		class LangArgFilterErrorMessage
1753 1752
 		{
1754 1753
 			/**
@@ -1757,7 +1756,7 @@  discard block
 block discarded – undo
1757 1756
 				@return
1758 1757
 				@param $property
1759 1758
 				@access
1760
-			*/
1759
+			 */
1761 1760
 			public function __get($property)
1762 1761
 			{
1763 1762
 				return 'Argument filter error';
Please login to merge, or discard this patch.
Spacing   +267 added lines, -286 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	{
96 96
 		parent::__construct("{$file}({$line_no}):\n\t$message");
97 97
 
98
-		$this->xml_file	= $file;
98
+		$this->xml_file = $file;
99 99
 		$this->xml_line_no = $line_no;
100 100
 		$this->xml_message = $message;
101 101
 	}
@@ -133,32 +133,32 @@  discard block
 block discarded – undo
133 133
 
134 134
 	$libXmlErrors = libxml_get_errors();
135 135
 
136
-	if(count($libXmlErrors))
136
+	if (count($libXmlErrors))
137 137
 	{
138
-		if(!$filename)
138
+		if (!$filename)
139 139
 		{
140 140
 			$filename = $libXmlErrors[0]->file;
141 141
 		}
142 142
 
143 143
 		$msg = '';
144 144
 
145
-		foreach($libXmlErrors as $libXmlError)
145
+		foreach ($libXmlErrors as $libXmlError)
146 146
 		{
147 147
 			$msg .= "{$libXmlError->file}({$libXmlError->line}):\n\t {$libXmlError->message}";
148 148
 		}
149 149
 
150
-		if($throw_error)
150
+		if ($throw_error)
151 151
 		{
152 152
 			throw new ErrorMessage($msg);
153 153
 		}
154 154
 		else
155 155
 		{
156
-			fwrite(STDERR, $msg . "\n");
156
+			fwrite(STDERR, $msg."\n");
157 157
 		}
158 158
 	}
159 159
 	else
160 160
 	{
161
-		if($throw_error)
161
+		if ($throw_error)
162 162
 		{
163 163
 			throw new ErrorMessage('Schema validation failed.');
164 164
 		}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 {
180 180
 	$children = $node->getElementsByTagName($child_tag);
181 181
 
182
-	if($children->length > 1)
182
+	if ($children->length > 1)
183 183
 	{
184 184
 		throw 
185 185
 			new XmlSchemaError(
@@ -217,21 +217,21 @@  discard block
 block discarded – undo
217 217
 {
218 218
 	$key_values = array();
219 219
 
220
-	foreach($node->childNodes as $child_node)
220
+	foreach ($node->childNodes as $child_node)
221 221
 	{
222
-		if($child_node->nodeType == XML_ELEMENT_NODE
222
+		if ($child_node->nodeType == XML_ELEMENT_NODE
223 223
 					&&
224 224
 				in_array($child_node->tagName, $child_tags))
225 225
 		{
226 226
 			$key_value = NULL;
227 227
 
228
-			foreach($attr_tags as $attr_tag)
228
+			foreach ($attr_tags as $attr_tag)
229 229
 			{
230
-				if($child_node->hasAttribute($attr_tag))
230
+				if ($child_node->hasAttribute($attr_tag))
231 231
 				{
232 232
 					$key_value = $child_node->getAttribute($attr_tag);
233 233
 
234
-					if(array_key_exists($key_value, $key_values))
234
+					if (array_key_exists($key_value, $key_values))
235 235
 					{
236 236
 						throw
237 237
 							new XmlSchemaError(
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				}
247 247
 			}
248 248
 
249
-			if(!$key_value && $key)
249
+			if (!$key_value && $key)
250 250
 			{
251 251
 				throw
252 252
 					new XmlSchemaError(
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 						$child_node->getLineNo(),
255 255
 						"<{$child_node->tagName}>: at least one of the following attributes is expected: "
256 256
 							.
257
-						implode(', ', $attr_tags) . '.'
257
+						implode(', ', $attr_tags).'.'
258 258
 					);
259 259
 			}
260 260
 		}
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
 	$table_name = NULL;
283 283
 	$join_type = NULL;
284 284
 
285
-	if($table_element->hasAttribute('name'))
285
+	if ($table_element->hasAttribute('name'))
286 286
 	{
287 287
 		$table_name = $table_element->getAttribute('name');
288 288
 	}
289 289
 
290
-	if($table_element->hasAttribute('type'))
290
+	if ($table_element->hasAttribute('type'))
291 291
 	{
292 292
 		$join_type = $table_element->getAttribute('type');
293 293
 	}
294 294
 
295
-	if($table_element->getAttribute('query') == 'true')
295
+	if ($table_element->getAttribute('query') == 'true')
296 296
 	{
297
-		if($table_name !== NULL)
297
+		if ($table_name !== NULL)
298 298
 		{
299 299
 			throw
300 300
 				new XmlSchemaError(
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 				);
305 305
 		}
306 306
 
307
-		if($join_type !== NULL)
307
+		if ($join_type !== NULL)
308 308
 		{
309 309
 			throw
310 310
 				new XmlSchemaError(
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 		// check contents for a select list or a table-specification
323 323
 		$has_query_clauses = FALSE;
324 324
 
325
-		foreach($table_element->childNodes as $query_clause)
325
+		foreach ($table_element->childNodes as $query_clause)
326 326
 		{
327
-			if($query_clause->nodeType == XML_ELEMENT_NODE
327
+			if ($query_clause->nodeType == XML_ELEMENT_NODE
328 328
 						&&
329 329
 					(
330 330
 						$query_clause->tagName == 'columns' 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 		}
337 337
 
338
-		if(!$has_query_clauses)
338
+		if (!$has_query_clauses)
339 339
 		{
340 340
 			throw
341 341
 				new XmlSchemaError(
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	{
352 352
 		// base table or view
353 353
 
354
-		if($join_type !== NULL)
354
+		if ($join_type !== NULL)
355 355
 		{
356 356
 			$has_conditions_element = FALSE;
357 357
 
358
-			foreach($table_element->childNodes as $child_node)
358
+			foreach ($table_element->childNodes as $child_node)
359 359
 			{
360
-				if($child_node->nodeType == XML_ELEMENT_NODE)
360
+				if ($child_node->nodeType == XML_ELEMENT_NODE)
361 361
 				{
362
-					if($child_node->tagName == 'conditions')
362
+					if ($child_node->tagName == 'conditions')
363 363
 					{
364
-						if($has_conditions_element)
364
+						if ($has_conditions_element)
365 365
 						{
366 366
 							throw
367 367
 								new XmlSchemaError(
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				}
388 388
 			}
389 389
 
390
-			if(!$has_conditions_element)
390
+			if (!$has_conditions_element)
391 391
 			{
392 392
 				throw
393 393
 					new XmlSchemaError(
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 		}
400 400
 		else
401 401
 		{
402
-			foreach($table_element->childNodes as $child_node)
402
+			foreach ($table_element->childNodes as $child_node)
403 403
 			{
404
-				if($child_node->nodeType == XML_ELEMENT_NODE)
404
+				if ($child_node->nodeType == XML_ELEMENT_NODE)
405 405
 				{
406 406
 					throw
407 407
 						new XmlSchemaError(
@@ -429,26 +429,25 @@  discard block
 block discarded – undo
429 429
  */
430 430
 function checkTablesClause($xml_file, $tables_element)
431 431
 {
432
-	checkUniqueKey
433
-		(
432
+	checkUniqueKey(
434 433
 			$xml_file,
435 434
 			$tables_element,
436
-			array('table'),				// child elements to be checked
437
-			array('alias', 'name'),		// attributes to be checked
435
+			array('table'), // child elements to be checked
436
+			array('alias', 'name'), // attributes to be checked
438 437
 			TRUE						// attributes are required
439 438
 		);
440 439
 
441
-	foreach($tables_element->childNodes as $table)
440
+	foreach ($tables_element->childNodes as $table)
442 441
 	{
443
-		if($table->nodeType == XML_ELEMENT_NODE
442
+		if ($table->nodeType == XML_ELEMENT_NODE
444 443
 					&&
445 444
 				$table->tagName == 'table')
446 445
 		{
447 446
 			checkTableExpression($xml_file, $table);
448 447
 
449
-			if($table->getAttribute('query') == 'true')
448
+			if ($table->getAttribute('query') == 'true')
450 449
 			{
451
-				validate_select_query($xml_file, $table);		// recursive call
450
+				validate_select_query($xml_file, $table); // recursive call
452 451
 			}
453 452
 		}
454 453
 	}
@@ -470,12 +469,11 @@  discard block
 block discarded – undo
470 469
  */
471 470
 function checkSelectListClause($xml_file, $columns_element)
472 471
 {
473
-	checkUniqueKey
474
-		(
472
+	checkUniqueKey(
475 473
 			$xml_file,
476 474
 			$columns_element,
477
-			array('column', 'query'),	// child elements
478
-			array('alias', 'name'),		// attributes
475
+			array('column', 'query'), // child elements
476
+			array('alias', 'name'), // attributes
479 477
 			FALSE						// ignore if no attributes present
480 478
 		);
481 479
 }
@@ -491,8 +489,7 @@  discard block
 block discarded – undo
491 489
 	@param $container_element
492 490
 	@param $child_tag
493 491
 */
494
-function checkVarContentsValidation
495
-	(
492
+function checkVarContentsValidation(
496 493
 		$xml_file,
497 494
 		$container_element,
498 495
 		$child_tag
@@ -503,23 +500,22 @@  discard block
 block discarded – undo
503 500
 
504 501
 	static
505 502
 		$var_attrs =
506
-			array
507
-			(
503
+			array(
508 504
 				'filter', 'notnull', 'minlength',
509 505
 				'maxlength'
510 506
 			);
511 507
 
512
-	foreach($container_element->childNodes as $child_node)
508
+	foreach ($container_element->childNodes as $child_node)
513 509
 	{
514
-		if($child_node->nodeType == XML_ELEMENT_NODE
510
+		if ($child_node->nodeType == XML_ELEMENT_NODE
515 511
 					&&
516 512
 				$child_node->tagName == $child_tag)
517 513
 		{
518
-			if(!$child_node->hasAttribute($key_attr))
514
+			if (!$child_node->hasAttribute($key_attr))
519 515
 			{
520
-				foreach($var_attrs as $var_attr)
516
+				foreach ($var_attrs as $var_attr)
521 517
 				{
522
-					if($child_node->hasAttribute($var_attr))
518
+					if ($child_node->hasAttribute($var_attr))
523 519
 					{
524 520
 						throw
525 521
 							new XmlSchemaError(
@@ -551,9 +547,9 @@  discard block
 block discarded – undo
551 547
 	$has_var_attribute = $condition->hasAttribute('var') || $condition->hasAttribute('default');
552 548
 	$query_line_no = -1;
553 549
 
554
-	foreach($condition->childNodes as $query_node)
550
+	foreach ($condition->childNodes as $query_node)
555 551
 	{
556
-		if($query_node->nodeType == XML_ELEMENT_NODE
552
+		if ($query_node->nodeType == XML_ELEMENT_NODE
557 553
 					&&
558 554
 				$query_node->tagName == 'query')
559 555
 		{
@@ -564,7 +560,7 @@  discard block
 block discarded – undo
564 560
 		}
565 561
 	}
566 562
 
567
-	if($child_query_node && $has_var_attribute)
563
+	if ($child_query_node && $has_var_attribute)
568 564
 	{
569 565
 		throw 
570 566
 			new XmlSchemaError(
@@ -574,7 +570,7 @@  discard block
 block discarded – undo
574 570
 			);
575 571
 	}
576 572
 
577
-	if(!($child_query_node || $has_var_attribute))
573
+	if (!($child_query_node || $has_var_attribute))
578 574
 	{
579 575
 		throw
580 576
 			new XmlSchemaError(
@@ -601,18 +597,18 @@  discard block
 block discarded – undo
601 597
 {
602 598
 	$first_child = TRUE;
603 599
 
604
-	foreach($conditions->childNodes as $child_node)
600
+	foreach ($conditions->childNodes as $child_node)
605 601
 	{
606
-		if($child_node->nodeType == XML_ELEMENT_NODE)
602
+		if ($child_node->nodeType == XML_ELEMENT_NODE)
607 603
 		{
608 604
 			// check for 'pipe' attribute
609
-			if($first_child)
605
+			if ($first_child)
610 606
 			{
611 607
 				$first_child = FALSE;
612 608
 			}
613 609
 			else
614 610
 			{
615
-				if(!$child_node->hasAttribute('pipe'))
611
+				if (!$child_node->hasAttribute('pipe'))
616 612
 				{
617 613
 					throw
618 614
 						new XmlSchemaError(
@@ -626,19 +622,19 @@  discard block
 block discarded – undo
626 622
 			}
627 623
 
628 624
 			// recurse in condition groups/queries
629
-			if($child_node->tagName == 'group')
625
+			if ($child_node->tagName == 'group')
630 626
 			{
631 627
 				checkConditionsGroup($xml_file, $child_node);
632 628
 			}
633 629
 			else
634 630
 			{
635
-				if($child_node->tagName == 'query')
631
+				if ($child_node->tagName == 'query')
636 632
 				{
637 633
 					validate_select_query($xml_file, $child_node);
638 634
 				}
639 635
 				else
640 636
 				{
641
-					if($child_node->tagName == 'condition')
637
+					if ($child_node->tagName == 'condition')
642 638
 					{
643 639
 						checkConditionElement($xml_file, $child_node);
644 640
 					}
@@ -664,12 +660,11 @@  discard block
 block discarded – undo
664 660
  */
665 661
 function checkNavigationClauses($xml_file, $navigation_element)
666 662
 {
667
-	foreach(array('list_count', 'page_count', 'page')
663
+	foreach (array('list_count', 'page_count', 'page')
668 664
 				as
669 665
 			$navigation_el)
670 666
 	{
671
-		checkDuplicateDescendants
672
-			(
667
+		checkDuplicateDescendants(
673 668
 				$xml_file,
674 669
 				$navigation_element,
675 670
 				$navigation_el
@@ -693,11 +688,11 @@  discard block
 block discarded – undo
693 688
  */
694 689
 function validate_select_query($xml_file, $query_element)
695 690
 {
696
-	foreach($query_element->childNodes as $select_clause)
691
+	foreach ($query_element->childNodes as $select_clause)
697 692
 	{
698
-		if($select_clause->nodeType == XML_ELEMENT_NODE)
693
+		if ($select_clause->nodeType == XML_ELEMENT_NODE)
699 694
 		{
700
-			switch($select_clause->tagName)
695
+			switch ($select_clause->tagName)
701 696
 			{
702 697
 				case 'columns':
703 698
 					checkSelectListClause($xml_file, $select_clause);
@@ -728,11 +723,11 @@  discard block
 block discarded – undo
728 723
  */
729 724
 function validate_update_query($xml_file, $query_element)
730 725
 {
731
-	foreach($query_element->childNodes as $update_clause)
726
+	foreach ($query_element->childNodes as $update_clause)
732 727
 	{
733
-		if($update_clause->nodeType == XML_ELEMENT_NODE)
728
+		if ($update_clause->nodeType == XML_ELEMENT_NODE)
734 729
 		{
735
-			switch($update_clause->tagName)
730
+			switch ($update_clause->tagName)
736 731
 			{
737 732
 				case 'tables':
738 733
 					checkTablesClause($xml_file, $update_clause);
@@ -755,11 +750,11 @@  discard block
 block discarded – undo
755 750
  */
756 751
 function validate_delete_query($xml_file, $query_element)
757 752
 {
758
-	foreach($query_element->childNodes as $delete_clause)
753
+	foreach ($query_element->childNodes as $delete_clause)
759 754
 	{
760
-		if($delete_clause->nodeType == XML_ELEMENT_NODE)
755
+		if ($delete_clause->nodeType == XML_ELEMENT_NODE)
761 756
 		{
762
-			switch($delete_clause->tagName)
757
+			switch ($delete_clause->tagName)
763 758
 			{
764 759
 				case 'conditions':
765 760
 					checkConditionsGroup($xml_file, $delete_clause);
@@ -778,11 +773,11 @@  discard block
 block discarded – undo
778 773
  */
779 774
 function validate_insert_select_query($xml_file, $query_element)
780 775
 {
781
-	foreach($query_element->childNodes as $statement_clause)
776
+	foreach ($query_element->childNodes as $statement_clause)
782 777
 	{
783
-		if($statement_clause->nodeType == XML_ELEMENT_NODE)
778
+		if ($statement_clause->nodeType == XML_ELEMENT_NODE)
784 779
 		{
785
-			switch($statement_clause->tagName)
780
+			switch ($statement_clause->tagName)
786 781
 			{
787 782
 				case 'query':
788 783
 					validate_select_query($xml_file, $statement_clause);
@@ -793,8 +788,7 @@  discard block
 block discarded – undo
793 788
 }
794 789
 
795 790
 $validate_query_type = 
796
-	array
797
-		(
791
+	array(
798 792
 			// 'insert' =>		
799 793
 							// there is currently nothing special to check
800 794
 							// for a plain insert, all the needed checks
@@ -818,13 +812,13 @@  discard block
 block discarded – undo
818 812
 
819 813
 	$action = $query_element->getAttribute('action');
820 814
 
821
-	if(array_key_exists($action, $validate_query_type))
815
+	if (array_key_exists($action, $validate_query_type))
822 816
 	{
823 817
 		$validate_query_type[$action]($xml_file, $query_element);
824 818
 	}
825 819
 }
826 820
 
827
-if(strpos(PHP_SAPI, 'cli') !== FALSE
821
+if (strpos(PHP_SAPI, 'cli') !== FALSE
828 822
 			|| 
829 823
 		strpos(PHP_SAPI, 'cgi') !== FALSE)
830 824
 {
@@ -857,7 +851,7 @@  discard block
 block discarded – undo
857 851
 				print "Failed to restore working dir {$this->dirname}.";
858 852
 			}
859 853
 
860
-			if(!$success)
854
+			if (!$success)
861 855
 			{
862 856
 				print "Failed to restore working dir {$this->dirname}.";
863 857
 			}
@@ -873,7 +867,7 @@  discard block
 block discarded – undo
873 867
 		{
874 868
 			$this->dirname = getcwd();
875 869
 
876
-			if(!$this->dirname)
870
+			if (!$this->dirname)
877 871
 			{
878 872
 				throw new ErrorMessage("Failed to get current directory.");
879 873
 			}
@@ -903,7 +897,7 @@  discard block
 block discarded – undo
903 897
 	$lowercase_name = strtolower($xml_path_info['basename']);
904 898
 	$uppercase_name = strtoupper($xml_path_info['basename']);
905 899
 
906
-	if(strlen($lowercase_name) != $filename_len
900
+	if (strlen($lowercase_name) != $filename_len
907 901
 				||
908 902
 			strlen($uppercase_name) != $filename_len)
909 903
 	{
@@ -916,9 +910,9 @@  discard block
 block discarded – undo
916 910
 
917 911
 	$varing_case_filename = '';
918 912
 
919
-	for($i = 0; $i < $filename_len; $i++)
913
+	for ($i = 0; $i < $filename_len; $i++)
920 914
 	{
921
-		if($lowercase_name[$i] != $uppercase_name[$i])
915
+		if ($lowercase_name[$i] != $uppercase_name[$i])
922 916
 		{
923 917
 			$varing_case_filename .= "[{$lowercase_name[$i]}{$uppercase_name[$i]}]";
924 918
 		}
@@ -932,13 +926,13 @@  discard block
 block discarded – undo
932 926
 
933 927
 	$restoreWorkDir = new RestoreWorkDir();
934 928
 
935
-	if($glob_pattern)
929
+	if ($glob_pattern)
936 930
 	{
937 931
 		// change current dir to the xml file directory to keep
938 932
 		// glob pattern shorter (maximum 260 chars).
939 933
 		$success = chdir($glob_pattern);
940 934
 
941
-		if(!$success)
935
+		if (!$success)
942 936
 		{
943 937
 			throw new ErrorMessage("Failed to change work dir to {$glob_pattern}.");
944 938
 		}
@@ -950,14 +944,14 @@  discard block
 block discarded – undo
950 944
 	// realpath() would have the same effect, but it is not documented as such
951 945
 	$matched_files = glob($glob_pattern, GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR);
952 946
 
953
-	unset($RestoreWorkDir);		// restore work dir after call to glob()
947
+	unset($RestoreWorkDir); // restore work dir after call to glob()
954 948
 
955
-	if($matched_files === FALSE || !is_array($matched_files))
949
+	if ($matched_files === FALSE || !is_array($matched_files))
956 950
 	{
957 951
 		throw new ErrorMessage("Directory listing for $xml_file failed.");
958 952
 	}
959 953
 
960
-	switch(count($matched_files))
954
+	switch (count($matched_files))
961 955
 	{
962 956
 		case 0:
963 957
 			throw new ErrorMessage("Directory listing for $xml_file failed.");
@@ -968,9 +962,9 @@  discard block
 block discarded – undo
968 962
 		default:
969 963
 			// more than one files with the same name and different case
970 964
 			// case-sensitive file system
971
-			foreach($mached_files as $matched_file)
965
+			foreach ($mached_files as $matched_file)
972 966
 			{
973
-				if(pathinfo($matched_file, PATHINFO_BASENAME) == $xml_path_info['basename'])
967
+				if (pathinfo($matched_file, PATHINFO_BASENAME) == $xml_path_info['basename'])
974 968
 				{
975 969
 					return ($xml_path_info['filename'] == $query_id);
976 970
 				}
@@ -979,7 +973,7 @@  discard block
 block discarded – undo
979 973
 
980 974
 	}
981 975
 
982
-	throw new ErrorMessage("Internal application error.");  // unreachable
976
+	throw new ErrorMessage("Internal application error."); // unreachable
983 977
 }
984 978
 
985 979
 /**
@@ -1000,9 +994,9 @@  discard block
 block discarded – undo
1000 994
 */
1001 995
 function validate_schema_doc($xml_file, $table_element)
1002 996
 {
1003
-	foreach($table_element->childNodes as $col_node)
997
+	foreach ($table_element->childNodes as $col_node)
1004 998
 	{
1005
-		if($col_node->nodeType == XML_ELEMENT_NODE
999
+		if ($col_node->nodeType == XML_ELEMENT_NODE
1006 1000
 					&&
1007 1001
 				$col_node->tagName == 'column')
1008 1002
 		{
@@ -1010,12 +1004,11 @@  discard block
 block discarded – undo
1010 1004
 			$col_size = NULL;
1011 1005
 
1012 1006
 			// check auto-increment column
1013
-			if($col_node->hasAttribute('auto_increment'))
1007
+			if ($col_node->hasAttribute('auto_increment'))
1014 1008
 			{
1015
-				fwrite
1016
-					(
1009
+				fwrite(
1017 1010
 						fopen('php://stdout', 'wt'), 
1018
-						$xml_file . '(' . $col_node->getLineNo() . ")\n\t"
1011
+						$xml_file.'('.$col_node->getLineNo().")\n\t"
1019 1012
 							.
1020 1013
 						"<column>: attribute 'auto_increment' is currently supported only by SQL Server and mysql backends.\n"
1021 1014
 					);
@@ -1023,7 +1016,7 @@  discard block
 block discarded – undo
1023 1016
 				static
1024 1017
 					$autoinc_types = array('number', 'bignumber');
1025 1018
 
1026
-				if(!in_array($col_type, $autoinc_types))
1019
+				if (!in_array($col_type, $autoinc_types))
1027 1020
 				{
1028 1021
 					throw
1029 1022
 						new XmlSchemaError(
@@ -1031,30 +1024,29 @@  discard block
 block discarded – undo
1031 1024
 							$col_node->getLineNo(),
1032 1025
 							"<column>: attribute 'auto_increment' only expected for one of the following types: "
1033 1026
 								.
1034
-							implode(', ', $autoinc_types) . '.'
1027
+							implode(', ', $autoinc_types).'.'
1035 1028
 						);
1036 1029
 				}
1037 1030
 			}
1038 1031
 
1039 1032
 			// check tinytext
1040
-			if($col_type == 'tinytext')
1033
+			if ($col_type == 'tinytext')
1041 1034
 			{
1042
-				fwrite
1043
-					(
1035
+				fwrite(
1044 1036
 						fopen('php://stdout', 'wt'), 
1045
-						$xml_file . '(' . $col_node->getLineNo() . ")\n\t"
1037
+						$xml_file.'('.$col_node->getLineNo().")\n\t"
1046 1038
 							.
1047 1039
 						"<column>: type \"tinytext\" is supported only by CUBRID.\n"
1048 1040
 					);
1049 1041
 			}
1050 1042
 
1051 1043
 			// check size attribute
1052
-			if($col_node->hasAttribute('size'))
1044
+			if ($col_node->hasAttribute('size'))
1053 1045
 			{
1054 1046
 				$col_size = $col_node->getAttribute('size');
1055 1047
 			}
1056 1048
 
1057
-			if($col_type == 'varchar' && $col_size === NULL)
1049
+			if ($col_type == 'varchar' && $col_size === NULL)
1058 1050
 			{
1059 1051
 				throw 
1060 1052
 					new XmlSchemaError(
@@ -1068,7 +1060,7 @@  discard block
 block discarded – undo
1068 1060
 				$varsize_types = array('char', 'varchar', 'float');
1069 1061
 					
1070 1062
 
1071
-			if($col_size !== NULL  && !in_array($col_type, $varsize_types))
1063
+			if ($col_size !== NULL && !in_array($col_type, $varsize_types))
1072 1064
 			{
1073 1065
 				throw 
1074 1066
 					new XmlSchemaError(
@@ -1076,7 +1068,7 @@  discard block
 block discarded – undo
1076 1068
 							$col_node->getLineNo(),
1077 1069
 							"<column>: 'size' attribute only expected for the following types: "
1078 1070
 								.
1079
-							implode(', ', $varsize_types) . "."
1071
+							implode(', ', $varsize_types)."."
1080 1072
 						);
1081 1073
 			}
1082 1074
 		}
@@ -1102,8 +1094,8 @@  discard block
 block discarded – undo
1102 1094
 	const RETCODE_GENERIC_XML_SYNTAX = 50;
1103 1095
 	const RETCODE_QUERY_ELEMENT = 40;
1104 1096
 	const RETCODE_XSD_VALIDATION = 30;
1105
-	const RETCODE_BUILTIN_CHECKS =	20;
1106
-	const RETCODE_DB_SCHEMA_MATCH = 10;	// no schema match is currently implemented.
1097
+	const RETCODE_BUILTIN_CHECKS = 20;
1098
+	const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented.
1107 1099
 	const RETCODE_SUCCESS = 0;
1108 1100
 
1109 1101
 
@@ -1116,13 +1108,13 @@  discard block
 block discarded – undo
1116 1108
 	*/
1117 1109
 	public function code($val = -1)
1118 1110
 	{
1119
-		if($val == -1)
1111
+		if ($val == -1)
1120 1112
 		{
1121 1113
 			return $this->exit_code;
1122 1114
 		}
1123 1115
 		else
1124 1116
 		{
1125
-			if($this->exit_code < $val)
1117
+			if ($this->exit_code < $val)
1126 1118
 			{
1127 1119
 				$this->exit_code = $val;
1128 1120
 			}
@@ -1184,7 +1176,7 @@  discard block
 block discarded – undo
1184 1176
 	*/
1185 1177
 	public function __destruct()
1186 1178
 	{
1187
-		if($this->file_name)
1179
+		if ($this->file_name)
1188 1180
 		{
1189 1181
 			unlink($this->file_name);
1190 1182
 			$this->file_name = NULL;
@@ -1214,12 +1206,12 @@  discard block
 block discarded – undo
1214 1206
 	$cmdname = CMD_NAME;
1215 1207
 
1216 1208
 	// php manual says resources should not normally be declared constant
1217
-	if(!defined('STDERR'))
1209
+	if (!defined('STDERR'))
1218 1210
 	{
1219 1211
 		define('STDERR', fopen('php://stderr', 'wt'));
1220 1212
 	}
1221 1213
 
1222
-	if(!defined('__DIR__'))
1214
+	if (!defined('__DIR__'))
1223 1215
 	{
1224 1216
 		define('__DIR__', dirname(__FILE__)); 
1225 1217
 	}
@@ -1234,7 +1226,7 @@  discard block
 block discarded – undo
1234 1226
 	$query_args = NULL;
1235 1227
 	$query_args_file = NULL;
1236 1228
 
1237
-	while($argc >= 2 && $argv[1][0] == '-')
1229
+	while ($argc >= 2 && $argv[1][0] == '-')
1238 1230
 	{
1239 1231
 		$option = $argv[1];
1240 1232
 
@@ -1242,17 +1234,17 @@  discard block
 block discarded – undo
1242 1234
 		$argv = array_values($argv);
1243 1235
 		$argc = count($argv);
1244 1236
 
1245
-		switch($option)
1237
+		switch ($option)
1246 1238
 		{
1247 1239
 			case '-s':
1248 1240
 			case '--schema':
1249 1241
 			case '--schema-language':
1250
-				if($query_args !== NULL)
1242
+				if ($query_args !== NULL)
1251 1243
 				{
1252 1244
 					throw new SyntaxError("Both --args-string and --schema-language options given.");
1253 1245
 				}
1254 1246
 
1255
-				if($query_args_file !== NULL)
1247
+				if ($query_args_file !== NULL)
1256 1248
 				{
1257 1249
 					throw new SyntaxError("Both --args-file and --schema-language options given.");
1258 1250
 				}
@@ -1272,7 +1264,7 @@  discard block
 block discarded – undo
1272 1264
 
1273 1265
 			case '--xe-path':
1274 1266
 			case '--xe':
1275
-				if($argc < 2)
1267
+				if ($argc < 2)
1276 1268
 				{
1277 1269
 					throw
1278 1270
 						new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`");
@@ -1290,17 +1282,17 @@  discard block
 block discarded – undo
1290 1282
 			case '--args-string':
1291 1283
 			case '--arguments':
1292 1284
 			case '--args':
1293
-				if($schema_language !== NULL)
1285
+				if ($schema_language !== NULL)
1294 1286
 				{
1295 1287
 					throw new SyntaxError("Both --schema-language and --args-string options given.");
1296 1288
 				}
1297 1289
 
1298
-				if($query_args_file !== NULL)
1290
+				if ($query_args_file !== NULL)
1299 1291
 				{
1300 1292
 					throw new SyntaxError("Both --args-string and --args-file options given.");
1301 1293
 				}
1302 1294
 
1303
-				if($argc < 2)
1295
+				if ($argc < 2)
1304 1296
 				{
1305 1297
 					throw
1306 1298
 						new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`");
@@ -1316,17 +1308,17 @@  discard block
 block discarded – undo
1316 1308
 
1317 1309
 			case '--arguments-file':
1318 1310
 			case '--args-file':
1319
-				if($schema_language !== NULL)
1311
+				if ($schema_language !== NULL)
1320 1312
 				{
1321 1313
 					throw new SyntaxError("Both --schema-language and --args-file options given.");
1322 1314
 				}
1323 1315
 
1324
-				if($query_args !== NULL)
1316
+				if ($query_args !== NULL)
1325 1317
 				{
1326 1318
 					throw new SyntaxError("Both --args-string and --args-file options given.");
1327 1319
 				}
1328 1320
 
1329
-				if($argc < 2)
1321
+				if ($argc < 2)
1330 1322
 				{
1331 1323
 					throw
1332 1324
 						new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`");
@@ -1357,7 +1349,7 @@  discard block
 block discarded – undo
1357 1349
 		}
1358 1350
 	}
1359 1351
 
1360
-	if($argc < 2 ||
1352
+	if ($argc < 2 ||
1361 1353
 			(
1362 1354
 				$argc == 2
1363 1355
 					&&
@@ -1366,48 +1358,48 @@  discard block
 block discarded – undo
1366 1358
 	{
1367 1359
 		throw
1368 1360
 			new SyntaxError(
1369
-				"Validates an XML document against a given schema definition (XSD), using the standard php library.\n" .
1370
-				"Syntax:\n" .
1371
-				"	{$cmdname} schema.xsd document.xml...\n" .
1372
-				"	{$cmdname} [ --schema-language ] [--skip-query-id] ... [--] document.xml...\n" .
1373
-				"Where:\n" .
1374
-				"	--schema-language\n" .
1375
-				"	--schema\n" .
1376
-				"	-s\n" .
1377
-				"		If given, the document(s) are validated against XE XML Schema Language,\n" .
1378
-				"		otherwise document(s) are validated against XE XML Query Language.\n" .
1379
-				"\n" .
1380
-				"	--skip-query-id\n" .
1381
-				"		Do not check the query id, which should normally match the file name.\n" .
1382
-				"\n" .
1383
-				"	--xe-path\n" .
1384
-				"	--xe\n" .
1385
-				"		Path to XE installation. Used to load the database-specific parsers to generate\n" .
1386
-				"		SQL from the XML language files.\n" .
1387
-				"\n" .
1388
-				"	--validate-only\n" .
1389
-				"		Only check XML schemas, no SQL generated with the database-specific parsers.\n" .
1390
-				"\n" .
1391
-				"	--args-string   \" 'name' => 'val..', 'name' => 'val...' \"\n" .
1392
-				"	--args-file		args/file/name.php\n" .
1393
-				"		Variables and values for the query, if it has any (only for XML Query Language).\n" .
1394
-				"		Use a comma-separated 'var-name' => 'var_value...' pairs, in php syntax for an\n" .
1395
-				"		array constructor. The validator script will directly eval()/include() this content.\n" .
1396
-				"		The file named with --args-file should include an array() constructor around the\n" .
1397
-				"		name-value list, and should immediately return it, without a named array variable.\n" .
1398
-				"		E.g.:\n" .
1399
-				"			return \n" .
1400
-				"				array\n" .
1401
-				"					(\n" .
1402
-				"						'name' => 'val',\n" .
1403
-				"						'name' => 'val',\n" .
1404
-				"						...\n" .
1405
-				"					);\n" .
1406
-				"\n" .
1407
-				"	schema.xsd		if given, is the file name for the schema definition to validate the\n" .
1408
-				"					document against\n" .
1409
-				"\n" .
1410
-				"	document.xml	is the file name for the XML document to be validated against the schema.\n" .
1361
+				"Validates an XML document against a given schema definition (XSD), using the standard php library.\n".
1362
+				"Syntax:\n".
1363
+				"	{$cmdname} schema.xsd document.xml...\n".
1364
+				"	{$cmdname} [ --schema-language ] [--skip-query-id] ... [--] document.xml...\n".
1365
+				"Where:\n".
1366
+				"	--schema-language\n".
1367
+				"	--schema\n".
1368
+				"	-s\n".
1369
+				"		If given, the document(s) are validated against XE XML Schema Language,\n".
1370
+				"		otherwise document(s) are validated against XE XML Query Language.\n".
1371
+				"\n".
1372
+				"	--skip-query-id\n".
1373
+				"		Do not check the query id, which should normally match the file name.\n".
1374
+				"\n".
1375
+				"	--xe-path\n".
1376
+				"	--xe\n".
1377
+				"		Path to XE installation. Used to load the database-specific parsers to generate\n".
1378
+				"		SQL from the XML language files.\n".
1379
+				"\n".
1380
+				"	--validate-only\n".
1381
+				"		Only check XML schemas, no SQL generated with the database-specific parsers.\n".
1382
+				"\n".
1383
+				"	--args-string   \" 'name' => 'val..', 'name' => 'val...' \"\n".
1384
+				"	--args-file		args/file/name.php\n".
1385
+				"		Variables and values for the query, if it has any (only for XML Query Language).\n".
1386
+				"		Use a comma-separated 'var-name' => 'var_value...' pairs, in php syntax for an\n".
1387
+				"		array constructor. The validator script will directly eval()/include() this content.\n".
1388
+				"		The file named with --args-file should include an array() constructor around the\n".
1389
+				"		name-value list, and should immediately return it, without a named array variable.\n".
1390
+				"		E.g.:\n".
1391
+				"			return \n".
1392
+				"				array\n".
1393
+				"					(\n".
1394
+				"						'name' => 'val',\n".
1395
+				"						'name' => 'val',\n".
1396
+				"						...\n".
1397
+				"					);\n".
1398
+				"\n".
1399
+				"	schema.xsd		if given, is the file name for the schema definition to validate the\n".
1400
+				"					document against\n".
1401
+				"\n".
1402
+				"	document.xml	is the file name for the XML document to be validated against the schema.\n".
1411 1403
 				"					Multiple .xml files can be given.\n"
1412 1404
 			);
1413 1405
 	}
@@ -1415,23 +1407,23 @@  discard block
 block discarded – undo
1415 1407
 	$query_user_args = array();
1416 1408
 
1417 1409
 	// check $xe_path, $query_args
1418
-	if(!$validate_only)
1410
+	if (!$validate_only)
1419 1411
 	{
1420
-		if($xe_path == NULL)
1412
+		if ($xe_path == NULL)
1421 1413
 		{
1422 1414
 			// assume validator.php is in directory .../xe/tools/dbxml_validator/ in an XE installation
1423 1415
 			$xe_path = dirname(dirname(realpath(__DIR__)));
1424 1416
 		}
1425 1417
 
1426
-		if(!file_exists($xe_path . '/index.php'))
1418
+		if (!file_exists($xe_path.'/index.php'))
1427 1419
 		{
1428 1420
 			throw
1429 1421
 				new ErrorMessage("File index.php not found in {$xe_path}.");
1430 1422
 		}
1431 1423
 
1432
-		if(!defined('_XE_PATH_'))
1424
+		if (!defined('_XE_PATH_'))
1433 1425
 		{
1434
-			define('_XE_PATH_', $xe_path . '/');
1426
+			define('_XE_PATH_', $xe_path.'/');
1435 1427
 		}
1436 1428
 
1437 1429
 		/**
@@ -1485,7 +1477,7 @@  discard block
 block discarded – undo
1485 1477
 			*/
1486 1478
 			public static function getDBType()
1487 1479
 			{
1488
-				if(self::$db_info)
1480
+				if (self::$db_info)
1489 1481
 				{
1490 1482
 					return self::$db_info->master_db['db_type'];
1491 1483
 				}
@@ -1538,10 +1530,9 @@  discard block
 block discarded – undo
1538 1530
 			*/
1539 1531
 			public static function setNoDBInfo()
1540 1532
 			{
1541
-				$db_info = (object)NULL;
1533
+				$db_info = (object) NULL;
1542 1534
 				$db_info->master_db =
1543
-					array
1544
-						(
1535
+					array(
1545 1536
 							'db_type' => NULL,
1546 1537
 							'db_hostname' => NULL,
1547 1538
 							'db_port' => NULL,
@@ -1565,10 +1556,9 @@  discard block
 block discarded – undo
1565 1556
 			*/
1566 1557
 			public static function setMysqlDBInfo()
1567 1558
 			{
1568
-				$db_info = (object)NULL;
1559
+				$db_info = (object) NULL;
1569 1560
 				$db_info->master_db =
1570
-					array
1571
-						(
1561
+					array(
1572 1562
 							'db_type' => 'mysql',
1573 1563
 							'db_hostname' => NULL,
1574 1564
 							'db_port' => NULL,
@@ -1584,7 +1574,7 @@  discard block
 block discarded – undo
1584 1574
 
1585 1575
 				self::setDBInfo($db_info);
1586 1576
 
1587
-				if(array_key_exists('__DB__', $GLOBALS)
1577
+				if (array_key_exists('__DB__', $GLOBALS)
1588 1578
 							&&
1589 1579
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1590 1580
 				{
@@ -1607,10 +1597,9 @@  discard block
 block discarded – undo
1607 1597
 			*/
1608 1598
 			public static function setMysqliDBInfo()
1609 1599
 			{
1610
-				$db_info = (object)NULL;
1600
+				$db_info = (object) NULL;
1611 1601
 				$db_info->master_db =
1612
-					array
1613
-						(
1602
+					array(
1614 1603
 							'db_type' => 'mysqli',
1615 1604
 							'db_hostname' => NULL,
1616 1605
 							'db_port' => NULL,
@@ -1626,7 +1615,7 @@  discard block
 block discarded – undo
1626 1615
 
1627 1616
 				self::setDBInfo($db_info);
1628 1617
 
1629
-				if(array_key_exists('__DB__', $GLOBALS)
1618
+				if (array_key_exists('__DB__', $GLOBALS)
1630 1619
 							&&
1631 1620
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1632 1621
 				{
@@ -1649,10 +1638,9 @@  discard block
 block discarded – undo
1649 1638
 			*/
1650 1639
 			public static function setCubridDBInfo()
1651 1640
 			{
1652
-				$db_info = (object)NULL;
1641
+				$db_info = (object) NULL;
1653 1642
 				$db_info->master_db =
1654
-					array
1655
-						(
1643
+					array(
1656 1644
 							'db_type' => 'cubrid',
1657 1645
 							'db_hostname' => NULL,
1658 1646
 							'db_port' => NULL,
@@ -1668,7 +1656,7 @@  discard block
 block discarded – undo
1668 1656
 
1669 1657
 				self::setDBInfo($db_info);
1670 1658
 
1671
-				if(array_key_exists('__DB__', $GLOBALS)
1659
+				if (array_key_exists('__DB__', $GLOBALS)
1672 1660
 							&&
1673 1661
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1674 1662
 				{
@@ -1691,10 +1679,9 @@  discard block
 block discarded – undo
1691 1679
 			*/
1692 1680
 			public static function setMssqlDBInfo()
1693 1681
 			{
1694
-				$db_info = (object)NULL;
1682
+				$db_info = (object) NULL;
1695 1683
 				$db_info->master_db =
1696
-					array
1697
-						(
1684
+					array(
1698 1685
 							'db_type' => 'mssql',
1699 1686
 							'db_hostname' => NULL,
1700 1687
 							'db_port' => NULL,
@@ -1710,7 +1697,7 @@  discard block
 block discarded – undo
1710 1697
 
1711 1698
 				self::setDBInfo($db_info);
1712 1699
 
1713
-				if(array_key_exists('__DB__', $GLOBALS)
1700
+				if (array_key_exists('__DB__', $GLOBALS)
1714 1701
 							&&
1715 1702
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1716 1703
 				{
@@ -1765,49 +1752,49 @@  discard block
 block discarded – undo
1765 1752
 		}
1766 1753
 
1767 1754
 		global $lang;
1768
-		$lang = new Any_prop_obj_base();	// to return NULL on non-existent properties
1755
+		$lang = new Any_prop_obj_base(); // to return NULL on non-existent properties
1769 1756
 		$lang->filter = New LangArgFilterErrorMessage();
1770 1757
 
1771
-		if(!defined('__XE__'))
1758
+		if (!defined('__XE__'))
1772 1759
 		{
1773 1760
 			define('__XE__', TRUE);
1774 1761
 		}
1775 1762
 
1776
-		if(!defined('__ZBXE__'))
1763
+		if (!defined('__ZBXE__'))
1777 1764
 		{
1778 1765
 			define('__ZBXE__', TRUE);
1779 1766
 		}
1780 1767
 
1781
-		if(!defined('__DEBUG__'))
1768
+		if (!defined('__DEBUG__'))
1782 1769
 		{
1783 1770
 			define('__DEBUG__', 0);
1784 1771
 		}
1785 1772
 
1786
-		if(!defined('__DEBUG_QUERY__'))
1773
+		if (!defined('__DEBUG_QUERY__'))
1787 1774
 		{
1788 1775
 			define('__DEBUG_QUERY__', 0);
1789 1776
 		}
1790 1777
 
1791
-		include(_XE_PATH_ . 'classes/object/BaseObject.class.php');
1792
-		include(_XE_PATH_ . 'classes/handler/Handler.class.php');
1793
-		include(_XE_PATH_ . 'classes/file/FileHandler.class.php');
1794
-		include(_XE_PATH_ . 'classes/page/PageHandler.class.php');
1778
+		include(_XE_PATH_.'classes/object/BaseObject.class.php');
1779
+		include(_XE_PATH_.'classes/handler/Handler.class.php');
1780
+		include(_XE_PATH_.'classes/file/FileHandler.class.php');
1781
+		include(_XE_PATH_.'classes/page/PageHandler.class.php');
1795 1782
 
1796 1783
 		Context::setNoDBInfo();
1797 1784
 
1798
-		require_once(_XE_PATH_ . 'classes/db/DB.class.php');
1799
-		require_once(_XE_PATH_ . 'classes/db/DBMysql.class.php');
1800
-		require_once(_XE_PATH_ . 'classes/db/DBMysqli.class.php');
1801
-		require_once(_XE_PATH_ . 'classes/db/DBMysql_innodb.class.php');
1802
-		require_once(_XE_PATH_ . 'classes/db/DBCubrid.class.php');
1803
-		require_once(_XE_PATH_ . 'classes/db/DBMssql.class.php');
1804
-		require_once(_XE_PATH_ . 'classes/xml/XmlParser.class.php');
1805
-		require_once(_XE_PATH_ . 'classes/xml/XmlQueryParser.class.php');
1785
+		require_once(_XE_PATH_.'classes/db/DB.class.php');
1786
+		require_once(_XE_PATH_.'classes/db/DBMysql.class.php');
1787
+		require_once(_XE_PATH_.'classes/db/DBMysqli.class.php');
1788
+		require_once(_XE_PATH_.'classes/db/DBMysql_innodb.class.php');
1789
+		require_once(_XE_PATH_.'classes/db/DBCubrid.class.php');
1790
+		require_once(_XE_PATH_.'classes/db/DBMssql.class.php');
1791
+		require_once(_XE_PATH_.'classes/xml/XmlParser.class.php');
1792
+		require_once(_XE_PATH_.'classes/xml/XmlQueryParser.class.php');
1806 1793
 
1807
-		require_once(__DIR__ . '/connect_wrapper.php');
1794
+		require_once(__DIR__.'/connect_wrapper.php');
1808 1795
 
1809 1796
 		// check $query_args, $query_args_file
1810
-		if($query_args_file)
1797
+		if ($query_args_file)
1811 1798
 		{
1812 1799
 			try
1813 1800
 			{
@@ -1821,11 +1808,11 @@  discard block
 block discarded – undo
1821 1808
 		}
1822 1809
 		else
1823 1810
 		{
1824
-			if($query_args)
1811
+			if ($query_args)
1825 1812
 			{
1826 1813
 				try
1827 1814
 				{
1828
-					eval('$query_user_args = array(' . $query_args . ');');
1815
+					eval('$query_user_args = array('.$query_args.');');
1829 1816
 				}
1830 1817
 				catch (Exception $exc)
1831 1818
 				{
@@ -1841,26 +1828,25 @@  discard block
 block discarded – undo
1841 1828
 
1842 1829
 	$schema_file = NULL;
1843 1830
 	$schemas_set =
1844
-		array
1845
-			(
1846
-				'delete' => __DIR__ . '/xml_delete.xsd',
1847
-				'update' => __DIR__ . '/xml_update.xsd',
1848
-				'select' => __DIR__ . '/xml_select.xsd',
1849
-				'insert' => __DIR__ . '/xml_insert.xsd',
1850
-				'insert-select' => __DIR__ . '/xml_insert_select.xsd'
1831
+		array(
1832
+				'delete' => __DIR__.'/xml_delete.xsd',
1833
+				'update' => __DIR__.'/xml_update.xsd',
1834
+				'select' => __DIR__.'/xml_select.xsd',
1835
+				'insert' => __DIR__.'/xml_insert.xsd',
1836
+				'insert-select' => __DIR__.'/xml_insert_select.xsd'
1851 1837
 			);
1852
-	$table_schema = __DIR__ . '/xml_create_table.xsd';
1838
+	$table_schema = __DIR__.'/xml_create_table.xsd';
1853 1839
 
1854 1840
 	$domDocument = new DOMDocument();
1855 1841
 
1856 1842
 	$i = 1;
1857 1843
 
1858
-	if(pathinfo($argv[1], PATHINFO_EXTENSION) == 'xsd')
1844
+	if (pathinfo($argv[1], PATHINFO_EXTENSION) == 'xsd')
1859 1845
 	{
1860 1846
 		$schema_file = $argv[$i++];
1861 1847
 	}
1862 1848
 	
1863
-	for(; $i < count($argv); $i++)
1849
+	for (; $i < count($argv); $i++)
1864 1850
 	{
1865 1851
 		try
1866 1852
 		{
@@ -1869,7 +1855,7 @@  discard block
 block discarded – undo
1869 1855
 			$use_schema_language = $schema_language;
1870 1856
 
1871 1857
 			$retcode->push(ReturnCode::RETCODE_GENERIC_XML_SYNTAX);
1872
-			if($domDocument->load($argv[$i]))
1858
+			if ($domDocument->load($argv[$i]))
1873 1859
 			{
1874 1860
 				$retcode->pop();
1875 1861
 
@@ -1883,7 +1869,7 @@  discard block
 block discarded – undo
1883 1869
 					}
1884 1870
 				}
1885 1871
 
1886
-				if(!$schema_file && !$use_schema_language
1872
+				if (!$schema_file && !$use_schema_language
1887 1873
 							&&
1888 1874
 						(
1889 1875
 							$queryElement->tagName != 'query'
@@ -1895,15 +1881,15 @@  discard block
 block discarded – undo
1895 1881
 
1896 1882
 					throw
1897 1883
 						new ErrorMessage(
1898
-								"{$argv[$i]}:" .
1899
-								"		Root element should be <query> and should have an action attribute of:" .
1900
-								"		insert, insert-select, select, update or delete." .
1901
-								"		Otherwise an explicit schema, to validate the document with, should be" .
1884
+								"{$argv[$i]}:".
1885
+								"		Root element should be <query> and should have an action attribute of:".
1886
+								"		insert, insert-select, select, update or delete.".
1887
+								"		Otherwise an explicit schema, to validate the document with, should be".
1902 1888
 								"		specified as first argument on the command line."
1903 1889
 							);
1904 1890
 				}
1905 1891
 
1906
-				if(!$schema_file && !$use_schema_language && !$skip_query_id
1892
+				if (!$schema_file && !$use_schema_language && !$skip_query_id
1907 1893
 							&&
1908 1894
 						!validate_query_id($argv[$i], $queryElement->getAttribute('id')))
1909 1895
 				{
@@ -1912,28 +1898,28 @@  discard block
 block discarded – undo
1912 1898
 
1913 1899
 					throw
1914 1900
 						new ErrorMessage(
1915
-							"{$argv[$i]}(" . $queryElement->getLineNo() . "):\n\tQuery 'id' attribute value \"{$query_id}\" should match file name."
1901
+							"{$argv[$i]}(".$queryElement->getLineNo()."):\n\tQuery 'id' attribute value \"{$query_id}\" should match file name."
1916 1902
 						);
1917 1903
 				}
1918 1904
 
1919
-				if($use_schema_language)
1905
+				if ($use_schema_language)
1920 1906
 				{
1921 1907
 					$document_schema = $table_schema;
1922 1908
 				}
1923 1909
 				else
1924 1910
 				{
1925
-					if(!$document_schema)
1911
+					if (!$document_schema)
1926 1912
 					{
1927 1913
 						$document_schema = $schemas_set[$queryElement->getAttribute('action')];
1928 1914
 					}
1929 1915
 				}
1930 1916
 
1931 1917
 				$retcode->push(ReturnCode::RETCODE_XSD_VALIDATION);
1932
-				if($domDocument->schemaValidate($document_schema))
1918
+				if ($domDocument->schemaValidate($document_schema))
1933 1919
 				{
1934 1920
 					$retcode->pop();
1935 1921
 
1936
-					if($use_schema_language)
1922
+					if ($use_schema_language)
1937 1923
 					{
1938 1924
 						validate_schema_doc($argv[$i], $domDocument->documentElement);
1939 1925
 					}
@@ -1944,22 +1930,22 @@  discard block
 block discarded – undo
1944 1930
 					$success = TRUE;
1945 1931
 				}
1946 1932
 
1947
-				if(!$validate_only)
1933
+				if (!$validate_only)
1948 1934
 				{
1949 1935
 					// Generate SQL with the db provider back-ends
1950 1936
 
1951
-					if(function_exists('sys_get_temp_dir'))
1937
+					if (function_exists('sys_get_temp_dir'))
1952 1938
 					{
1953 1939
 						$tmpdir = sys_get_temp_dir();
1954 1940
 					}
1955 1941
 					else
1956 1942
 					{
1957 1943
 						$tmpdir = getenv('TEMP');
1958
-						if(!$tmpdir)
1944
+						if (!$tmpdir)
1959 1945
 						{
1960 1946
 							$tmpdir = getenv('TMP');
1961 1947
 						}
1962
-						if(!$tmpdir)
1948
+						if (!$tmpdir)
1963 1949
 						{
1964 1950
 							$tmpdir = '/tmp';
1965 1951
 						}
@@ -1968,30 +1954,29 @@  discard block
 block discarded – undo
1968 1954
 
1969 1955
 					global $_SERVER;
1970 1956
 
1971
-					if(!is_array($_SERVER))
1957
+					if (!is_array($_SERVER))
1972 1958
 					{
1973 1959
 						$_SERVER = array();
1974 1960
 					}
1975 1961
 
1976
-					if(!array_key_exists('REMOTE_ADDR', $_SERVER))
1962
+					if (!array_key_exists('REMOTE_ADDR', $_SERVER))
1977 1963
 					{
1978 1964
 						$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
1979 1965
 					}
1980 1966
 
1981 1967
 					$set_db_info_methods =
1982
-						array
1983
-							(
1968
+						array(
1984 1969
 								'mysql'		=> 'setMysqlDBInfo',
1985 1970
 								'mysqli'	=> 'setMysqliDBInfo',
1986 1971
 								'cubrid'	=> 'setCubridDBInfo',
1987 1972
 								'mssql'		=> 'setMssqlDBInfo'
1988 1973
 							);
1989 1974
 
1990
-					foreach($set_db_info_methods as $db_type => $set_info_method)
1975
+					foreach ($set_db_info_methods as $db_type => $set_info_method)
1991 1976
 					{
1992 1977
 						Context::$set_info_method(); // calls setMysqlDBInfo()/setCubridDBInfo()/...
1993 1978
 
1994
-						if($use_schema_language)
1979
+						if ($use_schema_language)
1995 1980
 						{
1996 1981
 							$GLOBALS['__DB__'][$db_type]->queries = '';
1997 1982
 							$GLOBALS['__DB__'][$db_type]->createTableByXmlFile($argv[$i]);
@@ -2010,39 +1995,38 @@  discard block
 block discarded – undo
2010 1995
 							// copied from classes/db/DB.class.php
2011 1996
 							$oParser = new XmlQueryParser();
2012 1997
 							$args_array =
2013
-								$oParser->parse_xml_query
2014
-									(
1998
+								$oParser->parse_xml_query(
2015 1999
 										pathinfo($argv[$i], PATHINFO_FILENAME), // query id
2016
-										$argv[$i],								// xml file
2000
+										$argv[$i], // xml file
2017 2001
 										$unlink_tmpfile->file_name				// cache file
2018 2002
 									);
2019 2003
 							$args_array = $args_array->queryTag->getArguments();
2020 2004
 
2021 2005
 							$GLOBALS['__DB__'][$db_type]->queries = '';
2022 2006
 							$k = 1;
2023
-							foreach($args_array as $arg)
2007
+							foreach ($args_array as $arg)
2024 2008
 							{
2025
-								if(// why would there be a query arg without a var name ?
2009
+								if (// why would there be a query arg without a var name ?
2026 2010
 										isset($arg->variable_name)
2027 2011
 											&&
2028 2012
 										!array_key_exists($arg->variable_name, $query_user_args))
2029 2013
 								{
2030
-									if(isset($arg->argument_validator))
2014
+									if (isset($arg->argument_validator))
2031 2015
 									{
2032
-										if(FALSE	// some default values are to be parsed by php, some are not...
2016
+										if (FALSE	// some default values are to be parsed by php, some are not...
2033 2017
 													&&
2034 2018
 												isset($arg->argument_validator->default_value)
2035 2019
 													&&
2036 2020
 												isset($arg->argument_validator->default_value->value))
2037 2021
 										{
2038 2022
 											$query_user_args[$arg->variable_name] =
2039
-												eval('return ' . $arg->argument_validator->default_value->toString() . ';');
2023
+												eval('return '.$arg->argument_validator->default_value->toString().';');
2040 2024
 										}
2041 2025
 										else
2042 2026
 										{
2043
-											if($arg->argument_validator->filter)
2027
+											if ($arg->argument_validator->filter)
2044 2028
 											{
2045
-												switch($arg->argument_validator->filter)
2029
+												switch ($arg->argument_validator->filter)
2046 2030
 												{
2047 2031
 													case 'email':
2048 2032
 													case 'email_address':
@@ -2081,18 +2065,17 @@  discard block
 block discarded – undo
2081 2065
 										}
2082 2066
 									}
2083 2067
 
2084
-									if(!array_key_exists($arg->variable_name, $query_user_args))
2068
+									if (!array_key_exists($arg->variable_name, $query_user_args))
2085 2069
 									{
2086 2070
 										$query_user_args[$arg->variable_name] = sprintf('%06d', $k);
2087 2071
 									}
2088 2072
 
2089
-									if(isset($arg->argument_validator))
2073
+									if (isset($arg->argument_validator))
2090 2074
 									{
2091
-										if(isset($arg->argument_validator->min_length))
2075
+										if (isset($arg->argument_validator->min_length))
2092 2076
 										{
2093 2077
 											$query_user_args[$arg->variable_name] =
2094
-												str_pad
2095
-													(
2078
+												str_pad(
2096 2079
 														$query_user_args[$arg->variable_name],
2097 2080
 														$arg->argument_validator->min_length,
2098 2081
 														isset($arg->argument_validator->filter) &&
@@ -2105,11 +2088,10 @@  discard block
 block discarded – undo
2105 2088
 													);
2106 2089
 										}
2107 2090
 
2108
-										if(isset($arg->argument_validator->max_length))
2091
+										if (isset($arg->argument_validator->max_length))
2109 2092
 										{
2110 2093
 											$query_user_args[$arg->variable_name] =
2111
-												substr
2112
-													(
2094
+												substr(
2113 2095
 														$query_user_args[$arg->variable_name],
2114 2096
 														0, 
2115 2097
 														$arg->argument_validator->max_length
@@ -2122,15 +2104,14 @@  discard block
 block discarded – undo
2122 2104
 							}
2123 2105
 
2124 2106
 							$resultset = 
2125
-								$GLOBALS['__DB__'][$db_type]->_executeQuery
2126
-									(
2127
-										$unlink_tmpfile->file_name,		// cache_file
2128
-										(object)$query_user_args,		// source_args
2129
-										basename($argv[$i]),			// query_id
2107
+								$GLOBALS['__DB__'][$db_type]->_executeQuery(
2108
+										$unlink_tmpfile->file_name, // cache_file
2109
+										(object) $query_user_args, // source_args
2110
+										basename($argv[$i]), // query_id
2130 2111
 										array()							// arg_columns
2131 2112
 									);
2132 2113
 
2133
-							if(is_a($resultset, 'BaseObject') && !$resultset->toBool())
2114
+							if (is_a($resultset, 'BaseObject') && !$resultset->toBool())
2134 2115
 							{
2135 2116
 								throw new XmlSchemaError($argv[$i], -1, 'mysql SQL query generation failed');
2136 2117
 							}
@@ -2147,7 +2128,7 @@  discard block
 block discarded – undo
2147 2128
 				}
2148 2129
 			}
2149 2130
 
2150
-			if(!$success)
2131
+			if (!$success)
2151 2132
 			{
2152 2133
 				libXmlDisplayError($argv[$i], TRUE);
2153 2134
 			}
@@ -2156,21 +2137,21 @@  discard block
 block discarded – undo
2156 2137
 		{
2157 2138
 			$retcode->code(ReturnCode::RETCODE_BUILTIN_CHECKS);
2158 2139
 
2159
-			fwrite(STDERR, $exc->getMessage() . "\n");
2140
+			fwrite(STDERR, $exc->getMessage()."\n");
2160 2141
 		}
2161 2142
 		catch (ErrorMessage $exc)
2162 2143
 		{
2163
-			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2144
+			if ($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2164 2145
 			{
2165 2146
 				$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2166 2147
 			}
2167 2148
 
2168
-			fwrite(STDERR, $exc->getMessage() . "\n");
2149
+			fwrite(STDERR, $exc->getMessage()."\n");
2169 2150
 			libXmlDisplayError($argv[$i]);
2170 2151
 		}
2171 2152
 		catch (ErrorException $exc)
2172 2153
 		{
2173
-			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2154
+			if ($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2174 2155
 			{
2175 2156
 				$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2176 2157
 			}
@@ -2183,7 +2164,7 @@  discard block
 block discarded – undo
2183 2164
 		{
2184 2165
 			$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2185 2166
 
2186
-			fwrite(STDERR, $exc->getMessage() . "\n");
2167
+			fwrite(STDERR, $exc->getMessage()."\n");
2187 2168
 			fwrite(STDERR, $exc->getTraceAsString());
2188 2169
 			libXmlDisplayError($argv[$i]);
2189 2170
 		}
@@ -2193,22 +2174,22 @@  discard block
 block discarded – undo
2193 2174
 }
2194 2175
 catch (SyntaxError $syntax)
2195 2176
 {
2196
-	fwrite(STDERR, $syntax->getMessage() . "\n");
2197
-	exit(254);	// wrong command line
2177
+	fwrite(STDERR, $syntax->getMessage()."\n");
2178
+	exit(254); // wrong command line
2198 2179
 				// 255 is reserved by php (for parse errors, etc.)
2199 2180
 }
2200 2181
 catch (ErrorMessage $exc)
2201 2182
 {
2202
-	fwrite(STDERR, $exc->getMessage() . "\n");
2183
+	fwrite(STDERR, $exc->getMessage()."\n");
2203 2184
 	libXmlDisplayError();
2204
-	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL);		// internal validator error
2185
+	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error
2205 2186
 }
2206 2187
 catch (Exception $exc)
2207 2188
 {
2208
-	fwrite(STDERR, $exc->getFile() . '(' . $exc->getLine() . ")\n\t" . $exc->getMessage() . "\n");
2189
+	fwrite(STDERR, $exc->getFile().'('.$exc->getLine().")\n\t".$exc->getMessage()."\n");
2209 2190
 	fwrite(STDERR, $exc->getTraceAsString());
2210 2191
 	libXmlDisplayError();
2211
-	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL);		// internal validator error
2192
+	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error
2212 2193
 }
2213 2194
 
2214 2195
 /* End of file validate.php */
Please login to merge, or discard this patch.
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -150,13 +150,11 @@  discard block
 block discarded – undo
150 150
 		if($throw_error)
151 151
 		{
152 152
 			throw new ErrorMessage($msg);
153
-		}
154
-		else
153
+		} else
155 154
 		{
156 155
 			fwrite(STDERR, $msg . "\n");
157 156
 		}
158
-	}
159
-	else
157
+	} else
160 158
 	{
161 159
 		if($throw_error)
162 160
 		{
@@ -346,8 +344,7 @@  discard block
 block discarded – undo
346 344
 					"\nANSI SQL-99 declares the table specification as required."
347 345
 				);
348 346
 		}
349
-	}
350
-	else
347
+	} else
351 348
 	{
352 349
 		// base table or view
353 350
 
@@ -369,13 +366,11 @@  discard block
 block discarded – undo
369 366
 									$child_node->getLineNo(),
370 367
 									'Duplicate <conditions> elements.'
371 368
 								);
372
-						}
373
-						else
369
+						} else
374 370
 						{
375 371
 							$has_conditions_element = TRUE;
376 372
 						}
377
-					}
378
-					else
373
+					} else
379 374
 					{
380 375
 						throw
381 376
 							new XmlSchemaError(
@@ -396,8 +391,7 @@  discard block
 block discarded – undo
396 391
 						'Expected <conditions> element as content.'
397 392
 					);
398 393
 			}
399
-		}
400
-		else
394
+		} else
401 395
 		{
402 396
 			foreach($table_element->childNodes as $child_node)
403 397
 			{
@@ -609,8 +603,7 @@  discard block
 block discarded – undo
609 603
 			if($first_child)
610 604
 			{
611 605
 				$first_child = FALSE;
612
-			}
613
-			else
606
+			} else
614 607
 			{
615 608
 				if(!$child_node->hasAttribute('pipe'))
616 609
 				{
@@ -629,14 +622,12 @@  discard block
 block discarded – undo
629 622
 			if($child_node->tagName == 'group')
630 623
 			{
631 624
 				checkConditionsGroup($xml_file, $child_node);
632
-			}
633
-			else
625
+			} else
634 626
 			{
635 627
 				if($child_node->tagName == 'query')
636 628
 				{
637 629
 					validate_select_query($xml_file, $child_node);
638
-				}
639
-				else
630
+				} else
640 631
 				{
641 632
 					if($child_node->tagName == 'condition')
642 633
 					{
@@ -851,8 +842,7 @@  discard block
 block discarded – undo
851 842
 			try
852 843
 			{
853 844
 				$success = chdir($this->dirname);
854
-			}
855
-			catch (Exception $e)
845
+			} catch (Exception $e)
856 846
 			{
857 847
 				print "Failed to restore working dir {$this->dirname}.";
858 848
 			}
@@ -921,8 +911,7 @@  discard block
 block discarded – undo
921 911
 		if($lowercase_name[$i] != $uppercase_name[$i])
922 912
 		{
923 913
 			$varing_case_filename .= "[{$lowercase_name[$i]}{$uppercase_name[$i]}]";
924
-		}
925
-		else
914
+		} else
926 915
 		{
927 916
 			$varing_case_filename .= $lowercase_name[$i];
928 917
 		}
@@ -1119,8 +1108,7 @@  discard block
 block discarded – undo
1119 1108
 		if($val == -1)
1120 1109
 		{
1121 1110
 			return $this->exit_code;
1122
-		}
1123
-		else
1111
+		} else
1124 1112
 		{
1125 1113
 			if($this->exit_code < $val)
1126 1114
 			{
@@ -1488,8 +1476,7 @@  discard block
 block discarded – undo
1488 1476
 				if(self::$db_info)
1489 1477
 				{
1490 1478
 					return self::$db_info->master_db['db_type'];
1491
-				}
1492
-				else
1479
+				} else
1493 1480
 				{
1494 1481
 					return NULL;
1495 1482
 				}
@@ -1588,8 +1575,7 @@  discard block
 block discarded – undo
1588 1575
 							&&
1589 1576
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1590 1577
 				{
1591
-				}
1592
-				else
1578
+				} else
1593 1579
 				{
1594 1580
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1595 1581
 						new DBMysqlConnectWrapper();
@@ -1630,8 +1616,7 @@  discard block
 block discarded – undo
1630 1616
 							&&
1631 1617
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1632 1618
 				{
1633
-				}
1634
-				else
1619
+				} else
1635 1620
 				{
1636 1621
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1637 1622
 						new DBMysqliConnectWrapper();
@@ -1672,8 +1657,7 @@  discard block
 block discarded – undo
1672 1657
 							&&
1673 1658
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1674 1659
 				{
1675
-				}
1676
-				else
1660
+				} else
1677 1661
 				{
1678 1662
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1679 1663
 						new DBCubridConnectWrapper();
@@ -1714,8 +1698,7 @@  discard block
 block discarded – undo
1714 1698
 							&&
1715 1699
 						array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__']))
1716 1700
 				{
1717
-				}
1718
-				else
1701
+				} else
1719 1702
 				{
1720 1703
 					$GLOBALS['__DB__'][$db_info->master_db['db_type']] =
1721 1704
 						new DBMssqlConnectWrapper();
@@ -1812,22 +1795,19 @@  discard block
 block discarded – undo
1812 1795
 			try
1813 1796
 			{
1814 1797
 				$query_user_args = require($query_args_file);
1815
-			}
1816
-			catch (Exception $exc)
1798
+			} catch (Exception $exc)
1817 1799
 			{
1818 1800
 				fwrite(STDERR, "Error in arguments file.\n");
1819 1801
 				throw $exc;
1820 1802
 			}
1821
-		}
1822
-		else
1803
+		} else
1823 1804
 		{
1824 1805
 			if($query_args)
1825 1806
 			{
1826 1807
 				try
1827 1808
 				{
1828 1809
 					eval('$query_user_args = array(' . $query_args . ');');
1829
-				}
1830
-				catch (Exception $exc)
1810
+				} catch (Exception $exc)
1831 1811
 				{
1832 1812
 					fwrite(STDERR, "Error in arguments string.\n");
1833 1813
 					throw $exc;
@@ -1919,8 +1899,7 @@  discard block
 block discarded – undo
1919 1899
 				if($use_schema_language)
1920 1900
 				{
1921 1901
 					$document_schema = $table_schema;
1922
-				}
1923
-				else
1902
+				} else
1924 1903
 				{
1925 1904
 					if(!$document_schema)
1926 1905
 					{
@@ -1936,8 +1915,7 @@  discard block
 block discarded – undo
1936 1915
 					if($use_schema_language)
1937 1916
 					{
1938 1917
 						validate_schema_doc($argv[$i], $domDocument->documentElement);
1939
-					}
1940
-					else
1918
+					} else
1941 1919
 					{
1942 1920
 						validate_xml_query($argv[$i], $domDocument->documentElement);
1943 1921
 					}
@@ -1951,8 +1929,7 @@  discard block
 block discarded – undo
1951 1929
 					if(function_exists('sys_get_temp_dir'))
1952 1930
 					{
1953 1931
 						$tmpdir = sys_get_temp_dir();
1954
-					}
1955
-					else
1932
+					} else
1956 1933
 					{
1957 1934
 						$tmpdir = getenv('TEMP');
1958 1935
 						if(!$tmpdir)
@@ -2001,8 +1978,7 @@  discard block
 block discarded – undo
2001 1978
 							print " {$db_type} query:\n";
2002 1979
 							print $GLOBALS['__DB__'][$db_type]->queries;
2003 1980
 							print "\n";
2004
-						}
2005
-						else
1981
+						} else
2006 1982
 						{
2007 1983
 							$unlink_tmpfile =
2008 1984
 								new UnlinkFile(tempnam($tmpdir, 'xe_'));
@@ -2037,8 +2013,7 @@  discard block
 block discarded – undo
2037 2013
 										{
2038 2014
 											$query_user_args[$arg->variable_name] =
2039 2015
 												eval('return ' . $arg->argument_validator->default_value->toString() . ';');
2040
-										}
2041
-										else
2016
+										} else
2042 2017
 										{
2043 2018
 											if($arg->argument_validator->filter)
2044 2019
 											{
@@ -2133,8 +2108,7 @@  discard block
 block discarded – undo
2133 2108
 							if(is_a($resultset, 'BaseObject') && !$resultset->toBool())
2134 2109
 							{
2135 2110
 								throw new XmlSchemaError($argv[$i], -1, 'mysql SQL query generation failed');
2136
-							}
2137
-							else
2111
+							} else
2138 2112
 							{
2139 2113
 								print "\n";
2140 2114
 								print pathinfo($argv[$i], PATHINFO_FILENAME);
@@ -2151,14 +2125,12 @@  discard block
 block discarded – undo
2151 2125
 			{
2152 2126
 				libXmlDisplayError($argv[$i], TRUE);
2153 2127
 			}
2154
-		}
2155
-		catch (XmlSchemaError $exc)
2128
+		} catch (XmlSchemaError $exc)
2156 2129
 		{
2157 2130
 			$retcode->code(ReturnCode::RETCODE_BUILTIN_CHECKS);
2158 2131
 
2159 2132
 			fwrite(STDERR, $exc->getMessage() . "\n");
2160
-		}
2161
-		catch (ErrorMessage $exc)
2133
+		} catch (ErrorMessage $exc)
2162 2134
 		{
2163 2135
 			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2164 2136
 			{
@@ -2167,8 +2139,7 @@  discard block
 block discarded – undo
2167 2139
 
2168 2140
 			fwrite(STDERR, $exc->getMessage() . "\n");
2169 2141
 			libXmlDisplayError($argv[$i]);
2170
-		}
2171
-		catch (ErrorException $exc)
2142
+		} catch (ErrorException $exc)
2172 2143
 		{
2173 2144
 			if($retcode->code() == ReturnCode::RETCODE_SUCCESS)
2174 2145
 			{
@@ -2178,8 +2149,7 @@  discard block
 block discarded – undo
2178 2149
 			fwrite(STDERR, "{$exc->getFile()}({$exc->getLine()}):\n\t{$exc->getMessage()}.\n");
2179 2150
 			fwrite(STDERR, $exc->getTraceAsString());
2180 2151
 			libXmlDisplayError($argv[$i]);
2181
-		}
2182
-		catch (Exception $exc)
2152
+		} catch (Exception $exc)
2183 2153
 		{
2184 2154
 			$retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL);
2185 2155
 
@@ -2190,20 +2160,17 @@  discard block
 block discarded – undo
2190 2160
 	}
2191 2161
 
2192 2162
 	exit($retcode->code());
2193
-}
2194
-catch (SyntaxError $syntax)
2163
+} catch (SyntaxError $syntax)
2195 2164
 {
2196 2165
 	fwrite(STDERR, $syntax->getMessage() . "\n");
2197 2166
 	exit(254);	// wrong command line
2198 2167
 				// 255 is reserved by php (for parse errors, etc.)
2199
-}
2200
-catch (ErrorMessage $exc)
2168
+} catch (ErrorMessage $exc)
2201 2169
 {
2202 2170
 	fwrite(STDERR, $exc->getMessage() . "\n");
2203 2171
 	libXmlDisplayError();
2204 2172
 	exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL);		// internal validator error
2205
-}
2206
-catch (Exception $exc)
2173
+} catch (Exception $exc)
2207 2174
 {
2208 2175
 	fwrite(STDERR, $exc->getFile() . '(' . $exc->getLine() . ")\n\t" . $exc->getMessage() . "\n");
2209 2176
 	fwrite(STDERR, $exc->getTraceAsString());
Please login to merge, or discard this patch.
tools/minify/cssmin/CSSmin.php 3 patches
Doc Comments   +11 added lines, -2 removed lines patch added patch discarded remove patch
@@ -606,6 +606,11 @@  discard block
 block discarded – undo
606 606
  * ---------------------------------------------------------------------------------------------
607 607
  */
608 608
 
609
+/**
610
+ * @param double $v1
611
+ * @param double $v2
612
+ * @param integer $vh
613
+ */
609 614
 private function hue_to_rgb($v1, $v2, $vh)
610 615
 {
611 616
 	$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
@@ -620,6 +625,10 @@  discard block
 block discarded – undo
620 625
 	return intval(floor(floatval($n) + 0.5), 10);
621 626
 }
622 627
 
628
+/**
629
+ * @param integer $min
630
+ * @param integer $max
631
+ */
623 632
 private function clamp_number($n, $min, $max)
624 633
 {
625 634
 	return min(max($n, $min), $max);
@@ -648,7 +657,7 @@  discard block
 block discarded – undo
648 657
  *
649 658
  * @param string   $str
650 659
  * @param int      $from index
651
- * @param int|bool $to index (optional)
660
+ * @param integer $to index (optional)
652 661
  * @return string
653 662
  */
654 663
 private function substring($str, $from = 0, $to = FALSE)
@@ -680,7 +689,7 @@  discard block
 block discarded – undo
680 689
  *
681 690
  * @param string   $str
682 691
  * @param int      $start index
683
- * @param int|bool $end index (optional)
692
+ * @param integer $end index (optional)
684 693
  * @return string
685 694
  */
686 695
 private function str_slice($str, $start = 0, $end = FALSE)
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -609,9 +609,15 @@
 block discarded – undo
609 609
 private function hue_to_rgb($v1, $v2, $vh)
610 610
 {
611 611
 	$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
612
-	if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
613
-	if ($vh * 2 < 1) return $v2;
614
-	if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
612
+	if ($vh * 6 < 1) {
613
+		return $v1 + ($v2 - $v1) * 6 * $vh;
614
+	}
615
+	if ($vh * 2 < 1) {
616
+		return $v2;
617
+	}
618
+	if ($vh * 3 < 2) {
619
+		return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
620
+	}
615 621
 	return $v1;
616 622
 }
617 623
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->memory_limit = 128 * 1048576; // 128MB in bytes
48 48
 		$this->max_execution_time = 60; // 1 min
49 49
 		$this->pcre_backtrack_limit = 1000 * 1000;
50
-		$this->pcre_recursion_limit =  500 * 1000;
50
+		$this->pcre_recursion_limit = 500 * 1000;
51 51
 
52 52
 		$this->raise_php_limits = (bool) $raise_php_limits;
53 53
 	}
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 			}
85 85
 		$comment_found = $this->str_slice($css, $start_index + 2, $end_index);
86 86
 		$this->comments[] = $comment_found;
87
-		$comment_preserve_string = self::COMMENT . (count($this->comments) - 1) . '___';
88
-		$css = $this->str_slice($css, 0, $start_index + 2) . $comment_preserve_string . $this->str_slice($css, $end_index);
87
+		$comment_preserve_string = self::COMMENT.(count($this->comments) - 1).'___';
88
+		$css = $this->str_slice($css, 0, $start_index + 2).$comment_preserve_string.$this->str_slice($css, $end_index);
89 89
 		// Set correct start_index: Fixes issue #2528130
90 90
 		$start_index = $end_index + 2 + strlen($comment_preserve_string) - strlen($comment_found);
91 91
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 }
146 146
 
147 147
 // Update the first chunk and push the charset to the top of the file.
148
-$css_chunks[0] = $charset . $css_chunks[0];
148
+$css_chunks[0] = $charset.$css_chunks[0];
149 149
 
150 150
 return implode('', $css_chunks);
151 151
 }
@@ -220,17 +220,17 @@  discard block
 block discarded – undo
220 220
 	for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
221 221
 
222 222
 		$token = $this->comments[$i];
223
-		$placeholder = '/' . self::COMMENT . $i . '___/';
223
+		$placeholder = '/'.self::COMMENT.$i.'___/';
224 224
 
225 225
 		// ! in the first position of the comment means preserve
226 226
 		// so push to the preserved tokens keeping the !
227 227
 		if (substr($token, 0, 1) === '!') {
228 228
 			$this->preserved_tokens[] = $token;
229
-			$token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
229
+			$token_tring = self::TOKEN.(count($this->preserved_tokens) - 1).'___';
230 230
 			$css = preg_replace($placeholder, $token_tring, $css, 1);
231 231
 			// Preserve new lines for /*! important comments
232
-			$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css);
233
-			$css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/S', '$1'.self::NL, $css);
232
+			$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'.$token_tring.')/S', self::NL.'$1', $css);
233
+			$css = preg_replace('/('.$token_tring.'\*\/)\s*[\n\r\f]+\s*/S', '$1'.self::NL, $css);
234 234
 			continue;
235 235
 		}
236 236
 
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 		// shorten that to /*\*/ and the next one to /**/
239 239
 		if (substr($token, (strlen($token) - 1), 1) === '\\') {
240 240
 			$this->preserved_tokens[] = '\\';
241
-			$css = preg_replace($placeholder,  self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
241
+			$css = preg_replace($placeholder, self::TOKEN.(count($this->preserved_tokens) - 1).'___', $css, 1);
242 242
 			$i = $i + 1; // attn: advancing the loop
243 243
 			$this->preserved_tokens[] = '';
244
-			$css = preg_replace('/' . self::COMMENT . $i . '___/',  self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
244
+			$css = preg_replace('/'.self::COMMENT.$i.'___/', self::TOKEN.(count($this->preserved_tokens) - 1).'___', $css, 1);
245 245
 			continue;
246 246
 		}
247 247
 
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 			if ($start_index > 2) {
253 253
 				if (substr($css, $start_index - 3, 1) === '>') {
254 254
 					$this->preserved_tokens[] = '';
255
-					$css = preg_replace($placeholder,  self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
255
+					$css = preg_replace($placeholder, self::TOKEN.(count($this->preserved_tokens) - 1).'___', $css, 1);
256 256
 				}
257 257
 			}
258 258
 		}
259 259
 
260 260
 		// in all other cases kill the comment
261
-		$css = preg_replace('/\/\*' . $this->str_slice($placeholder, 1, -1) . '\*\//', '', $css, 1);
261
+		$css = preg_replace('/\/\*'.$this->str_slice($placeholder, 1, -1).'\*\//', '', $css, 1);
262 262
 	}
263 263
 
264 264
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	// Swap out any pseudo-class colons with the token, and then swap back.
292 292
 	$css = preg_replace_callback('/(?:^|\})(?:(?:[^\{\:])+\:)+(?:[^\{]*\{)/', array($this, 'replace_colon'), $css);
293 293
 	$css = preg_replace('/\s+([\!\{\}\;\:\>\+\(\)\]\~\=,])/', '$1', $css);
294
-	$css = preg_replace('/' . self::CLASSCOLON . '/', ':', $css);
294
+	$css = preg_replace('/'.self::CLASSCOLON.'/', ':', $css);
295 295
 
296 296
 	// retain space for special IE6 cases
297 297
 	$css = preg_replace('/\:first\-(line|letter)(\{|,)/i', ':first-$1 $2', $css);
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 					while ($i < strlen($css)) {
356 356
 					$i++;
357 357
 					if ($css[$i - 1] === '}' && $i - $start_index > $linebreak_pos) {
358
-					$css = $this->str_slice($css, 0, $i) . "\n" . $this->str_slice($css, $i);
358
+					$css = $this->str_slice($css, 0, $i)."\n".$this->str_slice($css, $i);
359 359
 					$start_index = $i;
360 360
 					}
361 361
 					}
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 					$css = preg_replace('/;;+/', ';', $css);
367 367
 
368 368
 					// Restore new lines for /*! important comments
369
-					$css = preg_replace('/'. self::NL .'/', "\n", $css);
369
+					$css = preg_replace('/'.self::NL.'/', "\n", $css);
370 370
 
371 371
 					// restore preserved comments and strings
372 372
 					for ($i = 0, $max = count($this->preserved_tokens); $i < $max; $i++) {
373
-						$css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1);
373
+						$css = preg_replace('/'.self::TOKEN.$i.'___/', $this->preserved_tokens[$i], $css, 1);
374 374
 					}
375 375
 
376 376
 					// Trim the final string (for any leading or trailing white spaces)
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 			$terminator = ')';
411 411
 		}
412 412
 
413
-		while ($found_terminator === FALSE && $end_index+1 <= $max_index) {
413
+		while ($found_terminator === FALSE && $end_index + 1 <= $max_index) {
414 414
 			$end_index = $this->index_of($css, $terminator, $end_index + 1);
415 415
 
416 416
 			// endIndex == 0 doesn't really apply here
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			$token = preg_replace('/\s+/', '', $token);
431 431
 			$this->preserved_tokens[] = $token;
432 432
 
433
-			$preserver = 'url(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___)';
433
+			$preserver = 'url('.self::TOKEN.(count($this->preserved_tokens) - 1).'___)';
434 434
 			$sb[] = $preserver;
435 435
 
436 436
 			$append_index = $end_index + 1;
@@ -491,16 +491,16 @@  discard block
 block discarded – undo
491 491
 
492 492
 		if ($is_filter) {
493 493
 			// Restore, maintain case, otherwise filter will break
494
-			$sb[] = $m[1] . '#' . $m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7];
494
+			$sb[] = $m[1].'#'.$m[2].$m[3].$m[4].$m[5].$m[6].$m[7];
495 495
 		} else {
496 496
 			if (strtolower($m[2]) == strtolower($m[3]) &&
497 497
 					strtolower($m[4]) == strtolower($m[5]) &&
498 498
 					strtolower($m[6]) == strtolower($m[7])) {
499 499
 				// Compress.
500
-				$hex = '#' . strtolower($m[3] . $m[5] . $m[7]);
500
+				$hex = '#'.strtolower($m[3].$m[5].$m[7]);
501 501
 			} else {
502 502
 				// Non compressible color, restore but lower case.
503
-				$hex = '#' . strtolower($m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]);
503
+				$hex = '#'.strtolower($m[2].$m[3].$m[4].$m[5].$m[6].$m[7]);
504 504
 			}
505 505
 			// replace Hex colors to short safe color names
506 506
 			$sb[] = array_key_exists($hex, $short_safe) ? $short_safe[$hex] : $hex;
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	// one, maybe more? put'em back then
530 530
 	if (($pos = $this->index_of($match, self::COMMENT)) >= 0) {
531 531
 		for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
532
-			$match = preg_replace('/' . self::COMMENT . $i . '___/', $this->comments[$i], $match, 1);
532
+			$match = preg_replace('/'.self::COMMENT.$i.'___/', $this->comments[$i], $match, 1);
533 533
 		}
534 534
 	}
535 535
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	$match = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $match);
538 538
 
539 539
 			$this->preserved_tokens[] = $match;
540
-			return $quote . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . $quote;
540
+			return $quote.self::TOKEN.(count($this->preserved_tokens) - 1).'___'.$quote;
541 541
 			}
542 542
 
543 543
 			private function replace_colon($matches)
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 			private function replace_calc($matches)
549 549
 			{
550 550
 			$this->preserved_tokens[] = preg_replace('/\s?([\*\/\(\),])\s?/', '$1', $matches[0]);
551
-			return self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
551
+			return self::TOKEN.(count($this->preserved_tokens) - 1).'___';
552 552
 			}
553 553
 
554 554
 			private function rgb_to_hex($matches)
555 555
 			{
556 556
 			// Support for percentage values rgb(100%, 0%, 45%);
557
-			if ($this->index_of($matches[1], '%') >= 0){
557
+			if ($this->index_of($matches[1], '%') >= 0) {
558 558
 				$rgbcolors = explode(',', str_replace('%', '', $matches[1]));
559 559
 				for ($i = 0; $i < count($rgbcolors); $i++) {
560 560
 					$rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55);
@@ -570,11 +570,11 @@  discard block
 block discarded – undo
570 570
 			}
571 571
 
572 572
 			// Fix for issue #2528093
573
-			if (!preg_match('/[\s\,\);\}]/', $matches[2])){
574
-				$matches[2] = ' ' . $matches[2];
573
+			if (!preg_match('/[\s\,\);\}]/', $matches[2])) {
574
+				$matches[2] = ' '.$matches[2];
575 575
 			}
576 576
 
577
-			return '#' . implode('', $rgbcolors) . $matches[2];
577
+			return '#'.implode('', $rgbcolors).$matches[2];
578 578
 			}
579 579
 
580 580
 private function hsl_to_hex($matches)
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
 	} else {
595 595
 		$v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
596 596
 		$v1 = (2 * $l) - $v2;
597
-		$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3)));
597
+		$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1 / 3)));
598 598
 		$g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h));
599
-		$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3)));
599
+		$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1 / 3)));
600 600
 	}
601 601
 
602 602
 	return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2]));
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
612 612
 	if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
613 613
 	if ($vh * 2 < 1) return $v2;
614
-	if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
614
+	if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2 / 3) - $vh) * 6;
615 615
 	return $v1;
616 616
 }
617 617
 
Please login to merge, or discard this patch.
tools/minify/jsminplus/jsminplus.php 4 patches
Doc Comments   +35 added lines patch added patch discarded remove patch
@@ -114,6 +114,9 @@  discard block
 block discarded – undo
114 114
 		$this->parser = new JSParser();
115 115
 	}
116 116
 
117
+	/**
118
+	 * @return string
119
+	 */
117 120
 	public static function minify($js, $filename='')
118 121
 	{
119 122
 		static $instance;
@@ -125,6 +128,9 @@  discard block
 block discarded – undo
125 128
 		return $instance->min($js, $filename);
126 129
 	}
127 130
 
131
+	/**
132
+	 * @param string $filename
133
+	 */
128 134
 	private function min($js, $filename)
129 135
 	{
130 136
 		try
@@ -140,6 +146,9 @@  discard block
 block discarded – undo
140 146
 		return false;
141 147
 	}
142 148
 
149
+	/**
150
+	 * @param JSNode $n
151
+	 */
143 152
 	private function parseTree($n, $noBlockGrouping = false)
144 153
 	{
145 154
 		$s = '';
@@ -545,6 +554,9 @@  discard block
 block discarded – undo
545 554
 		return $s;
546 555
 	}
547 556
 
557
+	/**
558
+	 * @param string $string
559
+	 */
548 560
 	private function isValidIdentifier($string)
549 561
 	{
550 562
 		return preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $string) && !in_array($string, $this->reserved);
@@ -608,6 +620,9 @@  discard block
 block discarded – undo
608 620
 		$this->t = new JSTokenizer();
609 621
 	}
610 622
 
623
+	/**
624
+	 * @param integer $l
625
+	 */
611 626
 	public function parse($s, $f, $l)
612 627
 	{
613 628
 		// initialize tokenizer
@@ -621,6 +636,9 @@  discard block
 block discarded – undo
621 636
 		return $n;
622 637
 	}
623 638
 
639
+	/**
640
+	 * @param JSCompilerContext $x
641
+	 */
624 642
 	private function Script($x)
625 643
 	{
626 644
 		$n = $this->Statements($x);
@@ -971,6 +989,10 @@  discard block
 block discarded – undo
971 989
 		return $n;
972 990
 	}
973 991
 
992
+	/**
993
+	 * @param boolean $requireName
994
+	 * @param integer $functionForm
995
+	 */
974 996
 	private function FunctionDefinition($x, $requireName, $functionForm)
975 997
 	{
976 998
 		$f = new JSNode($this->t);
@@ -1437,6 +1459,10 @@  discard block
 block discarded – undo
1437 1459
 	}
1438 1460
 
1439 1461
 	// Statement stack and nested statement handler.
1462
+
1463
+	/**
1464
+	 * @param JSNode $node
1465
+	 */
1440 1466
 	private function nest($x, $node, $end = false)
1441 1467
 	{
1442 1468
 		array_push($x->stmtStack, $node);
@@ -1501,6 +1527,9 @@  discard block
 block discarded – undo
1501 1527
 	public $funDecls = array();
1502 1528
 	public $varDecls = array();
1503 1529
 
1530
+	/**
1531
+	 * @param boolean $inFunction
1532
+	 */
1504 1533
 	public function __construct($inFunction)
1505 1534
 	{
1506 1535
 		$this->inFunction = $inFunction;
@@ -1519,6 +1548,9 @@  discard block
 block discarded – undo
1519 1548
 	public $funDecls = array();
1520 1549
 	public $varDecls = array();
1521 1550
 
1551
+	/**
1552
+	 * @param JSTokenizer $t
1553
+	 */
1522 1554
 	public function __construct($t, $type=0)
1523 1555
 	{
1524 1556
 		if ($token = $t->currentToken())
@@ -1673,6 +1705,9 @@  discard block
 block discarded – undo
1673 1705
 		$this->scanOperand = true;
1674 1706
 	}
1675 1707
 
1708
+	/**
1709
+	 * @param integer|null $chunksize
1710
+	 */
1676 1711
 	public function getInput($chunksize)
1677 1712
 	{
1678 1713
 		if ($chunksize)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
 			return $n;
787 787
 
788 788
 			case KEYWORD_WHILE:
789
-			        $n = new JSNode($this->t);
790
-			        $n->isLoop = true;
791
-			        $n->condition = $this->ParenExpression($x);
792
-			        $n->body = $this->nest($x, $n);
789
+					$n = new JSNode($this->t);
790
+					$n->isLoop = true;
791
+					$n->condition = $this->ParenExpression($x);
792
+					$n->body = $this->nest($x, $n);
793 793
 			return $n;
794 794
 
795 795
 			case KEYWORD_DO:
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 
910 910
 			case KEYWORD_VAR:
911 911
 			case KEYWORD_CONST:
912
-			        $n = $this->Variables($x);
912
+					$n = $this->Variables($x);
913 913
 			break;
914 914
 
915 915
 			case TOKEN_CONDCOMMENT_START:
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
 
1694 1694
 	public function mustMatch($tt)
1695 1695
 	{
1696
-	        if (!$this->match($tt))
1696
+			if (!$this->match($tt))
1697 1697
 			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1698 1698
 
1699 1699
 		return $this->currentToken();
Please login to merge, or discard this patch.
Braces   +350 added lines, -274 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@  discard block
 block discarded – undo
119 119
 		static $instance;
120 120
 
121 121
 		// this is a singleton
122
-		if(!$instance)
123
-			$instance = new JSMinPlus();
122
+		if(!$instance) {
123
+					$instance = new JSMinPlus();
124
+		}
124 125
 
125 126
 		return $instance->min($js, $filename);
126 127
 	}
@@ -131,8 +132,7 @@  discard block
 block discarded – undo
131 132
 		{
132 133
 			$n = $this->parser->parse($js, $filename, 1);
133 134
 			return $this->parseTree($n);
134
-		}
135
-		catch(Exception $e)
135
+		} catch(Exception $e)
136 136
 		{
137 137
 			echo $e->getMessage() . "\n";
138 138
 		}
@@ -149,8 +149,9 @@  discard block
 block discarded – undo
149 149
 			case KEYWORD_FUNCTION:
150 150
 				$s .= 'function' . ($n->name ? ' ' . $n->name : '') . '(';
151 151
 				$params = $n->params;
152
-				for ($i = 0, $j = count($params); $i < $j; $i++)
153
-					$s .= ($i ? ',' : '') . $params[$i];
152
+				for ($i = 0, $j = count($params); $i < $j; $i++) {
153
+									$s .= ($i ? ',' : '') . $params[$i];
154
+				}
154 155
 				$s .= '){' . $this->parseTree($n->body, true) . '}';
155 156
 			break;
156 157
 
@@ -176,13 +177,11 @@  discard block
 block discarded – undo
176 177
 							{
177 178
 								// put declared functions on a new line
178 179
 								$s .= "\n";
179
-							}
180
-							elseif ($type == KEYWORD_VAR && $type == $lastType)
180
+							} elseif ($type == KEYWORD_VAR && $type == $lastType)
181 181
 							{
182 182
 								// mutiple var-statements can go into one
183 183
 								$t = ',' . substr($t, 4);
184
-							}
185
-							else
184
+							} else
186 185
 							{
187 186
 								// add terminator
188 187
 								$s .= ';';
@@ -208,24 +207,26 @@  discard block
 block discarded – undo
208 207
 				$elsePart = $n->elsePart ? $this->parseTree($n->elsePart) : null;
209 208
 
210 209
 				// empty if-statement
211
-				if ($thenPart == '')
212
-					$thenPart = ';';
210
+				if ($thenPart == '') {
211
+									$thenPart = ';';
212
+				}
213 213
 
214 214
 				if ($elsePart)
215 215
 				{
216 216
 					// be carefull and always make a block out of the thenPart; could be more optimized but is a lot of trouble
217
-					if ($thenPart != ';' && $thenPart[0] != '{')
218
-						$thenPart = '{' . $thenPart . '}';
217
+					if ($thenPart != ';' && $thenPart[0] != '{') {
218
+											$thenPart = '{' . $thenPart . '}';
219
+					}
219 220
 
220 221
 					$s .= $thenPart . 'else';
221 222
 
222 223
 					// we could check for more, but that hardly ever applies so go for performance
223
-					if ($elsePart[0] != '{')
224
-						$s .= ' ';
224
+					if ($elsePart[0] != '{') {
225
+											$s .= ' ';
226
+					}
225 227
 
226 228
 					$s .= $elsePart;
227
-				}
228
-				else
229
+				} else
229 230
 				{
230 231
 					$s .= $thenPart;
231 232
 				}
@@ -237,18 +238,20 @@  discard block
 block discarded – undo
237 238
 				for ($i = 0, $j = count($cases); $i < $j; $i++)
238 239
 				{
239 240
 					$case = $cases[$i];
240
-					if ($case->type == KEYWORD_CASE)
241
-						$s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':';
242
-					else
243
-						$s .= 'default:';
241
+					if ($case->type == KEYWORD_CASE) {
242
+											$s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':';
243
+					} else {
244
+											$s .= 'default:';
245
+					}
244 246
 
245 247
 					$statement = $this->parseTree($case->statements, true);
246 248
 					if ($statement)
247 249
 					{
248 250
 						$s .= $statement;
249 251
 						// no terminator for last statement
250
-						if ($i + 1 < $j)
251
-							$s .= ';';
252
+						if ($i + 1 < $j) {
253
+													$s .= ';';
254
+						}
252 255
 					}
253 256
 				}
254 257
 				$s .= '}';
@@ -260,8 +263,9 @@  discard block
 block discarded – undo
260 263
 					. ';' . ($n->update ? $this->parseTree($n->update) : '') . ')';
261 264
 
262 265
 				$body  = $this->parseTree($n->body);
263
-				if ($body == '')
264
-					$body = ';';
266
+				if ($body == '') {
267
+									$body = ';';
268
+				}
265 269
 
266 270
 				$s .= $body;
267 271
 			break;
@@ -270,8 +274,9 @@  discard block
 block discarded – undo
270 274
 				$s = 'while(' . $this->parseTree($n->condition) . ')';
271 275
 
272 276
 				$body  = $this->parseTree($n->body);
273
-				if ($body == '')
274
-					$body = ';';
277
+				if ($body == '') {
278
+									$body = ';';
279
+				}
275 280
 
276 281
 				$s .= $body;
277 282
 			break;
@@ -280,8 +285,9 @@  discard block
 block discarded – undo
280 285
 				$s = 'for(' . ($n->varDecl ? $this->parseTree($n->varDecl) : $this->parseTree($n->iterator)) . ' in ' . $this->parseTree($n->object) . ')';
281 286
 
282 287
 				$body  = $this->parseTree($n->body);
283
-				if ($body == '')
284
-					$body = ';';
288
+				if ($body == '') {
289
+									$body = ';';
290
+				}
285 291
 
286 292
 				$s .= $body;
287 293
 			break;
@@ -303,8 +309,9 @@  discard block
 block discarded – undo
303 309
 					$t = $catchClauses[$i];
304 310
 					$s .= 'catch(' . $t->varName . ($t->guard ? ' if ' . $this->parseTree($t->guard) : '') . '){' . $this->parseTree($t->block, true) . '}';
305 311
 				}
306
-				if ($n->finallyBlock)
307
-					$s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}';
312
+				if ($n->finallyBlock) {
313
+									$s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}';
314
+				}
308 315
 			break;
309 316
 
310 317
 			case KEYWORD_THROW:
@@ -320,8 +327,9 @@  discard block
 block discarded – undo
320 327
 					{
321 328
 						if (	$t[0] != '(' && $t[0] != '[' && $t[0] != '{' &&
322 329
 							$t[0] != '"' && $t[0] != "'" && $t[0] != '/'
323
-						)
324
-							$s .= ' ';
330
+						) {
331
+													$s .= ' ';
332
+						}
325 333
 
326 334
 						$s .= $t;
327 335
 					}
@@ -341,8 +349,9 @@  discard block
 block discarded – undo
341 349
 					$t = $childs[$i];
342 350
 					$s .= ($i ? ',' : '') . $t->name;
343 351
 					$u = $t->initializer;
344
-					if ($u)
345
-						$s .= '=' . $this->parseTree($u);
352
+					if ($u) {
353
+											$s .= '=' . $this->parseTree($u);
354
+					}
346 355
 				}
347 356
 			break;
348 357
 
@@ -354,13 +363,15 @@  discard block
 block discarded – undo
354 363
 			case TOKEN_CONDCOMMENT_END:
355 364
 				$s = $n->value . ($n->type == TOKEN_CONDCOMMENT_START ? ' ' : '');
356 365
 				$childs = $n->treeNodes;
357
-				for ($i = 0, $j = count($childs); $i < $j; $i++)
358
-					$s .= $this->parseTree($childs[$i]);
366
+				for ($i = 0, $j = count($childs); $i < $j; $i++) {
367
+									$s .= $this->parseTree($childs[$i]);
368
+				}
359 369
 			break;
360 370
 
361 371
 			case OP_SEMICOLON:
362
-				if ($expression = $n->expression)
363
-					$s = $this->parseTree($expression);
372
+				if ($expression = $n->expression) {
373
+									$s = $this->parseTree($expression);
374
+				}
364 375
 			break;
365 376
 
366 377
 			case JS_LABEL:
@@ -369,8 +380,9 @@  discard block
 block discarded – undo
369 380
 
370 381
 			case OP_COMMA:
371 382
 				$childs = $n->treeNodes;
372
-				for ($i = 0, $j = count($childs); $i < $j; $i++)
373
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
383
+				for ($i = 0, $j = count($childs); $i < $j; $i++) {
384
+									$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
385
+				}
374 386
 			break;
375 387
 
376 388
 			case OP_ASSIGN:
@@ -449,10 +461,11 @@  discard block
 block discarded – undo
449 461
 
450 462
 			case OP_INCREMENT:
451 463
 			case OP_DECREMENT:
452
-				if ($n->postfix)
453
-					$s = $this->parseTree($n->treeNodes[0]) . $n->value;
454
-				else
455
-					$s = $n->value . $this->parseTree($n->treeNodes[0]);
464
+				if ($n->postfix) {
465
+									$s = $this->parseTree($n->treeNodes[0]) . $n->value;
466
+				} else {
467
+									$s = $n->value . $this->parseTree($n->treeNodes[0]);
468
+				}
456 469
 			break;
457 470
 
458 471
 			case OP_DOT:
@@ -465,16 +478,18 @@  discard block
 block discarded – undo
465 478
 				if (	$n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
466 479
 					$n->treeNodes[1]->type == TOKEN_STRING &&
467 480
 					$this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1))
468
-				)
469
-					$s .= '.' . substr($n->treeNodes[1]->value, 1, -1);
470
-				else
471
-					$s .= '[' . $this->parseTree($n->treeNodes[1]) . ']';
481
+				) {
482
+									$s .= '.' . substr($n->treeNodes[1]->value, 1, -1);
483
+				} else {
484
+									$s .= '[' . $this->parseTree($n->treeNodes[1]) . ']';
485
+				}
472 486
 			break;
473 487
 
474 488
 			case JS_LIST:
475 489
 				$childs = $n->treeNodes;
476
-				for ($i = 0, $j = count($childs); $i < $j; $i++)
477
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
490
+				for ($i = 0, $j = count($childs); $i < $j; $i++) {
491
+									$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
492
+				}
478 493
 			break;
479 494
 
480 495
 			case JS_CALL:
@@ -502,27 +517,29 @@  discard block
 block discarded – undo
502 517
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
503 518
 				{
504 519
 					$t = $childs[$i];
505
-					if ($i)
506
-						$s .= ',';
520
+					if ($i) {
521
+											$s .= ',';
522
+					}
507 523
 					if ($t->type == JS_PROPERTY_INIT)
508 524
 					{
509 525
 						// Ditch the quotes when the index is a valid identifier
510 526
 						if (	$t->treeNodes[0]->type == TOKEN_STRING &&
511 527
 							$this->isValidIdentifier(substr($t->treeNodes[0]->value, 1, -1))
512
-						)
513
-							$s .= substr($t->treeNodes[0]->value, 1, -1);
514
-						else
515
-							$s .= $t->treeNodes[0]->value;
528
+						) {
529
+													$s .= substr($t->treeNodes[0]->value, 1, -1);
530
+						} else {
531
+													$s .= $t->treeNodes[0]->value;
532
+						}
516 533
 
517 534
 						$s .= ':' . $this->parseTree($t->treeNodes[1]);
518
-					}
519
-					else
535
+					} else
520 536
 					{
521 537
 						$s .= $t->type == JS_GETTER ? 'get' : 'set';
522 538
 						$s .= ' ' . $t->name . '(';
523 539
 						$params = $t->params;
524
-						for ($i = 0, $j = count($params); $i < $j; $i++)
525
-							$s .= ($i ? ',' : '') . $params[$i];
540
+						for ($i = 0, $j = count($params); $i < $j; $i++) {
541
+													$s .= ($i ? ',' : '') . $params[$i];
542
+						}
526 543
 						$s .= '){' . $this->parseTree($t->body, true) . '}';
527 544
 					}
528 545
 				}
@@ -615,8 +632,9 @@  discard block
 block discarded – undo
615 632
 
616 633
 		$x = new JSCompilerContext(false);
617 634
 		$n = $this->Script($x);
618
-		if (!$this->t->isDone())
619
-			throw $this->t->newSyntaxError('Syntax error');
635
+		if (!$this->t->isDone()) {
636
+					throw $this->t->newSyntaxError('Syntax error');
637
+		}
620 638
 
621 639
 		return $n;
622 640
 	}
@@ -636,8 +654,9 @@  discard block
 block discarded – undo
636 654
 		$n = new JSNode($this->t, JS_BLOCK);
637 655
 		array_push($x->stmtStack, $n);
638 656
 
639
-		while (!$this->t->isDone() && $this->t->peek() != OP_RIGHT_CURLY)
640
-			$n->addNode($this->Statement($x));
657
+		while (!$this->t->isDone() && $this->t->peek() != OP_RIGHT_CURLY) {
658
+					$n->addNode($this->Statement($x));
659
+		}
641 660
 
642 661
 		array_pop($x->stmtStack);
643 662
 
@@ -701,15 +720,17 @@  discard block
 block discarded – undo
701 720
 					switch ($tt)
702 721
 					{
703 722
 						case KEYWORD_DEFAULT:
704
-							if ($n->defaultIndex >= 0)
705
-								throw $this->t->newSyntaxError('More than one switch default');
723
+							if ($n->defaultIndex >= 0) {
724
+															throw $this->t->newSyntaxError('More than one switch default');
725
+							}
706 726
 							// FALL THROUGH
707 727
 						case KEYWORD_CASE:
708 728
 							$n2 = new JSNode($this->t);
709
-							if ($tt == KEYWORD_DEFAULT)
710
-								$n->defaultIndex = count($n->cases);
711
-							else
712
-								$n2->caseLabel = $this->Expression($x, OP_COLON);
729
+							if ($tt == KEYWORD_DEFAULT) {
730
+															$n->defaultIndex = count($n->cases);
731
+							} else {
732
+															$n2->caseLabel = $this->Expression($x, OP_COLON);
733
+							}
713 734
 								break;
714 735
 						default:
715 736
 							throw $this->t->newSyntaxError('Invalid switch case');
@@ -717,8 +738,9 @@  discard block
 block discarded – undo
717 738
 
718 739
 					$this->t->mustMatch(OP_COLON);
719 740
 					$n2->statements = new JSNode($this->t, JS_BLOCK);
720
-					while (($tt = $this->t->peek()) != KEYWORD_CASE && $tt != KEYWORD_DEFAULT && $tt != OP_RIGHT_CURLY)
721
-						$n2->statements->addNode($this->Statement($x));
741
+					while (($tt = $this->t->peek()) != KEYWORD_CASE && $tt != KEYWORD_DEFAULT && $tt != OP_RIGHT_CURLY) {
742
+											$n2->statements->addNode($this->Statement($x));
743
+					}
722 744
 
723 745
 					array_push($n->cases, $n2);
724 746
 				}
@@ -738,8 +760,7 @@  discard block
 block discarded – undo
738 760
 					{
739 761
 						$this->t->get();
740 762
 						$n2 = $this->Variables($x);
741
-					}
742
-					else
763
+					} else
743 764
 					{
744 765
 						$n2 = $this->Expression($x);
745 766
 					}
@@ -763,16 +784,14 @@  discard block
 block discarded – undo
763 784
 						// NB: n2[0].type == IDENTIFIER and n2[0].value == n2[0].name.
764 785
 						$n->iterator = $n2->treeNodes[0];
765 786
 						$n->varDecl = $n2;
766
-					}
767
-					else
787
+					} else
768 788
 					{
769 789
 						$n->iterator = $n2;
770 790
 						$n->varDecl = null;
771 791
 					}
772 792
 
773 793
 					$n->object = $this->Expression($x);
774
-				}
775
-				else
794
+				} else
776 795
 				{
777 796
 					$n->setup = $n2 ? $n2 : null;
778 797
 					$this->t->mustMatch(OP_SEMICOLON);
@@ -824,17 +843,18 @@  discard block
 block discarded – undo
824 843
 				{
825 844
 					do
826 845
 					{
827
-						if (--$i < 0)
828
-							throw $this->t->newSyntaxError('Label not found');
846
+						if (--$i < 0) {
847
+													throw $this->t->newSyntaxError('Label not found');
848
+						}
829 849
 					}
830 850
 					while ($ss[$i]->label != $label);
831
-				}
832
-				else
851
+				} else
833 852
 				{
834 853
 					do
835 854
 					{
836
-						if (--$i < 0)
837
-							throw $this->t->newSyntaxError('Invalid ' . $tt);
855
+						if (--$i < 0) {
856
+													throw $this->t->newSyntaxError('Invalid ' . $tt);
857
+						}
838 858
 					}
839 859
 					while (!$ss[$i]->isLoop && ($tt != KEYWORD_BREAK || $ss[$i]->type != KEYWORD_SWITCH));
840 860
 				}
@@ -855,15 +875,16 @@  discard block
 block discarded – undo
855 875
 
856 876
 					if ($this->t->match(KEYWORD_IF))
857 877
 					{
858
-						if ($x->ecmaStrictMode)
859
-							throw $this->t->newSyntaxError('Illegal catch guard');
878
+						if ($x->ecmaStrictMode) {
879
+													throw $this->t->newSyntaxError('Illegal catch guard');
880
+						}
860 881
 
861
-						if (count($n->catchClauses) && !end($n->catchClauses)->guard)
862
-							throw $this->t->newSyntaxError('Guarded catch after unguarded');
882
+						if (count($n->catchClauses) && !end($n->catchClauses)->guard) {
883
+													throw $this->t->newSyntaxError('Guarded catch after unguarded');
884
+						}
863 885
 
864 886
 						$n2->guard = $this->Expression($x);
865
-					}
866
-					else
887
+					} else
867 888
 					{
868 889
 						$n2->guard = null;
869 890
 					}
@@ -873,11 +894,13 @@  discard block
 block discarded – undo
873 894
 					array_push($n->catchClauses, $n2);
874 895
 				}
875 896
 
876
-				if ($this->t->match(KEYWORD_FINALLY))
877
-					$n->finallyBlock = $this->Block($x);
897
+				if ($this->t->match(KEYWORD_FINALLY)) {
898
+									$n->finallyBlock = $this->Block($x);
899
+				}
878 900
 
879
-				if (!count($n->catchClauses) && !$n->finallyBlock)
880
-					throw $this->t->newSyntaxError('Invalid try statement');
901
+				if (!count($n->catchClauses) && !$n->finallyBlock) {
902
+									throw $this->t->newSyntaxError('Invalid try statement');
903
+				}
881 904
 			return $n;
882 905
 
883 906
 			case KEYWORD_CATCH:
@@ -890,15 +913,17 @@  discard block
 block discarded – undo
890 913
 			break;
891 914
 
892 915
 			case KEYWORD_RETURN:
893
-				if (!$x->inFunction)
894
-					throw $this->t->newSyntaxError('Invalid return');
916
+				if (!$x->inFunction) {
917
+									throw $this->t->newSyntaxError('Invalid return');
918
+				}
895 919
 
896 920
 				$n = new JSNode($this->t);
897 921
 				$tt = $this->t->peekOnSameLine();
898
-				if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY)
899
-					$n->value = $this->Expression($x);
900
-				else
901
-					$n->value = null;
922
+				if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY) {
923
+									$n->value = $this->Expression($x);
924
+				} else {
925
+									$n->value = null;
926
+				}
902 927
 			break;
903 928
 
904 929
 			case KEYWORD_WITH:
@@ -939,8 +964,9 @@  discard block
 block discarded – undo
939 964
 						$ss = $x->stmtStack;
940 965
 						for ($i = count($ss) - 1; $i >= 0; --$i)
941 966
 						{
942
-							if ($ss[$i]->label == $label)
943
-								throw $this->t->newSyntaxError('Duplicate label');
967
+							if ($ss[$i]->label == $label) {
968
+															throw $this->t->newSyntaxError('Duplicate label');
969
+							}
944 970
 						}
945 971
 
946 972
 						$this->t->get();
@@ -962,8 +988,9 @@  discard block
 block discarded – undo
962 988
 		if ($this->t->lineno == $this->t->currentToken()->lineno)
963 989
 		{
964 990
 			$tt = $this->t->peekOnSameLine();
965
-			if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY)
966
-				throw $this->t->newSyntaxError('Missing ; before statement');
991
+			if ($tt != TOKEN_END && $tt != TOKEN_NEWLINE && $tt != OP_SEMICOLON && $tt != OP_RIGHT_CURLY) {
992
+							throw $this->t->newSyntaxError('Missing ; before statement');
993
+			}
967 994
 		}
968 995
 
969 996
 		$this->t->match(OP_SEMICOLON);
@@ -975,26 +1002,30 @@  discard block
 block discarded – undo
975 1002
 	{
976 1003
 		$f = new JSNode($this->t);
977 1004
 
978
-		if ($f->type != KEYWORD_FUNCTION)
979
-			$f->type = ($f->value == 'get') ? JS_GETTER : JS_SETTER;
1005
+		if ($f->type != KEYWORD_FUNCTION) {
1006
+					$f->type = ($f->value == 'get') ? JS_GETTER : JS_SETTER;
1007
+		}
980 1008
 
981
-		if ($this->t->match(TOKEN_IDENTIFIER))
982
-			$f->name = $this->t->currentToken()->value;
983
-		elseif ($requireName)
984
-			throw $this->t->newSyntaxError('Missing function identifier');
1009
+		if ($this->t->match(TOKEN_IDENTIFIER)) {
1010
+					$f->name = $this->t->currentToken()->value;
1011
+		} elseif ($requireName) {
1012
+					throw $this->t->newSyntaxError('Missing function identifier');
1013
+		}
985 1014
 
986 1015
 		$this->t->mustMatch(OP_LEFT_PAREN);
987 1016
 			$f->params = array();
988 1017
 
989 1018
 		while (($tt = $this->t->get()) != OP_RIGHT_PAREN)
990 1019
 		{
991
-			if ($tt != TOKEN_IDENTIFIER)
992
-				throw $this->t->newSyntaxError('Missing formal parameter');
1020
+			if ($tt != TOKEN_IDENTIFIER) {
1021
+							throw $this->t->newSyntaxError('Missing formal parameter');
1022
+			}
993 1023
 
994 1024
 			array_push($f->params, $this->t->currentToken()->value);
995 1025
 
996
-			if ($this->t->peek() != OP_RIGHT_PAREN)
997
-				$this->t->mustMatch(OP_COMMA);
1026
+			if ($this->t->peek() != OP_RIGHT_PAREN) {
1027
+							$this->t->mustMatch(OP_COMMA);
1028
+			}
998 1029
 		}
999 1030
 
1000 1031
 		$this->t->mustMatch(OP_LEFT_CURLY);
@@ -1006,8 +1037,9 @@  discard block
 block discarded – undo
1006 1037
 		$f->end = $this->t->currentToken()->end;
1007 1038
 
1008 1039
 		$f->functionForm = $functionForm;
1009
-		if ($functionForm == DECLARED_FORM)
1010
-			array_push($x->funDecls, $f);
1040
+		if ($functionForm == DECLARED_FORM) {
1041
+					array_push($x->funDecls, $f);
1042
+		}
1011 1043
 
1012 1044
 		return $f;
1013 1045
 	}
@@ -1025,8 +1057,9 @@  discard block
 block discarded – undo
1025 1057
 
1026 1058
 			if ($this->t->match(OP_ASSIGN))
1027 1059
 			{
1028
-				if ($this->t->currentToken()->assignOp)
1029
-					throw $this->t->newSyntaxError('Invalid variable initialization');
1060
+				if ($this->t->currentToken()->assignOp) {
1061
+									throw $this->t->newSyntaxError('Invalid variable initialization');
1062
+				}
1030 1063
 
1031 1064
 				$n2->initializer = $this->Expression($x, OP_COMMA);
1032 1065
 			}
@@ -1073,13 +1106,15 @@  discard block
 block discarded – undo
1073 1106
 					break 2;
1074 1107
 
1075 1108
 				case OP_HOOK:
1076
-					if ($this->t->scanOperand)
1077
-						break 2;
1109
+					if ($this->t->scanOperand) {
1110
+											break 2;
1111
+					}
1078 1112
 
1079 1113
 					while (	!empty($operators) &&
1080 1114
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1081
-					)
1082
-						$this->reduce($operators, $operands);
1115
+					) {
1116
+											$this->reduce($operators, $operands);
1117
+					}
1083 1118
 
1084 1119
 					array_push($operators, new JSNode($this->t));
1085 1120
 
@@ -1087,29 +1122,33 @@  discard block
 block discarded – undo
1087 1122
 					$this->t->scanOperand = true;
1088 1123
 					$n = $this->Expression($x);
1089 1124
 
1090
-					if (!$this->t->match(OP_COLON))
1091
-						break 2;
1125
+					if (!$this->t->match(OP_COLON)) {
1126
+											break 2;
1127
+					}
1092 1128
 
1093 1129
 					--$x->hookLevel;
1094 1130
 					array_push($operands, $n);
1095 1131
 				break;
1096 1132
 
1097 1133
 				case OP_COLON:
1098
-					if ($x->hookLevel)
1099
-						break 2;
1134
+					if ($x->hookLevel) {
1135
+											break 2;
1136
+					}
1100 1137
 
1101 1138
 					throw $this->t->newSyntaxError('Invalid label');
1102 1139
 				break;
1103 1140
 
1104 1141
 				case OP_ASSIGN:
1105
-					if ($this->t->scanOperand)
1106
-						break 2;
1142
+					if ($this->t->scanOperand) {
1143
+											break 2;
1144
+					}
1107 1145
 
1108 1146
 					// Use >, not >=, for right-associative ASSIGN
1109 1147
 					while (	!empty($operators) &&
1110 1148
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1111
-					)
1112
-						$this->reduce($operators, $operands);
1149
+					) {
1150
+											$this->reduce($operators, $operands);
1151
+					}
1113 1152
 
1114 1153
 					array_push($operators, new JSNode($this->t));
1115 1154
 					end($operands)->assignOp = $this->t->currentToken()->assignOp;
@@ -1123,8 +1162,9 @@  discard block
 block discarded – undo
1123 1162
 					if ($x->inForLoopInit && !$x->hookLevel &&
1124 1163
 						!$x->bracketLevel && !$x->curlyLevel &&
1125 1164
 						!$x->parenLevel
1126
-					)
1127
-						break 2;
1165
+					) {
1166
+											break 2;
1167
+					}
1128 1168
 				// FALL THROUGH
1129 1169
 				case OP_COMMA:
1130 1170
 					// A comma operator should not be parsed if we're parsing the then part
@@ -1132,8 +1172,9 @@  discard block
 block discarded – undo
1132 1172
 					if ($tt == OP_COMMA && $x->hookLevel &&
1133 1173
 						!$x->bracketLevel && !$x->curlyLevel &&
1134 1174
 						!$x->parenLevel
1135
-					)
1136
-						break 2;
1175
+					) {
1176
+											break 2;
1177
+					}
1137 1178
 				// Treat comma as left-associative so reduce can fold left-heavy
1138 1179
 				// COMMA trees into a single array.
1139 1180
 				// FALL THROUGH
@@ -1149,20 +1190,21 @@  discard block
 block discarded – undo
1149 1190
 				case OP_PLUS: case OP_MINUS:
1150 1191
 				case OP_MUL: case OP_DIV: case OP_MOD:
1151 1192
 				case OP_DOT:
1152
-					if ($this->t->scanOperand)
1153
-						break 2;
1193
+					if ($this->t->scanOperand) {
1194
+											break 2;
1195
+					}
1154 1196
 
1155 1197
 					while (	!empty($operators) &&
1156 1198
 						$this->opPrecedence[end($operators)->type] >= $this->opPrecedence[$tt]
1157
-					)
1158
-						$this->reduce($operators, $operands);
1199
+					) {
1200
+											$this->reduce($operators, $operands);
1201
+					}
1159 1202
 
1160 1203
 					if ($tt == OP_DOT)
1161 1204
 					{
1162 1205
 						$this->t->mustMatch(TOKEN_IDENTIFIER);
1163 1206
 						array_push($operands, new JSNode($this->t, OP_DOT, array_pop($operands), new JSNode($this->t)));
1164
-					}
1165
-					else
1207
+					} else
1166 1208
 					{
1167 1209
 						array_push($operators, new JSNode($this->t));
1168 1210
 						$this->t->scanOperand = true;
@@ -1172,8 +1214,9 @@  discard block
 block discarded – undo
1172 1214
 				case KEYWORD_DELETE: case KEYWORD_VOID: case KEYWORD_TYPEOF:
1173 1215
 				case OP_NOT: case OP_BITWISE_NOT: case OP_UNARY_PLUS: case OP_UNARY_MINUS:
1174 1216
 				case KEYWORD_NEW:
1175
-					if (!$this->t->scanOperand)
1176
-						break 2;
1217
+					if (!$this->t->scanOperand) {
1218
+											break 2;
1219
+					}
1177 1220
 
1178 1221
 					array_push($operators, new JSNode($this->t));
1179 1222
 				break;
@@ -1182,19 +1225,20 @@  discard block
 block discarded – undo
1182 1225
 					if ($this->t->scanOperand)
1183 1226
 					{
1184 1227
 						array_push($operators, new JSNode($this->t));  // prefix increment or decrement
1185
-					}
1186
-					else
1228
+					} else
1187 1229
 					{
1188 1230
 						// Don't cross a line boundary for postfix {in,de}crement.
1189 1231
 						$t = $this->t->tokens[($this->t->tokenIndex + $this->t->lookahead - 1) & 3];
1190
-						if ($t && $t->lineno != $this->t->lineno)
1191
-							break 2;
1232
+						if ($t && $t->lineno != $this->t->lineno) {
1233
+													break 2;
1234
+						}
1192 1235
 
1193 1236
 						if (!empty($operators))
1194 1237
 						{
1195 1238
 							// Use >, not >=, so postfix has higher precedence than prefix.
1196
-							while ($this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt])
1197
-								$this->reduce($operators, $operands);
1239
+							while ($this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]) {
1240
+															$this->reduce($operators, $operands);
1241
+							}
1198 1242
 						}
1199 1243
 
1200 1244
 						$n = new JSNode($this->t, $tt, array_pop($operands));
@@ -1204,8 +1248,9 @@  discard block
 block discarded – undo
1204 1248
 				break;
1205 1249
 
1206 1250
 				case KEYWORD_FUNCTION:
1207
-					if (!$this->t->scanOperand)
1208
-						break 2;
1251
+					if (!$this->t->scanOperand) {
1252
+											break 2;
1253
+					}
1209 1254
 
1210 1255
 					array_push($operands, $this->FunctionDefinition($x, false, EXPRESSED_FORM));
1211 1256
 					$this->t->scanOperand = false;
@@ -1213,8 +1258,9 @@  discard block
 block discarded – undo
1213 1258
 
1214 1259
 				case KEYWORD_NULL: case KEYWORD_THIS: case KEYWORD_TRUE: case KEYWORD_FALSE:
1215 1260
 				case TOKEN_IDENTIFIER: case TOKEN_NUMBER: case TOKEN_STRING: case TOKEN_REGEXP:
1216
-					if (!$this->t->scanOperand)
1217
-						break 2;
1261
+					if (!$this->t->scanOperand) {
1262
+											break 2;
1263
+					}
1218 1264
 
1219 1265
 					array_push($operands, new JSNode($this->t));
1220 1266
 					$this->t->scanOperand = false;
@@ -1222,10 +1268,11 @@  discard block
 block discarded – undo
1222 1268
 
1223 1269
 				case TOKEN_CONDCOMMENT_START:
1224 1270
 				case TOKEN_CONDCOMMENT_END:
1225
-					if ($this->t->scanOperand)
1226
-						array_push($operators, new JSNode($this->t));
1227
-					else
1228
-						array_push($operands, new JSNode($this->t));
1271
+					if ($this->t->scanOperand) {
1272
+											array_push($operators, new JSNode($this->t));
1273
+					} else {
1274
+											array_push($operands, new JSNode($this->t));
1275
+					}
1229 1276
 				break;
1230 1277
 
1231 1278
 				case OP_LEFT_BRACKET:
@@ -1244,15 +1291,15 @@  discard block
 block discarded – undo
1244 1291
 							}
1245 1292
 
1246 1293
 							$n->addNode($this->Expression($x, OP_COMMA));
1247
-							if (!$this->t->match(OP_COMMA))
1248
-								break;
1294
+							if (!$this->t->match(OP_COMMA)) {
1295
+															break;
1296
+							}
1249 1297
 						}
1250 1298
 
1251 1299
 						$this->t->mustMatch(OP_RIGHT_BRACKET);
1252 1300
 						array_push($operands, $n);
1253 1301
 						$this->t->scanOperand = false;
1254
-					}
1255
-					else
1302
+					} else
1256 1303
 					{
1257 1304
 						// Property indexing operator.
1258 1305
 						array_push($operators, new JSNode($this->t, JS_INDEX));
@@ -1262,18 +1309,21 @@  discard block
 block discarded – undo
1262 1309
 				break;
1263 1310
 
1264 1311
 				case OP_RIGHT_BRACKET:
1265
-					if ($this->t->scanOperand || $x->bracketLevel == $bl)
1266
-						break 2;
1312
+					if ($this->t->scanOperand || $x->bracketLevel == $bl) {
1313
+											break 2;
1314
+					}
1267 1315
 
1268
-					while ($this->reduce($operators, $operands)->type != JS_INDEX)
1269
-						continue;
1316
+					while ($this->reduce($operators, $operands)->type != JS_INDEX) {
1317
+											continue;
1318
+					}
1270 1319
 
1271 1320
 					--$x->bracketLevel;
1272 1321
 				break;
1273 1322
 
1274 1323
 				case OP_LEFT_CURLY:
1275
-					if (!$this->t->scanOperand)
1276
-						break 2;
1324
+					if (!$this->t->scanOperand) {
1325
+											break 2;
1326
+					}
1277 1327
 
1278 1328
 					// Object initialiser.  As for array initialisers (see above),
1279 1329
 					// parse using recursive descent.
@@ -1287,12 +1337,12 @@  discard block
 block discarded – undo
1287 1337
 							$tv = $this->t->currentToken()->value;
1288 1338
 							if (($tv == 'get' || $tv == 'set') && $this->t->peek() == TOKEN_IDENTIFIER)
1289 1339
 							{
1290
-								if ($x->ecmaStrictMode)
1291
-									throw $this->t->newSyntaxError('Illegal property accessor');
1340
+								if ($x->ecmaStrictMode) {
1341
+																	throw $this->t->newSyntaxError('Illegal property accessor');
1342
+								}
1292 1343
 
1293 1344
 								$n->addNode($this->FunctionDefinition($x, true, EXPRESSED_FORM));
1294
-							}
1295
-							else
1345
+							} else
1296 1346
 							{
1297 1347
 								switch ($tt)
1298 1348
 								{
@@ -1303,8 +1353,9 @@  discard block
 block discarded – undo
1303 1353
 									break;
1304 1354
 
1305 1355
 									case OP_RIGHT_CURLY:
1306
-										if ($x->ecmaStrictMode)
1307
-											throw $this->t->newSyntaxError('Illegal trailing ,');
1356
+										if ($x->ecmaStrictMode) {
1357
+																					throw $this->t->newSyntaxError('Illegal trailing ,');
1358
+										}
1308 1359
 									break 3;
1309 1360
 
1310 1361
 									default:
@@ -1327,21 +1378,22 @@  discard block
 block discarded – undo
1327 1378
 				break;
1328 1379
 
1329 1380
 				case OP_RIGHT_CURLY:
1330
-					if (!$this->t->scanOperand && $x->curlyLevel != $cl)
1331
-						throw new Exception('PANIC: right curly botch');
1381
+					if (!$this->t->scanOperand && $x->curlyLevel != $cl) {
1382
+											throw new Exception('PANIC: right curly botch');
1383
+					}
1332 1384
 				break 2;
1333 1385
 
1334 1386
 				case OP_LEFT_PAREN:
1335 1387
 					if ($this->t->scanOperand)
1336 1388
 					{
1337 1389
 						array_push($operators, new JSNode($this->t, JS_GROUP));
1338
-					}
1339
-					else
1390
+					} else
1340 1391
 					{
1341 1392
 						while (	!empty($operators) &&
1342 1393
 							$this->opPrecedence[end($operators)->type] > $this->opPrecedence[KEYWORD_NEW]
1343
-						)
1344
-							$this->reduce($operators, $operands);
1394
+						) {
1395
+													$this->reduce($operators, $operands);
1396
+						}
1345 1397
 
1346 1398
 						// Handle () now, to regularize the n-ary case for n > 0.
1347 1399
 						// We must set scanOperand in case there are arguments and
@@ -1354,8 +1406,7 @@  discard block
 block discarded – undo
1354 1406
 							{
1355 1407
 								array_pop($operators);
1356 1408
 								$n->addNode(array_pop($operands));
1357
-							}
1358
-							else
1409
+							} else
1359 1410
 							{
1360 1411
 								$n = new JSNode($this->t, JS_CALL, array_pop($operands), new JSNode($this->t, JS_LIST));
1361 1412
 							}
@@ -1365,18 +1416,20 @@  discard block
 block discarded – undo
1365 1416
 							break;
1366 1417
 						}
1367 1418
 
1368
-						if ($n && $n->type == KEYWORD_NEW)
1369
-							$n->type = JS_NEW_WITH_ARGS;
1370
-						else
1371
-							array_push($operators, new JSNode($this->t, JS_CALL));
1419
+						if ($n && $n->type == KEYWORD_NEW) {
1420
+													$n->type = JS_NEW_WITH_ARGS;
1421
+						} else {
1422
+													array_push($operators, new JSNode($this->t, JS_CALL));
1423
+						}
1372 1424
 					}
1373 1425
 
1374 1426
 					++$x->parenLevel;
1375 1427
 				break;
1376 1428
 
1377 1429
 				case OP_RIGHT_PAREN:
1378
-					if ($this->t->scanOperand || $x->parenLevel == $pl)
1379
-						break 2;
1430
+					if ($this->t->scanOperand || $x->parenLevel == $pl) {
1431
+											break 2;
1432
+					}
1380 1433
 
1381 1434
 					while (($tt = $this->reduce($operators, $operands)->type) != JS_GROUP &&
1382 1435
 						$tt != JS_CALL && $tt != JS_NEW_WITH_ARGS
@@ -1388,10 +1441,11 @@  discard block
 block discarded – undo
1388 1441
 					if ($tt != JS_GROUP)
1389 1442
 					{
1390 1443
 						$n = end($operands);
1391
-						if ($n->treeNodes[1]->type != OP_COMMA)
1392
-							$n->treeNodes[1] = new JSNode($this->t, JS_LIST, $n->treeNodes[1]);
1393
-						else
1394
-							$n->treeNodes[1]->type = JS_LIST;
1444
+						if ($n->treeNodes[1]->type != OP_COMMA) {
1445
+													$n->treeNodes[1] = new JSNode($this->t, JS_LIST, $n->treeNodes[1]);
1446
+						} else {
1447
+													$n->treeNodes[1]->type = JS_LIST;
1448
+						}
1395 1449
 					}
1396 1450
 
1397 1451
 					--$x->parenLevel;
@@ -1405,24 +1459,29 @@  discard block
 block discarded – undo
1405 1459
 			}
1406 1460
 		}
1407 1461
 
1408
-		if ($x->hookLevel != $hl)
1409
-			throw $this->t->newSyntaxError('Missing : in conditional expression');
1462
+		if ($x->hookLevel != $hl) {
1463
+					throw $this->t->newSyntaxError('Missing : in conditional expression');
1464
+		}
1410 1465
 
1411
-		if ($x->parenLevel != $pl)
1412
-			throw $this->t->newSyntaxError('Missing ) in parenthetical');
1466
+		if ($x->parenLevel != $pl) {
1467
+					throw $this->t->newSyntaxError('Missing ) in parenthetical');
1468
+		}
1413 1469
 
1414
-		if ($x->bracketLevel != $bl)
1415
-			throw $this->t->newSyntaxError('Missing ] in index expression');
1470
+		if ($x->bracketLevel != $bl) {
1471
+					throw $this->t->newSyntaxError('Missing ] in index expression');
1472
+		}
1416 1473
 
1417
-		if ($this->t->scanOperand)
1418
-			throw $this->t->newSyntaxError('Missing operand');
1474
+		if ($this->t->scanOperand) {
1475
+					throw $this->t->newSyntaxError('Missing operand');
1476
+		}
1419 1477
 
1420 1478
 		// Resume default mode, scanning for operands, not operators.
1421 1479
 		$this->t->scanOperand = true;
1422 1480
 		$this->t->unget();
1423 1481
 
1424
-		while (count($operators))
1425
-			$this->reduce($operators, $operands);
1482
+		while (count($operators)) {
1483
+					$this->reduce($operators, $operands);
1484
+		}
1426 1485
 
1427 1486
 		return array_pop($operands);
1428 1487
 	}
@@ -1443,8 +1502,9 @@  discard block
 block discarded – undo
1443 1502
 		$n = $this->statement($x);
1444 1503
 		array_pop($x->stmtStack);
1445 1504
 
1446
-		if ($end)
1447
-			$this->t->mustMatch($end);
1505
+		if ($end) {
1506
+					$this->t->mustMatch($end);
1507
+		}
1448 1508
 
1449 1509
 		return $n;
1450 1510
 	}
@@ -1473,13 +1533,15 @@  discard block
 block discarded – undo
1473 1533
 
1474 1534
 		// Always use push to add operands to n, to update start and end
1475 1535
 		$a = array_splice($operands, $c - $arity);
1476
-		for ($i = 0; $i < $arity; $i++)
1477
-			$n->addNode($a[$i]);
1536
+		for ($i = 0; $i < $arity; $i++) {
1537
+					$n->addNode($a[$i]);
1538
+		}
1478 1539
 
1479 1540
 		// Include closing bracket or postfix operator in [start,end]
1480 1541
 		$te = $this->t->currentToken()->end;
1481
-		if ($n->end < $te)
1482
-			$n->end = $te;
1542
+		if ($n->end < $te) {
1543
+					$n->end = $te;
1544
+		}
1483 1545
 
1484 1546
 		array_push($operands, $n);
1485 1547
 
@@ -1528,8 +1590,7 @@  discard block
 block discarded – undo
1528 1590
 			$this->lineno = $token->lineno;
1529 1591
 			$this->start = $token->start;
1530 1592
 			$this->end = $token->end;
1531
-		}
1532
-		else
1593
+		} else
1533 1594
 		{
1534 1595
 			$this->type = $type;
1535 1596
 			$this->lineno = $t->lineno;
@@ -1538,8 +1599,9 @@  discard block
 block discarded – undo
1538 1599
 		if (($numargs = func_num_args()) > 2)
1539 1600
 		{
1540 1601
 			$args = func_get_args();;
1541
-			for ($i = 2; $i < $numargs; $i++)
1542
-				$this->addNode($args[$i]);
1602
+			for ($i = 2; $i < $numargs; $i++) {
1603
+							$this->addNode($args[$i]);
1604
+			}
1543 1605
 		}
1544 1606
 	}
1545 1607
 
@@ -1551,8 +1613,9 @@  discard block
 block discarded – undo
1551 1613
 
1552 1614
 	public function __get($name)
1553 1615
 	{
1554
-		if (isset($this->$name))
1555
-			return $this->$name;
1616
+		if (isset($this->$name)) {
1617
+					return $this->$name;
1618
+		}
1556 1619
 
1557 1620
 		return null;
1558 1621
 	}
@@ -1561,10 +1624,12 @@  discard block
 block discarded – undo
1561 1624
 	{
1562 1625
 		if ($node !== null)
1563 1626
 		{
1564
-			if ($node->start < $this->start)
1565
-				$this->start = $node->start;
1566
-			if ($this->end < $node->end)
1567
-				$this->end = $node->end;
1627
+			if ($node->start < $this->start) {
1628
+							$this->start = $node->start;
1629
+			}
1630
+			if ($this->end < $node->end) {
1631
+							$this->end = $node->end;
1632
+			}
1568 1633
 		}
1569 1634
 
1570 1635
 		$this->treeNodes[] = $node;
@@ -1649,14 +1714,16 @@  discard block
 block discarded – undo
1649 1714
 		$this->opRegExp = '#^(' . implode('|', array_map('preg_quote', array_keys($this->opTypeNames))) . ')#';
1650 1715
 
1651 1716
 		// this is quite a hidden yet convenient place to create the defines for operators and keywords
1652
-		foreach ($this->opTypeNames as $operand => $name)
1653
-			define('OP_' . $name, $operand);
1717
+		foreach ($this->opTypeNames as $operand => $name) {
1718
+					define('OP_' . $name, $operand);
1719
+		}
1654 1720
 
1655 1721
 		define('OP_UNARY_PLUS', 'U+');
1656 1722
 		define('OP_UNARY_MINUS', 'U-');
1657 1723
 
1658
-		foreach ($this->keywords as $keyword)
1659
-			define('KEYWORD_' . strtoupper($keyword), $keyword);
1724
+		foreach ($this->keywords as $keyword) {
1725
+					define('KEYWORD_' . strtoupper($keyword), $keyword);
1726
+		}
1660 1727
 	}
1661 1728
 
1662 1729
 	public function init($source, $filename = '', $lineno = 1)
@@ -1675,8 +1742,9 @@  discard block
 block discarded – undo
1675 1742
 
1676 1743
 	public function getInput($chunksize)
1677 1744
 	{
1678
-		if ($chunksize)
1679
-			return substr($this->source, $this->cursor, $chunksize);
1745
+		if ($chunksize) {
1746
+					return substr($this->source, $this->cursor, $chunksize);
1747
+		}
1680 1748
 
1681 1749
 		return substr($this->source, $this->cursor);
1682 1750
 	}
@@ -1693,8 +1761,9 @@  discard block
 block discarded – undo
1693 1761
 
1694 1762
 	public function mustMatch($tt)
1695 1763
 	{
1696
-	        if (!$this->match($tt))
1697
-			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1764
+	        if (!$this->match($tt)) {
1765
+	        			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1766
+	        }
1698 1767
 
1699 1768
 		return $this->currentToken();
1700 1769
 	}
@@ -1704,12 +1773,12 @@  discard block
 block discarded – undo
1704 1773
 		if ($this->lookahead)
1705 1774
 		{
1706 1775
 			$next = $this->tokens[($this->tokenIndex + $this->lookahead) & 3];
1707
-			if ($this->scanNewlines && $next->lineno != $this->lineno)
1708
-				$tt = TOKEN_NEWLINE;
1709
-			else
1710
-				$tt = $next->type;
1711
-		}
1712
-		else
1776
+			if ($this->scanNewlines && $next->lineno != $this->lineno) {
1777
+							$tt = TOKEN_NEWLINE;
1778
+			} else {
1779
+							$tt = $next->type;
1780
+			}
1781
+		} else
1713 1782
 		{
1714 1783
 			$tt = $this->get();
1715 1784
 			$this->unget();
@@ -1729,8 +1798,9 @@  discard block
 block discarded – undo
1729 1798
 
1730 1799
 	public function currentToken()
1731 1800
 	{
1732
-		if (!empty($this->tokens))
1733
-			return $this->tokens[$this->tokenIndex];
1801
+		if (!empty($this->tokens)) {
1802
+					return $this->tokens[$this->tokenIndex];
1803
+		}
1734 1804
 	}
1735 1805
 
1736 1806
 	public function get($chunksize = 1000)
@@ -1740,8 +1810,9 @@  discard block
 block discarded – undo
1740 1810
 			$this->lookahead--;
1741 1811
 			$this->tokenIndex = ($this->tokenIndex + 1) & 3;
1742 1812
 			$token = $this->tokens[$this->tokenIndex];
1743
-			if ($token->type != TOKEN_NEWLINE || $this->scanNewlines)
1744
-				return $token->type;
1813
+			if ($token->type != TOKEN_NEWLINE || $this->scanNewlines) {
1814
+							return $token->type;
1815
+			}
1745 1816
 		}
1746 1817
 
1747 1818
 		$conditional_comment = false;
@@ -1758,22 +1829,27 @@  discard block
 block discarded – undo
1758 1829
 				$spaces = $match[0];
1759 1830
 				$spacelen = strlen($spaces);
1760 1831
 				$this->cursor += $spacelen;
1761
-				if (!$this->scanNewlines)
1762
-					$this->lineno += substr_count($spaces, "\n");
1832
+				if (!$this->scanNewlines) {
1833
+									$this->lineno += substr_count($spaces, "\n");
1834
+				}
1763 1835
 
1764
-				if ($spacelen == $chunksize)
1765
-					continue; // complete chunk contained whitespace
1836
+				if ($spacelen == $chunksize) {
1837
+									continue;
1838
+				}
1839
+				// complete chunk contained whitespace
1766 1840
 
1767 1841
 				$input = $this->getInput($chunksize);
1768
-				if ($input == '' || $input[0] != '/')
1769
-					break;
1842
+				if ($input == '' || $input[0] != '/') {
1843
+									break;
1844
+				}
1770 1845
 			}
1771 1846
 
1772 1847
 			// Comments
1773 1848
 			if (!preg_match('/^\/(?:\*(@(?:cc_on|if|elif|else|end))?.*?\*\/|\/[^\n]*)/s', $input, $match))
1774 1849
 			{
1775
-				if (!$chunksize)
1776
-					break;
1850
+				if (!$chunksize) {
1851
+									break;
1852
+				}
1777 1853
 
1778 1854
 				// retry with a full chunk fetch; this also prevents breakage of long regular expressions (which will never match a comment)
1779 1855
 				$chunksize = null;
@@ -1786,8 +1862,7 @@  discard block
 block discarded – undo
1786 1862
 				$match[0] = '/*' . $match[1];
1787 1863
 				$conditional_comment = true;
1788 1864
 				break;
1789
-			}
1790
-			else
1865
+			} else
1791 1866
 			{
1792 1867
 				$this->cursor += strlen($match[0]);
1793 1868
 				$this->lineno += substr_count($match[0], "\n");
@@ -1798,12 +1873,10 @@  discard block
 block discarded – undo
1798 1873
 		{
1799 1874
 			$tt = TOKEN_END;
1800 1875
 			$match = array('');
1801
-		}
1802
-		elseif ($conditional_comment)
1876
+		} elseif ($conditional_comment)
1803 1877
 		{
1804 1878
 			$tt = TOKEN_CONDCOMMENT_START;
1805
-		}
1806
-		else
1879
+		} else
1807 1880
 		{
1808 1881
 			switch ($input[0])
1809 1882
 			{
@@ -1812,8 +1885,7 @@  discard block
 block discarded – undo
1812 1885
 					if (preg_match('/^\d+\.\d*(?:[eE][-+]?\d+)?|^\d+(?:\.\d*)?[eE][-+]?\d+/', $input, $match))
1813 1886
 					{
1814 1887
 						$tt = TOKEN_NUMBER;
1815
-					}
1816
-					else if (preg_match('/^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/', $input, $match))
1888
+					} else if (preg_match('/^0[xX][\da-fA-F]+|^0[0-7]*|^\d+/', $input, $match))
1817 1889
 					{
1818 1890
 						// this should always match because of \d+
1819 1891
 						$tt = TOKEN_NUMBER;
@@ -1825,11 +1897,12 @@  discard block
 block discarded – undo
1825 1897
 					if (preg_match('/^"(?:\\\\(?:.|\r?\n)|[^\\\\"\r\n]+)*"|^\'(?:\\\\(?:.|\r?\n)|[^\\\\\'\r\n]+)*\'/', $input, $match))
1826 1898
 					{
1827 1899
 						$tt = TOKEN_STRING;
1828
-					}
1829
-					else
1900
+					} else
1830 1901
 					{
1831
-						if ($chunksize)
1832
-							return $this->get(null); // retry with a full chunk fetch
1902
+						if ($chunksize) {
1903
+													return $this->get(null);
1904
+						}
1905
+						// retry with a full chunk fetch
1833 1906
 
1834 1907
 						throw $this->newSyntaxError('Unterminated string literal');
1835 1908
 					}
@@ -1861,16 +1934,16 @@  discard block
 block discarded – undo
1861 1934
 					{
1862 1935
 						$tt = OP_ASSIGN;
1863 1936
 						$match[0] .= '=';
1864
-					}
1865
-					else
1937
+					} else
1866 1938
 					{
1867 1939
 						$tt = $op;
1868 1940
 						if ($this->scanOperand)
1869 1941
 						{
1870
-							if ($op == OP_PLUS)
1871
-								$tt = OP_UNARY_PLUS;
1872
-							elseif ($op == OP_MINUS)
1873
-								$tt = OP_UNARY_MINUS;
1942
+							if ($op == OP_PLUS) {
1943
+															$tt = OP_UNARY_PLUS;
1944
+							} elseif ($op == OP_MINUS) {
1945
+															$tt = OP_UNARY_MINUS;
1946
+							}
1874 1947
 						}
1875 1948
 						$op = null;
1876 1949
 					}
@@ -1906,9 +1979,9 @@  discard block
 block discarded – undo
1906 1979
 					{
1907 1980
 						$match = array('@*/');
1908 1981
 						$tt = TOKEN_CONDCOMMENT_END;
1982
+					} else {
1983
+											throw $this->newSyntaxError('Illegal token');
1909 1984
 					}
1910
-					else
1911
-						throw $this->newSyntaxError('Illegal token');
1912 1985
 				break;
1913 1986
 
1914 1987
 				case "\n":
@@ -1916,9 +1989,9 @@  discard block
 block discarded – undo
1916 1989
 					{
1917 1990
 						$match = array("\n");
1918 1991
 						$tt = TOKEN_NEWLINE;
1992
+					} else {
1993
+											throw $this->newSyntaxError('Illegal token');
1919 1994
 					}
1920
-					else
1921
-						throw $this->newSyntaxError('Illegal token');
1922 1995
 				break;
1923 1996
 
1924 1997
 				default:
@@ -1926,22 +1999,24 @@  discard block
 block discarded – undo
1926 1999
 					if (preg_match('/^[$\w]+/', $input, $match))
1927 2000
 					{
1928 2001
 						$tt = in_array($match[0], $this->keywords) ? $match[0] : TOKEN_IDENTIFIER;
2002
+					} else {
2003
+											throw $this->newSyntaxError('Illegal token');
1929 2004
 					}
1930
-					else
1931
-						throw $this->newSyntaxError('Illegal token');
1932 2005
 			}
1933 2006
 		}
1934 2007
 
1935 2008
 		$this->tokenIndex = ($this->tokenIndex + 1) & 3;
1936 2009
 
1937
-		if (!isset($this->tokens[$this->tokenIndex]))
1938
-			$this->tokens[$this->tokenIndex] = new JSToken();
2010
+		if (!isset($this->tokens[$this->tokenIndex])) {
2011
+					$this->tokens[$this->tokenIndex] = new JSToken();
2012
+		}
1939 2013
 
1940 2014
 		$token = $this->tokens[$this->tokenIndex];
1941 2015
 		$token->type = $tt;
1942 2016
 
1943
-		if ($tt == OP_ASSIGN)
1944
-			$token->assignOp = $op;
2017
+		if ($tt == OP_ASSIGN) {
2018
+					$token->assignOp = $op;
2019
+		}
1945 2020
 
1946 2021
 		$token->start = $this->cursor;
1947 2022
 
@@ -1956,8 +2031,9 @@  discard block
 block discarded – undo
1956 2031
 
1957 2032
 	public function unget()
1958 2033
 	{
1959
-		if (++$this->lookahead == 4)
1960
-			throw $this->newSyntaxError('PANIC: too much lookahead!');
2034
+		if (++$this->lookahead == 4) {
2035
+					throw $this->newSyntaxError('PANIC: too much lookahead!');
2036
+		}
1961 2037
 
1962 2038
 		$this->tokenIndex = ($this->tokenIndex - 1) & 3;
1963 2039
 	}
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 		$this->parser = new JSParser();
115 115
 	}
116 116
 
117
-	public static function minify($js, $filename='')
117
+	public static function minify($js, $filename = '')
118 118
 	{
119 119
 		static $instance;
120 120
 
121 121
 		// this is a singleton
122
-		if(!$instance)
122
+		if (!$instance)
123 123
 			$instance = new JSMinPlus();
124 124
 
125 125
 		return $instance->min($js, $filename);
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 			$n = $this->parser->parse($js, $filename, 1);
133 133
 			return $this->parseTree($n);
134 134
 		}
135
-		catch(Exception $e)
135
+		catch (Exception $e)
136 136
 		{
137
-			echo $e->getMessage() . "\n";
137
+			echo $e->getMessage()."\n";
138 138
 		}
139 139
 
140 140
 		return false;
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 		switch ($n->type)
148 148
 		{
149 149
 			case KEYWORD_FUNCTION:
150
-				$s .= 'function' . ($n->name ? ' ' . $n->name : '') . '(';
150
+				$s .= 'function'.($n->name ? ' '.$n->name : '').'(';
151 151
 				$params = $n->params;
152 152
 				for ($i = 0, $j = count($params); $i < $j; $i++)
153
-					$s .= ($i ? ',' : '') . $params[$i];
154
-				$s .= '){' . $this->parseTree($n->body, true) . '}';
153
+					$s .= ($i ? ',' : '').$params[$i];
154
+				$s .= '){'.$this->parseTree($n->body, true).'}';
155 155
 			break;
156 156
 
157 157
 			case JS_SCRIPT:
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 							elseif ($type == KEYWORD_VAR && $type == $lastType)
181 181
 							{
182 182
 								// mutiple var-statements can go into one
183
-								$t = ',' . substr($t, 4);
183
+								$t = ','.substr($t, 4);
184 184
 							}
185 185
 							else
186 186
 							{
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
 
199 199
 				if ($c > 1 && !$noBlockGrouping)
200 200
 				{
201
-					$s = '{' . $s . '}';
201
+					$s = '{'.$s.'}';
202 202
 				}
203 203
 			break;
204 204
 
205 205
 			case KEYWORD_IF:
206
-				$s = 'if(' . $this->parseTree($n->condition) . ')';
206
+				$s = 'if('.$this->parseTree($n->condition).')';
207 207
 				$thenPart = $this->parseTree($n->thenPart);
208 208
 				$elsePart = $n->elsePart ? $this->parseTree($n->elsePart) : null;
209 209
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 				{
216 216
 					// be carefull and always make a block out of the thenPart; could be more optimized but is a lot of trouble
217 217
 					if ($thenPart != ';' && $thenPart[0] != '{')
218
-						$thenPart = '{' . $thenPart . '}';
218
+						$thenPart = '{'.$thenPart.'}';
219 219
 
220
-					$s .= $thenPart . 'else';
220
+					$s .= $thenPart.'else';
221 221
 
222 222
 					// we could check for more, but that hardly ever applies so go for performance
223 223
 					if ($elsePart[0] != '{')
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 			break;
233 233
 
234 234
 			case KEYWORD_SWITCH:
235
-				$s = 'switch(' . $this->parseTree($n->discriminant) . '){';
235
+				$s = 'switch('.$this->parseTree($n->discriminant).'){';
236 236
 				$cases = $n->cases;
237 237
 				for ($i = 0, $j = count($cases); $i < $j; $i++)
238 238
 				{
239 239
 					$case = $cases[$i];
240 240
 					if ($case->type == KEYWORD_CASE)
241
-						$s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':';
241
+						$s .= 'case'.($case->caseLabel->type != TOKEN_STRING ? ' ' : '').$this->parseTree($case->caseLabel).':';
242 242
 					else
243 243
 						$s .= 'default:';
244 244
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 			break;
256 256
 
257 257
 			case KEYWORD_FOR:
258
-				$s = 'for(' . ($n->setup ? $this->parseTree($n->setup) : '')
259
-					. ';' . ($n->condition ? $this->parseTree($n->condition) : '')
260
-					. ';' . ($n->update ? $this->parseTree($n->update) : '') . ')';
258
+				$s = 'for('.($n->setup ? $this->parseTree($n->setup) : '')
259
+					. ';'.($n->condition ? $this->parseTree($n->condition) : '')
260
+					. ';'.($n->update ? $this->parseTree($n->update) : '').')';
261 261
 
262 262
 				$body  = $this->parseTree($n->body);
263 263
 				if ($body == '')
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			break;
268 268
 
269 269
 			case KEYWORD_WHILE:
270
-				$s = 'while(' . $this->parseTree($n->condition) . ')';
270
+				$s = 'while('.$this->parseTree($n->condition).')';
271 271
 
272 272
 				$body  = $this->parseTree($n->body);
273 273
 				if ($body == '')
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 			break;
278 278
 
279 279
 			case JS_FOR_IN:
280
-				$s = 'for(' . ($n->varDecl ? $this->parseTree($n->varDecl) : $this->parseTree($n->iterator)) . ' in ' . $this->parseTree($n->object) . ')';
280
+				$s = 'for('.($n->varDecl ? $this->parseTree($n->varDecl) : $this->parseTree($n->iterator)).' in '.$this->parseTree($n->object).')';
281 281
 
282 282
 				$body  = $this->parseTree($n->body);
283 283
 				if ($body == '')
@@ -287,28 +287,28 @@  discard block
 block discarded – undo
287 287
 			break;
288 288
 
289 289
 			case KEYWORD_DO:
290
-				$s = 'do{' . $this->parseTree($n->body, true) . '}while(' . $this->parseTree($n->condition) . ')';
290
+				$s = 'do{'.$this->parseTree($n->body, true).'}while('.$this->parseTree($n->condition).')';
291 291
 			break;
292 292
 
293 293
 			case KEYWORD_BREAK:
294 294
 			case KEYWORD_CONTINUE:
295
-				$s = $n->value . ($n->label ? ' ' . $n->label : '');
295
+				$s = $n->value.($n->label ? ' '.$n->label : '');
296 296
 			break;
297 297
 
298 298
 			case KEYWORD_TRY:
299
-				$s = 'try{' . $this->parseTree($n->tryBlock, true) . '}';
299
+				$s = 'try{'.$this->parseTree($n->tryBlock, true).'}';
300 300
 				$catchClauses = $n->catchClauses;
301 301
 				for ($i = 0, $j = count($catchClauses); $i < $j; $i++)
302 302
 				{
303 303
 					$t = $catchClauses[$i];
304
-					$s .= 'catch(' . $t->varName . ($t->guard ? ' if ' . $this->parseTree($t->guard) : '') . '){' . $this->parseTree($t->block, true) . '}';
304
+					$s .= 'catch('.$t->varName.($t->guard ? ' if '.$this->parseTree($t->guard) : '').'){'.$this->parseTree($t->block, true).'}';
305 305
 				}
306 306
 				if ($n->finallyBlock)
307
-					$s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}';
307
+					$s .= 'finally{'.$this->parseTree($n->finallyBlock, true).'}';
308 308
 			break;
309 309
 
310 310
 			case KEYWORD_THROW:
311
-				$s = 'throw ' . $this->parseTree($n->exception);
311
+				$s = 'throw '.$this->parseTree($n->exception);
312 312
 			break;
313 313
 
314 314
 			case KEYWORD_RETURN:
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 					$t = $this->parseTree($n->value);
319 319
 					if (strlen($t))
320 320
 					{
321
-						if (	$t[0] != '(' && $t[0] != '[' && $t[0] != '{' &&
321
+						if ($t[0] != '(' && $t[0] != '[' && $t[0] != '{' &&
322 322
 							$t[0] != '"' && $t[0] != "'" && $t[0] != '/'
323 323
 						)
324 324
 							$s .= ' ';
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
 			break;
330 330
 
331 331
 			case KEYWORD_WITH:
332
-				$s = 'with(' . $this->parseTree($n->object) . ')' . $this->parseTree($n->body);
332
+				$s = 'with('.$this->parseTree($n->object).')'.$this->parseTree($n->body);
333 333
 			break;
334 334
 
335 335
 			case KEYWORD_VAR:
336 336
 			case KEYWORD_CONST:
337
-				$s = $n->value . ' ';
337
+				$s = $n->value.' ';
338 338
 				$childs = $n->treeNodes;
339 339
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
340 340
 				{
341 341
 					$t = $childs[$i];
342
-					$s .= ($i ? ',' : '') . $t->name;
342
+					$s .= ($i ? ',' : '').$t->name;
343 343
 					$u = $t->initializer;
344 344
 					if ($u)
345
-						$s .= '=' . $this->parseTree($u);
345
+						$s .= '='.$this->parseTree($u);
346 346
 				}
347 347
 			break;
348 348
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 			case TOKEN_CONDCOMMENT_START:
354 354
 			case TOKEN_CONDCOMMENT_END:
355
-				$s = $n->value . ($n->type == TOKEN_CONDCOMMENT_START ? ' ' : '');
355
+				$s = $n->value.($n->type == TOKEN_CONDCOMMENT_START ? ' ' : '');
356 356
 				$childs = $n->treeNodes;
357 357
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
358 358
 					$s .= $this->parseTree($childs[$i]);
@@ -364,21 +364,21 @@  discard block
 block discarded – undo
364 364
 			break;
365 365
 
366 366
 			case JS_LABEL:
367
-				$s = $n->label . ':' . $this->parseTree($n->statement);
367
+				$s = $n->label.':'.$this->parseTree($n->statement);
368 368
 			break;
369 369
 
370 370
 			case OP_COMMA:
371 371
 				$childs = $n->treeNodes;
372 372
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
373
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
373
+					$s .= ($i ? ',' : '').$this->parseTree($childs[$i]);
374 374
 			break;
375 375
 
376 376
 			case OP_ASSIGN:
377
-				$s = $this->parseTree($n->treeNodes[0]) . $n->value . $this->parseTree($n->treeNodes[1]);
377
+				$s = $this->parseTree($n->treeNodes[0]).$n->value.$this->parseTree($n->treeNodes[1]);
378 378
 			break;
379 379
 
380 380
 			case OP_HOOK:
381
-				$s = $this->parseTree($n->treeNodes[0]) . '?' . $this->parseTree($n->treeNodes[1]) . ':' . $this->parseTree($n->treeNodes[2]);
381
+				$s = $this->parseTree($n->treeNodes[0]).'?'.$this->parseTree($n->treeNodes[1]).':'.$this->parseTree($n->treeNodes[2]);
382 382
 			break;
383 383
 
384 384
 			case OP_OR: case OP_AND:
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			case OP_LT: case OP_LE: case OP_GE: case OP_GT:
388 388
 			case OP_LSH: case OP_RSH: case OP_URSH:
389 389
 			case OP_MUL: case OP_DIV: case OP_MOD:
390
-				$s = $this->parseTree($n->treeNodes[0]) . $n->type . $this->parseTree($n->treeNodes[1]);
390
+				$s = $this->parseTree($n->treeNodes[0]).$n->type.$this->parseTree($n->treeNodes[1]);
391 391
 			break;
392 392
 
393 393
 			case OP_PLUS:
@@ -403,87 +403,87 @@  discard block
 block discarded – undo
403 403
 					case OP_DECREMENT:
404 404
 					case OP_UNARY_PLUS:
405 405
 					case OP_UNARY_MINUS:
406
-						$s = $left . $n->type . ' ' . $right;
406
+						$s = $left.$n->type.' '.$right;
407 407
 					break;
408 408
 
409 409
 					case TOKEN_STRING:
410 410
 						//combine concatted strings with same quotestyle
411 411
 						if ($n->type == OP_PLUS && substr($left, -1) == $right[0])
412 412
 						{
413
-							$s = substr($left, 0, -1) . substr($right, 1);
413
+							$s = substr($left, 0, -1).substr($right, 1);
414 414
 							break;
415 415
 						}
416 416
 					// FALL THROUGH
417 417
 
418 418
 					default:
419
-						$s = $left . $n->type . $right;
419
+						$s = $left.$n->type.$right;
420 420
 				}
421 421
 			break;
422 422
 
423 423
 			case KEYWORD_IN:
424
-				$s = $this->parseTree($n->treeNodes[0]) . ' in ' . $this->parseTree($n->treeNodes[1]);
424
+				$s = $this->parseTree($n->treeNodes[0]).' in '.$this->parseTree($n->treeNodes[1]);
425 425
 			break;
426 426
 
427 427
 			case KEYWORD_INSTANCEOF:
428
-				$s = $this->parseTree($n->treeNodes[0]) . ' instanceof ' . $this->parseTree($n->treeNodes[1]);
428
+				$s = $this->parseTree($n->treeNodes[0]).' instanceof '.$this->parseTree($n->treeNodes[1]);
429 429
 			break;
430 430
 
431 431
 			case KEYWORD_DELETE:
432
-				$s = 'delete ' . $this->parseTree($n->treeNodes[0]);
432
+				$s = 'delete '.$this->parseTree($n->treeNodes[0]);
433 433
 			break;
434 434
 
435 435
 			case KEYWORD_VOID:
436
-				$s = 'void(' . $this->parseTree($n->treeNodes[0]) . ')';
436
+				$s = 'void('.$this->parseTree($n->treeNodes[0]).')';
437 437
 			break;
438 438
 
439 439
 			case KEYWORD_TYPEOF:
440
-				$s = 'typeof ' . $this->parseTree($n->treeNodes[0]);
440
+				$s = 'typeof '.$this->parseTree($n->treeNodes[0]);
441 441
 			break;
442 442
 
443 443
 			case OP_NOT:
444 444
 			case OP_BITWISE_NOT:
445 445
 			case OP_UNARY_PLUS:
446 446
 			case OP_UNARY_MINUS:
447
-				$s = $n->value . $this->parseTree($n->treeNodes[0]);
447
+				$s = $n->value.$this->parseTree($n->treeNodes[0]);
448 448
 			break;
449 449
 
450 450
 			case OP_INCREMENT:
451 451
 			case OP_DECREMENT:
452 452
 				if ($n->postfix)
453
-					$s = $this->parseTree($n->treeNodes[0]) . $n->value;
453
+					$s = $this->parseTree($n->treeNodes[0]).$n->value;
454 454
 				else
455
-					$s = $n->value . $this->parseTree($n->treeNodes[0]);
455
+					$s = $n->value.$this->parseTree($n->treeNodes[0]);
456 456
 			break;
457 457
 
458 458
 			case OP_DOT:
459
-				$s = $this->parseTree($n->treeNodes[0]) . '.' . $this->parseTree($n->treeNodes[1]);
459
+				$s = $this->parseTree($n->treeNodes[0]).'.'.$this->parseTree($n->treeNodes[1]);
460 460
 			break;
461 461
 
462 462
 			case JS_INDEX:
463 463
 				$s = $this->parseTree($n->treeNodes[0]);
464 464
 				// See if we can replace named index with a dot saving 3 bytes
465
-				if (	$n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
465
+				if ($n->treeNodes[0]->type == TOKEN_IDENTIFIER &&
466 466
 					$n->treeNodes[1]->type == TOKEN_STRING &&
467 467
 					$this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1))
468 468
 				)
469
-					$s .= '.' . substr($n->treeNodes[1]->value, 1, -1);
469
+					$s .= '.'.substr($n->treeNodes[1]->value, 1, -1);
470 470
 				else
471
-					$s .= '[' . $this->parseTree($n->treeNodes[1]) . ']';
471
+					$s .= '['.$this->parseTree($n->treeNodes[1]).']';
472 472
 			break;
473 473
 
474 474
 			case JS_LIST:
475 475
 				$childs = $n->treeNodes;
476 476
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
477
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
477
+					$s .= ($i ? ',' : '').$this->parseTree($childs[$i]);
478 478
 			break;
479 479
 
480 480
 			case JS_CALL:
481
-				$s = $this->parseTree($n->treeNodes[0]) . '(' . $this->parseTree($n->treeNodes[1]) . ')';
481
+				$s = $this->parseTree($n->treeNodes[0]).'('.$this->parseTree($n->treeNodes[1]).')';
482 482
 			break;
483 483
 
484 484
 			case KEYWORD_NEW:
485 485
 			case JS_NEW_WITH_ARGS:
486
-				$s = 'new ' . $this->parseTree($n->treeNodes[0]) . '(' . ($n->type == JS_NEW_WITH_ARGS ? $this->parseTree($n->treeNodes[1]) : '') . ')';
486
+				$s = 'new '.$this->parseTree($n->treeNodes[0]).'('.($n->type == JS_NEW_WITH_ARGS ? $this->parseTree($n->treeNodes[1]) : '').')';
487 487
 			break;
488 488
 
489 489
 			case JS_ARRAY_INIT:
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 				$childs = $n->treeNodes;
492 492
 				for ($i = 0, $j = count($childs); $i < $j; $i++)
493 493
 				{
494
-					$s .= ($i ? ',' : '') . $this->parseTree($childs[$i]);
494
+					$s .= ($i ? ',' : '').$this->parseTree($childs[$i]);
495 495
 				}
496 496
 				$s .= ']';
497 497
 			break;
@@ -507,23 +507,23 @@  discard block
 block discarded – undo
507 507
 					if ($t->type == JS_PROPERTY_INIT)
508 508
 					{
509 509
 						// Ditch the quotes when the index is a valid identifier
510
-						if (	$t->treeNodes[0]->type == TOKEN_STRING &&
510
+						if ($t->treeNodes[0]->type == TOKEN_STRING &&
511 511
 							$this->isValidIdentifier(substr($t->treeNodes[0]->value, 1, -1))
512 512
 						)
513 513
 							$s .= substr($t->treeNodes[0]->value, 1, -1);
514 514
 						else
515 515
 							$s .= $t->treeNodes[0]->value;
516 516
 
517
-						$s .= ':' . $this->parseTree($t->treeNodes[1]);
517
+						$s .= ':'.$this->parseTree($t->treeNodes[1]);
518 518
 					}
519 519
 					else
520 520
 					{
521 521
 						$s .= $t->type == JS_GETTER ? 'get' : 'set';
522
-						$s .= ' ' . $t->name . '(';
522
+						$s .= ' '.$t->name.'(';
523 523
 						$params = $t->params;
524 524
 						for ($i = 0, $j = count($params); $i < $j; $i++)
525
-							$s .= ($i ? ',' : '') . $params[$i];
526
-						$s .= '){' . $this->parseTree($t->body, true) . '}';
525
+							$s .= ($i ? ',' : '').$params[$i];
526
+						$s .= '){'.$this->parseTree($t->body, true).'}';
527 527
 					}
528 528
 				}
529 529
 				$s .= '}';
@@ -535,11 +535,11 @@  discard block
 block discarded – undo
535 535
 			break;
536 536
 
537 537
 			case JS_GROUP:
538
-				$s = '(' . $this->parseTree($n->treeNodes[0]) . ')';
538
+				$s = '('.$this->parseTree($n->treeNodes[0]).')';
539 539
 			break;
540 540
 
541 541
 			default:
542
-				throw new Exception('UNKNOWN TOKEN TYPE: ' . $n->type);
542
+				throw new Exception('UNKNOWN TOKEN TYPE: '.$n->type);
543 543
 		}
544 544
 
545 545
 		return $s;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 					do
835 835
 					{
836 836
 						if (--$i < 0)
837
-							throw $this->t->newSyntaxError('Invalid ' . $tt);
837
+							throw $this->t->newSyntaxError('Invalid '.$tt);
838 838
 					}
839 839
 					while (!$ss[$i]->isLoop && ($tt != KEYWORD_BREAK || $ss[$i]->type != KEYWORD_SWITCH));
840 840
 				}
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		return $n;
1042 1042
 	}
1043 1043
 
1044
-	private function Expression($x, $stop=false)
1044
+	private function Expression($x, $stop = false)
1045 1045
 	{
1046 1046
 		$operators = array();
1047 1047
 		$operands = array();
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 					if ($this->t->scanOperand)
1077 1077
 						break 2;
1078 1078
 
1079
-					while (	!empty($operators) &&
1079
+					while (!empty($operators) &&
1080 1080
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1081 1081
 					)
1082 1082
 						$this->reduce($operators, $operands);
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 						break 2;
1107 1107
 
1108 1108
 					// Use >, not >=, for right-associative ASSIGN
1109
-					while (	!empty($operators) &&
1109
+					while (!empty($operators) &&
1110 1110
 						$this->opPrecedence[end($operators)->type] > $this->opPrecedence[$tt]
1111 1111
 					)
1112 1112
 						$this->reduce($operators, $operands);
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 					if ($this->t->scanOperand)
1153 1153
 						break 2;
1154 1154
 
1155
-					while (	!empty($operators) &&
1155
+					while (!empty($operators) &&
1156 1156
 						$this->opPrecedence[end($operators)->type] >= $this->opPrecedence[$tt]
1157 1157
 					)
1158 1158
 						$this->reduce($operators, $operands);
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 				case OP_INCREMENT: case OP_DECREMENT:
1182 1182
 					if ($this->t->scanOperand)
1183 1183
 					{
1184
-						array_push($operators, new JSNode($this->t));  // prefix increment or decrement
1184
+						array_push($operators, new JSNode($this->t)); // prefix increment or decrement
1185 1185
 					}
1186 1186
 					else
1187 1187
 					{
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 					}
1339 1339
 					else
1340 1340
 					{
1341
-						while (	!empty($operators) &&
1341
+						while (!empty($operators) &&
1342 1342
 							$this->opPrecedence[end($operators)->type] > $this->opPrecedence[KEYWORD_NEW]
1343 1343
 						)
1344 1344
 							$this->reduce($operators, $operands);
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 	public $funDecls = array();
1520 1520
 	public $varDecls = array();
1521 1521
 
1522
-	public function __construct($t, $type=0)
1522
+	public function __construct($t, $type = 0)
1523 1523
 	{
1524 1524
 		if ($token = $t->currentToken())
1525 1525
 		{
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
 		if (($numargs = func_num_args()) > 2)
1539 1539
 		{
1540
-			$args = func_get_args();;
1540
+			$args = func_get_args(); ;
1541 1541
 			for ($i = 2; $i < $numargs; $i++)
1542 1542
 				$this->addNode($args[$i]);
1543 1543
 		}
@@ -1646,17 +1646,17 @@  discard block
 block discarded – undo
1646 1646
 
1647 1647
 	public function __construct()
1648 1648
 	{
1649
-		$this->opRegExp = '#^(' . implode('|', array_map('preg_quote', array_keys($this->opTypeNames))) . ')#';
1649
+		$this->opRegExp = '#^('.implode('|', array_map('preg_quote', array_keys($this->opTypeNames))).')#';
1650 1650
 
1651 1651
 		// this is quite a hidden yet convenient place to create the defines for operators and keywords
1652 1652
 		foreach ($this->opTypeNames as $operand => $name)
1653
-			define('OP_' . $name, $operand);
1653
+			define('OP_'.$name, $operand);
1654 1654
 
1655 1655
 		define('OP_UNARY_PLUS', 'U+');
1656 1656
 		define('OP_UNARY_MINUS', 'U-');
1657 1657
 
1658 1658
 		foreach ($this->keywords as $keyword)
1659
-			define('KEYWORD_' . strtoupper($keyword), $keyword);
1659
+			define('KEYWORD_'.strtoupper($keyword), $keyword);
1660 1660
 	}
1661 1661
 
1662 1662
 	public function init($source, $filename = '', $lineno = 1)
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
 	public function mustMatch($tt)
1695 1695
 	{
1696 1696
 	        if (!$this->match($tt))
1697
-			throw $this->newSyntaxError('Unexpected token; token ' . $tt . ' expected');
1697
+			throw $this->newSyntaxError('Unexpected token; token '.$tt.' expected');
1698 1698
 
1699 1699
 		return $this->currentToken();
1700 1700
 	}
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
 
1736 1736
 	public function get($chunksize = 1000)
1737 1737
 	{
1738
-		while($this->lookahead)
1738
+		while ($this->lookahead)
1739 1739
 		{
1740 1740
 			$this->lookahead--;
1741 1741
 			$this->tokenIndex = ($this->tokenIndex + 1) & 3;
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 		$conditional_comment = false;
1748 1748
 
1749 1749
 		// strip whitespace and comments
1750
-		while(true)
1750
+		while (true)
1751 1751
 		{
1752 1752
 			$input = $this->getInput($chunksize);
1753 1753
 
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 			// check if this is a conditional (JScript) comment
1784 1784
 			if (!empty($match[1]))
1785 1785
 			{
1786
-				$match[0] = '/*' . $match[1];
1786
+				$match[0] = '/*'.$match[1];
1787 1787
 				$conditional_comment = true;
1788 1788
 				break;
1789 1789
 			}
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 
1965 1965
 	public function newSyntaxError($m)
1966 1966
 	{
1967
-		return new Exception('Parse error: ' . $m . ' in file \'' . $this->filename . '\' on line ' . $this->lineno);
1967
+		return new Exception('Parse error: '.$m.' in file \''.$this->filename.'\' on line '.$this->lineno);
1968 1968
 	}
1969 1969
 }
1970 1970
 
Please login to merge, or discard this patch.
tools/minify/minify.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -172,6 +172,9 @@  discard block
 block discarded – undo
172 172
 	}
173 173
 }
174 174
 
175
+/**
176
+ * @param string $ext
177
+ */
175 178
 function get_target_files($ext, $dir, $files_to_skip) {
176 179
 	$files = glob("{$dir}*.{$ext}");
177 180
 	$skips = glob("{$dir}*.min.{$ext}");
@@ -181,6 +184,9 @@  discard block
 block discarded – undo
181 184
 	return $files;
182 185
 }
183 186
 
187
+/**
188
+ * @param string $content
189
+ */
184 190
 function closure_compile($content) {
185 191
 	require_once dirname(__FILE__).'/../../classes/httprequest/XEHttpRequest.class.php';
186 192
 
Please login to merge, or discard this patch.
Braces   +49 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,9 +21,13 @@  discard block
 block discarded – undo
21 21
 	$argc = $_SERVER['argc'];
22 22
 
23 23
 	// get target directories
24
-	if($argc < 1) exit;
25
-	elseif($argc < 2) $dirs = array($_SERVER['PWD']);
26
-	else $dirs = array_slice($argv, 1);
24
+	if($argc < 1) {
25
+		exit;
26
+	} elseif($argc < 2) {
27
+		$dirs = array($_SERVER['PWD']);
28
+	} else {
29
+		$dirs = array_slice($argv, 1);
30
+	}
27 31
 
28 32
 	$dirs = array_map('realpath', $dirs);
29 33
 	$dirs = array_map('add_dirsep', $dirs);
@@ -33,7 +37,9 @@  discard block
 block discarded – undo
33 37
 
34 38
 // add directory separator
35 39
 function add_dirsep($path) {
36
-	if(substr($path,-1) != DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;
40
+	if(substr($path,-1) != DIRECTORY_SEPARATOR) {
41
+		$path .= DIRECTORY_SEPARATOR;
42
+	}
37 43
 	return $path;
38 44
 }
39 45
 
@@ -53,7 +59,9 @@  discard block
 block discarded – undo
53 59
 	// files to skip
54 60
 	$files_to_skip = $config['skip'];
55 61
 	foreach($files_to_skip as $idx=>$file) {
56
-		if($file) $files_to_skip[$idx] = realpath($dir.trim($file));
62
+		if($file) {
63
+			$files_to_skip[$idx] = realpath($dir.trim($file));
64
+		}
57 65
 	}
58 66
 
59 67
 	echo "  Minifying JavaScript files...";
@@ -63,7 +71,9 @@  discard block
 block discarded – undo
63 71
 		require dirname(__FILE__).'/jsminplus/jsminplus.php';
64 72
 	}
65 73
 	foreach($js_files as $file) {
66
-		if(!is_readable($file)) continue;
74
+		if(!is_readable($file)) {
75
+			continue;
76
+		}
67 77
 
68 78
 		$target  = preg_replace('@\.js$@', '.min.js', $file);
69 79
 		$content = file_get_contents($file);
@@ -102,7 +112,9 @@  discard block
 block discarded – undo
102 112
 	$oCSSmin = new CSSmin();
103 113
 
104 114
 	foreach($css_files as $file) {
105
-		if(!is_readable($file)) continue;
115
+		if(!is_readable($file)) {
116
+			continue;
117
+		}
106 118
 
107 119
 		$target  = preg_replace('@\.css$@', '.min.css', $file);
108 120
 		$content = file_get_contents($file);
@@ -117,51 +129,71 @@  discard block
 block discarded – undo
117 129
 	$default = array('option'=>array(), 'skip'=>array(), 'merge'=>array());
118 130
 	$file    = $dir.'minify.ini';
119 131
 
120
-	if(!is_readable($file)) return $default;
132
+	if(!is_readable($file)) {
133
+		return $default;
134
+	}
121 135
 
122 136
 	$config_str = file_get_contents($file);
123 137
 	$config_str = preg_replace_callback('/(\[(?:skip|merge *>> *.+?)\])([\s\S]+?)(?=\[|$)/', 'transform_config_str', $config_str);
124 138
 
125 139
 	$config = parse_ini_string($config_str, 1);
126
-	if($config === false) return $default;
140
+	if($config === false) {
141
+		return $default;
142
+	}
127 143
 
128
-	if(is_array($config['skip'])) $config['skip'] = array_keys($config['skip']);
144
+	if(is_array($config['skip'])) {
145
+		$config['skip'] = array_keys($config['skip']);
146
+	}
129 147
 
130 148
 	foreach($config as $section=>$value) {
131 149
 		if(preg_match('/merge *>> *(.+)/', $section, $match)) {
132
-			if(!is_array($config['merge'])) $config['merge'] = array();
150
+			if(!is_array($config['merge'])) {
151
+				$config['merge'] = array();
152
+			}
133 153
 			$config['merge'][trim($match[1])] = array_keys($value);
134 154
 
135 155
 			unset($config[$section]);
136 156
 		}
137 157
 	}
138 158
 
139
-	if(is_array($config['option'])) $config = array_merge($config['option'], $config);
159
+	if(is_array($config['option'])) {
160
+		$config = array_merge($config['option'], $config);
161
+	}
140 162
 	$config = array_merge($default, $config);
141 163
 
142 164
 	return $config;
143 165
 }
144 166
 
145 167
 function transform_config_str($matches) {
146
-	if(!$matches[2]) return $matches[0];
168
+	if(!$matches[2]) {
169
+		return $matches[0];
170
+	}
147 171
 	$values = preg_replace('/$/m', '=', trim($matches[2]));
148 172
 
149 173
 	return "{$matches[1]}\n{$values}\n\n";
150 174
 }
151 175
 
152 176
 function merge($files, $target, $base_dir) {
153
-	if(!is_array($files)) return false;
177
+	if(!is_array($files)) {
178
+		return false;
179
+	}
154 180
 
155 181
 	$body   = '';
156 182
 	$is_css = !!preg_match('/\.css$/', $target);
157 183
 
158 184
 	foreach($files as $file) {
159 185
 		$file = $base_dir.trim($file);
160
-		if(!is_readable($file)) continue;
186
+		if(!is_readable($file)) {
187
+			continue;
188
+		}
161 189
 
162 190
 		$content = trim(file_get_contents($file));
163
-		if($is_css && $body) $content = preg_replace('/^@.+?;/m', '', $content);
164
-		if($content) $body .= $content."\n";
191
+		if($is_css && $body) {
192
+			$content = preg_replace('/^@.+?;/m', '', $content);
193
+		}
194
+		if($content) {
195
+			$body .= $content."\n";
196
+		}
165 197
 	}
166 198
 
167 199
 	if ($body) {
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author NAVER([email protected])
12 12
  */
13 13
 
14
-if(version_compare(PHP_VERSION, '5.3.0', '<')) {
14
+if (version_compare(PHP_VERSION, '5.3.0', '<')) {
15 15
 	echo "PHP 5.3.0 or above version is required.";
16 16
 	exit(1);
17 17
 }
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	$argc = $_SERVER['argc'];
22 22
 
23 23
 	// get target directories
24
-	if($argc < 1) exit;
25
-	elseif($argc < 2) $dirs = array($_SERVER['PWD']);
24
+	if ($argc < 1) exit;
25
+	elseif ($argc < 2) $dirs = array($_SERVER['PWD']);
26 26
 	else $dirs = array_slice($argv, 1);
27 27
 
28 28
 	$dirs = array_map('realpath', $dirs);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // add directory separator
35 35
 function add_dirsep($path) {
36
-	if(substr($path,-1) != DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;
36
+	if (substr($path, -1) != DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;
37 37
 	return $path;
38 38
 }
39 39
 
@@ -46,38 +46,38 @@  discard block
 block discarded – undo
46 46
 	echo " Done\n";
47 47
 
48 48
 	// merge
49
-	foreach($config['merge'] as $target=>$files) {
49
+	foreach ($config['merge'] as $target=>$files) {
50 50
 		merge($files, $target, $dir);
51 51
 	}
52 52
 
53 53
 	// files to skip
54 54
 	$files_to_skip = $config['skip'];
55
-	foreach($files_to_skip as $idx=>$file) {
56
-		if($file) $files_to_skip[$idx] = realpath($dir.trim($file));
55
+	foreach ($files_to_skip as $idx=>$file) {
56
+		if ($file) $files_to_skip[$idx] = realpath($dir.trim($file));
57 57
 	}
58 58
 
59 59
 	echo "  Minifying JavaScript files...";
60 60
 	$js_files = get_target_files('js', $dir, $files_to_skip);
61 61
 
62
-	if(count($js_files) && !class_exists('JSMinPlus')) {
62
+	if (count($js_files) && !class_exists('JSMinPlus')) {
63 63
 		require dirname(__FILE__).'/jsminplus/jsminplus.php';
64 64
 	}
65
-	foreach($js_files as $file) {
66
-		if(!is_readable($file)) continue;
65
+	foreach ($js_files as $file) {
66
+		if (!is_readable($file)) continue;
67 67
 
68 68
 		$target  = preg_replace('@\.js$@', '.min.js', $file);
69 69
 		$content = file_get_contents($file);
70 70
 
71 71
 		// save copyright to preserve it
72
-		if(preg_match('@^[ \t]*(/\*\*.+?\*/)@s', $content, $matches)) {
72
+		if (preg_match('@^[ \t]*(/\*\*.+?\*/)@s', $content, $matches)) {
73 73
 			$copyright = $matches[1]."\n";
74 74
 		} else {
75 75
 			$copyright = '';
76 76
 		}
77 77
 
78
-		if($config['use_closure_compiler']) {
78
+		if ($config['use_closure_compiler']) {
79 79
 			$content = closure_compile($content);
80
-			if(!$content) {
80
+			if (!$content) {
81 81
 				echo "   CANNOT compile the js file with closure compiler.\n";
82 82
 				echo "   Trying again with JSMinPlus.\n";
83 83
 				$content = JSMinPlus::minify($content);
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	echo "  Minifying CSS files...";
96 96
 	$css_files = get_target_files('css', $dir, $files_to_skip);
97 97
 
98
-	if(count($css_files) && !class_exists('CSSmin')) {
98
+	if (count($css_files) && !class_exists('CSSmin')) {
99 99
 		require dirname(__FILE__).'/cssmin/CSSmin.php';
100 100
 	}
101 101
 
102 102
 	$oCSSmin = new CSSmin();
103 103
 
104
-	foreach($css_files as $file) {
105
-		if(!is_readable($file)) continue;
104
+	foreach ($css_files as $file) {
105
+		if (!is_readable($file)) continue;
106 106
 
107 107
 		$target  = preg_replace('@\.css$@', '.min.css', $file);
108 108
 		$content = file_get_contents($file);
@@ -117,51 +117,51 @@  discard block
 block discarded – undo
117 117
 	$default = array('option'=>array(), 'skip'=>array(), 'merge'=>array());
118 118
 	$file    = $dir.'minify.ini';
119 119
 
120
-	if(!is_readable($file)) return $default;
120
+	if (!is_readable($file)) return $default;
121 121
 
122 122
 	$config_str = file_get_contents($file);
123 123
 	$config_str = preg_replace_callback('/(\[(?:skip|merge *>> *.+?)\])([\s\S]+?)(?=\[|$)/', 'transform_config_str', $config_str);
124 124
 
125 125
 	$config = parse_ini_string($config_str, 1);
126
-	if($config === false) return $default;
126
+	if ($config === false) return $default;
127 127
 
128
-	if(is_array($config['skip'])) $config['skip'] = array_keys($config['skip']);
128
+	if (is_array($config['skip'])) $config['skip'] = array_keys($config['skip']);
129 129
 
130
-	foreach($config as $section=>$value) {
131
-		if(preg_match('/merge *>> *(.+)/', $section, $match)) {
132
-			if(!is_array($config['merge'])) $config['merge'] = array();
130
+	foreach ($config as $section=>$value) {
131
+		if (preg_match('/merge *>> *(.+)/', $section, $match)) {
132
+			if (!is_array($config['merge'])) $config['merge'] = array();
133 133
 			$config['merge'][trim($match[1])] = array_keys($value);
134 134
 
135 135
 			unset($config[$section]);
136 136
 		}
137 137
 	}
138 138
 
139
-	if(is_array($config['option'])) $config = array_merge($config['option'], $config);
139
+	if (is_array($config['option'])) $config = array_merge($config['option'], $config);
140 140
 	$config = array_merge($default, $config);
141 141
 
142 142
 	return $config;
143 143
 }
144 144
 
145 145
 function transform_config_str($matches) {
146
-	if(!$matches[2]) return $matches[0];
146
+	if (!$matches[2]) return $matches[0];
147 147
 	$values = preg_replace('/$/m', '=', trim($matches[2]));
148 148
 
149 149
 	return "{$matches[1]}\n{$values}\n\n";
150 150
 }
151 151
 
152 152
 function merge($files, $target, $base_dir) {
153
-	if(!is_array($files)) return false;
153
+	if (!is_array($files)) return false;
154 154
 
155 155
 	$body   = '';
156 156
 	$is_css = !!preg_match('/\.css$/', $target);
157 157
 
158
-	foreach($files as $file) {
158
+	foreach ($files as $file) {
159 159
 		$file = $base_dir.trim($file);
160
-		if(!is_readable($file)) continue;
160
+		if (!is_readable($file)) continue;
161 161
 
162 162
 		$content = trim(file_get_contents($file));
163
-		if($is_css && $body) $content = preg_replace('/^@.+?;/m', '', $content);
164
-		if($content) $body .= $content."\n";
163
+		if ($is_css && $body) $content = preg_replace('/^@.+?;/m', '', $content);
164
+		if ($content) $body .= $content."\n";
165 165
 	}
166 166
 
167 167
 	if ($body) {
Please login to merge, or discard this patch.
addons/adminlogging/adminlogging.addon.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if (!defined('__XE__'))
5 5
 	exit();
6 6
 
7 7
 /**
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @brief admin log
11 11
  */
12 12
 $logged_info = Context::get('logged_info');
13
-if($logged_info && $logged_info->is_admin == 'Y' && stripos(Context::get('act'), 'admin') !== false && $called_position == 'before_module_proc')
13
+if ($logged_info && $logged_info->is_admin == 'Y' && stripos(Context::get('act'), 'admin') !== false && $called_position == 'before_module_proc')
14 14
 {
15 15
 	$oAdminloggingController = getController('adminlogging');
16 16
 	$oAdminloggingController->insertLog($this->module, $this->act);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,8 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-if(!defined('__XE__'))
4
+if(!defined('__XE__')) {
5 5
 	exit();
6
+}
6 7
 
7 8
 /**
8 9
  * @file adminlogging.addon.php
Please login to merge, or discard this patch.