{"action":"created","comment":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/59553892","id":59553892,"diff_hunk":"@@ -0,0 +1,145 @@\n+<?php\n+\n+/*\n+ * This file is part of PHP CS Fixer.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *     Dariusz Rumiński <dariusz.ruminski@gmail.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 PhpCsFixer\\Report;\n+\n+/**\n+ * @author Boris Gorbylev <ekho@ekho.name>\n+ *\n+ * @internal\n+ */\n+final class JunitReporter implements ReporterInterface\n+{\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function getFormat()\n+    {\n+        return 'junit';\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function generate(ReportSummary $reportSummary)\n+    {\n+        $dom = new \\DOMDocument('1.0', 'UTF-8');\n+        $testsuites = $dom->appendChild($dom->createElement('testsuites'));\n+        /** @var \\DomElement $testsuite */\n+        $testsuite = $testsuites->appendChild($dom->createElement('testsuite'));\n+        $testsuite->setAttribute('name', 'PHP CS Fixer report');\n+\n+        if (count($reportSummary->getChanged())) {\n+            $this->createFailedTestCases($dom, $testsuite, $reportSummary);\n+        } else {\n+            $this->createSuccessTestCase($dom, $testsuite);\n+        }\n+\n+        if ($reportSummary->getTime()) {\n+            $testsuite->setAttribute(\n+                'time',\n+                sprintf(\n+                    '%.3f',\n+                    $reportSummary->getTime() / 1000\n+                )\n+            );\n+        }\n+\n+        $dom->formatOutput = true;\n+\n+        return $dom->saveXML();\n+    }\n+\n+    private function createSuccessTestCase(\\DOMDocument $dom, \\DOMElement $testsuite)\n+    {\n+        $testcase = $dom->createElement('testcase');\n+        $testcase->setAttribute('name', 'All OK');\n+        $testcase->setAttribute('assertions', 1);\n+\n+        $testsuite->appendChild($testcase);\n+        $testsuite->setAttribute('tests', 1);\n+        $testsuite->setAttribute('assertions', 1);\n+        $testsuite->setAttribute('failures', 0);\n+        $testsuite->setAttribute('errors', 0);\n+    }\n+\n+    /**\n+     * @param \\DOMDocument  $dom\n+     * @param \\DOMElement   $testsuite\n+     * @param ReportSummary $reportSummary\n+     */\n+    private function createFailedTestCases(\\DOMDocument $dom, \\DOMElement $testsuite, ReportSummary $reportSummary)\n+    {\n+        $assertionsCount = 0;\n+        foreach ($reportSummary->getChanged() as $file => $fixResult) {\n+            $testcase = $this->createFailedTestCase(\n+                $dom,\n+                $file,\n+                $fixResult,\n+                $reportSummary->shouldAddAppliedFixers()\n+            );\n+            $testsuite->appendChild($testcase);\n+            $assertionsCount += (int) $testcase->getAttribute('assertions');\n+        }\n+\n+        $testsuite->setAttribute('tests', count($reportSummary->getChanged()));\n+        $testsuite->setAttribute('assertions', $assertionsCount);\n+        $testsuite->setAttribute('failures', $assertionsCount);\n+        $testsuite->setAttribute('errors', 0);\n+    }\n+\n+    /**\n+     * @param \\DOMDocument $dom\n+     * @param string       $file\n+     * @param array        $fixResult\n+     * @param bool         $addAppliedFixers\n+     *\n+     * @return \\DOMElement\n+     */\n+    private function createFailedTestCase(\\DOMDocument $dom, $file, array $fixResult, $addAppliedFixers)\n+    {\n+        $appliedFixersCount = count($fixResult['appliedFixers']);\n+\n+        $testName = str_replace('.', '_DOT_', preg_replace('@\\.'.pathinfo($file, PATHINFO_EXTENSION).'$@', '', $file));\n+\n+        $testcase = $dom->createElement('testcase');\n+        $testcase->setAttribute('name', $testName);\n+        $testcase->setAttribute('class', $testName);\n+        $testcase->setAttribute('file', $file);\n+        $testcase->setAttribute('assertions', $appliedFixersCount);\n+\n+        if ($addAppliedFixers) {\n+            foreach ($fixResult['appliedFixers'] as $appliedFixer) {\n+                $failure = $dom->createElement('failure');\n+                $failure->setAttribute('type', $appliedFixer);","path":"src/Report/JunitReporter.php","position":123,"original_position":123,"commit_id":"c8c12b03632f80f8e421e7d6ba1af5f1446fc41f","original_commit_id":"c8c12b03632f80f8e421e7d6ba1af5f1446fc41f","user":{"login":"ekho","id":374426,"avatar_url":"https://avatars.githubusercontent.com/u/374426?v=3","gravatar_id":"","url":"https://api.github.com/users/ekho","html_url":"https://github.com/ekho","followers_url":"https://api.github.com/users/ekho/followers","following_url":"https://api.github.com/users/ekho/following{/other_user}","gists_url":"https://api.github.com/users/ekho/gists{/gist_id}","starred_url":"https://api.github.com/users/ekho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekho/subscriptions","organizations_url":"https://api.github.com/users/ekho/orgs","repos_url":"https://api.github.com/users/ekho/repos","events_url":"https://api.github.com/users/ekho/events{/privacy}","received_events_url":"https://api.github.com/users/ekho/received_events","type":"User","site_admin":false},"body":"when `--verbose` then `type` is a fixer name\r\nelse we must show whatever, I chose `csc`","created_at":"2016-04-13T14:08:31Z","updated_at":"2016-04-13T14:08:31Z","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1825#discussion_r59553892","pull_request_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825","_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/59553892"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1825#discussion_r59553892"},"pull_request":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825"}}},"pull_request":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825","id":62778314,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1825","diff_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1825.diff","patch_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1825.patch","issue_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1825","number":1825,"state":"open","locked":false,"title":"Added junit format","user":{"login":"ekho","id":374426,"avatar_url":"https://avatars.githubusercontent.com/u/374426?v=3","gravatar_id":"","url":"https://api.github.com/users/ekho","html_url":"https://github.com/ekho","followers_url":"https://api.github.com/users/ekho/followers","following_url":"https://api.github.com/users/ekho/following{/other_user}","gists_url":"https://api.github.com/users/ekho/gists{/gist_id}","starred_url":"https://api.github.com/users/ekho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekho/subscriptions","organizations_url":"https://api.github.com/users/ekho/orgs","repos_url":"https://api.github.com/users/ekho/repos","events_url":"https://api.github.com/users/ekho/events{/privacy}","received_events_url":"https://api.github.com/users/ekho/received_events","type":"User","site_admin":false},"body":"This pull request allowes to use php-cs-fixer in CI\r\n\r\nDepends on #1824 ","created_at":"2016-03-14T16:40:43Z","updated_at":"2016-04-13T14:08:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9db766eafa28ca02f307577d28f6fded22141555","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825/commits","review_comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825/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/1825/comments","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/c8c12b03632f80f8e421e7d6ba1af5f1446fc41f","head":{"label":"bankiru:feature-junit-format","ref":"feature-junit-format","sha":"c8c12b03632f80f8e421e7d6ba1af5f1446fc41f","user":{"login":"bankiru","id":7599828,"avatar_url":"https://avatars.githubusercontent.com/u/7599828?v=3","gravatar_id":"","url":"https://api.github.com/users/bankiru","html_url":"https://github.com/bankiru","followers_url":"https://api.github.com/users/bankiru/followers","following_url":"https://api.github.com/users/bankiru/following{/other_user}","gists_url":"https://api.github.com/users/bankiru/gists{/gist_id}","starred_url":"https://api.github.com/users/bankiru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bankiru/subscriptions","organizations_url":"https://api.github.com/users/bankiru/orgs","repos_url":"https://api.github.com/users/bankiru/repos","events_url":"https://api.github.com/users/bankiru/events{/privacy}","received_events_url":"https://api.github.com/users/bankiru/received_events","type":"Organization","site_admin":false},"repo":{"id":53840909,"name":"PHP-CS-Fixer","full_name":"bankiru/PHP-CS-Fixer","owner":{"login":"bankiru","id":7599828,"avatar_url":"https://avatars.githubusercontent.com/u/7599828?v=3","gravatar_id":"","url":"https://api.github.com/users/bankiru","html_url":"https://github.com/bankiru","followers_url":"https://api.github.com/users/bankiru/followers","following_url":"https://api.github.com/users/bankiru/following{/other_user}","gists_url":"https://api.github.com/users/bankiru/gists{/gist_id}","starred_url":"https://api.github.com/users/bankiru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bankiru/subscriptions","organizations_url":"https://api.github.com/users/bankiru/orgs","repos_url":"https://api.github.com/users/bankiru/repos","events_url":"https://api.github.com/users/bankiru/events{/privacy}","received_events_url":"https://api.github.com/users/bankiru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bankiru/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/bankiru/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/issues/comments{/number}","contents_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/releases{/id}","deployments_url":"https://api.github.com/repos/bankiru/PHP-CS-Fixer/deployments","created_at":"2016-03-14T08:56:26Z","updated_at":"2016-03-14T08:56:28Z","pushed_at":"2016-04-10T06:35:59Z","git_url":"git://github.com/bankiru/PHP-CS-Fixer.git","ssh_url":"git@github.com:bankiru/PHP-CS-Fixer.git","clone_url":"https://github.com/bankiru/PHP-CS-Fixer.git","svn_url":"https://github.com/bankiru/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":5407,"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:master","ref":"master","sha":"73e8bd847e74f0b920880d7decff767deb66ca14","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}","deployments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/deployments","created_at":"2012-05-16T06:42:23Z","updated_at":"2016-04-13T03:27:41Z","pushed_at":"2016-04-13T07:25:41Z","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":10924,"stargazers_count":3137,"watchers_count":3137,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":476,"mirror_url":null,"open_issues_count":128,"forks":476,"open_issues":128,"watchers":3137,"default_branch":"1.11"}},"_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1825"},"issue":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1825"},"comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1825/comments"},"review_comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1825/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/1825/commits"},"statuses":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/c8c12b03632f80f8e421e7d6ba1af5f1446fc41f"}}}}