GitHub PullRequestReviewCommentEvent at 2014-10-16 19:38:33
Repository: PHP-CS-Fixer
Actor: keradus
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/comments/18980677","id":18980677,"diff_hunk":"@@ -0,0 +1,128 @@\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;\n+\n+/**\n+ * @author Fabien Potencier <fabien@symfony.com>\n+ * @author Katsuhiro Ogawa <ko.fivestar@gmail.com>\n+ */\n+class FixersResolver\n+{\n+    protected $allFixers;\n+    protected $fixers;\n+    protected $config;\n+\n+    public function __construct(array $allFixers, ConfigInterface $config)\n+    {\n+        $this->allFixers = $allFixers;\n+        $this->fixers = $allFixers;\n+        $this->config = $config;\n+    }\n+\n+    public function resolve($levelOption, $fixerOption)\n+    {\n+        $this->resolveByLevel($levelOption, $fixerOption);\n+        $this->resolveByNames($fixerOption);\n+\n+        return $this->getFixers();\n+    }\n+\n+    public function getFixers()\n+    {\n+        return $this->fixers;\n+    }\n+\n+    protected function resolveByLevel($levelOption, $fixerOption)\n+    {\n+        $level = $this->parseLevelOption($levelOption, $fixerOption);\n+\n+        $fixers = array();\n+\n+        foreach ($this->allFixers as $fixer) {\n+            if ($fixer->getLevel() === ($fixer->getLevel() & $level)) {\n+                $fixers[] = $fixer;\n+            }\n+        }\n+\n+        $this->fixers = $fixers;\n+    }\n+\n+    protected function resolveByNames($fixerOption)\n+    {\n+        $names = $this->parseFixerOption($fixerOption);\n+\n+        $addNames = array();\n+        $removeNames = array();\n+        foreach ($names as $name) {\n+            if (0 === strpos($name, '-')) {\n+                $removeNames[ltrim($name, '-')] = true;\n+            } else {\n+                $addNames[$name] = true;\n+            }\n+        }\n+\n+        foreach ($this->fixers as $key => $fixer) {\n+            if (isset($removeNames[$fixer->getName()])) {\n+                unset($this->fixers[$key]);\n+            }\n+        }\n+\n+        foreach ($this->allFixers as $fixer) {\n+            if (isset($addNames[$fixer->getName()]) && !in_array($fixer, $this->fixers, true)) {\n+                $this->fixers[] = $fixer;\n+            }\n+        }\n+    }\n+\n+    protected function parseLevelOption($levelOption, $fixerOption)\n+    {\n+        static $levelMap = array(\n+            'psr0'    => FixerInterface::PSR0_LEVEL,\n+            'psr1'    => FixerInterface::PSR1_LEVEL,\n+            'psr2'    => FixerInterface::PSR2_LEVEL,\n+            'symfony' => FixerInterface::SYMFONY_LEVEL,\n+        );\n+\n+        if (isset($levelMap[$levelOption])) {\n+            $level = $levelMap[$levelOption];\n+        } elseif (null === $levelOption) {\n+            $level = null;\n+\n+            $names = $this->parseFixerOption($fixerOption);\n+            if (empty($names)) {\n+                $level = $this->config->getLevel();\n+            } else {\n+                foreach ($names as $name) {\n+                    if (0 === strpos($name, '-')) {\n+                        $level = $this->config->getLevel();\n+                        break;\n+                    }\n+                }\n+            }\n+        } else {\n+            throw new \\InvalidArgumentException(sprintf('The level \"%s\" is not defined.', $levelOption));\n+        }\n+\n+        return $level;\n+    }\n+\n+    protected function parseFixerOption($fixerOption)\n+    {\n+        if (null === $fixerOption) {\n+            $names = $this->config->getFixers();\n+        } else {\n+            $names = array_map('trim', explode(',', $fixerOption));\n+        }\n+\n+        return $names;","path":"Symfony/CS/FixersResolver.php","position":126,"original_position":126,"commit_id":"bd484aa5a8a09c39ddebb3987e565f8f42298166","original_commit_id":"bd484aa5a8a09c39ddebb3987e565f8f42298166","user":{"login":"keradus","id":2716794,"avatar_url":"https://avatars.githubusercontent.com/u/2716794?v=2","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":"```php\r\nif (null === $fixerOptions) {\r\n    return $this->config->getFixers();\r\n}\r\n\r\nreturn  array_map('trim', explode(',', $fixerOption));\r\n```","created_at":"2014-10-16T19:38:33Z","updated_at":"2014-10-16T19:38:33Z","html_url":"https://github.com/fabpot/PHP-CS-Fixer/pull/599#discussion_r18980677","pull_request_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599","_links":{"self":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/comments/18980677"},"html":{"href":"https://github.com/fabpot/PHP-CS-Fixer/pull/599#discussion_r18980677"},"pull_request":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599"}}},"pull_request":{"url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599","id":21778624,"html_url":"https://github.com/fabpot/PHP-CS-Fixer/pull/599","diff_url":"https://github.com/fabpot/PHP-CS-Fixer/pull/599.diff","patch_url":"https://github.com/fabpot/PHP-CS-Fixer/pull/599.patch","issue_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues/599","number":599,"state":"open","locked":false,"title":"Fix `fix` command to handle `--fixers` option when contains extra and excluding fixers","user":{"login":"fivestar","id":30999,"avatar_url":"https://avatars.githubusercontent.com/u/30999?v=2","gravatar_id":"","url":"https://api.github.com/users/fivestar","html_url":"https://github.com/fivestar","followers_url":"https://api.github.com/users/fivestar/followers","following_url":"https://api.github.com/users/fivestar/following{/other_user}","gists_url":"https://api.github.com/users/fivestar/gists{/gist_id}","starred_url":"https://api.github.com/users/fivestar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fivestar/subscriptions","organizations_url":"https://api.github.com/users/fivestar/orgs","repos_url":"https://api.github.com/users/fivestar/repos","events_url":"https://api.github.com/users/fivestar/events{/privacy}","received_events_url":"https://api.github.com/users/fivestar/received_events","type":"User","site_admin":false},"body":"Currently, when `--fixers` option contains extra and excluding mixed filters such as `-eol_ending,concat_with_spaces`, excluding filter will be enabled, however, extra filter will not be enabled.\r\n\r\nThis PR fixes this behavior, so enable both type filters when mixed filters given.\r\n\r\n----\r\n\r\n`sample.php`\r\n\r\n```php\r\n<?php\r\necho 'foo'.'bar', PHP_EOL;\r\n\r\n```\r\n\r\nCurrent version: (`concat_with_spaces` is not enabled)\r\n\r\n```\r\n% php-cs-fixer fix -v --diff --fixers=\"-eol_ending,concat_with_spaces\" --dry-run sample.php   \r\n   1) /home/fivestar/sample.php (eof_ending)\r\n      ---------- begin diff ----------\r\n      --- Original\r\n      +++ New\r\n      @@ @@\r\n       <?php\r\n       echo 'foo'.'bar', PHP_EOL;\r\n       \r\n      -\r\n      \r\n      ---------- end diff ----------\r\n```\r\n\r\nFixed version: (`concat_with_spaces` is enabled)\r\n\r\n```\r\n% php-cs-fixer fix -v --diff --fixers=\"-eol_ending,concat_with_spaces\" --dry-run sample.php \r\n   1) /home/fivestar/sample.php (eof_ending, concat_with_spaces)\r\n      ---------- begin diff ----------\r\n      --- Original\r\n      +++ New\r\n      @@ @@\r\n       <?php\r\n      -echo 'foo'.'bar', PHP_EOL;\r\n      -\r\n      +echo 'foo' . 'bar', PHP_EOL;\r\n       \r\n      \r\n      ---------- end diff ----------\r\n```","created_at":"2014-09-25T12:18:16Z","updated_at":"2014-10-16T19:38:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"112d2421a9780969839ac05de935e04abad4f787","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599/commits","review_comments_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599/comments","review_comment_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/comments/{number}","comments_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues/599/comments","statuses_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/statuses/bd484aa5a8a09c39ddebb3987e565f8f42298166","head":{"label":"fivestar:resolve-mixed-fixtures","ref":"resolve-mixed-fixtures","sha":"bd484aa5a8a09c39ddebb3987e565f8f42298166","user":{"login":"fivestar","id":30999,"avatar_url":"https://avatars.githubusercontent.com/u/30999?v=2","gravatar_id":"","url":"https://api.github.com/users/fivestar","html_url":"https://github.com/fivestar","followers_url":"https://api.github.com/users/fivestar/followers","following_url":"https://api.github.com/users/fivestar/following{/other_user}","gists_url":"https://api.github.com/users/fivestar/gists{/gist_id}","starred_url":"https://api.github.com/users/fivestar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fivestar/subscriptions","organizations_url":"https://api.github.com/users/fivestar/orgs","repos_url":"https://api.github.com/users/fivestar/repos","events_url":"https://api.github.com/users/fivestar/events{/privacy}","received_events_url":"https://api.github.com/users/fivestar/received_events","type":"User","site_admin":false},"repo":{"id":24455635,"name":"PHP-CS-Fixer","full_name":"fivestar/PHP-CS-Fixer","owner":{"login":"fivestar","id":30999,"avatar_url":"https://avatars.githubusercontent.com/u/30999?v=2","gravatar_id":"","url":"https://api.github.com/users/fivestar","html_url":"https://github.com/fivestar","followers_url":"https://api.github.com/users/fivestar/followers","following_url":"https://api.github.com/users/fivestar/following{/other_user}","gists_url":"https://api.github.com/users/fivestar/gists{/gist_id}","starred_url":"https://api.github.com/users/fivestar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fivestar/subscriptions","organizations_url":"https://api.github.com/users/fivestar/orgs","repos_url":"https://api.github.com/users/fivestar/repos","events_url":"https://api.github.com/users/fivestar/events{/privacy}","received_events_url":"https://api.github.com/users/fivestar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fivestar/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/fivestar/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/issues/comments/{number}","contents_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/fivestar/PHP-CS-Fixer/releases{/id}","created_at":"2014-09-25T11:36:23Z","updated_at":"2014-10-05T16:09:34Z","pushed_at":"2014-10-16T14:49:00Z","git_url":"git://github.com/fivestar/PHP-CS-Fixer.git","ssh_url":"git@github.com:fivestar/PHP-CS-Fixer.git","clone_url":"https://github.com/fivestar/PHP-CS-Fixer.git","svn_url":"https://github.com/fivestar/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":1374,"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":"fabpot:master","ref":"master","sha":"45a7ff3b135bb0abc5463a2055e4a8657b16ba55","user":{"login":"fabpot","id":47313,"avatar_url":"https://avatars.githubusercontent.com/u/47313?v=2","gravatar_id":"","url":"https://api.github.com/users/fabpot","html_url":"https://github.com/fabpot","followers_url":"https://api.github.com/users/fabpot/followers","following_url":"https://api.github.com/users/fabpot/following{/other_user}","gists_url":"https://api.github.com/users/fabpot/gists{/gist_id}","starred_url":"https://api.github.com/users/fabpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabpot/subscriptions","organizations_url":"https://api.github.com/users/fabpot/orgs","repos_url":"https://api.github.com/users/fabpot/repos","events_url":"https://api.github.com/users/fabpot/events{/privacy}","received_events_url":"https://api.github.com/users/fabpot/received_events","type":"User","site_admin":false},"repo":{"id":4344257,"name":"PHP-CS-Fixer","full_name":"fabpot/PHP-CS-Fixer","owner":{"login":"fabpot","id":47313,"avatar_url":"https://avatars.githubusercontent.com/u/47313?v=2","gravatar_id":"","url":"https://api.github.com/users/fabpot","html_url":"https://github.com/fabpot","followers_url":"https://api.github.com/users/fabpot/followers","following_url":"https://api.github.com/users/fabpot/following{/other_user}","gists_url":"https://api.github.com/users/fabpot/gists{/gist_id}","starred_url":"https://api.github.com/users/fabpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabpot/subscriptions","organizations_url":"https://api.github.com/users/fabpot/orgs","repos_url":"https://api.github.com/users/fabpot/repos","events_url":"https://api.github.com/users/fabpot/events{/privacy}","received_events_url":"https://api.github.com/users/fabpot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabpot/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/fabpot/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues/comments/{number}","contents_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/releases{/id}","created_at":"2012-05-16T06:42:23Z","updated_at":"2014-10-16T16:16:26Z","pushed_at":"2014-10-14T21:49:55Z","git_url":"git://github.com/fabpot/PHP-CS-Fixer.git","ssh_url":"git@github.com:fabpot/PHP-CS-Fixer.git","clone_url":"https://github.com/fabpot/PHP-CS-Fixer.git","svn_url":"https://github.com/fabpot/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":8443,"stargazers_count":1555,"watchers_count":1555,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":266,"mirror_url":null,"open_issues_count":47,"forks":266,"open_issues":47,"watchers":1555,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599"},"html":{"href":"https://github.com/fabpot/PHP-CS-Fixer/pull/599"},"issue":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues/599"},"comments":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/issues/599/comments"},"review_comments":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599/comments"},"review_comment":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/pulls/599/commits"},"statuses":{"href":"https://api.github.com/repos/fabpot/PHP-CS-Fixer/statuses/bd484aa5a8a09c39ddebb3987e565f8f42298166"}}}}