{"action":"created","comment":{"url":"https://api.github.com/repos/doctrine/doctrine2/pulls/comments/66221197","id":66221197,"diff_hunk":"@@ -820,39 +821,48 @@ public function initializeObject($obj)\n     /**\n      * Factory method to create EntityManager instances.\n      *\n-     * @param mixed         $conn         An array with the connection parameters or an existing Connection instance.\n-     * @param Configuration $config       The Configuration instance to use.\n-     * @param EventManager  $eventManager The EventManager instance to use.\n+     * @param array|Connection $connection   An array with the connection parameters or an existing Connection instance.\n+     * @param Configuration    $config       The Configuration instance to use.\n+     * @param EventManager     $eventManager The EventManager instance to use.\n      *\n      * @return EntityManager The created EntityManager.\n      *\n      * @throws \\InvalidArgumentException\n      * @throws ORMException\n      */\n-    public static function create($conn, Configuration $config, EventManager $eventManager = null)\n+    public static function create($connection, Configuration $config, EventManager $eventManager = null)\n     {\n         if ( ! $config->getMetadataDriverImpl()) {\n             throw ORMException::missingMappingDriverImpl();\n         }\n \n-        switch (true) {\n-            case (is_array($conn)):\n-                $conn = \\Doctrine\\DBAL\\DriverManager::getConnection(\n-                    $conn, $config, ($eventManager ?: new EventManager())\n-                );\n-                break;\n+        $connection = static::createConnection($connection, $config, $eventManager);\n \n-            case ($conn instanceof Connection):\n-                if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {\n-                     throw ORMException::mismatchedEventManager();\n-                }\n-                break;\n+        return new EntityManager($connection, $config, $connection->getEventManager());\n+    }\n \n-            default:\n-                throw new \\InvalidArgumentException(\"Invalid argument: \" . $conn);\n+    /**\n+     * Factory method to create Connection instances.\n+     *\n+     * @param array|Connection $connection   An array with the connection parameters or an existing Connection instance.\n+     * @param Configuration    $config       The Configuration instance to use.\n+     * @param EventManager     $eventManager The EventManager instance to use.\n+     *\n+     * @return Connection\n+     *\n+     * @throws \\InvalidArgumentException\n+     */\n+    protected static function createConnection($connection, Configuration $config, EventManager $eventManager = null)\n+    {\n+        if (is_array($connection)) {\n+            return DriverManager::getConnection($connection, $config, $eventManager ?: new EventManager());\n+        }\n+\n+        if ( ! $connection instanceof Connection) {\n+            throw new \\InvalidArgumentException(\"Invalid argument: \" . $connection);\n         }\n \n-        return new EntityManager($conn, $config, $conn->getEventManager());\n+        return $connection;","path":"lib/Doctrine/ORM/EntityManager.php","position":113,"original_position":113,"commit_id":"c0a87597fabf6dc0530e1ddde3b0203175e5687f","original_commit_id":"c0a87597fabf6dc0530e1ddde3b0203175e5687f","user":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"body":"Checking whether `$conn->getEventManager() === $eventManager` is still required (sorry, previous comment may have been misleading)","created_at":"2016-06-08T09:18:12Z","updated_at":"2016-06-08T09:18:12Z","html_url":"https://github.com/doctrine/doctrine2/pull/5860#discussion_r66221197","pull_request_url":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860","_links":{"self":{"href":"https://api.github.com/repos/doctrine/doctrine2/pulls/comments/66221197"},"html":{"href":"https://github.com/doctrine/doctrine2/pull/5860#discussion_r66221197"},"pull_request":{"href":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860"}}},"pull_request":{"url":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860","id":72998517,"html_url":"https://github.com/doctrine/doctrine2/pull/5860","diff_url":"https://github.com/doctrine/doctrine2/pull/5860.diff","patch_url":"https://github.com/doctrine/doctrine2/pull/5860.patch","issue_url":"https://api.github.com/repos/doctrine/doctrine2/issues/5860","number":5860,"state":"open","locked":false,"title":"Change switch/case to if/else","user":{"login":"peter-gribanov","id":1954436,"avatar_url":"https://avatars.githubusercontent.com/u/1954436?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-gribanov","html_url":"https://github.com/peter-gribanov","followers_url":"https://api.github.com/users/peter-gribanov/followers","following_url":"https://api.github.com/users/peter-gribanov/following{/other_user}","gists_url":"https://api.github.com/users/peter-gribanov/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-gribanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-gribanov/subscriptions","organizations_url":"https://api.github.com/users/peter-gribanov/orgs","repos_url":"https://api.github.com/users/peter-gribanov/repos","events_url":"https://api.github.com/users/peter-gribanov/events{/privacy}","received_events_url":"https://api.github.com/users/peter-gribanov/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-08T07:30:17Z","updated_at":"2016-06-08T09:18:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"167e40909fa8926b5c116d849b60cbf2571b9cdf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860/commits","review_comments_url":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860/comments","review_comment_url":"https://api.github.com/repos/doctrine/doctrine2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/5860/comments","statuses_url":"https://api.github.com/repos/doctrine/doctrine2/statuses/c0a87597fabf6dc0530e1ddde3b0203175e5687f","head":{"label":"peter-gribanov:master","ref":"master","sha":"c0a87597fabf6dc0530e1ddde3b0203175e5687f","user":{"login":"peter-gribanov","id":1954436,"avatar_url":"https://avatars.githubusercontent.com/u/1954436?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-gribanov","html_url":"https://github.com/peter-gribanov","followers_url":"https://api.github.com/users/peter-gribanov/followers","following_url":"https://api.github.com/users/peter-gribanov/following{/other_user}","gists_url":"https://api.github.com/users/peter-gribanov/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-gribanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-gribanov/subscriptions","organizations_url":"https://api.github.com/users/peter-gribanov/orgs","repos_url":"https://api.github.com/users/peter-gribanov/repos","events_url":"https://api.github.com/users/peter-gribanov/events{/privacy}","received_events_url":"https://api.github.com/users/peter-gribanov/received_events","type":"User","site_admin":false},"repo":{"id":60677585,"name":"doctrine2","full_name":"peter-gribanov/doctrine2","owner":{"login":"peter-gribanov","id":1954436,"avatar_url":"https://avatars.githubusercontent.com/u/1954436?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-gribanov","html_url":"https://github.com/peter-gribanov","followers_url":"https://api.github.com/users/peter-gribanov/followers","following_url":"https://api.github.com/users/peter-gribanov/following{/other_user}","gists_url":"https://api.github.com/users/peter-gribanov/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-gribanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-gribanov/subscriptions","organizations_url":"https://api.github.com/users/peter-gribanov/orgs","repos_url":"https://api.github.com/users/peter-gribanov/repos","events_url":"https://api.github.com/users/peter-gribanov/events{/privacy}","received_events_url":"https://api.github.com/users/peter-gribanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peter-gribanov/doctrine2","description":"Doctrine 2 Object Relational Mapper (ORM)","fork":true,"url":"https://api.github.com/repos/peter-gribanov/doctrine2","forks_url":"https://api.github.com/repos/peter-gribanov/doctrine2/forks","keys_url":"https://api.github.com/repos/peter-gribanov/doctrine2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peter-gribanov/doctrine2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peter-gribanov/doctrine2/teams","hooks_url":"https://api.github.com/repos/peter-gribanov/doctrine2/hooks","issue_events_url":"https://api.github.com/repos/peter-gribanov/doctrine2/issues/events{/number}","events_url":"https://api.github.com/repos/peter-gribanov/doctrine2/events","assignees_url":"https://api.github.com/repos/peter-gribanov/doctrine2/assignees{/user}","branches_url":"https://api.github.com/repos/peter-gribanov/doctrine2/branches{/branch}","tags_url":"https://api.github.com/repos/peter-gribanov/doctrine2/tags","blobs_url":"https://api.github.com/repos/peter-gribanov/doctrine2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peter-gribanov/doctrine2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peter-gribanov/doctrine2/git/refs{/sha}","trees_url":"https://api.github.com/repos/peter-gribanov/doctrine2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peter-gribanov/doctrine2/statuses/{sha}","languages_url":"https://api.github.com/repos/peter-gribanov/doctrine2/languages","stargazers_url":"https://api.github.com/repos/peter-gribanov/doctrine2/stargazers","contributors_url":"https://api.github.com/repos/peter-gribanov/doctrine2/contributors","subscribers_url":"https://api.github.com/repos/peter-gribanov/doctrine2/subscribers","subscription_url":"https://api.github.com/repos/peter-gribanov/doctrine2/subscription","commits_url":"https://api.github.com/repos/peter-gribanov/doctrine2/commits{/sha}","git_commits_url":"https://api.github.com/repos/peter-gribanov/doctrine2/git/commits{/sha}","comments_url":"https://api.github.com/repos/peter-gribanov/doctrine2/comments{/number}","issue_comment_url":"https://api.github.com/repos/peter-gribanov/doctrine2/issues/comments{/number}","contents_url":"https://api.github.com/repos/peter-gribanov/doctrine2/contents/{+path}","compare_url":"https://api.github.com/repos/peter-gribanov/doctrine2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peter-gribanov/doctrine2/merges","archive_url":"https://api.github.com/repos/peter-gribanov/doctrine2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peter-gribanov/doctrine2/downloads","issues_url":"https://api.github.com/repos/peter-gribanov/doctrine2/issues{/number}","pulls_url":"https://api.github.com/repos/peter-gribanov/doctrine2/pulls{/number}","milestones_url":"https://api.github.com/repos/peter-gribanov/doctrine2/milestones{/number}","notifications_url":"https://api.github.com/repos/peter-gribanov/doctrine2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peter-gribanov/doctrine2/labels{/name}","releases_url":"https://api.github.com/repos/peter-gribanov/doctrine2/releases{/id}","deployments_url":"https://api.github.com/repos/peter-gribanov/doctrine2/deployments","created_at":"2016-06-08T07:24:25Z","updated_at":"2016-06-08T07:24:30Z","pushed_at":"2016-06-08T08:47:23Z","git_url":"git://github.com/peter-gribanov/doctrine2.git","ssh_url":"git@github.com:peter-gribanov/doctrine2.git","clone_url":"https://github.com/peter-gribanov/doctrine2.git","svn_url":"https://github.com/peter-gribanov/doctrine2","homepage":"http://www.doctrine-project.org","size":27306,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"doctrine:master","ref":"master","sha":"3bc61d5f5e4aa75479dfe141e52326243972f530","user":{"login":"doctrine","id":209254,"avatar_url":"https://avatars.githubusercontent.com/u/209254?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"repo":{"id":597887,"name":"doctrine2","full_name":"doctrine/doctrine2","owner":{"login":"doctrine","id":209254,"avatar_url":"https://avatars.githubusercontent.com/u/209254?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/doctrine/doctrine2","description":"Doctrine 2 Object Relational Mapper (ORM)","fork":false,"url":"https://api.github.com/repos/doctrine/doctrine2","forks_url":"https://api.github.com/repos/doctrine/doctrine2/forks","keys_url":"https://api.github.com/repos/doctrine/doctrine2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/doctrine/doctrine2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/doctrine/doctrine2/teams","hooks_url":"https://api.github.com/repos/doctrine/doctrine2/hooks","issue_events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/events{/number}","events_url":"https://api.github.com/repos/doctrine/doctrine2/events","assignees_url":"https://api.github.com/repos/doctrine/doctrine2/assignees{/user}","branches_url":"https://api.github.com/repos/doctrine/doctrine2/branches{/branch}","tags_url":"https://api.github.com/repos/doctrine/doctrine2/tags","blobs_url":"https://api.github.com/repos/doctrine/doctrine2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/doctrine/doctrine2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/doctrine/doctrine2/git/refs{/sha}","trees_url":"https://api.github.com/repos/doctrine/doctrine2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/doctrine/doctrine2/statuses/{sha}","languages_url":"https://api.github.com/repos/doctrine/doctrine2/languages","stargazers_url":"https://api.github.com/repos/doctrine/doctrine2/stargazers","contributors_url":"https://api.github.com/repos/doctrine/doctrine2/contributors","subscribers_url":"https://api.github.com/repos/doctrine/doctrine2/subscribers","subscription_url":"https://api.github.com/repos/doctrine/doctrine2/subscription","commits_url":"https://api.github.com/repos/doctrine/doctrine2/commits{/sha}","git_commits_url":"https://api.github.com/repos/doctrine/doctrine2/git/commits{/sha}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/comments{/number}","issue_comment_url":"https://api.github.com/repos/doctrine/doctrine2/issues/comments{/number}","contents_url":"https://api.github.com/repos/doctrine/doctrine2/contents/{+path}","compare_url":"https://api.github.com/repos/doctrine/doctrine2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/doctrine/doctrine2/merges","archive_url":"https://api.github.com/repos/doctrine/doctrine2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/doctrine/doctrine2/downloads","issues_url":"https://api.github.com/repos/doctrine/doctrine2/issues{/number}","pulls_url":"https://api.github.com/repos/doctrine/doctrine2/pulls{/number}","milestones_url":"https://api.github.com/repos/doctrine/doctrine2/milestones{/number}","notifications_url":"https://api.github.com/repos/doctrine/doctrine2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/doctrine/doctrine2/labels{/name}","releases_url":"https://api.github.com/repos/doctrine/doctrine2/releases{/id}","deployments_url":"https://api.github.com/repos/doctrine/doctrine2/deployments","created_at":"2010-04-06T21:42:59Z","updated_at":"2016-06-08T08:10:30Z","pushed_at":"2016-06-08T08:47:24Z","git_url":"git://github.com/doctrine/doctrine2.git","ssh_url":"git@github.com:doctrine/doctrine2.git","clone_url":"https://github.com/doctrine/doctrine2.git","svn_url":"https://github.com/doctrine/doctrine2","homepage":"http://www.doctrine-project.org","size":37266,"stargazers_count":3071,"watchers_count":3071,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1506,"mirror_url":null,"open_issues_count":1046,"forks":1506,"open_issues":1046,"watchers":3071,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860"},"html":{"href":"https://github.com/doctrine/doctrine2/pull/5860"},"issue":{"href":"https://api.github.com/repos/doctrine/doctrine2/issues/5860"},"comments":{"href":"https://api.github.com/repos/doctrine/doctrine2/issues/5860/comments"},"review_comments":{"href":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860/comments"},"review_comment":{"href":"https://api.github.com/repos/doctrine/doctrine2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/doctrine/doctrine2/pulls/5860/commits"},"statuses":{"href":"https://api.github.com/repos/doctrine/doctrine2/statuses/c0a87597fabf6dc0530e1ddde3b0203175e5687f"}}}}
{"actor":{"display_login":"Ocramius"}}