GitHub PullRequestReviewCommentEvent at 2014-05-01 10:26:52
Repository: MinkZombieDriver
Actor: aik099
Payload: {"comment":{"url":"https://api.github.com/repos/Behat/MinkZombieDriver/pulls/comments/12183664","id":12183664,"diff_hunk":"@@ -4,35 +4,52 @@\n \n use Behat\\Mink\\Driver\\NodeJS\\Connection;\n use Behat\\Mink\\Driver\\NodeJS\\Server;\n+use Behat\\Mink\\Exception\\DriverException;\n \n class ZombieServer extends Server\n {\n+    const ERROR_PREFIX = 'CAUGHT_ERROR:';\n+\n     protected function doEvalJS(Connection $conn, $str, $returnType = 'js')\n     {\n-        $result = null;\n+        $result = $rawResult = null;\n+\n         switch ($returnType) {\n             case 'js':\n-                $result = $conn->socketSend($str);\n+                $result = $rawResult = $conn->socketSend($str);\n                 break;\n+\n             case 'json':\n-                $result = json_decode($conn->socketSend(\"stream.end(JSON.stringify({$str}))\"));\n+                $rawResult = $conn->socketSend(\"stream.end(JSON.stringify({$str}))\");\n+                $result = json_decode($rawResult);","path":"src/Behat/Mink/Driver/NodeJS/Server/ZombieServer.php","position":24,"original_position":24,"commit_id":"d46e77199c36009aa65a4c4855ed785882523df3","original_commit_id":"d46e77199c36009aa65a4c4855ed785882523df3","user":{"login":"aik099","id":1277526,"avatar_url":"https://avatars.githubusercontent.com/u/1277526?","gravatar_id":"027e03406c7dfd1dd54dc944b0745d2f","url":"https://api.github.com/users/aik099","html_url":"https://github.com/aik099","followers_url":"https://api.github.com/users/aik099/followers","following_url":"https://api.github.com/users/aik099/following{/other_user}","gists_url":"https://api.github.com/users/aik099/gists{/gist_id}","starred_url":"https://api.github.com/users/aik099/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aik099/subscriptions","organizations_url":"https://api.github.com/users/aik099/orgs","repos_url":"https://api.github.com/users/aik099/repos","events_url":"https://api.github.com/users/aik099/events{/privacy}","received_events_url":"https://api.github.com/users/aik099/received_events","type":"User","site_admin":false},"body":"I thought about this, but that would check if `'json' === $returnType` in 2 places: SWITCH and IF.\r\n\r\nAlso I would rather use `preg_match` to detect an error, since that would result in cleaner code, but since this code will be executed a lot, then I decided to stick with `substr` because it will work faster IMO.","created_at":"2014-05-01T10:26:52Z","updated_at":"2014-05-01T10:26:52Z","html_url":"https://github.com/Behat/MinkZombieDriver/pull/73#discussion_r12183664","pull_request_url":"https://api.github.com/repos/Behat/MinkZombieDriver/pulls/73","_links":{"self":{"href":"https://api.github.com/repos/Behat/MinkZombieDriver/pulls/comments/12183664"},"html":{"href":"https://github.com/Behat/MinkZombieDriver/pull/73#discussion_r12183664"},"pull_request":{"href":"https://api.github.com/repos/Behat/MinkZombieDriver/pulls/73"}}}}