{"action":"created","issue":{"url":"https://api.github.com/repos/phpstan/phpstan/issues/140","repository_url":"https://api.github.com/repos/phpstan/phpstan","labels_url":"https://api.github.com/repos/phpstan/phpstan/issues/140/labels{/name}","comments_url":"https://api.github.com/repos/phpstan/phpstan/issues/140/comments","events_url":"https://api.github.com/repos/phpstan/phpstan/issues/140/events","html_url":"https://github.com/phpstan/phpstan/issues/140","id":206491751,"number":140,"title":"finally keyword seems not to be in scope","user":{"login":"jeroenvdgulik","id":242090,"avatar_url":"https://avatars0.githubusercontent.com/u/242090?v=3","gravatar_id":"","url":"https://api.github.com/users/jeroenvdgulik","html_url":"https://github.com/jeroenvdgulik","followers_url":"https://api.github.com/users/jeroenvdgulik/followers","following_url":"https://api.github.com/users/jeroenvdgulik/following{/other_user}","gists_url":"https://api.github.com/users/jeroenvdgulik/gists{/gist_id}","starred_url":"https://api.github.com/users/jeroenvdgulik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeroenvdgulik/subscriptions","organizations_url":"https://api.github.com/users/jeroenvdgulik/orgs","repos_url":"https://api.github.com/users/jeroenvdgulik/repos","events_url":"https://api.github.com/users/jeroenvdgulik/events{/privacy}","received_events_url":"https://api.github.com/users/jeroenvdgulik/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-09T12:38:07Z","updated_at":"2017-05-13T19:09:21Z","closed_at":"2017-05-13T19:09:21Z","body":"PHPStan seems to ignore the fact that `finally` is always called. In this case let's say we want to have some debug statements about the time it took to resolve the request.\r\n\r\n```php\r\n<?php\r\n\r\nnamespace Example;\r\n\r\nclass Book {\r\n\t/** Psr\\Log\\LoggerInterface */\r\n\tprivate $logger;\r\n\r\n\tpublic function get($id)\r\n\t{\r\n\t\ttry {\r\n\t\t\t// $this->amazon->get($id);\r\n\t\t} catch (\\Throwable $e) {\r\n\t\t\t// amazon not reachable\r\n\t\t} finally {\r\n\t\t\t$endTime = new \\DateTimeImmutable();\r\n\t\t}\r\n\r\n\t\t$this->logger->debug('Request ended at ' . $endTime);\r\n\t}\r\n}\r\n```\r\n\r\nThe expected behaviour of `PHPStan` would be that it would recognise that `$endTime` will always be filled, regardless of whatever happens in the `try/catch` block. The actual behaviour:\r\n\r\n```bash\r\n➜  phpstan vendor/bin/phpstan analyze -l 5 src\r\n 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%\r\n\r\n ------ ------------------------------\r\n  Line   src/Example/Book.php\r\n ------ ------------------------------\r\n  19     Undefined variable: $endTime\r\n ------ ------------------------------\r\n\r\n\r\n [ERROR] Found 1 error\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/phpstan/phpstan/issues/comments/301268519","html_url":"https://github.com/phpstan/phpstan/issues/140#issuecomment-301268519","issue_url":"https://api.github.com/repos/phpstan/phpstan/issues/140","id":301268519,"user":{"login":"ondrejmirtes","id":104888,"avatar_url":"https://avatars3.githubusercontent.com/u/104888?v=3","gravatar_id":"","url":"https://api.github.com/users/ondrejmirtes","html_url":"https://github.com/ondrejmirtes","followers_url":"https://api.github.com/users/ondrejmirtes/followers","following_url":"https://api.github.com/users/ondrejmirtes/following{/other_user}","gists_url":"https://api.github.com/users/ondrejmirtes/gists{/gist_id}","starred_url":"https://api.github.com/users/ondrejmirtes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ondrejmirtes/subscriptions","organizations_url":"https://api.github.com/users/ondrejmirtes/orgs","repos_url":"https://api.github.com/users/ondrejmirtes/repos","events_url":"https://api.github.com/users/ondrejmirtes/events{/privacy}","received_events_url":"https://api.github.com/users/ondrejmirtes/received_events","type":"User","site_admin":false},"created_at":"2017-05-13T19:09:21Z","updated_at":"2017-05-13T19:09:21Z","body":"Fixed: https://github.com/phpstan/phpstan/commit/eb296522c7d78807adf46ae5f242cd38ff931ee4"}}
{"actor":{"display_login":"ondrejmirtes"}}