@@ -64,8 +64,8 @@ class Connection implements LoggerAwareInterface {
6464
6565 protected $ _brokerUri = null ;
6666 protected $ _socket = null ;
67- protected $ _params = array () ;
68- protected $ _subscriptions = array () ;
67+ protected $ _params = [] ;
68+ protected $ _subscriptions = [] ;
6969 protected $ _defaultPort = 61613 ;
7070 protected $ _attempts = 10 ;
7171 protected $ _username = '' ;
@@ -173,7 +173,7 @@ function connect($username = '', $password = '', $version = '1.0,1.1,1.2') {
173173 if ($ password != '' ) {
174174 $ this ->_password = $ password ;
175175 }
176- $ headers = array ( 'login ' => $ this ->_username , 'passcode ' => $ this ->_password ) ;
176+ $ headers = [ 'login ' => $ this ->_username , 'passcode ' => $ this ->_password ] ;
177177 if ($ this ->clientId != null ) {
178178 $ headers ["client-id " ] = $ this ->clientId ;
179179 }
@@ -234,7 +234,7 @@ function getSessionId() {
234234 * @return boolean
235235 */
236236 public
237- function send ($ destination , $ msg , $ properties = array () , $ sync = null ) {
237+ function send ($ destination , $ msg , $ properties = [] , $ sync = null ) {
238238 $ this ->logger ->debug ("Sending message to $ destination " );
239239
240240 if ($ msg instanceof Frame) {
@@ -328,10 +328,10 @@ function _waitForReceipt(Frame $frame, $sync) {
328328 */
329329 public
330330 function subscribe ($ destination , $ properties = null , $ sync = null ) {
331- $ headers = array (
331+ $ headers = [
332332 'ack ' => 'client-individual ' ,
333333 'id ' => 0 ,
334- ) ;
334+ ] ;
335335
336336 $ headers ['activemq.prefetchSize ' ] = $ this ->prefetchSize ;
337337 if ($ this ->clientId != null ) {
@@ -368,7 +368,7 @@ function subscribe($destination, $properties = null, $sync = null) {
368368 */
369369 public
370370 function unsubscribe ($ destination , $ properties = null , $ sync = null ) {
371- $ headers = array () ;
371+ $ headers = [] ;
372372 if (isset ($ properties )) {
373373 foreach ($ properties as $ name => $ value ) {
374374 $ headers [$ name ] = $ value ;
@@ -399,7 +399,7 @@ function unsubscribe($destination, $properties = null, $sync = null) {
399399 */
400400 public
401401 function begin ($ transactionId = null , $ sync = null ) {
402- $ headers = array () ;
402+ $ headers = [] ;
403403 if (isset ($ transactionId )) {
404404 $ headers ['transaction ' ] = $ transactionId ;
405405 }
@@ -421,7 +421,7 @@ function begin($transactionId = null, $sync = null) {
421421 */
422422 public
423423 function commit ($ transactionId = null , $ sync = null ) {
424- $ headers = array () ;
424+ $ headers = [] ;
425425 if (isset ($ transactionId )) {
426426 $ headers ['transaction ' ] = $ transactionId ;
427427 }
@@ -440,7 +440,7 @@ function commit($transactionId = null, $sync = null) {
440440 */
441441 public
442442 function abort ($ transactionId = null , $ sync = null ) {
443- $ headers = array () ;
443+ $ headers = [] ;
444444 if (isset ($ transactionId )) {
445445 $ headers ['transaction ' ] = $ transactionId ;
446446 }
@@ -463,42 +463,35 @@ function abort($transactionId = null, $sync = null) {
463463 */
464464 private
465465 function abstract_ack ($ command , $ message , $ transactionId = null ) {
466+ $ headers = [];
467+
466468 if ($ message instanceof Frame) {
467469 $ headers = $ message ->headers ;
468470
469- $ ack_headers = array (
471+ $ headers = [
470472 'subscription ' => $ headers ['subscription ' ],
471473 'message-id ' => $ headers ['message-id ' ]
472- );
473-
474- if ($ this ->_version > 1.1 ) {
475- $ ack_headers ['id ' ] = $ headers ['ack ' ];
476- }
474+ ];
477475
478- if ( isset ( $ transactionId )) {
479- $ ack_headers [ ' transaction ' ] = $ transactionId ;
480- }
476+ } else {
477+ $ headers [ ' message-id ' ] = $ message ;
478+ }
481479
482- $ this ->logger -> info ( " ACK Frame for -> " , $ ack_headers );
483- $ frame = new Frame ( $ command , $ ack_headers ) ;
484- $ this -> _writeFrame ( $ frame );
480+ if ( $ this ->_version > 1.1 ) {
481+ $ headers [ ' id ' ] = $ headers [ ' message-id ' ] ;
482+ }
485483
486- return true ;
484+ if (isset ($ transactionId )) {
485+ $ ack_headers ['transaction ' ] = $ transactionId ;
487486 }
488- else {
489- $ headers = array ();
490- if (isset ($ transactionId )) {
491- $ headers ['transaction ' ] = $ transactionId ;
492- }
493487
494- $ headers ['message-id ' ] = $ message ;
495- $ this ->logger ->info ("ACK ID -> " , $ headers );
488+ $ this ->logger ->info ($ command , $ headers );
489+
490+ $ frame = new Frame ($ command , $ headers );
491+ $ this ->_writeFrame ($ frame );
496492
497- $ frame = new Frame ($ command , $ headers );
498- $ this ->_writeFrame ($ frame );
493+ return true ;
499494
500- return true ;
501- }
502495 }
503496
504497 public
@@ -527,7 +520,7 @@ function nack($message, $transactionId = null) {
527520 */
528521 public
529522 function disconnect () {
530- $ headers = array () ;
523+ $ headers = [] ;
531524
532525 if ($ this ->clientId != null ) {
533526 $ headers ["client-id " ] = $ this ->clientId ;
@@ -539,7 +532,7 @@ function disconnect() {
539532 }
540533 $ this ->_socket = null ;
541534 $ this ->_sessionId = null ;
542- $ this ->_subscriptions = array () ;
535+ $ this ->_subscriptions = [] ;
543536 $ this ->_username = '' ;
544537 $ this ->_password = '' ;
545538 }
@@ -630,12 +623,12 @@ function readFrame() {
630623 $ len = mb_strlen ($ data , '8bit ' );
631624 } while ($ len < 2 || $ end == false );
632625
633- $ this ->logger ->debug ("Read frame " , array ( 'frame ' => $ data) );
626+ $ this ->logger ->debug ("Read frame " , [ 'frame ' => $ data] );
634627
635628
636629 list ($ header , $ body ) = explode ("\n\n" , $ data , 2 );
637630 $ header = explode ("\n" , $ header );
638- $ headers = array () ;
631+ $ headers = [] ;
639632 $ command = null ;
640633 foreach ($ header as $ v ) {
641634
@@ -757,7 +750,7 @@ function _extractNextMessage() {
757750 */
758751 public
759752 function hasFrameToRead () {
760- $ read = array ( $ this ->_socket ) ;
753+ $ read = [ $ this ->_socket ] ;
761754 $ write = null ;
762755 $ except = null ;
763756
0 commit comments