{"action":"created","comment":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/25571210","id":25571210,"diff_hunk":"@@ -0,0 +1,131 @@\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\\Symfony;\n+\n+use Symfony\\CS\\AbstractFixer;\n+use Symfony\\CS\\DocBlock\\DocBlock;\n+use Symfony\\CS\\DocBlock\\Line;\n+use Symfony\\CS\\Tokenizer\\Tokens;\n+\n+/**\n+ * @author Graham Campbell <graham@mineuk.com>\n+ */\n+class PhpdocScalarFixer extends AbstractFixer\n+{\n+    /**\n+     * The annotation tags search inside.\n+     *\n+     * @var array\n+     */\n+    private static $tags = array('param', 'return', 'type', 'var');\n+\n+    /**\n+     * The types to fix.\n+     *\n+     * @var array\n+     */\n+    private static $types = array(\n+        'integer' => 'int',\n+        'boolean' => 'bool',\n+        'real'    => 'float',\n+        'double'  => 'float',\n+    );\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function fix(\\SplFileInfo $file, $content)\n+    {\n+        $tokens = Tokens::fromCode($content);\n+\n+        foreach ($tokens->findGivenKind(T_DOC_COMMENT) as $token) {\n+            $doc = new DocBlock($token->getContent());\n+\n+            foreach ($doc->getAnnotationsOfType(self::$tags) as $annotation) {\n+                $this->fixScalars($doc->getLine($annotation->getStart()), $annotation->getTag()->getName());\n+            }\n+\n+            $token->setContent($doc->getContent());\n+        }\n+\n+        return $tokens->generateCode();\n+    }\n+\n+    /**\n+     * Fix scalar types.\n+     *\n+     * We must be super careful not to modify parts of words.\n+     *\n+     * @param Line   $line\n+     * @param string $tag\n+     */\n+    private function fixScalars(Line $line, $tag)\n+    {\n+        $content = $line->getContent();\n+        $tagSplit = preg_split('/\\s*\\@'.$tag.'\\s*/', $content);\n+        $spaceSplit = preg_split('/\\s/', $tagSplit[1]);\n+        $usefulContent = $spaceSplit[0];\n+\n+        if (strpos($usefulContent, '|') !== false) {\n+            $newContent = implode('|', self::normalizeTypes(explode('|', $usefulContent)));\n+        } else {\n+            $newContent = self::normalizeType($usefulContent);\n+        }\n+\n+        if ($newContent !== $usefulContent) {\n+            // limiting to 1 replacement to prevent errors like\n+            // \"integer $integer\" being converted to \"int $int\"","path":"Symfony/CS/Fixer/Symfony/PhpdocScalarFixer.php","position":86,"original_position":86,"commit_id":"6f2dbc0f8ee5ed0dcfc1212f87ccb0a2fada1094","original_commit_id":"6f2dbc0f8ee5ed0dcfc1212f87ccb0a2fada1094","user":{"login":"GrahamCampbell","id":2829600,"avatar_url":"https://avatars.githubusercontent.com/u/2829600?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamCampbell","html_url":"https://github.com/GrahamCampbell","followers_url":"https://api.github.com/users/GrahamCampbell/followers","following_url":"https://api.github.com/users/GrahamCampbell/following{/other_user}","gists_url":"https://api.github.com/users/GrahamCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamCampbell/subscriptions","organizations_url":"https://api.github.com/users/GrahamCampbell/orgs","repos_url":"https://api.github.com/users/GrahamCampbell/repos","events_url":"https://api.github.com/users/GrahamCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamCampbell/received_events","type":"User","site_admin":false},"body":"I do have a test for this, but with bool and boolean. Basically the same, and works because of the identical code.","created_at":"2015-03-01T20:45:57Z","updated_at":"2015-03-01T20:45:57Z","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1037#discussion_r25571210","pull_request_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037","_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/25571210"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1037#discussion_r25571210"},"pull_request":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037"}}},"pull_request":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037","id":30226730,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1037","diff_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1037.diff","patch_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1037.patch","issue_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1037","number":1037,"state":"open","locked":false,"title":"Added phpdoc scalar fixer","user":{"login":"GrahamCampbell","id":2829600,"avatar_url":"https://avatars.githubusercontent.com/u/2829600?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamCampbell","html_url":"https://github.com/GrahamCampbell","followers_url":"https://api.github.com/users/GrahamCampbell/followers","following_url":"https://api.github.com/users/GrahamCampbell/following{/other_user}","gists_url":"https://api.github.com/users/GrahamCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamCampbell/subscriptions","organizations_url":"https://api.github.com/users/GrahamCampbell/orgs","repos_url":"https://api.github.com/users/GrahamCampbell/repos","events_url":"https://api.github.com/users/GrahamCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamCampbell/received_events","type":"User","site_admin":false},"body":"This fixer had to be taken out of my original massive phpdoc fixer pull request. Now it's time to bring it back.","created_at":"2015-02-28T16:46:16Z","updated_at":"2015-03-01T20:45:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d09e3224052b3211ef91eb9941933bf2356af38a","assignee":null,"milestone":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/milestones/9","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/milestones/v1.6","labels_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/milestones/9/labels","id":995302,"number":9,"title":"v1.6","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":2,"closed_issues":1,"state":"open","created_at":"2015-02-25T15:06:26Z","updated_at":"2015-03-01T20:22:12Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037/commits","review_comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037/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/1037/comments","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/6f2dbc0f8ee5ed0dcfc1212f87ccb0a2fada1094","head":{"label":"GrahamForks:1.6-phpdoc-scalar","ref":"1.6-phpdoc-scalar","sha":"6f2dbc0f8ee5ed0dcfc1212f87ccb0a2fada1094","user":{"login":"GrahamForks","id":10179291,"avatar_url":"https://avatars.githubusercontent.com/u/10179291?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamForks","html_url":"https://github.com/GrahamForks","followers_url":"https://api.github.com/users/GrahamForks/followers","following_url":"https://api.github.com/users/GrahamForks/following{/other_user}","gists_url":"https://api.github.com/users/GrahamForks/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamForks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamForks/subscriptions","organizations_url":"https://api.github.com/users/GrahamForks/orgs","repos_url":"https://api.github.com/users/GrahamForks/repos","events_url":"https://api.github.com/users/GrahamForks/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamForks/received_events","type":"Organization","site_admin":false},"repo":{"id":27316229,"name":"PHP-CS-Fixer","full_name":"GrahamForks/PHP-CS-Fixer","owner":{"login":"GrahamForks","id":10179291,"avatar_url":"https://avatars.githubusercontent.com/u/10179291?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamForks","html_url":"https://github.com/GrahamForks","followers_url":"https://api.github.com/users/GrahamForks/followers","following_url":"https://api.github.com/users/GrahamForks/following{/other_user}","gists_url":"https://api.github.com/users/GrahamForks/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamForks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamForks/subscriptions","organizations_url":"https://api.github.com/users/GrahamForks/orgs","repos_url":"https://api.github.com/users/GrahamForks/repos","events_url":"https://api.github.com/users/GrahamForks/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamForks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GrahamForks/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/GrahamForks/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/issues/comments{/number}","contents_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/GrahamForks/PHP-CS-Fixer/releases{/id}","created_at":"2014-11-29T21:55:32Z","updated_at":"2015-02-28T15:58:43Z","pushed_at":"2015-02-28T21:06:16Z","git_url":"git://github.com/GrahamForks/PHP-CS-Fixer.git","ssh_url":"git@github.com:GrahamForks/PHP-CS-Fixer.git","clone_url":"https://github.com/GrahamForks/PHP-CS-Fixer.git","svn_url":"https://github.com/GrahamForks/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":3014,"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":"1.5"}},"base":{"label":"FriendsOfPHP:1.6","ref":"1.6","sha":"5bb005502e71759aa0ee0c0c1b051967dee29d2d","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-03-01T20:17:38Z","pushed_at":"2015-03-01T20:17:38Z","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":10679,"stargazers_count":1994,"watchers_count":1994,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":316,"mirror_url":null,"open_issues_count":49,"forks":316,"open_issues":49,"watchers":1994,"default_branch":"1.5"}},"_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1037"},"issue":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1037"},"comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1037/comments"},"review_comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1037/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/1037/commits"},"statuses":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/6f2dbc0f8ee5ed0dcfc1212f87ccb0a2fada1094"}}}}