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
Pull Request — develop (#1930)
by
unknown
12:28
created
classes/xml/xmlquery/tags/column/UpdateColumnTag.class.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,14 +41,12 @@  discard block
 block discarded – undo
41 41
 		if($column->attrs->var)
42 42
 		{
43 43
 			$this->argument = new QueryArgument($column);
44
-		}
45
-		else
44
+		} else
46 45
 		{
47 46
 			if(strpos($column->attrs->default, '.') !== FALSE)
48 47
 			{
49 48
 				$this->default_value = "'" . $dbParser->parseColumnName($column->attrs->default) . "'";
50
-			}
51
-			else
49
+			} else
52 50
 			{
53 51
 				$default_value = new DefaultValue($this->name, $column->attrs->default);
54 52
 				if($default_value->isOperation())
@@ -84,8 +82,7 @@  discard block
 block discarded – undo
84 82
 			return sprintf('new UpdateExpression(\'%s\', ${\'%s_argument\'})'
85 83
 							, $this->name
86 84
 							, $this->argument->argument_name);
87
-		}
88
-		else
85
+		} else
89 86
 		{
90 87
 			return sprintf('new UpdateExpressionWithoutArgument(\'%s\', %s)'
91 88
 							, $this->name
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
 		$dbParser = DB::getParser();
39 39
 		$this->name = $dbParser->parseColumnName($this->name);
40 40
 
41
-		if($column->attrs->var)
41
+		if ($column->attrs->var)
42 42
 		{
43 43
 			$this->argument = new QueryArgument($column);
44 44
 		}
45 45
 		else
46 46
 		{
47
-			if(strpos($column->attrs->default, '.') !== FALSE)
47
+			if (strpos($column->attrs->default, '.') !== FALSE)
48 48
 			{
49
-				$this->default_value = "'" . $dbParser->parseColumnName($column->attrs->default) . "'";
49
+				$this->default_value = "'".$dbParser->parseColumnName($column->attrs->default)."'";
50 50
 			}
51 51
 			else
52 52
 			{
53 53
 				$default_value = new DefaultValue($this->name, $column->attrs->default);
54
-				if($default_value->isOperation())
54
+				if ($default_value->isOperation())
55 55
 				{
56 56
 					$this->argument = new QueryArgument($column, TRUE);
57 57
 				}
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 				else
60 60
 				{
61 61
 					$this->default_value = $default_value->toString();
62
-					if($default_value->isStringFromFunction())
62
+					if ($default_value->isStringFromFunction())
63 63
 					{
64
-						$this->default_value = '"\'".' . $this->default_value . '."\'"';
64
+						$this->default_value = '"\'".'.$this->default_value.'."\'"';
65 65
 					}
66
-					if($default_value->isString())
66
+					if ($default_value->isString())
67 67
 					{
68
-						$this->default_value = '"' . $this->default_value . '"';
68
+						$this->default_value = '"'.$this->default_value.'"';
69 69
 					}
70 70
 				}
71 71
 			}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	function getExpressionString()
81 81
 	{
82
-		if($this->argument)
82
+		if ($this->argument)
83 83
 		{
84 84
 			return sprintf('new UpdateExpression(\'%s\', ${\'%s_argument\'})'
85 85
 							, $this->name
Please login to merge, or discard this patch.
classes/xml/xmlquery/tags/column/UpdateColumnsTag.class.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@
 block discarded – undo
38 38
 			if($column->name === 'query')
39 39
 			{
40 40
 				$this->columns[] = new QueryTag($column, true);
41
-			}
42
-			else
41
+			} else
43 42
 			{
44 43
 				$this->columns[] = new UpdateColumnTag($column);
45 44
 			}
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		$this->columns = array();
30 30
 
31
-		if(!is_array($xml_columns))
31
+		if (!is_array($xml_columns))
32 32
 		{
33 33
 			$xml_columns = array($xml_columns);
34 34
 		}
35 35
 
36
-		foreach($xml_columns as $column)
36
+		foreach ($xml_columns as $column)
37 37
 		{
38
-			if($column->name === 'query')
38
+			if ($column->name === 'query')
39 39
 			{
40 40
 				$this->columns[] = new QueryTag($column, true);
41 41
 			}
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function toString()
55 55
 	{
56
-		$output_columns = 'array(' . PHP_EOL;
57
-		foreach($this->columns as $column)
56
+		$output_columns = 'array('.PHP_EOL;
57
+		foreach ($this->columns as $column)
58 58
 		{
59
-			$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
59
+			$output_columns .= $column->getExpressionString().PHP_EOL.',';
60 60
 		}
61 61
 		$output_columns = substr($output_columns, 0, -1);
62 62
 		$output_columns .= ')';
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	function getArguments()
72 72
 	{
73 73
 		$arguments = array();
74
-		foreach($this->columns as $column)
74
+		foreach ($this->columns as $column)
75 75
 		{
76 76
 			$arguments[] = $column->getArgument();
77 77
 		}
Please login to merge, or discard this patch.
classes/xml/xmlquery/tags/condition/ConditionTag.class.php 2 patches
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -78,13 +78,11 @@  discard block
 block discarded – undo
78 78
 		{
79 79
 			$this->query = new QueryTag($condition, TRUE);
80 80
 			$this->default_column = $this->query->toString();
81
-		}
82
-		else if($condition->attrs->var && !strpos($condition->attrs->var, '.'))
81
+		} else if($condition->attrs->var && !strpos($condition->attrs->var, '.'))
83 82
 		{
84 83
 			$this->argument = new QueryArgument($condition);
85 84
 			$this->argument_name = $this->argument->getArgumentName();
86
-		}
87
-		else
85
+		} else
88 86
 		{
89 87
 			if(isset($condition->attrs->default))
90 88
 			{
@@ -95,13 +93,11 @@  discard block
 block discarded – undo
95 93
 					if(strpos($default_value, "'") !== FALSE)
96 94
 					{
97 95
 						$default_value = "\"" . $default_value . "\"";
98
-					}
99
-					else
96
+					} else
100 97
 					{
101 98
 						$default_value = "'" . $default_value . "'";
102 99
 					}
103
-				}
104
-				else
100
+				} else
105 101
 				{
106 102
 					$default_value_object = new DefaultValue($this->column_name, $condition->attrs->default);
107 103
 					$default_value = $default_value_object->toString();
@@ -116,16 +112,14 @@  discard block
 block discarded – undo
116 112
 						if(strpos($default_value, "'") !== FALSE)
117 113
 						{
118 114
 							$default_value = "\"" . $default_value . "\"";
119
-						}
120
-						else
115
+						} else
121 116
 						{
122 117
 							$default_value = "'" . $default_value . "'";
123 118
 						}
124 119
 					}
125 120
 				}
126 121
 				$this->default_column = $default_value;
127
-			}
128
-			else
122
+			} else
129 123
 			{
130 124
 				$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'";
131 125
 			}
@@ -161,8 +155,7 @@  discard block
 block discarded – undo
161 155
 							, '"' . $this->operation . '"'
162 156
 							, $this->pipe ? ", '" . $this->pipe . "'" : ''
163 157
 			);
164
-		}
165
-		else if(isset($this->default_column))
158
+		} else if(isset($this->default_column))
166 159
 		{
167 160
 			return sprintf("new ConditionWithoutArgument('%s',%s,%s%s)"
168 161
 							, $this->column_name
@@ -170,8 +163,7 @@  discard block
 block discarded – undo
170 163
 							, '"' . $this->operation . '"'
171 164
 							, $this->pipe ? ", '" . $this->pipe . "'" : ''
172 165
 			);
173
-		}
174
-		else
166
+		} else
175 167
 		{
176 168
 			return sprintf("new ConditionWithArgument('%s',%s,%s%s)"
177 169
 							, $this->column_name
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -67,38 +67,38 @@  discard block
 block discarded – undo
67 67
 		$this->column_name = $dbParser->parseExpression($condition->attrs->column);
68 68
 
69 69
 		// If default value is column name, it should be escaped
70
-		if($isColumnName = (strpos($condition->attrs->default, '.') !== FALSE
70
+		if ($isColumnName = (strpos($condition->attrs->default, '.') !== FALSE
71 71
 				&& strpos($condition->attrs->default, '.') !== 0
72
-				&& strpos($condition->attrs->default, '%') === FALSE ))
72
+				&& strpos($condition->attrs->default, '%') === FALSE))
73 73
 		{
74 74
 			$condition->attrs->default = $dbParser->parseExpression($condition->attrs->default);
75 75
 		}
76 76
 
77
-		if($condition->node_name == 'query')
77
+		if ($condition->node_name == 'query')
78 78
 		{
79 79
 			$this->query = new QueryTag($condition, TRUE);
80 80
 			$this->default_column = $this->query->toString();
81 81
 		}
82
-		else if($condition->attrs->var && !strpos($condition->attrs->var, '.'))
82
+		else if ($condition->attrs->var && !strpos($condition->attrs->var, '.'))
83 83
 		{
84 84
 			$this->argument = new QueryArgument($condition);
85 85
 			$this->argument_name = $this->argument->getArgumentName();
86 86
 		}
87 87
 		else
88 88
 		{
89
-			if(isset($condition->attrs->default))
89
+			if (isset($condition->attrs->default))
90 90
 			{
91 91
 				$operationList = array('in' => 1, 'between' => 1, 'notin' => 1, 'not_in' => 1);
92
-				if(isset($operationList[$this->operation]))
92
+				if (isset($operationList[$this->operation]))
93 93
 				{
94 94
 					$default_value = $condition->attrs->default;
95
-					if(strpos($default_value, "'") !== FALSE)
95
+					if (strpos($default_value, "'") !== FALSE)
96 96
 					{
97
-						$default_value = "\"" . $default_value . "\"";
97
+						$default_value = "\"".$default_value."\"";
98 98
 					}
99 99
 					else
100 100
 					{
101
-						$default_value = "'" . $default_value . "'";
101
+						$default_value = "'".$default_value."'";
102 102
 					}
103 103
 				}
104 104
 				else
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
 					$default_value_object = new DefaultValue($this->column_name, $condition->attrs->default);
107 107
 					$default_value = $default_value_object->toString();
108 108
 
109
-					if($default_value_object->isStringFromFunction())
109
+					if ($default_value_object->isStringFromFunction())
110 110
 					{
111
-						$default_value = '"\'".' . $default_value . '."\'"';
111
+						$default_value = '"\'".'.$default_value.'."\'"';
112 112
 					}
113 113
 
114
-					if($default_value_object->isString() && !$isColumnName && !is_numeric($condition->attrs->default))
114
+					if ($default_value_object->isString() && !$isColumnName && !is_numeric($condition->attrs->default))
115 115
 					{
116
-						if(strpos($default_value, "'") !== FALSE)
116
+						if (strpos($default_value, "'") !== FALSE)
117 117
 						{
118
-							$default_value = "\"" . $default_value . "\"";
118
+							$default_value = "\"".$default_value."\"";
119 119
 						}
120 120
 						else
121 121
 						{
122
-							$default_value = "'" . $default_value . "'";
122
+							$default_value = "'".$default_value."'";
123 123
 						}
124 124
 					}
125 125
 				}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 			else
129 129
 			{
130
-				$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'";
130
+				$this->default_column = "'".$dbParser->parseColumnName($condition->attrs->var)."'";
131 131
 			}
132 132
 		}
133 133
 	}
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 	function getArguments()
141 141
 	{
142 142
 		$arguments = array();
143
-		if($this->query)
143
+		if ($this->query)
144 144
 		{
145 145
 			$arguments = array_merge($arguments, $this->query->getArguments());
146 146
 		}
147
-		if($this->argument)
147
+		if ($this->argument)
148 148
 		{
149 149
 			$arguments[] = $this->argument;
150 150
 		}
@@ -153,31 +153,31 @@  discard block
 block discarded – undo
153 153
 
154 154
 	function getConditionString()
155 155
 	{
156
-		if($this->query)
156
+		if ($this->query)
157 157
 		{
158 158
 			return sprintf("new ConditionSubquery('%s',%s,%s%s)"
159 159
 							, $this->column_name
160 160
 							, $this->default_column
161
-							, '"' . $this->operation . '"'
162
-							, $this->pipe ? ", '" . $this->pipe . "'" : ''
161
+							, '"'.$this->operation.'"'
162
+							, $this->pipe ? ", '".$this->pipe."'" : ''
163 163
 			);
164 164
 		}
165
-		else if(isset($this->default_column))
165
+		else if (isset($this->default_column))
166 166
 		{
167 167
 			return sprintf("new ConditionWithoutArgument('%s',%s,%s%s)"
168 168
 							, $this->column_name
169 169
 							, $this->default_column
170
-							, '"' . $this->operation . '"'
171
-							, $this->pipe ? ", '" . $this->pipe . "'" : ''
170
+							, '"'.$this->operation.'"'
171
+							, $this->pipe ? ", '".$this->pipe."'" : ''
172 172
 			);
173 173
 		}
174 174
 		else
175 175
 		{
176 176
 			return sprintf("new ConditionWithArgument('%s',%s,%s%s)"
177 177
 							, $this->column_name
178
-							, '$' . $this->argument_name . '_argument'
179
-							, '"' . $this->operation . '"'
180
-							, $this->pipe ? ", '" . $this->pipe . "'" : ''
178
+							, '$'.$this->argument_name.'_argument'
179
+							, '"'.$this->operation.'"'
180
+							, $this->pipe ? ", '".$this->pipe."'" : ''
181 181
 			);
182 182
 		}
183 183
 	}
Please login to merge, or discard this patch.
classes/xml/xmlquery/tags/navigation/LimitTag.class.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	function LimitTag($index)
44 44
 	{
45
-		if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs)
45
+		if ($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs)
46 46
 		{
47
-			if(!isset($index->page->attrs->default))
47
+			if (!isset($index->page->attrs->default))
48 48
 				$index->page->attrs->default = 1;
49
-			if(!isset($index->page_count->attrs->default))
49
+			if (!isset($index->page_count->attrs->default))
50 50
 				$index->page_count->attrs->default = 10;
51 51
 			$this->page = new QueryArgument($index->page);
52 52
 			$this->page_count = new QueryArgument($index->page_count);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			$this->arguments[] = $this->page_count;
55 55
 		}
56 56
 
57
-		if(!isset($index->list_count->attrs->default))
57
+		if (!isset($index->list_count->attrs->default))
58 58
 			$index->list_count->attrs->default = 0;
59 59
 		$this->list_count = new QueryArgument($index->list_count);
60 60
 		$this->arguments[] = $this->list_count;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
 	function toString()
64 64
 	{
65
-		if($this->page)
65
+		if ($this->page)
66 66
 		{
67 67
 			return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
68 68
 		}
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,18 +44,21 @@  discard block
 block discarded – undo
44 44
 	{
45 45
 		if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs)
46 46
 		{
47
-			if(!isset($index->page->attrs->default))
48
-				$index->page->attrs->default = 1;
49
-			if(!isset($index->page_count->attrs->default))
50
-				$index->page_count->attrs->default = 10;
47
+			if(!isset($index->page->attrs->default)) {
48
+							$index->page->attrs->default = 1;
49
+			}
50
+			if(!isset($index->page_count->attrs->default)) {
51
+							$index->page_count->attrs->default = 10;
52
+			}
51 53
 			$this->page = new QueryArgument($index->page);
52 54
 			$this->page_count = new QueryArgument($index->page_count);
53 55
 			$this->arguments[] = $this->page;
54 56
 			$this->arguments[] = $this->page_count;
55 57
 		}
56 58
 
57
-		if(!isset($index->list_count->attrs->default))
58
-			$index->list_count->attrs->default = 0;
59
+		if(!isset($index->list_count->attrs->default)) {
60
+					$index->list_count->attrs->default = 0;
61
+		}
59 62
 		$this->list_count = new QueryArgument($index->list_count);
60 63
 		$this->arguments[] = $this->list_count;
61 64
 	}
@@ -65,8 +68,7 @@  discard block
 block discarded – undo
65 68
 		if($this->page)
66 69
 		{
67 70
 			return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
68
-		}
69
-		else
71
+		} else
70 72
 		{
71 73
 			return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName());
72 74
 		}
Please login to merge, or discard this patch.
classes/xml/xmlquery/tags/navigation/NavigationTag.class.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@
 block discarded – undo
111 111
 		if($this->limit)
112 112
 		{
113 113
 			return $this->limit->toString();
114
-		}
115
-		else
114
+		} else
116 115
 		{
117 116
 			return "";
118 117
 		}
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,36 +49,36 @@  discard block
 block discarded – undo
49 49
 	function NavigationTag($xml_navigation)
50 50
 	{
51 51
 		$this->order = array();
52
-		if($xml_navigation)
52
+		if ($xml_navigation)
53 53
 		{
54 54
 			$order = $xml_navigation->index;
55
-			if($order)
55
+			if ($order)
56 56
 			{
57
-				if(!is_array($order))
57
+				if (!is_array($order))
58 58
 				{
59 59
 					$order = array($order);
60 60
 				}
61
-				foreach($order as $order_info)
61
+				foreach ($order as $order_info)
62 62
 				{
63 63
 					$this->order[] = new IndexTag($order_info);
64 64
 				}
65 65
 
66
-				if($xml_navigation->page && $xml_navigation->page->attrs || $xml_navigation->list_count && $xml_navigation->list_count->attrs)
66
+				if ($xml_navigation->page && $xml_navigation->page->attrs || $xml_navigation->list_count && $xml_navigation->list_count->attrs)
67 67
 				{
68 68
 					$this->limit = new LimitTag($xml_navigation);
69 69
 				}
70 70
 
71
-				if($xml_navigation->list_count)
71
+				if ($xml_navigation->list_count)
72 72
 				{
73 73
 					$this->list_count = $xml_navigation->list_count->attrs;
74 74
 				}
75 75
 
76
-				if($xml_navigation->page_count)
76
+				if ($xml_navigation->page_count)
77 77
 				{
78 78
 					$this->page_count = $xml_navigation->page_count->attrs;
79 79
 				}
80 80
 
81
-				if($xml_navigation->page)
81
+				if ($xml_navigation->page)
82 82
 				{
83 83
 					$this->page = $xml_navigation->page->attrs;
84 84
 				}
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	function getOrderByString()
94 94
 	{
95
-		$output = 'array(' . PHP_EOL;
96
-		foreach($this->order as $order)
95
+		$output = 'array('.PHP_EOL;
96
+		foreach ($this->order as $order)
97 97
 		{
98
-			$output .= $order->toString() . PHP_EOL . ',';
98
+			$output .= $order->toString().PHP_EOL.',';
99 99
 		}
100 100
 		$output = substr($output, 0, -1);
101 101
 		$output .= ')';
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	function getLimitString()
110 110
 	{
111
-		if($this->limit)
111
+		if ($this->limit)
112 112
 		{
113 113
 			return $this->limit->toString();
114 114
 		}
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	function getArguments()
122 122
 	{
123 123
 		$arguments = array();
124
-		foreach($this->order as $order)
124
+		foreach ($this->order as $order)
125 125
 		{
126 126
 			$arguments = array_merge($order->getArguments(), $arguments);
127 127
 		}
128
-		if($this->limit)
128
+		if ($this->limit)
129 129
 		{
130 130
 			$arguments = array_merge($this->limit->getArguments(), $arguments);
131 131
 		}
Please login to merge, or discard this patch.
classes/xml/xmlquery/tags/table/TablesTag.class.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,14 +68,12 @@  discard block
 block discarded – undo
68 68
 			if($tag->attrs->query == 'true')
69 69
 			{
70 70
 				$this->tables[] = new QueryTag($tag, true);
71
-			}
72
-			else
71
+			} else
73 72
 			{
74 73
 				if(isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
75 74
 				{
76 75
 					$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
77
-				}
78
-				else
76
+				} else
79 77
 				{
80 78
 					$this->tables[] = new TableTag($tag);
81 79
 				}
@@ -96,8 +94,7 @@  discard block
 block discarded – undo
96 94
 			if(is_a($table, 'QueryTag'))
97 95
 			{
98 96
 				$output_tables .= $table->toString() . PHP_EOL . ',';
99
-			}
100
-			else
97
+			} else
101 98
 			{
102 99
 				$output_tables .= $table->getTableString() . PHP_EOL . ',';
103 100
 			}
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
 		$this->tables = array();
39 39
 
40 40
 		$xml_tables = $xml_tables_tag->table;
41
-		if(!is_array($xml_tables))
41
+		if (!is_array($xml_tables))
42 42
 		{
43 43
 			$xml_tables = array($xml_tables);
44 44
 		}
45 45
 
46
-		if($xml_index_hints_tag)
46
+		if ($xml_index_hints_tag)
47 47
 		{
48 48
 			$index_nodes = $xml_index_hints_tag->index;
49
-			if(!is_array($index_nodes))
49
+			if (!is_array($index_nodes))
50 50
 			{
51 51
 				$index_nodes = array($index_nodes);
52 52
 			}
53
-			foreach($index_nodes as $index_node)
53
+			foreach ($index_nodes as $index_node)
54 54
 			{
55
-				if(!isset($indexes[$index_node->attrs->table]))
55
+				if (!isset($indexes[$index_node->attrs->table]))
56 56
 				{
57 57
 					$indexes[$index_node->attrs->table] = array();
58 58
 				}
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
 			}
64 64
 		}
65 65
 
66
-		foreach($xml_tables as $tag)
66
+		foreach ($xml_tables as $tag)
67 67
 		{
68
-			if($tag->attrs->query == 'true')
68
+			if ($tag->attrs->query == 'true')
69 69
 			{
70 70
 				$this->tables[] = new QueryTag($tag, true);
71 71
 			}
72 72
 			else
73 73
 			{
74
-				if(isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
74
+				if (isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
75 75
 				{
76 76
 					$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
77 77
 				}
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
 
91 91
 	function toString()
92 92
 	{
93
-		$output_tables = 'array(' . PHP_EOL;
94
-		foreach($this->tables as $table)
93
+		$output_tables = 'array('.PHP_EOL;
94
+		foreach ($this->tables as $table)
95 95
 		{
96
-			if(is_a($table, 'QueryTag'))
96
+			if (is_a($table, 'QueryTag'))
97 97
 			{
98
-				$output_tables .= $table->toString() . PHP_EOL . ',';
98
+				$output_tables .= $table->toString().PHP_EOL.',';
99 99
 			}
100 100
 			else
101 101
 			{
102
-				$output_tables .= $table->getTableString() . PHP_EOL . ',';
102
+				$output_tables .= $table->getTableString().PHP_EOL.',';
103 103
 			}
104 104
 		}
105 105
 		$output_tables = substr($output_tables, 0, -1);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	function getArguments()
111 111
 	{
112 112
 		$arguments = array();
113
-		foreach($this->tables as $table)
113
+		foreach ($this->tables as $table)
114 114
 		{
115 115
 			$arguments = array_merge($arguments, $table->getArguments());
116 116
 		}
Please login to merge, or discard this patch.
config/config.inc.php 2 patches
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 if(version_compare(PHP_VERSION, '5.4.0', '<'))
11 11
 {
12 12
 	@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING);
13
-}
14
-else
13
+} else
15 14
 {
16 15
 	@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT);
17 16
 }
@@ -56,8 +55,7 @@  discard block
 block discarded – undo
56 55
 if(file_exists(_XE_PATH_ . 'config/package.inc.php'))
57 56
 {
58 57
 	require _XE_PATH_ . 'config/package.inc.php';
59
-}
60
-else
58
+} else
61 59
 {
62 60
 	/**
63 61
 	 * Package type
@@ -398,12 +396,13 @@  discard block
 block discarded – undo
398 396
 	if(isset($GLOBALS['__xe_autoload_file_map'][strtolower($class_name)]))
399 397
 	{
400 398
 		require _XE_PATH_ . $GLOBALS['__xe_autoload_file_map'][strtolower($class_name)];
401
-	}
402
-	elseif(preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches))
399
+	} elseif(preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches))
403 400
 	{
404 401
 		$candidate_filename = array();
405 402
 		$candidate_filename[] = 'modules/' . $matches[1] . '/' . $matches[1];
406
-		if(isset($matches[2]) && $matches[2]) $candidate_filename[] = 'admin';
403
+		if(isset($matches[2]) && $matches[2]) {
404
+			$candidate_filename[] = 'admin';
405
+		}
407 406
 		$candidate_filename[] = (isset($matches[3]) && $matches[3]) ? strtolower($matches[3]) : 'class';
408 407
 		$candidate_filename[] = 'php';
409 408
 
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @file   config/config.inc.php
8 8
  * @author NAVER ([email protected])
9 9
  */
10
-if(version_compare(PHP_VERSION, '5.4.0', '<'))
10
+if (version_compare(PHP_VERSION, '5.4.0', '<'))
11 11
 {
12 12
 	@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING);
13 13
 }
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT);
17 17
 }
18 18
 
19
-if(!defined('__XE__'))
19
+if (!defined('__XE__'))
20 20
 {
21 21
 	exit();
22 22
 }
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 ini_set('session.use_only_cookies', 0);
54 54
 
55 55
 
56
-if(file_exists(_XE_PATH_ . 'config/package.inc.php'))
56
+if (file_exists(_XE_PATH_.'config/package.inc.php'))
57 57
 {
58
-	require _XE_PATH_ . 'config/package.inc.php';
58
+	require _XE_PATH_.'config/package.inc.php';
59 59
 }
60 60
 else
61 61
 {
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
  * define('__ENABLE_PHPUNIT_TEST__', 0);
98 98
  * define('__PROXY_SERVER__', 'http://domain:port/path');
99 99
  */
100
-if(file_exists(_XE_PATH_ . 'config/config.user.inc.php'))
100
+if (file_exists(_XE_PATH_.'config/config.user.inc.php'))
101 101
 {
102
-	require _XE_PATH_ . 'config/config.user.inc.php';
102
+	require _XE_PATH_.'config/config.user.inc.php';
103 103
 }
104 104
 
105
-if(!defined('__DEBUG__'))
105
+if (!defined('__DEBUG__'))
106 106
 {
107 107
 	/**
108 108
 	 * output debug message(bit value)
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	define('__DEBUG__', 0);
118 118
 }
119 119
 
120
-if(!defined('__DEBUG_OUTPUT__'))
120
+if (!defined('__DEBUG_OUTPUT__'))
121 121
 {
122 122
 	/**
123 123
 	 * output location of debug message
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	define('__DEBUG_OUTPUT__', 0);
132 132
 }
133 133
 
134
-if(!defined('__DEBUG_PROTECT__'))
134
+if (!defined('__DEBUG_PROTECT__'))
135 135
 {
136 136
 	/**
137 137
 	 * output comments of the firePHP console and browser
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	define('__DEBUG_PROTECT__', 1);
145 145
 }
146 146
 
147
-if(!defined('__DEBUG_PROTECT_IP__'))
147
+if (!defined('__DEBUG_PROTECT_IP__'))
148 148
 {
149 149
 	/**
150 150
 	 * Set a ip address to allow debug
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	define('__DEBUG_PROTECT_IP__', '127.0.0.1');
153 153
 }
154 154
 
155
-if(!defined('__DEBUG_DB_OUTPUT__'))
155
+if (!defined('__DEBUG_DB_OUTPUT__'))
156 156
 {
157 157
 	/**
158 158
 	 * DB error message definition
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	define('__DEBUG_DB_OUTPUT__', 0);
166 166
 }
167 167
 
168
-if(!defined('__LOG_SLOW_QUERY__'))
168
+if (!defined('__LOG_SLOW_QUERY__'))
169 169
 {
170 170
 	/**
171 171
 	 * Query log for only timeout query among DB queries
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	define('__LOG_SLOW_QUERY__', 0);
180 180
 }
181 181
 
182
-if(!defined('__LOG_SLOW_TRIGGER__'))
182
+if (!defined('__LOG_SLOW_TRIGGER__'))
183 183
 {
184 184
 	/**
185 185
 	 * Trigger excute time log
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	define('__LOG_SLOW_TRIGGER__', 0);
194 194
 }
195 195
 
196
-if(!defined('__LOG_SLOW_ADDON__'))
196
+if (!defined('__LOG_SLOW_ADDON__'))
197 197
 {
198 198
 	/**
199 199
 	 * Addon excute time log
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	define('__LOG_SLOW_ADDON__', 0);
208 208
 }
209 209
 
210
-if(!defined('__LOG_SLOW_WIDGET__'))
210
+if (!defined('__LOG_SLOW_WIDGET__'))
211 211
 {
212 212
 	/**
213 213
 	 * Widget excute time log
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	define('__LOG_SLOW_WIDGET__', 0);
222 222
 }
223 223
 
224
-if(!defined('__DEBUG_QUERY__'))
224
+if (!defined('__DEBUG_QUERY__'))
225 225
 {
226 226
 	/**
227 227
 	 * Leave DB query information
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	define('__DEBUG_QUERY__', 0);
235 235
 }
236 236
 
237
-if(!defined('__OB_GZHANDLER_ENABLE__'))
237
+if (!defined('__OB_GZHANDLER_ENABLE__'))
238 238
 {
239 239
 	/**
240 240
 	 * option to enable/disable a compression feature using ob_gzhandler
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	define('__OB_GZHANDLER_ENABLE__', 1);
249 249
 }
250 250
 
251
-if(!defined('__ENABLE_PHPUNIT_TEST__'))
251
+if (!defined('__ENABLE_PHPUNIT_TEST__'))
252 252
 {
253 253
 	/**
254 254
 	 * decide to use/not use the php unit test (Path/tests/index.php)
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	define('__ENABLE_PHPUNIT_TEST__', 0);
262 262
 }
263 263
 
264
-if(!defined('__PROXY_SERVER__'))
264
+if (!defined('__PROXY_SERVER__'))
265 265
 {
266 266
 	/**
267 267
 	 * __PROXY_SERVER__ has server information to request to the external through the target server
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
 }
272 272
 
273 273
 // Require specific files when using Firebug console output
274
-if((__DEBUG_OUTPUT__ == 2) && version_compare(PHP_VERSION, '6.0.0') === -1)
274
+if ((__DEBUG_OUTPUT__ == 2) && version_compare(PHP_VERSION, '6.0.0') === -1)
275 275
 {
276
-	require _XE_PATH_ . 'libs/FirePHPCore/FirePHP.class.php';
276
+	require _XE_PATH_.'libs/FirePHPCore/FirePHP.class.php';
277 277
 }
278 278
 
279 279
 // Set Timezone as server time
280
-if(version_compare(PHP_VERSION, '5.3.0') >= 0)
280
+if (version_compare(PHP_VERSION, '5.3.0') >= 0)
281 281
 {
282 282
 	date_default_timezone_set(@date_default_timezone_get());
283 283
 }
284 284
 
285 285
 // Require a function-defined-file for simple use
286
-require(_XE_PATH_ . 'config/func.inc.php');
286
+require(_XE_PATH_.'config/func.inc.php');
287 287
 
288
-if(__DEBUG__) {
288
+if (__DEBUG__) {
289 289
 	define('__StartTime__', getMicroTime());
290 290
 }
291 291
 
292
-if(__DEBUG__) {
292
+if (__DEBUG__) {
293 293
 	$GLOBALS['__elapsed_class_load__'] = 0;
294 294
 }
295 295
 
@@ -391,38 +391,38 @@  discard block
 block discarded – undo
391 391
 
392 392
 function __xe_autoload($class_name)
393 393
 {
394
-	if(__DEBUG__) {
394
+	if (__DEBUG__) {
395 395
 		$time_at = getMicroTime();
396 396
 	}
397 397
 
398
-	if(isset($GLOBALS['__xe_autoload_file_map'][strtolower($class_name)]))
398
+	if (isset($GLOBALS['__xe_autoload_file_map'][strtolower($class_name)]))
399 399
 	{
400
-		require _XE_PATH_ . $GLOBALS['__xe_autoload_file_map'][strtolower($class_name)];
400
+		require _XE_PATH_.$GLOBALS['__xe_autoload_file_map'][strtolower($class_name)];
401 401
 	}
402
-	elseif(preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches))
402
+	elseif (preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches))
403 403
 	{
404 404
 		$candidate_filename = array();
405
-		$candidate_filename[] = 'modules/' . $matches[1] . '/' . $matches[1];
406
-		if(isset($matches[2]) && $matches[2]) $candidate_filename[] = 'admin';
405
+		$candidate_filename[] = 'modules/'.$matches[1].'/'.$matches[1];
406
+		if (isset($matches[2]) && $matches[2]) $candidate_filename[] = 'admin';
407 407
 		$candidate_filename[] = (isset($matches[3]) && $matches[3]) ? strtolower($matches[3]) : 'class';
408 408
 		$candidate_filename[] = 'php';
409 409
 
410 410
 		$candidate_filename = implode('.', $candidate_filename);
411 411
 
412
-		if(file_exists(_XE_PATH_ . $candidate_filename))
412
+		if (file_exists(_XE_PATH_.$candidate_filename))
413 413
 		{
414
-			require _XE_PATH_ . $candidate_filename;
414
+			require _XE_PATH_.$candidate_filename;
415 415
 		}
416 416
 	}
417 417
 
418
-	if(__DEBUG__) {
418
+	if (__DEBUG__) {
419 419
 		$GLOBALS['__elapsed_class_load__'] += getMicroTime() - $time_at;
420 420
 	}
421 421
 }
422 422
 spl_autoload_register('__xe_autoload');
423 423
 
424
-if(file_exists(_XE_PATH_  . '/vendor/autoload.php')) {
425
-	require _XE_PATH_  . '/vendor/autoload.php';
424
+if (file_exists(_XE_PATH_.'/vendor/autoload.php')) {
425
+	require _XE_PATH_.'/vendor/autoload.php';
426 426
 }
427 427
 /* End of file config.inc.php */
428 428
 /* Location: ./config/config.inc.php */
Please login to merge, or discard this patch.
index.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@
 block discarded – undo
58 58
 		{
59 59
 			$oModuleHandler->displayContent($oModuleHandler->procModule());
60 60
 		}
61
-	}
62
-	catch(Exception $e)
61
+	} catch(Exception $e)
63 62
 	{
64 63
 		htmlHeader();
65 64
 		echo Context::getLang($e->getMessage());
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 /**
33 33
  * @brief Declare constants for generic use and for checking to avoid a direct call from the Web
34 34
  **/
35
-define('__XE__',   TRUE);
35
+define('__XE__', TRUE);
36 36
 /**
37 37
  * @brief Include the necessary configuration files
38 38
  **/
39
-require dirname(__FILE__) . '/config/config.inc.php';
39
+require dirname(__FILE__).'/config/config.inc.php';
40 40
 
41 41
 /**
42 42
  * @brief Initialize by creating Context object
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 /**
49 49
  * @brief If default_url is set and it is different from the current url, attempt to redirect for SSO authentication and then process the module
50 50
  **/
51
-if($oContext->checkSSO())
51
+if ($oContext->checkSSO())
52 52
 {
53 53
 	$oModuleHandler = new ModuleHandler();
54 54
 
55 55
 	try
56 56
 	{
57
-		if($oModuleHandler->init())
57
+		if ($oModuleHandler->init())
58 58
 		{
59 59
 			$oModuleHandler->displayContent($oModuleHandler->procModule());
60 60
 		}
61 61
 	}
62
-	catch(Exception $e)
62
+	catch (Exception $e)
63 63
 	{
64 64
 		htmlHeader();
65 65
 		echo Context::getLang($e->getMessage());
Please login to merge, or discard this patch.
libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php 3 patches
Switch Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -268,29 +268,29 @@  discard block
 block discarded – undo
268 268
 
269 269
         // set HTTP version
270 270
         switch ($this->request->getConfig('protocol_version')) {
271
-        case '1.0':
272
-            curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
273
-            break;
274
-        case '1.1':
275
-            curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
271
+        	case '1.0':
272
+            	curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
273
+            	break;
274
+        	case '1.1':
275
+            	curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
276 276
         }
277 277
 
278 278
         // set request method
279 279
         switch ($this->request->getMethod()) {
280
-        case HTTP_Request2::METHOD_GET:
281
-            curl_setopt($ch, CURLOPT_HTTPGET, true);
282
-            break;
283
-        case HTTP_Request2::METHOD_POST:
284
-            curl_setopt($ch, CURLOPT_POST, true);
285
-            break;
286
-        case HTTP_Request2::METHOD_HEAD:
287
-            curl_setopt($ch, CURLOPT_NOBODY, true);
288
-            break;
289
-        case HTTP_Request2::METHOD_PUT:
290
-            curl_setopt($ch, CURLOPT_UPLOAD, true);
291
-            break;
292
-        default:
293
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod());
280
+        	case HTTP_Request2::METHOD_GET:
281
+            	curl_setopt($ch, CURLOPT_HTTPGET, true);
282
+            	break;
283
+        	case HTTP_Request2::METHOD_POST:
284
+            	curl_setopt($ch, CURLOPT_POST, true);
285
+            	break;
286
+        	case HTTP_Request2::METHOD_HEAD:
287
+            	curl_setopt($ch, CURLOPT_NOBODY, true);
288
+            	break;
289
+        	case HTTP_Request2::METHOD_PUT:
290
+            	curl_setopt($ch, CURLOPT_UPLOAD, true);
291
+            	break;
292
+        	default:
293
+            	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod());
294 294
         }
295 295
 
296 296
         // set proxy, if needed
@@ -307,25 +307,25 @@  discard block
 block discarded – undo
307 307
                     $user . ':' . $this->request->getConfig('proxy_password')
308 308
                 );
309 309
                 switch ($this->request->getConfig('proxy_auth_scheme')) {
310
-                case HTTP_Request2::AUTH_BASIC:
311
-                    curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
312
-                    break;
313
-                case HTTP_Request2::AUTH_DIGEST:
314
-                    curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
310
+                	case HTTP_Request2::AUTH_BASIC:
311
+                    	curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
312
+                    	break;
313
+                	case HTTP_Request2::AUTH_DIGEST:
314
+                    	curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
315 315
                 }
316 316
             }
317 317
             if ($type = $this->request->getConfig('proxy_type')) {
318 318
                 switch ($type) {
319
-                case 'http':
320
-                    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
321
-                    break;
322
-                case 'socks5':
323
-                    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
324
-                    break;
325
-                default:
326
-                    throw new HTTP_Request2_NotImplementedException(
327
-                        "Proxy type '{$type}' is not supported"
328
-                    );
319
+                	case 'http':
320
+                    	curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
321
+                    	break;
322
+                	case 'socks5':
323
+                    	curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
324
+                    	break;
325
+                	default:
326
+                    	throw new HTTP_Request2_NotImplementedException(
327
+                        	"Proxy type '{$type}' is not supported"
328
+                    	);
329 329
                 }
330 330
             }
331 331
         }
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
         if ($auth = $this->request->getAuth()) {
335 335
             curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']);
336 336
             switch ($auth['scheme']) {
337
-            case HTTP_Request2::AUTH_BASIC:
338
-                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
339
-                break;
340
-            case HTTP_Request2::AUTH_DIGEST:
341
-                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
337
+            	case HTTP_Request2::AUTH_BASIC:
338
+                	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
339
+                	break;
340
+            	case HTTP_Request2::AUTH_DIGEST:
341
+                	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
342 342
             }
343 343
         }
344 344
 
Please login to merge, or discard this patch.
Indentation   +528 added lines, -528 removed lines patch added patch discarded remove patch
@@ -35,533 +35,533 @@
 block discarded – undo
35 35
  */
36 36
 class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter
37 37
 {
38
-    /**
39
-     * Mapping of header names to cURL options
40
-     * @var  array
41
-     */
42
-    protected static $headerMap = array(
43
-        'accept-encoding' => CURLOPT_ENCODING,
44
-        'cookie'          => CURLOPT_COOKIE,
45
-        'referer'         => CURLOPT_REFERER,
46
-        'user-agent'      => CURLOPT_USERAGENT
47
-    );
48
-
49
-    /**
50
-     * Mapping of SSL context options to cURL options
51
-     * @var  array
52
-     */
53
-    protected static $sslContextMap = array(
54
-        'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER,
55
-        'ssl_cafile'      => CURLOPT_CAINFO,
56
-        'ssl_capath'      => CURLOPT_CAPATH,
57
-        'ssl_local_cert'  => CURLOPT_SSLCERT,
58
-        'ssl_passphrase'  => CURLOPT_SSLCERTPASSWD
59
-    );
60
-
61
-    /**
62
-     * Mapping of CURLE_* constants to Exception subclasses and error codes
63
-     * @var  array
64
-     */
65
-    protected static $errorMap = array(
66
-        CURLE_UNSUPPORTED_PROTOCOL  => array('HTTP_Request2_MessageException',
67
-                                             HTTP_Request2_Exception::NON_HTTP_REDIRECT),
68
-        CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'),
69
-        CURLE_COULDNT_RESOLVE_HOST  => array('HTTP_Request2_ConnectionException'),
70
-        CURLE_COULDNT_CONNECT       => array('HTTP_Request2_ConnectionException'),
71
-        // error returned from write callback
72
-        CURLE_WRITE_ERROR           => array('HTTP_Request2_MessageException',
73
-                                             HTTP_Request2_Exception::NON_HTTP_REDIRECT),
74
-        CURLE_OPERATION_TIMEOUTED   => array('HTTP_Request2_MessageException',
75
-                                             HTTP_Request2_Exception::TIMEOUT),
76
-        CURLE_HTTP_RANGE_ERROR      => array('HTTP_Request2_MessageException'),
77
-        CURLE_SSL_CONNECT_ERROR     => array('HTTP_Request2_ConnectionException'),
78
-        CURLE_LIBRARY_NOT_FOUND     => array('HTTP_Request2_LogicException',
79
-                                             HTTP_Request2_Exception::MISCONFIGURATION),
80
-        CURLE_FUNCTION_NOT_FOUND    => array('HTTP_Request2_LogicException',
81
-                                             HTTP_Request2_Exception::MISCONFIGURATION),
82
-        CURLE_ABORTED_BY_CALLBACK   => array('HTTP_Request2_MessageException',
83
-                                             HTTP_Request2_Exception::NON_HTTP_REDIRECT),
84
-        CURLE_TOO_MANY_REDIRECTS    => array('HTTP_Request2_MessageException',
85
-                                             HTTP_Request2_Exception::TOO_MANY_REDIRECTS),
86
-        CURLE_SSL_PEER_CERTIFICATE  => array('HTTP_Request2_ConnectionException'),
87
-        CURLE_GOT_NOTHING           => array('HTTP_Request2_MessageException'),
88
-        CURLE_SSL_ENGINE_NOTFOUND   => array('HTTP_Request2_LogicException',
89
-                                             HTTP_Request2_Exception::MISCONFIGURATION),
90
-        CURLE_SSL_ENGINE_SETFAILED  => array('HTTP_Request2_LogicException',
91
-                                             HTTP_Request2_Exception::MISCONFIGURATION),
92
-        CURLE_SEND_ERROR            => array('HTTP_Request2_MessageException'),
93
-        CURLE_RECV_ERROR            => array('HTTP_Request2_MessageException'),
94
-        CURLE_SSL_CERTPROBLEM       => array('HTTP_Request2_LogicException',
95
-                                             HTTP_Request2_Exception::INVALID_ARGUMENT),
96
-        CURLE_SSL_CIPHER            => array('HTTP_Request2_ConnectionException'),
97
-        CURLE_SSL_CACERT            => array('HTTP_Request2_ConnectionException'),
98
-        CURLE_BAD_CONTENT_ENCODING  => array('HTTP_Request2_MessageException'),
99
-    );
100
-
101
-    /**
102
-     * Response being received
103
-     * @var  HTTP_Request2_Response
104
-     */
105
-    protected $response;
106
-
107
-    /**
108
-     * Whether 'sentHeaders' event was sent to observers
109
-     * @var  boolean
110
-     */
111
-    protected $eventSentHeaders = false;
112
-
113
-    /**
114
-     * Whether 'receivedHeaders' event was sent to observers
115
-     * @var boolean
116
-     */
117
-    protected $eventReceivedHeaders = false;
118
-
119
-    /**
120
-     * Position within request body
121
-     * @var  integer
122
-     * @see  callbackReadBody()
123
-     */
124
-    protected $position = 0;
125
-
126
-    /**
127
-     * Information about last transfer, as returned by curl_getinfo()
128
-     * @var  array
129
-     */
130
-    protected $lastInfo;
131
-
132
-    /**
133
-     * Creates a subclass of HTTP_Request2_Exception from curl error data
134
-     *
135
-     * @param resource $ch curl handle
136
-     *
137
-     * @return HTTP_Request2_Exception
138
-     */
139
-    protected static function wrapCurlError($ch)
140
-    {
141
-        $nativeCode = curl_errno($ch);
142
-        $message    = 'Curl error: ' . curl_error($ch);
143
-        if (!isset(self::$errorMap[$nativeCode])) {
144
-            return new HTTP_Request2_Exception($message, 0, $nativeCode);
145
-        } else {
146
-            $class = self::$errorMap[$nativeCode][0];
147
-            $code  = empty(self::$errorMap[$nativeCode][1])
148
-                     ? 0 : self::$errorMap[$nativeCode][1];
149
-            return new $class($message, $code, $nativeCode);
150
-        }
151
-    }
152
-
153
-    /**
154
-     * Sends request to the remote server and returns its response
155
-     *
156
-     * @param HTTP_Request2 $request HTTP request message
157
-     *
158
-     * @return   HTTP_Request2_Response
159
-     * @throws   HTTP_Request2_Exception
160
-     */
161
-    public function sendRequest(HTTP_Request2 $request)
162
-    {
163
-        if (!extension_loaded('curl')) {
164
-            throw new HTTP_Request2_LogicException(
165
-                'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION
166
-            );
167
-        }
168
-
169
-        $this->request              = $request;
170
-        $this->response             = null;
171
-        $this->position             = 0;
172
-        $this->eventSentHeaders     = false;
173
-        $this->eventReceivedHeaders = false;
174
-
175
-        try {
176
-            if (false === curl_exec($ch = $this->createCurlHandle())) {
177
-                $e = self::wrapCurlError($ch);
178
-            }
179
-        } catch (Exception $e) {
180
-        }
181
-        if (isset($ch)) {
182
-            $this->lastInfo = curl_getinfo($ch);
183
-            curl_close($ch);
184
-        }
185
-
186
-        $response = $this->response;
187
-        unset($this->request, $this->requestBody, $this->response);
188
-
189
-        if (!empty($e)) {
190
-            throw $e;
191
-        }
192
-
193
-        if ($jar = $request->getCookieJar()) {
194
-            $jar->addCookiesFromResponse($response, $request->getUrl());
195
-        }
196
-
197
-        if (0 < $this->lastInfo['size_download']) {
198
-            $request->setLastEvent('receivedBody', $response);
199
-        }
200
-        return $response;
201
-    }
202
-
203
-    /**
204
-     * Returns information about last transfer
205
-     *
206
-     * @return   array   associative array as returned by curl_getinfo()
207
-     */
208
-    public function getInfo()
209
-    {
210
-        return $this->lastInfo;
211
-    }
212
-
213
-    /**
214
-     * Creates a new cURL handle and populates it with data from the request
215
-     *
216
-     * @return   resource    a cURL handle, as created by curl_init()
217
-     * @throws   HTTP_Request2_LogicException
218
-     * @throws   HTTP_Request2_NotImplementedException
219
-     */
220
-    protected function createCurlHandle()
221
-    {
222
-        $ch = curl_init();
223
-
224
-        curl_setopt_array($ch, array(
225
-            // setup write callbacks
226
-            CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'),
227
-            CURLOPT_WRITEFUNCTION  => array($this, 'callbackWriteBody'),
228
-            // buffer size
229
-            CURLOPT_BUFFERSIZE     => $this->request->getConfig('buffer_size'),
230
-            // connection timeout
231
-            CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'),
232
-            // save full outgoing headers, in case someone is interested
233
-            CURLINFO_HEADER_OUT    => true,
234
-            // request url
235
-            CURLOPT_URL            => $this->request->getUrl()->getUrl()
236
-        ));
237
-
238
-        // set up redirects
239
-        if (!$this->request->getConfig('follow_redirects')) {
240
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
241
-        } else {
242
-            if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) {
243
-                throw new HTTP_Request2_LogicException(
244
-                    'Redirect support in curl is unavailable due to open_basedir or safe_mode setting',
245
-                    HTTP_Request2_Exception::MISCONFIGURATION
246
-                );
247
-            }
248
-            curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects'));
249
-            // limit redirects to http(s), works in 5.2.10+
250
-            if (defined('CURLOPT_REDIR_PROTOCOLS')) {
251
-                curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
252
-            }
253
-            // works in 5.3.2+, http://bugs.php.net/bug.php?id=49571
254
-            if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) {
255
-                curl_setopt($ch, CURLOPT_POSTREDIR, 3);
256
-            }
257
-        }
258
-
259
-        // set local IP via CURLOPT_INTERFACE (request #19515)
260
-        if ($ip = $this->request->getConfig('local_ip')) {
261
-            curl_setopt($ch, CURLOPT_INTERFACE, $ip);
262
-        }
263
-
264
-        // request timeout
265
-        if ($timeout = $this->request->getConfig('timeout')) {
266
-            curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
267
-        }
268
-
269
-        // set HTTP version
270
-        switch ($this->request->getConfig('protocol_version')) {
271
-        case '1.0':
272
-            curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
273
-            break;
274
-        case '1.1':
275
-            curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
276
-        }
277
-
278
-        // set request method
279
-        switch ($this->request->getMethod()) {
280
-        case HTTP_Request2::METHOD_GET:
281
-            curl_setopt($ch, CURLOPT_HTTPGET, true);
282
-            break;
283
-        case HTTP_Request2::METHOD_POST:
284
-            curl_setopt($ch, CURLOPT_POST, true);
285
-            break;
286
-        case HTTP_Request2::METHOD_HEAD:
287
-            curl_setopt($ch, CURLOPT_NOBODY, true);
288
-            break;
289
-        case HTTP_Request2::METHOD_PUT:
290
-            curl_setopt($ch, CURLOPT_UPLOAD, true);
291
-            break;
292
-        default:
293
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod());
294
-        }
295
-
296
-        // set proxy, if needed
297
-        if ($host = $this->request->getConfig('proxy_host')) {
298
-            if (!($port = $this->request->getConfig('proxy_port'))) {
299
-                throw new HTTP_Request2_LogicException(
300
-                    'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE
301
-                );
302
-            }
303
-            curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port);
304
-            if ($user = $this->request->getConfig('proxy_user')) {
305
-                curl_setopt(
306
-                    $ch, CURLOPT_PROXYUSERPWD,
307
-                    $user . ':' . $this->request->getConfig('proxy_password')
308
-                );
309
-                switch ($this->request->getConfig('proxy_auth_scheme')) {
310
-                case HTTP_Request2::AUTH_BASIC:
311
-                    curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
312
-                    break;
313
-                case HTTP_Request2::AUTH_DIGEST:
314
-                    curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
315
-                }
316
-            }
317
-            if ($type = $this->request->getConfig('proxy_type')) {
318
-                switch ($type) {
319
-                case 'http':
320
-                    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
321
-                    break;
322
-                case 'socks5':
323
-                    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
324
-                    break;
325
-                default:
326
-                    throw new HTTP_Request2_NotImplementedException(
327
-                        "Proxy type '{$type}' is not supported"
328
-                    );
329
-                }
330
-            }
331
-        }
332
-
333
-        // set authentication data
334
-        if ($auth = $this->request->getAuth()) {
335
-            curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']);
336
-            switch ($auth['scheme']) {
337
-            case HTTP_Request2::AUTH_BASIC:
338
-                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
339
-                break;
340
-            case HTTP_Request2::AUTH_DIGEST:
341
-                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
342
-            }
343
-        }
344
-
345
-        // set SSL options
346
-        foreach ($this->request->getConfig() as $name => $value) {
347
-            if ('ssl_verify_host' == $name && null !== $value) {
348
-                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0);
349
-            } elseif (isset(self::$sslContextMap[$name]) && null !== $value) {
350
-                curl_setopt($ch, self::$sslContextMap[$name], $value);
351
-            }
352
-        }
353
-
354
-        $headers = $this->request->getHeaders();
355
-        // make cURL automagically send proper header
356
-        if (!isset($headers['accept-encoding'])) {
357
-            $headers['accept-encoding'] = '';
358
-        }
359
-
360
-        if (($jar = $this->request->getCookieJar())
361
-            && ($cookies = $jar->getMatching($this->request->getUrl(), true))
362
-        ) {
363
-            $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies;
364
-        }
365
-
366
-        // set headers having special cURL keys
367
-        foreach (self::$headerMap as $name => $option) {
368
-            if (isset($headers[$name])) {
369
-                curl_setopt($ch, $option, $headers[$name]);
370
-                unset($headers[$name]);
371
-            }
372
-        }
373
-
374
-        $this->calculateRequestLength($headers);
375
-        if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) {
376
-            $this->workaroundPhpBug47204($ch, $headers);
377
-        }
378
-
379
-        // set headers not having special keys
380
-        $headersFmt = array();
381
-        foreach ($headers as $name => $value) {
382
-            $canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
383
-            $headersFmt[]  = $canonicalName . ': ' . $value;
384
-        }
385
-        curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt);
386
-
387
-        return $ch;
388
-    }
389
-
390
-    /**
391
-     * Workaround for PHP bug #47204 that prevents rewinding request body
392
-     *
393
-     * The workaround consists of reading the entire request body into memory
394
-     * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large
395
-     * file uploads, use Socket adapter instead.
396
-     *
397
-     * @param resource $ch       cURL handle
398
-     * @param array    &$headers Request headers
399
-     */
400
-    protected function workaroundPhpBug47204($ch, &$headers)
401
-    {
402
-        // no redirects, no digest auth -> probably no rewind needed
403
-        if (!$this->request->getConfig('follow_redirects')
404
-            && (!($auth = $this->request->getAuth())
405
-                || HTTP_Request2::AUTH_DIGEST != $auth['scheme'])
406
-        ) {
407
-            curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody'));
408
-
409
-        } else {
410
-            // rewind may be needed, read the whole body into memory
411
-            if ($this->requestBody instanceof HTTP_Request2_MultipartBody) {
412
-                $this->requestBody = $this->requestBody->__toString();
413
-
414
-            } elseif (is_resource($this->requestBody)) {
415
-                $fp = $this->requestBody;
416
-                $this->requestBody = '';
417
-                while (!feof($fp)) {
418
-                    $this->requestBody .= fread($fp, 16384);
419
-                }
420
-            }
421
-            // curl hangs up if content-length is present
422
-            unset($headers['content-length']);
423
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody);
424
-        }
425
-    }
426
-
427
-    /**
428
-     * Callback function called by cURL for reading the request body
429
-     *
430
-     * @param resource $ch     cURL handle
431
-     * @param resource $fd     file descriptor (not used)
432
-     * @param integer  $length maximum length of data to return
433
-     *
434
-     * @return   string      part of the request body, up to $length bytes
435
-     */
436
-    protected function callbackReadBody($ch, $fd, $length)
437
-    {
438
-        if (!$this->eventSentHeaders) {
439
-            $this->request->setLastEvent(
440
-                'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT)
441
-            );
442
-            $this->eventSentHeaders = true;
443
-        }
444
-        if (in_array($this->request->getMethod(), self::$bodyDisallowed)
445
-            || 0 == $this->contentLength || $this->position >= $this->contentLength
446
-        ) {
447
-            return '';
448
-        }
449
-        if (is_string($this->requestBody)) {
450
-            $string = substr($this->requestBody, $this->position, $length);
451
-        } elseif (is_resource($this->requestBody)) {
452
-            $string = fread($this->requestBody, $length);
453
-        } else {
454
-            $string = $this->requestBody->read($length);
455
-        }
456
-        $this->request->setLastEvent('sentBodyPart', strlen($string));
457
-        $this->position += strlen($string);
458
-        return $string;
459
-    }
460
-
461
-    /**
462
-     * Callback function called by cURL for saving the response headers
463
-     *
464
-     * @param resource $ch     cURL handle
465
-     * @param string   $string response header (with trailing CRLF)
466
-     *
467
-     * @return   integer     number of bytes saved
468
-     * @see      HTTP_Request2_Response::parseHeaderLine()
469
-     */
470
-    protected function callbackWriteHeader($ch, $string)
471
-    {
472
-        // we may receive a second set of headers if doing e.g. digest auth
473
-        if ($this->eventReceivedHeaders || !$this->eventSentHeaders) {
474
-            // don't bother with 100-Continue responses (bug #15785)
475
-            if (!$this->eventSentHeaders
476
-                || $this->response->getStatus() >= 200
477
-            ) {
478
-                $this->request->setLastEvent(
479
-                    'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT)
480
-                );
481
-            }
482
-            $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD);
483
-            // if body wasn't read by a callback, send event with total body size
484
-            if ($upload > $this->position) {
485
-                $this->request->setLastEvent(
486
-                    'sentBodyPart', $upload - $this->position
487
-                );
488
-                $this->position = $upload;
489
-            }
490
-            if ($upload && (!$this->eventSentHeaders
491
-                            || $this->response->getStatus() >= 200)
492
-            ) {
493
-                $this->request->setLastEvent('sentBody', $upload);
494
-            }
495
-            $this->eventSentHeaders = true;
496
-            // we'll need a new response object
497
-            if ($this->eventReceivedHeaders) {
498
-                $this->eventReceivedHeaders = false;
499
-                $this->response             = null;
500
-            }
501
-        }
502
-        if (empty($this->response)) {
503
-            $this->response = new HTTP_Request2_Response(
504
-                $string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)
505
-            );
506
-        } else {
507
-            $this->response->parseHeaderLine($string);
508
-            if ('' == trim($string)) {
509
-                // don't bother with 100-Continue responses (bug #15785)
510
-                if (200 <= $this->response->getStatus()) {
511
-                    $this->request->setLastEvent('receivedHeaders', $this->response);
512
-                }
513
-
514
-                if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) {
515
-                    $redirectUrl = new Net_URL2($this->response->getHeader('location'));
516
-
517
-                    // for versions lower than 5.2.10, check the redirection URL protocol
518
-                    if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute()
519
-                        && !in_array($redirectUrl->getScheme(), array('http', 'https'))
520
-                    ) {
521
-                        return -1;
522
-                    }
523
-
524
-                    if ($jar = $this->request->getCookieJar()) {
525
-                        $jar->addCookiesFromResponse($this->response, $this->request->getUrl());
526
-                        if (!$redirectUrl->isAbsolute()) {
527
-                            $redirectUrl = $this->request->getUrl()->resolve($redirectUrl);
528
-                        }
529
-                        if ($cookies = $jar->getMatching($redirectUrl, true)) {
530
-                            curl_setopt($ch, CURLOPT_COOKIE, $cookies);
531
-                        }
532
-                    }
533
-                }
534
-                $this->eventReceivedHeaders = true;
535
-            }
536
-        }
537
-        return strlen($string);
538
-    }
539
-
540
-    /**
541
-     * Callback function called by cURL for saving the response body
542
-     *
543
-     * @param resource $ch     cURL handle (not used)
544
-     * @param string   $string part of the response body
545
-     *
546
-     * @return   integer     number of bytes saved
547
-     * @throws   HTTP_Request2_MessageException
548
-     * @see      HTTP_Request2_Response::appendBody()
549
-     */
550
-    protected function callbackWriteBody($ch, $string)
551
-    {
552
-        // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if
553
-        // response doesn't start with proper HTTP status line (see bug #15716)
554
-        if (empty($this->response)) {
555
-            throw new HTTP_Request2_MessageException(
556
-                "Malformed response: {$string}",
557
-                HTTP_Request2_Exception::MALFORMED_RESPONSE
558
-            );
559
-        }
560
-        if ($this->request->getConfig('store_body')) {
561
-            $this->response->appendBody($string);
562
-        }
563
-        $this->request->setLastEvent('receivedBodyPart', $string);
564
-        return strlen($string);
565
-    }
38
+	/**
39
+	 * Mapping of header names to cURL options
40
+	 * @var  array
41
+	 */
42
+	protected static $headerMap = array(
43
+		'accept-encoding' => CURLOPT_ENCODING,
44
+		'cookie'          => CURLOPT_COOKIE,
45
+		'referer'         => CURLOPT_REFERER,
46
+		'user-agent'      => CURLOPT_USERAGENT
47
+	);
48
+
49
+	/**
50
+	 * Mapping of SSL context options to cURL options
51
+	 * @var  array
52
+	 */
53
+	protected static $sslContextMap = array(
54
+		'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER,
55
+		'ssl_cafile'      => CURLOPT_CAINFO,
56
+		'ssl_capath'      => CURLOPT_CAPATH,
57
+		'ssl_local_cert'  => CURLOPT_SSLCERT,
58
+		'ssl_passphrase'  => CURLOPT_SSLCERTPASSWD
59
+	);
60
+
61
+	/**
62
+	 * Mapping of CURLE_* constants to Exception subclasses and error codes
63
+	 * @var  array
64
+	 */
65
+	protected static $errorMap = array(
66
+		CURLE_UNSUPPORTED_PROTOCOL  => array('HTTP_Request2_MessageException',
67
+											 HTTP_Request2_Exception::NON_HTTP_REDIRECT),
68
+		CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'),
69
+		CURLE_COULDNT_RESOLVE_HOST  => array('HTTP_Request2_ConnectionException'),
70
+		CURLE_COULDNT_CONNECT       => array('HTTP_Request2_ConnectionException'),
71
+		// error returned from write callback
72
+		CURLE_WRITE_ERROR           => array('HTTP_Request2_MessageException',
73
+											 HTTP_Request2_Exception::NON_HTTP_REDIRECT),
74
+		CURLE_OPERATION_TIMEOUTED   => array('HTTP_Request2_MessageException',
75
+											 HTTP_Request2_Exception::TIMEOUT),
76
+		CURLE_HTTP_RANGE_ERROR      => array('HTTP_Request2_MessageException'),
77
+		CURLE_SSL_CONNECT_ERROR     => array('HTTP_Request2_ConnectionException'),
78
+		CURLE_LIBRARY_NOT_FOUND     => array('HTTP_Request2_LogicException',
79
+											 HTTP_Request2_Exception::MISCONFIGURATION),
80
+		CURLE_FUNCTION_NOT_FOUND    => array('HTTP_Request2_LogicException',
81
+											 HTTP_Request2_Exception::MISCONFIGURATION),
82
+		CURLE_ABORTED_BY_CALLBACK   => array('HTTP_Request2_MessageException',
83
+											 HTTP_Request2_Exception::NON_HTTP_REDIRECT),
84
+		CURLE_TOO_MANY_REDIRECTS    => array('HTTP_Request2_MessageException',
85
+											 HTTP_Request2_Exception::TOO_MANY_REDIRECTS),
86
+		CURLE_SSL_PEER_CERTIFICATE  => array('HTTP_Request2_ConnectionException'),
87
+		CURLE_GOT_NOTHING           => array('HTTP_Request2_MessageException'),
88
+		CURLE_SSL_ENGINE_NOTFOUND   => array('HTTP_Request2_LogicException',
89
+											 HTTP_Request2_Exception::MISCONFIGURATION),
90
+		CURLE_SSL_ENGINE_SETFAILED  => array('HTTP_Request2_LogicException',
91
+											 HTTP_Request2_Exception::MISCONFIGURATION),
92
+		CURLE_SEND_ERROR            => array('HTTP_Request2_MessageException'),
93
+		CURLE_RECV_ERROR            => array('HTTP_Request2_MessageException'),
94
+		CURLE_SSL_CERTPROBLEM       => array('HTTP_Request2_LogicException',
95
+											 HTTP_Request2_Exception::INVALID_ARGUMENT),
96
+		CURLE_SSL_CIPHER            => array('HTTP_Request2_ConnectionException'),
97
+		CURLE_SSL_CACERT            => array('HTTP_Request2_ConnectionException'),
98
+		CURLE_BAD_CONTENT_ENCODING  => array('HTTP_Request2_MessageException'),
99
+	);
100
+
101
+	/**
102
+	 * Response being received
103
+	 * @var  HTTP_Request2_Response
104
+	 */
105
+	protected $response;
106
+
107
+	/**
108
+	 * Whether 'sentHeaders' event was sent to observers
109
+	 * @var  boolean
110
+	 */
111
+	protected $eventSentHeaders = false;
112
+
113
+	/**
114
+	 * Whether 'receivedHeaders' event was sent to observers
115
+	 * @var boolean
116
+	 */
117
+	protected $eventReceivedHeaders = false;
118
+
119
+	/**
120
+	 * Position within request body
121
+	 * @var  integer
122
+	 * @see  callbackReadBody()
123
+	 */
124
+	protected $position = 0;
125
+
126
+	/**
127
+	 * Information about last transfer, as returned by curl_getinfo()
128
+	 * @var  array
129
+	 */
130
+	protected $lastInfo;
131
+
132
+	/**
133
+	 * Creates a subclass of HTTP_Request2_Exception from curl error data
134
+	 *
135
+	 * @param resource $ch curl handle
136
+	 *
137
+	 * @return HTTP_Request2_Exception
138
+	 */
139
+	protected static function wrapCurlError($ch)
140
+	{
141
+		$nativeCode = curl_errno($ch);
142
+		$message    = 'Curl error: ' . curl_error($ch);
143
+		if (!isset(self::$errorMap[$nativeCode])) {
144
+			return new HTTP_Request2_Exception($message, 0, $nativeCode);
145
+		} else {
146
+			$class = self::$errorMap[$nativeCode][0];
147
+			$code  = empty(self::$errorMap[$nativeCode][1])
148
+					 ? 0 : self::$errorMap[$nativeCode][1];
149
+			return new $class($message, $code, $nativeCode);
150
+		}
151
+	}
152
+
153
+	/**
154
+	 * Sends request to the remote server and returns its response
155
+	 *
156
+	 * @param HTTP_Request2 $request HTTP request message
157
+	 *
158
+	 * @return   HTTP_Request2_Response
159
+	 * @throws   HTTP_Request2_Exception
160
+	 */
161
+	public function sendRequest(HTTP_Request2 $request)
162
+	{
163
+		if (!extension_loaded('curl')) {
164
+			throw new HTTP_Request2_LogicException(
165
+				'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION
166
+			);
167
+		}
168
+
169
+		$this->request              = $request;
170
+		$this->response             = null;
171
+		$this->position             = 0;
172
+		$this->eventSentHeaders     = false;
173
+		$this->eventReceivedHeaders = false;
174
+
175
+		try {
176
+			if (false === curl_exec($ch = $this->createCurlHandle())) {
177
+				$e = self::wrapCurlError($ch);
178
+			}
179
+		} catch (Exception $e) {
180
+		}
181
+		if (isset($ch)) {
182
+			$this->lastInfo = curl_getinfo($ch);
183
+			curl_close($ch);
184
+		}
185
+
186
+		$response = $this->response;
187
+		unset($this->request, $this->requestBody, $this->response);
188
+
189
+		if (!empty($e)) {
190
+			throw $e;
191
+		}
192
+
193
+		if ($jar = $request->getCookieJar()) {
194
+			$jar->addCookiesFromResponse($response, $request->getUrl());
195
+		}
196
+
197
+		if (0 < $this->lastInfo['size_download']) {
198
+			$request->setLastEvent('receivedBody', $response);
199
+		}
200
+		return $response;
201
+	}
202
+
203
+	/**
204
+	 * Returns information about last transfer
205
+	 *
206
+	 * @return   array   associative array as returned by curl_getinfo()
207
+	 */
208
+	public function getInfo()
209
+	{
210
+		return $this->lastInfo;
211
+	}
212
+
213
+	/**
214
+	 * Creates a new cURL handle and populates it with data from the request
215
+	 *
216
+	 * @return   resource    a cURL handle, as created by curl_init()
217
+	 * @throws   HTTP_Request2_LogicException
218
+	 * @throws   HTTP_Request2_NotImplementedException
219
+	 */
220
+	protected function createCurlHandle()
221
+	{
222
+		$ch = curl_init();
223
+
224
+		curl_setopt_array($ch, array(
225
+			// setup write callbacks
226
+			CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'),
227
+			CURLOPT_WRITEFUNCTION  => array($this, 'callbackWriteBody'),
228
+			// buffer size
229
+			CURLOPT_BUFFERSIZE     => $this->request->getConfig('buffer_size'),
230
+			// connection timeout
231
+			CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'),
232
+			// save full outgoing headers, in case someone is interested
233
+			CURLINFO_HEADER_OUT    => true,
234
+			// request url
235
+			CURLOPT_URL            => $this->request->getUrl()->getUrl()
236
+		));
237
+
238
+		// set up redirects
239
+		if (!$this->request->getConfig('follow_redirects')) {
240
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
241
+		} else {
242
+			if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) {
243
+				throw new HTTP_Request2_LogicException(
244
+					'Redirect support in curl is unavailable due to open_basedir or safe_mode setting',
245
+					HTTP_Request2_Exception::MISCONFIGURATION
246
+				);
247
+			}
248
+			curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects'));
249
+			// limit redirects to http(s), works in 5.2.10+
250
+			if (defined('CURLOPT_REDIR_PROTOCOLS')) {
251
+				curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
252
+			}
253
+			// works in 5.3.2+, http://bugs.php.net/bug.php?id=49571
254
+			if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) {
255
+				curl_setopt($ch, CURLOPT_POSTREDIR, 3);
256
+			}
257
+		}
258
+
259
+		// set local IP via CURLOPT_INTERFACE (request #19515)
260
+		if ($ip = $this->request->getConfig('local_ip')) {
261
+			curl_setopt($ch, CURLOPT_INTERFACE, $ip);
262
+		}
263
+
264
+		// request timeout
265
+		if ($timeout = $this->request->getConfig('timeout')) {
266
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
267
+		}
268
+
269
+		// set HTTP version
270
+		switch ($this->request->getConfig('protocol_version')) {
271
+		case '1.0':
272
+			curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
273
+			break;
274
+		case '1.1':
275
+			curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
276
+		}
277
+
278
+		// set request method
279
+		switch ($this->request->getMethod()) {
280
+		case HTTP_Request2::METHOD_GET:
281
+			curl_setopt($ch, CURLOPT_HTTPGET, true);
282
+			break;
283
+		case HTTP_Request2::METHOD_POST:
284
+			curl_setopt($ch, CURLOPT_POST, true);
285
+			break;
286
+		case HTTP_Request2::METHOD_HEAD:
287
+			curl_setopt($ch, CURLOPT_NOBODY, true);
288
+			break;
289
+		case HTTP_Request2::METHOD_PUT:
290
+			curl_setopt($ch, CURLOPT_UPLOAD, true);
291
+			break;
292
+		default:
293
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod());
294
+		}
295
+
296
+		// set proxy, if needed
297
+		if ($host = $this->request->getConfig('proxy_host')) {
298
+			if (!($port = $this->request->getConfig('proxy_port'))) {
299
+				throw new HTTP_Request2_LogicException(
300
+					'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE
301
+				);
302
+			}
303
+			curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port);
304
+			if ($user = $this->request->getConfig('proxy_user')) {
305
+				curl_setopt(
306
+					$ch, CURLOPT_PROXYUSERPWD,
307
+					$user . ':' . $this->request->getConfig('proxy_password')
308
+				);
309
+				switch ($this->request->getConfig('proxy_auth_scheme')) {
310
+				case HTTP_Request2::AUTH_BASIC:
311
+					curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
312
+					break;
313
+				case HTTP_Request2::AUTH_DIGEST:
314
+					curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
315
+				}
316
+			}
317
+			if ($type = $this->request->getConfig('proxy_type')) {
318
+				switch ($type) {
319
+				case 'http':
320
+					curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
321
+					break;
322
+				case 'socks5':
323
+					curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
324
+					break;
325
+				default:
326
+					throw new HTTP_Request2_NotImplementedException(
327
+						"Proxy type '{$type}' is not supported"
328
+					);
329
+				}
330
+			}
331
+		}
332
+
333
+		// set authentication data
334
+		if ($auth = $this->request->getAuth()) {
335
+			curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']);
336
+			switch ($auth['scheme']) {
337
+			case HTTP_Request2::AUTH_BASIC:
338
+				curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
339
+				break;
340
+			case HTTP_Request2::AUTH_DIGEST:
341
+				curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
342
+			}
343
+		}
344
+
345
+		// set SSL options
346
+		foreach ($this->request->getConfig() as $name => $value) {
347
+			if ('ssl_verify_host' == $name && null !== $value) {
348
+				curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0);
349
+			} elseif (isset(self::$sslContextMap[$name]) && null !== $value) {
350
+				curl_setopt($ch, self::$sslContextMap[$name], $value);
351
+			}
352
+		}
353
+
354
+		$headers = $this->request->getHeaders();
355
+		// make cURL automagically send proper header
356
+		if (!isset($headers['accept-encoding'])) {
357
+			$headers['accept-encoding'] = '';
358
+		}
359
+
360
+		if (($jar = $this->request->getCookieJar())
361
+			&& ($cookies = $jar->getMatching($this->request->getUrl(), true))
362
+		) {
363
+			$headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies;
364
+		}
365
+
366
+		// set headers having special cURL keys
367
+		foreach (self::$headerMap as $name => $option) {
368
+			if (isset($headers[$name])) {
369
+				curl_setopt($ch, $option, $headers[$name]);
370
+				unset($headers[$name]);
371
+			}
372
+		}
373
+
374
+		$this->calculateRequestLength($headers);
375
+		if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) {
376
+			$this->workaroundPhpBug47204($ch, $headers);
377
+		}
378
+
379
+		// set headers not having special keys
380
+		$headersFmt = array();
381
+		foreach ($headers as $name => $value) {
382
+			$canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
383
+			$headersFmt[]  = $canonicalName . ': ' . $value;
384
+		}
385
+		curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt);
386
+
387
+		return $ch;
388
+	}
389
+
390
+	/**
391
+	 * Workaround for PHP bug #47204 that prevents rewinding request body
392
+	 *
393
+	 * The workaround consists of reading the entire request body into memory
394
+	 * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large
395
+	 * file uploads, use Socket adapter instead.
396
+	 *
397
+	 * @param resource $ch       cURL handle
398
+	 * @param array    &$headers Request headers
399
+	 */
400
+	protected function workaroundPhpBug47204($ch, &$headers)
401
+	{
402
+		// no redirects, no digest auth -> probably no rewind needed
403
+		if (!$this->request->getConfig('follow_redirects')
404
+			&& (!($auth = $this->request->getAuth())
405
+				|| HTTP_Request2::AUTH_DIGEST != $auth['scheme'])
406
+		) {
407
+			curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody'));
408
+
409
+		} else {
410
+			// rewind may be needed, read the whole body into memory
411
+			if ($this->requestBody instanceof HTTP_Request2_MultipartBody) {
412
+				$this->requestBody = $this->requestBody->__toString();
413
+
414
+			} elseif (is_resource($this->requestBody)) {
415
+				$fp = $this->requestBody;
416
+				$this->requestBody = '';
417
+				while (!feof($fp)) {
418
+					$this->requestBody .= fread($fp, 16384);
419
+				}
420
+			}
421
+			// curl hangs up if content-length is present
422
+			unset($headers['content-length']);
423
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody);
424
+		}
425
+	}
426
+
427
+	/**
428
+	 * Callback function called by cURL for reading the request body
429
+	 *
430
+	 * @param resource $ch     cURL handle
431
+	 * @param resource $fd     file descriptor (not used)
432
+	 * @param integer  $length maximum length of data to return
433
+	 *
434
+	 * @return   string      part of the request body, up to $length bytes
435
+	 */
436
+	protected function callbackReadBody($ch, $fd, $length)
437
+	{
438
+		if (!$this->eventSentHeaders) {
439
+			$this->request->setLastEvent(
440
+				'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT)
441
+			);
442
+			$this->eventSentHeaders = true;
443
+		}
444
+		if (in_array($this->request->getMethod(), self::$bodyDisallowed)
445
+			|| 0 == $this->contentLength || $this->position >= $this->contentLength
446
+		) {
447
+			return '';
448
+		}
449
+		if (is_string($this->requestBody)) {
450
+			$string = substr($this->requestBody, $this->position, $length);
451
+		} elseif (is_resource($this->requestBody)) {
452
+			$string = fread($this->requestBody, $length);
453
+		} else {
454
+			$string = $this->requestBody->read($length);
455
+		}
456
+		$this->request->setLastEvent('sentBodyPart', strlen($string));
457
+		$this->position += strlen($string);
458
+		return $string;
459
+	}
460
+
461
+	/**
462
+	 * Callback function called by cURL for saving the response headers
463
+	 *
464
+	 * @param resource $ch     cURL handle
465
+	 * @param string   $string response header (with trailing CRLF)
466
+	 *
467
+	 * @return   integer     number of bytes saved
468
+	 * @see      HTTP_Request2_Response::parseHeaderLine()
469
+	 */
470
+	protected function callbackWriteHeader($ch, $string)
471
+	{
472
+		// we may receive a second set of headers if doing e.g. digest auth
473
+		if ($this->eventReceivedHeaders || !$this->eventSentHeaders) {
474
+			// don't bother with 100-Continue responses (bug #15785)
475
+			if (!$this->eventSentHeaders
476
+				|| $this->response->getStatus() >= 200
477
+			) {
478
+				$this->request->setLastEvent(
479
+					'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT)
480
+				);
481
+			}
482
+			$upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD);
483
+			// if body wasn't read by a callback, send event with total body size
484
+			if ($upload > $this->position) {
485
+				$this->request->setLastEvent(
486
+					'sentBodyPart', $upload - $this->position
487
+				);
488
+				$this->position = $upload;
489
+			}
490
+			if ($upload && (!$this->eventSentHeaders
491
+							|| $this->response->getStatus() >= 200)
492
+			) {
493
+				$this->request->setLastEvent('sentBody', $upload);
494
+			}
495
+			$this->eventSentHeaders = true;
496
+			// we'll need a new response object
497
+			if ($this->eventReceivedHeaders) {
498
+				$this->eventReceivedHeaders = false;
499
+				$this->response             = null;
500
+			}
501
+		}
502
+		if (empty($this->response)) {
503
+			$this->response = new HTTP_Request2_Response(
504
+				$string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)
505
+			);
506
+		} else {
507
+			$this->response->parseHeaderLine($string);
508
+			if ('' == trim($string)) {
509
+				// don't bother with 100-Continue responses (bug #15785)
510
+				if (200 <= $this->response->getStatus()) {
511
+					$this->request->setLastEvent('receivedHeaders', $this->response);
512
+				}
513
+
514
+				if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) {
515
+					$redirectUrl = new Net_URL2($this->response->getHeader('location'));
516
+
517
+					// for versions lower than 5.2.10, check the redirection URL protocol
518
+					if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute()
519
+						&& !in_array($redirectUrl->getScheme(), array('http', 'https'))
520
+					) {
521
+						return -1;
522
+					}
523
+
524
+					if ($jar = $this->request->getCookieJar()) {
525
+						$jar->addCookiesFromResponse($this->response, $this->request->getUrl());
526
+						if (!$redirectUrl->isAbsolute()) {
527
+							$redirectUrl = $this->request->getUrl()->resolve($redirectUrl);
528
+						}
529
+						if ($cookies = $jar->getMatching($redirectUrl, true)) {
530
+							curl_setopt($ch, CURLOPT_COOKIE, $cookies);
531
+						}
532
+					}
533
+				}
534
+				$this->eventReceivedHeaders = true;
535
+			}
536
+		}
537
+		return strlen($string);
538
+	}
539
+
540
+	/**
541
+	 * Callback function called by cURL for saving the response body
542
+	 *
543
+	 * @param resource $ch     cURL handle (not used)
544
+	 * @param string   $string part of the response body
545
+	 *
546
+	 * @return   integer     number of bytes saved
547
+	 * @throws   HTTP_Request2_MessageException
548
+	 * @see      HTTP_Request2_Response::appendBody()
549
+	 */
550
+	protected function callbackWriteBody($ch, $string)
551
+	{
552
+		// cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if
553
+		// response doesn't start with proper HTTP status line (see bug #15716)
554
+		if (empty($this->response)) {
555
+			throw new HTTP_Request2_MessageException(
556
+				"Malformed response: {$string}",
557
+				HTTP_Request2_Exception::MALFORMED_RESPONSE
558
+			);
559
+		}
560
+		if ($this->request->getConfig('store_body')) {
561
+			$this->response->appendBody($string);
562
+		}
563
+		$this->request->setLastEvent('receivedBodyPart', $string);
564
+		return strlen($string);
565
+	}
566 566
 }
567 567
 ?>
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     protected static function wrapCurlError($ch)
140 140
     {
141 141
         $nativeCode = curl_errno($ch);
142
-        $message    = 'Curl error: ' . curl_error($ch);
142
+        $message    = 'Curl error: '.curl_error($ch);
143 143
         if (!isset(self::$errorMap[$nativeCode])) {
144 144
             return new HTTP_Request2_Exception($message, 0, $nativeCode);
145 145
         } else {
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
                     'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE
301 301
                 );
302 302
             }
303
-            curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port);
303
+            curl_setopt($ch, CURLOPT_PROXY, $host.':'.$port);
304 304
             if ($user = $this->request->getConfig('proxy_user')) {
305 305
                 curl_setopt(
306 306
                     $ch, CURLOPT_PROXYUSERPWD,
307
-                    $user . ':' . $this->request->getConfig('proxy_password')
307
+                    $user.':'.$this->request->getConfig('proxy_password')
308 308
                 );
309 309
                 switch ($this->request->getConfig('proxy_auth_scheme')) {
310 310
                 case HTTP_Request2::AUTH_BASIC:
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
         // set authentication data
334 334
         if ($auth = $this->request->getAuth()) {
335
-            curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']);
335
+            curl_setopt($ch, CURLOPT_USERPWD, $auth['user'].':'.$auth['password']);
336 336
             switch ($auth['scheme']) {
337 337
             case HTTP_Request2::AUTH_BASIC:
338 338
                 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         // set SSL options
346 346
         foreach ($this->request->getConfig() as $name => $value) {
347 347
             if ('ssl_verify_host' == $name && null !== $value) {
348
-                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0);
348
+                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value ? 2 : 0);
349 349
             } elseif (isset(self::$sslContextMap[$name]) && null !== $value) {
350 350
                 curl_setopt($ch, self::$sslContextMap[$name], $value);
351 351
             }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
         if (($jar = $this->request->getCookieJar())
361 361
             && ($cookies = $jar->getMatching($this->request->getUrl(), true))
362 362
         ) {
363
-            $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies;
363
+            $headers['cookie'] = (empty($headers['cookie']) ? '' : $headers['cookie'].'; ').$cookies;
364 364
         }
365 365
 
366 366
         // set headers having special cURL keys
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
         $headersFmt = array();
381 381
         foreach ($headers as $name => $value) {
382 382
             $canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
383
-            $headersFmt[]  = $canonicalName . ': ' . $value;
383
+            $headersFmt[]  = $canonicalName.': '.$value;
384 384
         }
385 385
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt);
386 386
 
Please login to merge, or discard this patch.