{"action":"created","comment":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/49699696","id":49699696,"diff_hunk":"@@ -0,0 +1,201 @@\n+<?php\n+\n+/*\n+ * This file is part of the PHP CS utility.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * This source file is subject to the MIT license that is bundled\n+ * with this source code in the file LICENSE.\n+ */\n+\n+namespace Symfony\\CS\\Fixer\\Contrib;\n+\n+use Symfony\\CS\\AbstractFixer;\n+use Symfony\\CS\\Tokenizer\\Token;\n+use Symfony\\CS\\Tokenizer\\Tokens;\n+\n+class MultipleUnsetFixer extends AbstractFixer\n+{\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function fix(\\SplFileInfo $file, $content)\n+    {\n+        $tokens = Tokens::fromCode($content);\n+\n+        // Offset start at 5, because any call to 'unset' that can possible be merged is\n+        // build up out of at least 4 Tokens; 'unset', '(', '[var]', ')' after at least one ';'.\n+        for ($index = $tokens->count() - 6; $index > 5; --$index) {\n+            if (!$tokens[$index]->isGivenKind(T_UNSET)) {\n+                continue;\n+            }\n+\n+            $previousUnsetCall = $this->getPreviousUnsetCall($tokens, $index);\n+            if (is_int($previousUnsetCall)) {\n+                $index = $previousUnsetCall;\n+                continue;\n+            }\n+\n+            list($previousUnset, $previousUnsetBraceStart, $previousUnsetBraceEnd, $previousUnsetSemicolon) = $previousUnsetCall;\n+\n+            // Merge the tokens inside the 'unset' call into the previous one 'unset' call.\n+            $tokensAddCount = $this->moveTokens(\n+                $tokens,\n+                $nextUnsetContentStart = $tokens->getNextTokenOfKind($index, array('(')),\n+                $nextUnsetContentEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $nextUnsetContentStart),\n+                $previousUnsetBraceEnd - 1\n+            );\n+\n+            $tokens->insertAt($previousUnsetBraceEnd, new Token(','));\n+            ++$tokensAddCount;\n+\n+            // Remove 'unset', '(', ')' and (possibly) ';' from the merged 'unset' call.\n+            $this->clearOffsetTokens($tokens, $tokensAddCount, array($index, $nextUnsetContentStart, $nextUnsetContentEnd));\n+\n+            $nextUnsetSemicolon = $tokens->getNextMeaningfulToken($nextUnsetContentEnd);\n+            if (null !== $nextUnsetSemicolon && $tokens[$nextUnsetSemicolon]->equals(';')) {\n+                $tokens[$nextUnsetSemicolon]->clear();\n+                $highestClearTokenIndex = $nextUnsetSemicolon;\n+            } else {\n+                $highestClearTokenIndex = $tokensAddCount + $nextUnsetContentEnd;\n+            }\n+\n+            // Since tokens are cleared and inserted there might be successive whitespace tokens which need to\n+            // be merge into one whitespace token. These tokens can only be after the first 'unset' call ';' token\n+            // up to the token after the last cleared token of the second 'unset' + 1\n+            $this->mergeWhitespaceTokens(","path":"Symfony/CS/Fixer/Contrib/MultipleUnsetFixer.php","position":67,"original_position":67,"commit_id":"4574db2c0766a6c321aabc924d35eb96079ed3f1","original_commit_id":"ac417656ba39545dd49352592e9c2b9d7eb71766","user":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"body":"it is .. .clearing tokens seems tricky... let me think about it","created_at":"2016-01-14T08:50:44Z","updated_at":"2016-01-14T08:50:44Z","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1662#discussion_r49699696","pull_request_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662","_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/49699696"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1662#discussion_r49699696"},"pull_request":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662"}}},"pull_request":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662","id":55564073,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1662","diff_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1662.diff","patch_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1662.patch","issue_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1662","number":1662,"state":"open","locked":false,"title":"MultipleUnsetFixer - Add","user":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-10T12:31:35Z","updated_at":"2016-01-14T08:50:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6eea95b3e995ead997b26036f141f3b12b9deed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662/commits","review_comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662/comments","review_comment_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1662/comments","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/4574db2c0766a6c321aabc924d35eb96079ed3f1","head":{"label":"SpacePossum:1_12_feature_multiple_unset","ref":"1_12_feature_multiple_unset","sha":"4574db2c0766a6c321aabc924d35eb96079ed3f1","user":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"repo":{"id":29018102,"name":"PHP-CS-Fixer","full_name":"SpacePossum/PHP-CS-Fixer","owner":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SpacePossum/PHP-CS-Fixer","description":"Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible)","fork":true,"url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/issues/comments{/number}","contents_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/releases{/id}","created_at":"2015-01-09T13:46:11Z","updated_at":"2016-01-11T16:10:45Z","pushed_at":"2016-01-13T18:55:23Z","git_url":"git://github.com/SpacePossum/PHP-CS-Fixer.git","ssh_url":"git@github.com:SpacePossum/PHP-CS-Fixer.git","clone_url":"https://github.com/SpacePossum/PHP-CS-Fixer.git","svn_url":"https://github.com/SpacePossum/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":4177,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"FriendsOfPHP:1.12","ref":"1.12","sha":"5d9470c7c06371b4645462a77151353ec00ce1b2","user":{"login":"FriendsOfPHP","id":5947812,"avatar_url":"https://avatars.githubusercontent.com/u/5947812?v=3","gravatar_id":"","url":"https://api.github.com/users/FriendsOfPHP","html_url":"https://github.com/FriendsOfPHP","followers_url":"https://api.github.com/users/FriendsOfPHP/followers","following_url":"https://api.github.com/users/FriendsOfPHP/following{/other_user}","gists_url":"https://api.github.com/users/FriendsOfPHP/gists{/gist_id}","starred_url":"https://api.github.com/users/FriendsOfPHP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FriendsOfPHP/subscriptions","organizations_url":"https://api.github.com/users/FriendsOfPHP/orgs","repos_url":"https://api.github.com/users/FriendsOfPHP/repos","events_url":"https://api.github.com/users/FriendsOfPHP/events{/privacy}","received_events_url":"https://api.github.com/users/FriendsOfPHP/received_events","type":"Organization","site_admin":false},"repo":{"id":4344257,"name":"PHP-CS-Fixer","full_name":"FriendsOfPHP/PHP-CS-Fixer","owner":{"login":"FriendsOfPHP","id":5947812,"avatar_url":"https://avatars.githubusercontent.com/u/5947812?v=3","gravatar_id":"","url":"https://api.github.com/users/FriendsOfPHP","html_url":"https://github.com/FriendsOfPHP","followers_url":"https://api.github.com/users/FriendsOfPHP/followers","following_url":"https://api.github.com/users/FriendsOfPHP/following{/other_user}","gists_url":"https://api.github.com/users/FriendsOfPHP/gists{/gist_id}","starred_url":"https://api.github.com/users/FriendsOfPHP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FriendsOfPHP/subscriptions","organizations_url":"https://api.github.com/users/FriendsOfPHP/orgs","repos_url":"https://api.github.com/users/FriendsOfPHP/repos","events_url":"https://api.github.com/users/FriendsOfPHP/events{/privacy}","received_events_url":"https://api.github.com/users/FriendsOfPHP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer","description":"Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible)","fork":false,"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/comments{/number}","contents_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/releases{/id}","created_at":"2012-05-16T06:42:23Z","updated_at":"2016-01-14T08:23:08Z","pushed_at":"2016-01-13T18:55:23Z","git_url":"git://github.com/FriendsOfPHP/PHP-CS-Fixer.git","ssh_url":"git@github.com:FriendsOfPHP/PHP-CS-Fixer.git","clone_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer.git","svn_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":7284,"stargazers_count":2867,"watchers_count":2867,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":444,"mirror_url":null,"open_issues_count":107,"forks":444,"open_issues":107,"watchers":2867,"default_branch":"1.12"}},"_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1662"},"issue":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1662"},"comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1662/comments"},"review_comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662/comments"},"review_comment":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1662/commits"},"statuses":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/4574db2c0766a6c321aabc924d35eb96079ed3f1"}}}}