{"action":"created","comment":{"url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/comments/79308229","id":79308229,"diff_hunk":"@@ -30,33 +30,32 @@ public function __construct($input)\n     {\n         $this->input = $input;\n         Loop\\addReadStream($this->input, function() {\n-            while (($c = fgetc($this->input)) !== false) {\n-                $this->buffer .= $c;\n-                switch ($this->parsingMode) {\n-                    case ParsingMode::HEADERS:\n-                        if ($this->buffer === \"\\r\\n\") {\n-                            $this->parsingMode = ParsingMode::BODY;\n-                            $this->contentLength = (int)$this->headers['Content-Length'];\n-                            $this->buffer = '';\n-                        } else if (substr($this->buffer, -2) === \"\\r\\n\") {\n-                            $parts = explode(':', $this->buffer);\n-                            $this->headers[$parts[0]] = trim($parts[1]);\n-                            $this->buffer = '';\n+            $c = fgetc($this->input);","path":"src/ProtocolStreamReader.php","position":16,"original_position":16,"commit_id":"d45664b91657bfa92e6a2a4a0a18f1e6d57fe157","original_commit_id":"d45664b91657bfa92e6a2a4a0a18f1e6d57fe157","user":{"login":"felixfbecker","id":10532611,"avatar_url":"https://avatars.githubusercontent.com/u/10532611?v=3","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"body":"Could you commend a bit on this change?\r\nAs I understand [`Loop\\addReadStream`](http://sabre.io/event/loop/), it calls the callback as soon as the stream has data in the buffer using `stream_select` under the hood. So as long as there is no data, it will not block. When the callback is called, it could be that there is more than one character in the buffer, so I call `fgetc` (blocking) until the buffer is empty again. I have to admit I was/am not familiar at all with what PHP stream read functions are suitable here as I never worked with them. I used `fgetc` because I wanted to be 100% sure I don't loose any data and the other functions seemed to only read a chunk of a specific size (while here `Loop\\addReadStream` should already take care of the chunking)","created_at":"2016-09-18T15:20:29Z","updated_at":"2016-09-18T16:02:29Z","html_url":"https://github.com/felixfbecker/php-language-server/pull/31#discussion_r79308229","pull_request_url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/comments/79308229"},"html":{"href":"https://github.com/felixfbecker/php-language-server/pull/31#discussion_r79308229"},"pull_request":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31","id":85712173,"html_url":"https://github.com/felixfbecker/php-language-server/pull/31","diff_url":"https://github.com/felixfbecker/php-language-server/pull/31.diff","patch_url":"https://github.com/felixfbecker/php-language-server/pull/31.patch","issue_url":"https://api.github.com/repos/felixfbecker/php-language-server/issues/31","number":31,"state":"open","locked":false,"title":"Global symbol search","user":{"login":"MadHed","id":2094371,"avatar_url":"https://avatars.githubusercontent.com/u/2094371?v=3","gravatar_id":"","url":"https://api.github.com/users/MadHed","html_url":"https://github.com/MadHed","followers_url":"https://api.github.com/users/MadHed/followers","following_url":"https://api.github.com/users/MadHed/following{/other_user}","gists_url":"https://api.github.com/users/MadHed/gists{/gist_id}","starred_url":"https://api.github.com/users/MadHed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MadHed/subscriptions","organizations_url":"https://api.github.com/users/MadHed/orgs","repos_url":"https://api.github.com/users/MadHed/repos","events_url":"https://api.github.com/users/MadHed/events{/privacy}","received_events_url":"https://api.github.com/users/MadHed/received_events","type":"User","site_admin":false},"body":"Closes #31 \r\n\r\nParsing the whole php-language-server project takes about 10 seconds on my machine.\r\nThe php-cli process takes up about 180MB of ram with all symbol information parsed.\r\n\r\nChanges made:\r\n* Added support for client:window/* commands\r\n* Added support for server:workspace/* commands\r\n* Refactored symbol database into own set of classes. (Was in Server/TextDocument before)\r\n* Disabled memory limit\r\n* ProtocolStreamReader was blocking the event loop, made non-blocking\r\n* Find all .php files on startup and start parsing one at a time with Loop/nextTick\r\n\r\nTo do:\r\n* [ ] Fix old tests\r\n* [ ] Add new tests\r\n* [ ] Reduce memory usage. Most of it is the AST, maybe we can throw it away after parsing,\r\n* [ ] Figure out solution for blocking STDIN. The current one is a hack. This is a windows limitation, see [https://bugs.php.net/bug.php?id=34972](https://bugs.php.net/bug.php?id=34972)\r\n","created_at":"2016-09-18T14:43:05Z","updated_at":"2016-09-18T16:02:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45651e5a749187895ff586a36e468b0c021c7849","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31/commits","review_comments_url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31/comments","review_comment_url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/felixfbecker/php-language-server/issues/31/comments","statuses_url":"https://api.github.com/repos/felixfbecker/php-language-server/statuses/d45664b91657bfa92e6a2a4a0a18f1e6d57fe157","head":{"label":"MadHed:workspace_symbols","ref":"workspace_symbols","sha":"d45664b91657bfa92e6a2a4a0a18f1e6d57fe157","user":{"login":"MadHed","id":2094371,"avatar_url":"https://avatars.githubusercontent.com/u/2094371?v=3","gravatar_id":"","url":"https://api.github.com/users/MadHed","html_url":"https://github.com/MadHed","followers_url":"https://api.github.com/users/MadHed/followers","following_url":"https://api.github.com/users/MadHed/following{/other_user}","gists_url":"https://api.github.com/users/MadHed/gists{/gist_id}","starred_url":"https://api.github.com/users/MadHed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MadHed/subscriptions","organizations_url":"https://api.github.com/users/MadHed/orgs","repos_url":"https://api.github.com/users/MadHed/repos","events_url":"https://api.github.com/users/MadHed/events{/privacy}","received_events_url":"https://api.github.com/users/MadHed/received_events","type":"User","site_admin":false},"repo":{"id":68322339,"name":"php-language-server","full_name":"MadHed/php-language-server","owner":{"login":"MadHed","id":2094371,"avatar_url":"https://avatars.githubusercontent.com/u/2094371?v=3","gravatar_id":"","url":"https://api.github.com/users/MadHed","html_url":"https://github.com/MadHed","followers_url":"https://api.github.com/users/MadHed/followers","following_url":"https://api.github.com/users/MadHed/following{/other_user}","gists_url":"https://api.github.com/users/MadHed/gists{/gist_id}","starred_url":"https://api.github.com/users/MadHed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MadHed/subscriptions","organizations_url":"https://api.github.com/users/MadHed/orgs","repos_url":"https://api.github.com/users/MadHed/repos","events_url":"https://api.github.com/users/MadHed/events{/privacy}","received_events_url":"https://api.github.com/users/MadHed/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MadHed/php-language-server","description":"PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥","fork":true,"url":"https://api.github.com/repos/MadHed/php-language-server","forks_url":"https://api.github.com/repos/MadHed/php-language-server/forks","keys_url":"https://api.github.com/repos/MadHed/php-language-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MadHed/php-language-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MadHed/php-language-server/teams","hooks_url":"https://api.github.com/repos/MadHed/php-language-server/hooks","issue_events_url":"https://api.github.com/repos/MadHed/php-language-server/issues/events{/number}","events_url":"https://api.github.com/repos/MadHed/php-language-server/events","assignees_url":"https://api.github.com/repos/MadHed/php-language-server/assignees{/user}","branches_url":"https://api.github.com/repos/MadHed/php-language-server/branches{/branch}","tags_url":"https://api.github.com/repos/MadHed/php-language-server/tags","blobs_url":"https://api.github.com/repos/MadHed/php-language-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MadHed/php-language-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MadHed/php-language-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/MadHed/php-language-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MadHed/php-language-server/statuses/{sha}","languages_url":"https://api.github.com/repos/MadHed/php-language-server/languages","stargazers_url":"https://api.github.com/repos/MadHed/php-language-server/stargazers","contributors_url":"https://api.github.com/repos/MadHed/php-language-server/contributors","subscribers_url":"https://api.github.com/repos/MadHed/php-language-server/subscribers","subscription_url":"https://api.github.com/repos/MadHed/php-language-server/subscription","commits_url":"https://api.github.com/repos/MadHed/php-language-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/MadHed/php-language-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/MadHed/php-language-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/MadHed/php-language-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/MadHed/php-language-server/contents/{+path}","compare_url":"https://api.github.com/repos/MadHed/php-language-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MadHed/php-language-server/merges","archive_url":"https://api.github.com/repos/MadHed/php-language-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MadHed/php-language-server/downloads","issues_url":"https://api.github.com/repos/MadHed/php-language-server/issues{/number}","pulls_url":"https://api.github.com/repos/MadHed/php-language-server/pulls{/number}","milestones_url":"https://api.github.com/repos/MadHed/php-language-server/milestones{/number}","notifications_url":"https://api.github.com/repos/MadHed/php-language-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MadHed/php-language-server/labels{/name}","releases_url":"https://api.github.com/repos/MadHed/php-language-server/releases{/id}","deployments_url":"https://api.github.com/repos/MadHed/php-language-server/deployments","created_at":"2016-09-15T18:55:21Z","updated_at":"2016-09-15T18:55:22Z","pushed_at":"2016-09-18T12:27:17Z","git_url":"git://github.com/MadHed/php-language-server.git","ssh_url":"git@github.com:MadHed/php-language-server.git","clone_url":"https://github.com/MadHed/php-language-server.git","svn_url":"https://github.com/MadHed/php-language-server","homepage":"","size":211,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"felixfbecker:master","ref":"master","sha":"817056270e0010a4f046519d9691217696259ab1","user":{"login":"felixfbecker","id":10532611,"avatar_url":"https://avatars.githubusercontent.com/u/10532611?v=3","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"repo":{"id":65535756,"name":"php-language-server","full_name":"felixfbecker/php-language-server","owner":{"login":"felixfbecker","id":10532611,"avatar_url":"https://avatars.githubusercontent.com/u/10532611?v=3","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/felixfbecker/php-language-server","description":"PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥","fork":false,"url":"https://api.github.com/repos/felixfbecker/php-language-server","forks_url":"https://api.github.com/repos/felixfbecker/php-language-server/forks","keys_url":"https://api.github.com/repos/felixfbecker/php-language-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/felixfbecker/php-language-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/felixfbecker/php-language-server/teams","hooks_url":"https://api.github.com/repos/felixfbecker/php-language-server/hooks","issue_events_url":"https://api.github.com/repos/felixfbecker/php-language-server/issues/events{/number}","events_url":"https://api.github.com/repos/felixfbecker/php-language-server/events","assignees_url":"https://api.github.com/repos/felixfbecker/php-language-server/assignees{/user}","branches_url":"https://api.github.com/repos/felixfbecker/php-language-server/branches{/branch}","tags_url":"https://api.github.com/repos/felixfbecker/php-language-server/tags","blobs_url":"https://api.github.com/repos/felixfbecker/php-language-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/felixfbecker/php-language-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/felixfbecker/php-language-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/felixfbecker/php-language-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/felixfbecker/php-language-server/statuses/{sha}","languages_url":"https://api.github.com/repos/felixfbecker/php-language-server/languages","stargazers_url":"https://api.github.com/repos/felixfbecker/php-language-server/stargazers","contributors_url":"https://api.github.com/repos/felixfbecker/php-language-server/contributors","subscribers_url":"https://api.github.com/repos/felixfbecker/php-language-server/subscribers","subscription_url":"https://api.github.com/repos/felixfbecker/php-language-server/subscription","commits_url":"https://api.github.com/repos/felixfbecker/php-language-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/felixfbecker/php-language-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/felixfbecker/php-language-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/felixfbecker/php-language-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/felixfbecker/php-language-server/contents/{+path}","compare_url":"https://api.github.com/repos/felixfbecker/php-language-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/felixfbecker/php-language-server/merges","archive_url":"https://api.github.com/repos/felixfbecker/php-language-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/felixfbecker/php-language-server/downloads","issues_url":"https://api.github.com/repos/felixfbecker/php-language-server/issues{/number}","pulls_url":"https://api.github.com/repos/felixfbecker/php-language-server/pulls{/number}","milestones_url":"https://api.github.com/repos/felixfbecker/php-language-server/milestones{/number}","notifications_url":"https://api.github.com/repos/felixfbecker/php-language-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/felixfbecker/php-language-server/labels{/name}","releases_url":"https://api.github.com/repos/felixfbecker/php-language-server/releases{/id}","deployments_url":"https://api.github.com/repos/felixfbecker/php-language-server/deployments","created_at":"2016-08-12T08:11:14Z","updated_at":"2016-09-15T16:35:40Z","pushed_at":"2016-09-18T14:43:05Z","git_url":"git://github.com/felixfbecker/php-language-server.git","ssh_url":"git@github.com:felixfbecker/php-language-server.git","clone_url":"https://github.com/felixfbecker/php-language-server.git","svn_url":"https://github.com/felixfbecker/php-language-server","homepage":"","size":209,"stargazers_count":13,"watchers_count":13,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":15,"forks":5,"open_issues":15,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31"},"html":{"href":"https://github.com/felixfbecker/php-language-server/pull/31"},"issue":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/issues/31"},"comments":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/felixfbecker/php-language-server/statuses/d45664b91657bfa92e6a2a4a0a18f1e6d57fe157"}}}}
{"actor":{"display_login":"felixfbecker"}}