@@ -51,14 +51,14 @@ class Socket implements HttpAdapter, StreamInterface
5151 *
5252 * @var array
5353 */
54- protected $ connected_to = array (null , null );
54+ protected $ connectedTo = array (null , null );
5555
5656 /**
5757 * Stream for storing output
5858 *
5959 * @var resource
6060 */
61- protected $ out_stream = null ;
61+ protected $ outStream = null ;
6262
6363 /**
6464 * Parameters array
@@ -189,11 +189,11 @@ public function getStreamContext()
189189 public function connect ($ host , $ port = 80 , $ secure = false )
190190 {
191191 // If we are connected to the wrong host, disconnect first
192- $ connected_host = (strpos ($ this ->connected_to [0 ], ':// ' ))
193- ? substr ($ this ->connected_to [0 ], (strpos ($ this ->connected_to [0 ], ':// ' ) + 3 ), strlen ($ this ->connected_to [0 ]))
194- : $ this ->connected_to [0 ];
192+ $ connectedHost = (strpos ($ this ->connectedTo [0 ], ':// ' ))
193+ ? substr ($ this ->connectedTo [0 ], (strpos ($ this ->connectedTo [0 ], ':// ' ) + 3 ), strlen ($ this ->connectedTo [0 ]))
194+ : $ this ->connectedTo [0 ];
195195
196- if ($ connected_host != $ host || $ this ->connected_to [1 ] != $ port ) {
196+ if ($ connectedHost != $ host || $ this ->connectedTo [1 ] != $ port ) {
197197 if (is_resource ($ this ->socket )) {
198198 $ this ->close ();
199199 }
@@ -313,8 +313,8 @@ public function connect($host, $port = 80, $secure = false)
313313 $ host = 'tcp:// ' . $ host ;
314314 }
315315
316- // Update connected_to
317- $ this ->connected_to = array ($ host , $ port );
316+ // Update connectedTo
317+ $ this ->connectedTo = array ($ host , $ port );
318318 }
319319 }
320320
@@ -324,13 +324,13 @@ public function connect($host, $port = 80, $secure = false)
324324 *
325325 * @param string $method
326326 * @param \Zend\Uri\Uri $uri
327- * @param string $http_ver
327+ * @param string $httpVer
328328 * @param array $headers
329329 * @param string $body
330330 * @throws AdapterException\RuntimeException
331331 * @return string Request as string
332332 */
333- public function write ($ method , $ uri , $ http_ver = '1.1 ' , $ headers = array (), $ body = '' )
333+ public function write ($ method , $ uri , $ httpVer = '1.1 ' , $ headers = array (), $ body = '' )
334334 {
335335 // Make sure we're properly connected
336336 if (! $ this ->socket ) {
@@ -339,7 +339,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
339339
340340 $ host = $ uri ->getHost ();
341341 $ host = (strtolower ($ uri ->getScheme ()) == 'https ' ? $ this ->config ['ssltransport ' ] : 'tcp ' ) . ':// ' . $ host ;
342- if ($ this ->connected_to [0 ] != $ host || $ this ->connected_to [1 ] != $ uri ->getPort ()) {
342+ if ($ this ->connectedTo [0 ] != $ host || $ this ->connectedTo [1 ] != $ uri ->getPort ()) {
343343 throw new AdapterException \RuntimeException ('Trying to write but we are connected to the wrong host ' );
344344 }
345345
@@ -349,7 +349,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
349349 // Build request headers
350350 $ path = $ uri ->getPath ();
351351 if ($ uri ->getQuery ()) $ path .= '? ' . $ uri ->getQuery ();
352- $ request = "{$ method } {$ path } HTTP/ {$ http_ver }\r\n" ;
352+ $ request = "{$ method } {$ path } HTTP/ {$ httpVer }\r\n" ;
353353 foreach ($ headers as $ k => $ v ) {
354354 if (is_string ($ k )) $ v = ucfirst ($ k ) . ": $ v " ;
355355 $ request .= "$ v \r\n" ;
@@ -427,11 +427,11 @@ public function read()
427427 }
428428
429429 // If we got a 'transfer-encoding: chunked' header
430- $ transfer_encoding = $ headers ->get ('transfer-encoding ' );
431- $ content_length = $ headers ->get ('content-length ' );
432- if ($ transfer_encoding !== false ) {
430+ $ transferEncoding = $ headers ->get ('transfer-encoding ' );
431+ $ contentLength = $ headers ->get ('content-length ' );
432+ if ($ transferEncoding !== false ) {
433433
434- if (strtolower ($ transfer_encoding ->getFieldValue ()) == 'chunked ' ) {
434+ if (strtolower ($ transferEncoding ->getFieldValue ()) == 'chunked ' ) {
435435
436436 do {
437437 $ line = fgets ($ this ->socket );
@@ -451,19 +451,19 @@ public function read()
451451 $ chunksize = hexdec ($ chunksize );
452452
453453 // Read next chunk
454- $ read_to = ftell ($ this ->socket ) + $ chunksize ;
454+ $ readTo = ftell ($ this ->socket ) + $ chunksize ;
455455
456456 do {
457- $ current_pos = ftell ($ this ->socket );
458- if ($ current_pos >= $ read_to ) break ;
457+ $ currentPos = ftell ($ this ->socket );
458+ if ($ currentPos >= $ readTo ) break ;
459459
460- if ($ this ->out_stream ) {
461- if (stream_copy_to_stream ($ this ->socket , $ this ->out_stream , $ read_to - $ current_pos ) == 0 ) {
460+ if ($ this ->outStream ) {
461+ if (stream_copy_to_stream ($ this ->socket , $ this ->outStream , $ readTo - $ currentPos ) == 0 ) {
462462 $ this ->_checkSocketReadTimeout ();
463463 break ;
464464 }
465465 } else {
466- $ line = fread ($ this ->socket , $ read_to - $ current_pos );
466+ $ line = fread ($ this ->socket , $ readTo - $ currentPos );
467467 if ($ line === false || strlen ($ line ) === 0 ) {
468468 $ this ->_checkSocketReadTimeout ();
469469 break ;
@@ -477,45 +477,45 @@ public function read()
477477 ErrorHandler::stop ();
478478 $ this ->_checkSocketReadTimeout ();
479479
480- if (!$ this ->out_stream ) {
480+ if (!$ this ->outStream ) {
481481 $ response .= $ chunk ;
482482 }
483483 } while ($ chunksize > 0 );
484484 } else {
485485 $ this ->close ();
486486 throw new AdapterException \RuntimeException ('Cannot handle " ' .
487- $ transfer_encoding ->getFieldValue () . '" transfer encoding ' );
487+ $ transferEncoding ->getFieldValue () . '" transfer encoding ' );
488488 }
489489
490490 // We automatically decode chunked-messages when writing to a stream
491491 // this means we have to disallow the Zend_Http_Response to do it again
492- if ($ this ->out_stream ) {
492+ if ($ this ->outStream ) {
493493 $ response = str_ireplace ("Transfer-Encoding: chunked \r\n" , '' , $ response );
494494 }
495495 // Else, if we got the content-length header, read this number of bytes
496- } elseif ($ content_length !== false ) {
496+ } elseif ($ contentLength !== false ) {
497497
498498 // If we got more than one Content-Length header (see ZF-9404) use
499499 // the last value sent
500- if (is_array ($ content_length )) {
501- $ content_length = $ content_length [count ($ content_length ) - 1 ];
500+ if (is_array ($ contentLength )) {
501+ $ contentLength = $ contentLength [count ($ contentLength ) - 1 ];
502502 }
503- $ contentLength = $ content_length ->getFieldValue ();
503+ $ contentLength = $ contentLength ->getFieldValue ();
504504
505- $ current_pos = ftell ($ this ->socket );
505+ $ currentPos = ftell ($ this ->socket );
506506 $ chunk = '' ;
507507
508- for ($ read_to = $ current_pos + $ contentLength ;
509- $ read_to > $ current_pos ;
510- $ current_pos = ftell ($ this ->socket )) {
508+ for ($ readTo = $ currentPos + $ contentLength ;
509+ $ readTo > $ currentPos ;
510+ $ currentPos = ftell ($ this ->socket )) {
511511
512- if ($ this ->out_stream ) {
513- if (stream_copy_to_stream ($ this ->socket , $ this ->out_stream , $ read_to - $ current_pos ) == 0 ) {
512+ if ($ this ->outStream ) {
513+ if (stream_copy_to_stream ($ this ->socket , $ this ->outStream , $ readTo - $ currentPos ) == 0 ) {
514514 $ this ->_checkSocketReadTimeout ();
515515 break ;
516516 }
517517 } else {
518- $ chunk = fread ($ this ->socket , $ read_to - $ current_pos );
518+ $ chunk = fread ($ this ->socket , $ readTo - $ currentPos );
519519 if ($ chunk === false || strlen ($ chunk ) === 0 ) {
520520 $ this ->_checkSocketReadTimeout ();
521521 break ;
@@ -532,8 +532,8 @@ public function read()
532532 } else {
533533
534534 do {
535- if ($ this ->out_stream ) {
536- if (stream_copy_to_stream ($ this ->socket , $ this ->out_stream ) == 0 ) {
535+ if ($ this ->outStream ) {
536+ if (stream_copy_to_stream ($ this ->socket , $ this ->outStream ) == 0 ) {
537537 $ this ->_checkSocketReadTimeout ();
538538 break ;
539539 }
@@ -573,7 +573,7 @@ public function close()
573573 ErrorHandler::stop ();
574574 }
575575 $ this ->socket = null ;
576- $ this ->connected_to = array (null , null );
576+ $ this ->connectedTo = array (null , null );
577577 }
578578
579579 /**
@@ -605,7 +605,7 @@ protected function _checkSocketReadTimeout()
605605 */
606606 public function setOutputStream ($ stream )
607607 {
608- $ this ->out_stream = $ stream ;
608+ $ this ->outStream = $ stream ;
609609 return $ this ;
610610 }
611611
0 commit comments