{"action":"closed","issue":{"url":"https://api.github.com/repos/phpstan/phpstan/issues/1116","repository_url":"https://api.github.com/repos/phpstan/phpstan","labels_url":"https://api.github.com/repos/phpstan/phpstan/issues/1116/labels{/name}","comments_url":"https://api.github.com/repos/phpstan/phpstan/issues/1116/comments","events_url":"https://api.github.com/repos/phpstan/phpstan/issues/1116/events","html_url":"https://github.com/phpstan/phpstan/issues/1116","id":335893174,"node_id":"MDU6SXNzdWUzMzU4OTMxNzQ=","number":1116,"title":"set_error_handler should return a callable?","user":{"login":"jaydiablo","id":136907,"node_id":"MDQ6VXNlcjEzNjkwNw==","avatar_url":"https://avatars0.githubusercontent.com/u/136907?v=4","gravatar_id":"","url":"https://api.github.com/users/jaydiablo","html_url":"https://github.com/jaydiablo","followers_url":"https://api.github.com/users/jaydiablo/followers","following_url":"https://api.github.com/users/jaydiablo/following{/other_user}","gists_url":"https://api.github.com/users/jaydiablo/gists{/gist_id}","starred_url":"https://api.github.com/users/jaydiablo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaydiablo/subscriptions","organizations_url":"https://api.github.com/users/jaydiablo/orgs","repos_url":"https://api.github.com/users/jaydiablo/repos","events_url":"https://api.github.com/users/jaydiablo/events{/privacy}","received_events_url":"https://api.github.com/users/jaydiablo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-26T16:12:20Z","updated_at":"2018-06-30T11:43:57Z","closed_at":"2018-06-30T11:43:57Z","author_association":"NONE","body":"<!-- Before reporting an issue please check that you are using the latest PHPStan version! -->\r\n\r\n### Summary of a problem or a feature request\r\n\r\nPHPstan is complaining that a property that is defined as type `callable` cannot accept type `string` returned from `set_error_handler`.\r\n\r\n### Code snippet that reproduces the problem\r\n\r\n```php\r\n<?php \r\n\r\nclass A {\r\n    /** @var callable|null */\r\n    protected $errorHandler = null;\r\n\r\n    public function __construct()\r\n    {\r\n        $this->errorHandler = set_error_handler([$this, 'errorHandler']);\r\n    }\r\n\r\n    public function errorHandler(int $errno, string $errstr, string $errfile = '', int $errline = 0, array $errcontext = []): bool\r\n    {\r\n        return false;\r\n    }\r\n}\r\n```\r\n\r\nhttps://phpstan.org/r/6bfa08eeb6ce5e4033da828bad887e81\r\n\r\n### Expected output\r\n\r\nI assume this shouldn't be an error, but phpstan reports this error:\r\n\r\n>Property A::$errorHandler (callable|null) does not accept string|null.\r\n\r\nI also wanted to note that `set_error_handler` may return an array, according to the PHP docs: https://secure.php.net/set_error_handler\r\n\r\n>Returns a string containing the previously defined error handler (if any). If the built-in error handler is used NULL is returned. NULL is also returned in case of an error such as an invalid callback. If the previous error handler was a class method, this function will return an indexed array with the class and the method name. \r\n\r\nBut phpstan's CallMap shows `?string` as the return type for this function.  https://github.com/phpstan/phpstan/blob/master/src/Reflection/SignatureMap/functionMap.php#L9847"}}
{"actor":{"display_login":"ondrejmirtes"}}