{"action":"created","issue":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2394","repository_url":"https://api.github.com/repos/sebastianbergmann/phpunit","labels_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2394/labels{/name}","comments_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2394/comments","events_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2394/events","html_url":"https://github.com/sebastianbergmann/phpunit/issues/2394","id":195189558,"number":2394,"title":"AssertionError \"Undefined index: file\"","user":{"login":"Fleshgrinder","id":1059453,"avatar_url":"https://avatars.githubusercontent.com/u/1059453?v=3","gravatar_id":"","url":"https://api.github.com/users/Fleshgrinder","html_url":"https://github.com/Fleshgrinder","followers_url":"https://api.github.com/users/Fleshgrinder/followers","following_url":"https://api.github.com/users/Fleshgrinder/following{/other_user}","gists_url":"https://api.github.com/users/Fleshgrinder/gists{/gist_id}","starred_url":"https://api.github.com/users/Fleshgrinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fleshgrinder/subscriptions","organizations_url":"https://api.github.com/users/Fleshgrinder/orgs","repos_url":"https://api.github.com/users/Fleshgrinder/repos","events_url":"https://api.github.com/users/Fleshgrinder/events{/privacy}","received_events_url":"https://api.github.com/users/Fleshgrinder/received_events","type":"User","site_admin":false},"labels":[{"id":44001,"url":"https://api.github.com/repos/sebastianbergmann/phpunit/labels/bug","name":"bug","color":"e11d21","default":true}],"state":"open","locked":false,"assignee":{"login":"sebastianbergmann","id":25218,"avatar_url":"https://avatars.githubusercontent.com/u/25218?v=3","gravatar_id":"","url":"https://api.github.com/users/sebastianbergmann","html_url":"https://github.com/sebastianbergmann","followers_url":"https://api.github.com/users/sebastianbergmann/followers","following_url":"https://api.github.com/users/sebastianbergmann/following{/other_user}","gists_url":"https://api.github.com/users/sebastianbergmann/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastianbergmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastianbergmann/subscriptions","organizations_url":"https://api.github.com/users/sebastianbergmann/orgs","repos_url":"https://api.github.com/users/sebastianbergmann/repos","events_url":"https://api.github.com/users/sebastianbergmann/events{/privacy}","received_events_url":"https://api.github.com/users/sebastianbergmann/received_events","type":"User","site_admin":false},"assignees":[{"login":"sebastianbergmann","id":25218,"avatar_url":"https://avatars.githubusercontent.com/u/25218?v=3","gravatar_id":"","url":"https://api.github.com/users/sebastianbergmann","html_url":"https://github.com/sebastianbergmann","followers_url":"https://api.github.com/users/sebastianbergmann/followers","following_url":"https://api.github.com/users/sebastianbergmann/following{/other_user}","gists_url":"https://api.github.com/users/sebastianbergmann/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastianbergmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastianbergmann/subscriptions","organizations_url":"https://api.github.com/users/sebastianbergmann/orgs","repos_url":"https://api.github.com/users/sebastianbergmann/repos","events_url":"https://api.github.com/users/sebastianbergmann/events{/privacy}","received_events_url":"https://api.github.com/users/sebastianbergmann/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-12-13T08:25:02Z","updated_at":"2016-12-13T16:11:03Z","closed_at":null,"body":"Handling of `AssertionError`s was introduced in 5.5 (see [this commit](https://github.com/sebastianbergmann/phpunit/commit/a1c7fea3392eda44a741b832cd0a4bd87cad14d4)) where we have the following lines of code:\r\n\r\n```php\r\n        } catch (AssertionError $e) {\r\n            // ...\r\n            $frame   = $e->getTrace()[0];\r\n            $e = new PHPUnit_Framework_AssertionFailedError(\r\n                sprintf(\r\n                    '%s in %s:%s',\r\n                    $e->getMessage(),\r\n                    $frame['file'],\r\n                    $frame['line']\r\n                )\r\n            );\r\n        }\r\n```\r\n\r\nThe problem is that this code is not compatible with PHP 5 and a custom `AssertionError` that is created from the assert callback feature. We have this at our company but also for instance [Drupal 8 has it](https://github.com/drupal/drupal/blob/8.0.x/core/lib/Drupal/Component/Assertion/Handle.php#L60-L65).\r\n\r\nThe first frame in such a case does not contain a `file` nor a `line` member since that one contains a closure and the second frame is the correct one. First entries from an example stack trace:\r\n\r\n```php\r\n$frames = $e->getTrace();\r\n$frames[0] = [\r\n    'function' => '{closure}',\r\n    'args' => [\r\n        '/path/to/file.php',\r\n        42,\r\n        '',\r\n        'assertion message',\r\n    ],\r\n];\r\n$frames[1] = [\r\n    'file' => '/path/to/file.php',\r\n    'line' => 42,\r\n    'function' => 'assert',\r\n    'args' => [\r\n        false,\r\n        'assertion message',\r\n    ],\r\n];\r\n```\r\n\r\nA simple and supposed fix for this would be to investigate if the first frame contains `{closure}` in the `function` member and then check if the next frame is from `assert`. Of course, this is no guarantee that one just found the right frame.\r\n\r\nWhat do you think how we should handle this? It is definitely a bug and makes all versions that contain the current logic incompatible with code that uses custom assertion errors via callbacks paired with PHP 5."},"comment":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/comments/266781291","html_url":"https://github.com/sebastianbergmann/phpunit/issues/2394#issuecomment-266781291","issue_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2394","id":266781291,"user":{"login":"Fleshgrinder","id":1059453,"avatar_url":"https://avatars.githubusercontent.com/u/1059453?v=3","gravatar_id":"","url":"https://api.github.com/users/Fleshgrinder","html_url":"https://github.com/Fleshgrinder","followers_url":"https://api.github.com/users/Fleshgrinder/followers","following_url":"https://api.github.com/users/Fleshgrinder/following{/other_user}","gists_url":"https://api.github.com/users/Fleshgrinder/gists{/gist_id}","starred_url":"https://api.github.com/users/Fleshgrinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fleshgrinder/subscriptions","organizations_url":"https://api.github.com/users/Fleshgrinder/orgs","repos_url":"https://api.github.com/users/Fleshgrinder/repos","events_url":"https://api.github.com/users/Fleshgrinder/events{/privacy}","received_events_url":"https://api.github.com/users/Fleshgrinder/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T16:11:02Z","updated_at":"2016-12-13T16:11:02Z","body":"Yes, this does solve the problem nicely and kudos for being so fast in replying to tickets. 👍 "}}
{"actor":{"display_login":"Fleshgrinder"}}