{"action":"created","issue":{"url":"https://api.github.com/repos/phpspec/prophecy/issues/286","repository_url":"https://api.github.com/repos/phpspec/prophecy","labels_url":"https://api.github.com/repos/phpspec/prophecy/issues/286/labels{/name}","comments_url":"https://api.github.com/repos/phpspec/prophecy/issues/286/comments","events_url":"https://api.github.com/repos/phpspec/prophecy/issues/286/events","html_url":"https://github.com/phpspec/prophecy/issues/286","id":176961502,"number":286,"title":"PHP 7.1 nullable arguments throws ParseError","user":{"login":"danizord","id":1850941,"avatar_url":"https://avatars.githubusercontent.com/u/1850941?v=3","gravatar_id":"","url":"https://api.github.com/users/danizord","html_url":"https://github.com/danizord","followers_url":"https://api.github.com/users/danizord/followers","following_url":"https://api.github.com/users/danizord/following{/other_user}","gists_url":"https://api.github.com/users/danizord/gists{/gist_id}","starred_url":"https://api.github.com/users/danizord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danizord/subscriptions","organizations_url":"https://api.github.com/users/danizord/orgs","repos_url":"https://api.github.com/users/danizord/repos","events_url":"https://api.github.com/users/danizord/events{/privacy}","received_events_url":"https://api.github.com/users/danizord/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-09-14T16:53:13Z","updated_at":"2016-09-28T19:02:35Z","closed_at":null,"body":"In PHP 7.1 (RC 1), the `ReflectionParameter::getType()` method returns the type with a leading `?` when the default value is null: https://3v4l.org/MERq5\r\n\r\nSo, when prophesizing a class which contains scalar typehint with default vale as null, the argument typehint is falling [here](https://github.com/phpspec/prophecy/blob/588bdd96556ecfdba4beceda6629e89b13d12654/src/Prophecy/Doubler/Generator/ClassCodeGenerator.php#L92-L96), and `ClassCodeGenerator` is adding a leading backslash to the typehint, which becomes `\\?string`.\r\n\r\nThat makes the `ClassCreator` throw a `ParseError` when parsing the class code [here](https://github.com/phpspec/prophecy/blob/588bdd96556ecfdba4beceda6629e89b13d12654/src/Prophecy/Doubler/Generator/ClassCreator.php#L49):\r\n\r\n>ParseError: syntax error, unexpected '?', expecting identifier (T_STRING)\r\n\r\nHow should we proceed to fix this issue?"},"comment":{"url":"https://api.github.com/repos/phpspec/prophecy/issues/comments/250266601","html_url":"https://github.com/phpspec/prophecy/issues/286#issuecomment-250266601","issue_url":"https://api.github.com/repos/phpspec/prophecy/issues/286","id":250266601,"user":{"login":"ciaranmcnulty","id":237866,"avatar_url":"https://avatars.githubusercontent.com/u/237866?v=3","gravatar_id":"","url":"https://api.github.com/users/ciaranmcnulty","html_url":"https://github.com/ciaranmcnulty","followers_url":"https://api.github.com/users/ciaranmcnulty/followers","following_url":"https://api.github.com/users/ciaranmcnulty/following{/other_user}","gists_url":"https://api.github.com/users/ciaranmcnulty/gists{/gist_id}","starred_url":"https://api.github.com/users/ciaranmcnulty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciaranmcnulty/subscriptions","organizations_url":"https://api.github.com/users/ciaranmcnulty/orgs","repos_url":"https://api.github.com/users/ciaranmcnulty/repos","events_url":"https://api.github.com/users/ciaranmcnulty/events{/privacy}","received_events_url":"https://api.github.com/users/ciaranmcnulty/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T19:02:35Z","updated_at":"2016-09-28T19:02:35Z","body":"Looks like https://github.com/php/php-src/pull/2137 got merged 🎉 "}}
{"actor":{"display_login":"ciaranmcnulty"}}