{"action":"created","comment":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/46483761","id":46483761,"diff_hunk":"@@ -0,0 +1,199 @@\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\\PSR2;\n+\n+use Symfony\\CS\\AbstractFixer;\n+use Symfony\\CS\\Tokenizer\\Token;\n+use Symfony\\CS\\Tokenizer\\Tokens;\n+\n+/**\n+ * Fixer for part of the rules defined in PSR2 ¶4.1 Extends and Implements.\n+ *\n+ * @author SpacePossum\n+ */\n+final class ClassDefinitionFixer extends AbstractFixer\n+{\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function fix(\\SplFileInfo $file, $content)\n+    {\n+        $tokens = Tokens::fromCode($content);\n+        for ($index = $tokens->getSize() - 1; $index > 0; --$index) {\n+            if (!$tokens[$index]->isClassy()) {\n+                continue;\n+            }\n+\n+            $this->fixClassDefinition($tokens, $index, $tokens->getNextTokenOfKind($index, array('{')));\n+        }\n+\n+        return $tokens->generateCode();\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function getDescription()\n+    {\n+        return 'White space around the key words of a class, trait or interfaces definition should be one space.';\n+    }\n+\n+    /**\n+     * @param Tokens $tokens\n+     * @param int    $start  Class definition token start index\n+     * @param int    $end    Class definition token end index\n+     */\n+    private function fixClassDefinition(Tokens $tokens, $start, $end)\n+    {\n+        // check if there is a `implements` part in the definition, since there are rules for it in PSR 2.\n+        $implementsInfo = $this->getMultiLineInfo($tokens, $start, $end);\n+\n+        // 4.1 The extends and implements keywords MUST be declared on the same line as the class name.\n+        if ($implementsInfo['numberOfInterfaces'] > 1 && $implementsInfo['multiLine']) {\n+            $end += $this->ensureWhiteSpaceSeparation($tokens, $start, $implementsInfo['breakAt']);\n+            $this->fixMultiLineImplements($tokens, $implementsInfo['breakAt'], $end);\n+        } else {\n+            $end -= $tokens[$end - 1]->isWhitespace() ? 2 : 1;\n+            $this->ensureWhiteSpaceSeparation($tokens, $start, $end);\n+        }\n+    }\n+\n+    /**\n+     * Returns an array with `implements` data.\n+     *\n+     * Returns array:\n+     * int  'breakAt'            index of the Token of type T_IMPLEMENTS for the definition, or 0\n+     * int  'numberOfInterfaces'\n+     * bool 'multiLine'","path":"Symfony/CS/Fixer/PSR2/ClassDefinitionFixer.php","position":76,"original_position":76,"commit_id":"21123227c14446db8abfa20caebf1edd51600bd2","original_commit_id":"21123227c14446db8abfa20caebf1edd51600bd2","user":{"login":"keradus","id":2716794,"avatar_url":"https://avatars.githubusercontent.com/u/2716794?v=3","gravatar_id":"","url":"https://api.github.com/users/keradus","html_url":"https://github.com/keradus","followers_url":"https://api.github.com/users/keradus/followers","following_url":"https://api.github.com/users/keradus/following{/other_user}","gists_url":"https://api.github.com/users/keradus/gists{/gist_id}","starred_url":"https://api.github.com/users/keradus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keradus/subscriptions","organizations_url":"https://api.github.com/users/keradus/orgs","repos_url":"https://api.github.com/users/keradus/repos","events_url":"https://api.github.com/users/keradus/events{/privacy}","received_events_url":"https://api.github.com/users/keradus/received_events","type":"User","site_admin":false},"body":"add bullets like\r\n- int\r\n- int\r\n- bool ","created_at":"2015-12-02T22:13:17Z","updated_at":"2015-12-02T22:13:17Z","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1518#discussion_r46483761","pull_request_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518","_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/46483761"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1518#discussion_r46483761"},"pull_request":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518"}}},"pull_request":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518","id":51201498,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1518","diff_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1518.diff","patch_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1518.patch","issue_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1518","number":1518,"state":"open","locked":false,"title":"[PSR2 4.1] Add class definition fixer.","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":"replaces https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1501","created_at":"2015-11-19T10:01:24Z","updated_at":"2015-12-02T22:13:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a5d5eee0a784117b4e3e3782d214b227a28dfe7","assignee":null,"milestone":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/milestones/27","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/milestones/v1.12","labels_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/milestones/27/labels","id":1436005,"number":27,"title":"v1.12","description":"","creator":{"login":"keradus","id":2716794,"avatar_url":"https://avatars.githubusercontent.com/u/2716794?v=3","gravatar_id":"","url":"https://api.github.com/users/keradus","html_url":"https://github.com/keradus","followers_url":"https://api.github.com/users/keradus/followers","following_url":"https://api.github.com/users/keradus/following{/other_user}","gists_url":"https://api.github.com/users/keradus/gists{/gist_id}","starred_url":"https://api.github.com/users/keradus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keradus/subscriptions","organizations_url":"https://api.github.com/users/keradus/orgs","repos_url":"https://api.github.com/users/keradus/repos","events_url":"https://api.github.com/users/keradus/events{/privacy}","received_events_url":"https://api.github.com/users/keradus/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2015-11-30T20:16:37Z","updated_at":"2015-12-02T21:09:57Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518/commits","review_comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518/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/1518/comments","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/21123227c14446db8abfa20caebf1edd51600bd2","head":{"label":"SpacePossum:1_11_feature_add_class_definition_fixer","ref":"1_11_feature_add_class_definition_fixer","sha":"21123227c14446db8abfa20caebf1edd51600bd2","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":"2015-04-14T09:59:34Z","pushed_at":"2015-12-02T13:59:35Z","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":3749,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"FriendsOfPHP:1.11","ref":"1.11","sha":"94fc43519d63488ba0465cca37fce4d2709c67f7","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":"2015-12-02T21:32:33Z","pushed_at":"2015-12-02T22:04:29Z","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":6648,"stargazers_count":2729,"watchers_count":2729,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":432,"mirror_url":null,"open_issues_count":89,"forks":432,"open_issues":89,"watchers":2729,"default_branch":"1.12"}},"_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1518"},"issue":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1518"},"comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1518/comments"},"review_comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1518/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/1518/commits"},"statuses":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/21123227c14446db8abfa20caebf1edd51600bd2"}}}}