note 123273 added to stomp.destruct

From: Date: Mon, 29 Oct 2018 16:11:57 +0000
Subject: note 123273 added to stomp.destruct
Groups: php.notes 
Request: Send a blank email to php-notes+get-209543@lists.php.net to get a copy of this message
Isn't it a little odd to have connect/disconnect in the constructor/destructor methods? I have a case where the connection is presumably kept alive until the PHP process ends: <?php class MyStompWrapper { public function doSend() { $stomp = $this->connect(); // returns Stomp Object $stomp->send('/destination', 'message', []); $this->disconnect($stomp); // $stomp still exists in this scope, hence, the connection is alive } private function disconnect(\Stomp $stompObj) { // only unsets the local $stomp pointer, does not actually disconnect unset($stomp); } private function connect():\Stomp { // try-catch block omitted for example brevity return new Stomp('url', 'username', 'password'); } } ?> This means that, in order to handle disconnecting, I have to create and destroy the Stomp object within the same scope. ---- Server IP: 208.43.231.9 Probable Submitter: 90.157.210.164 ---- Manual Page -- http://php.net/manual/en/stomp.destruct.php Edit -- https://master.php.net/note/edit/123273 Del: integrated -- https://master.php.net/note/delete/123273/integrated Del: useless -- https://master.php.net/note/delete/123273/useless Del: bad code -- https://master.php.net/note/delete/123273/bad+code Del: spam -- https://master.php.net/note/delete/123273/spam Del: non-english -- https://master.php.net/note/delete/123273/non-english Del: in docs -- https://master.php.net/note/delete/123273/in+docs Del: other reasons-- https://master.php.net/note/delete/123273 Reject -- https://master.php.net/note/reject/123273 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209543) next »