{"action":"created","issue":{"url":"https://api.github.com/repos/dompdf/dompdf/issues/1136","repository_url":"https://api.github.com/repos/dompdf/dompdf","labels_url":"https://api.github.com/repos/dompdf/dompdf/issues/1136/labels{/name}","comments_url":"https://api.github.com/repos/dompdf/dompdf/issues/1136/comments","events_url":"https://api.github.com/repos/dompdf/dompdf/issues/1136/events","html_url":"https://github.com/dompdf/dompdf/issues/1136","id":138415711,"number":1136,"title":"Fatal error: Call to a member function getFontMetrics() on null in /dompdf/dompdf/src/FrameReflower/Text.php(453) : runtime-created function on line 1","user":{"login":"jewei","id":51693,"avatar_url":"https://avatars.githubusercontent.com/u/51693?v=3","gravatar_id":"","url":"https://api.github.com/users/jewei","html_url":"https://github.com/jewei","followers_url":"https://api.github.com/users/jewei/followers","following_url":"https://api.github.com/users/jewei/following{/other_user}","gists_url":"https://api.github.com/users/jewei/gists{/gist_id}","starred_url":"https://api.github.com/users/jewei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jewei/subscriptions","organizations_url":"https://api.github.com/users/jewei/orgs","repos_url":"https://api.github.com/users/jewei/repos","events_url":"https://api.github.com/users/jewei/events{/privacy}","received_events_url":"https://api.github.com/users/jewei/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dompdf/dompdf/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/dompdf/dompdf/milestones/3","html_url":"https://github.com/dompdf/dompdf/milestones/0.7.0","labels_url":"https://api.github.com/repos/dompdf/dompdf/milestones/3/labels","id":592841,"number":3,"title":"0.7.0","description":"","creator":{"login":"gabrielbull","id":671923,"avatar_url":"https://avatars.githubusercontent.com/u/671923?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrielbull","html_url":"https://github.com/gabrielbull","followers_url":"https://api.github.com/users/gabrielbull/followers","following_url":"https://api.github.com/users/gabrielbull/following{/other_user}","gists_url":"https://api.github.com/users/gabrielbull/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrielbull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrielbull/subscriptions","organizations_url":"https://api.github.com/users/gabrielbull/orgs","repos_url":"https://api.github.com/users/gabrielbull/repos","events_url":"https://api.github.com/users/gabrielbull/events{/privacy}","received_events_url":"https://api.github.com/users/gabrielbull/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":16,"state":"open","created_at":"2014-03-10T16:29:16Z","updated_at":"2016-03-22T04:16:31Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-03-04T08:37:37Z","updated_at":"2016-03-23T01:24:59Z","closed_at":null,"body":"In dompdf/dompdf/src/FrameReflower/Text.php` line 447:\r\n\r\n```\r\narray_walk(\r\n    $lines,\r\n    create_function(\r\n        '&$val,$str',\r\n        '$val = $this->getFontMetrics()->getTextWidth($str, \"' . $font . '\", ' . $size . ', ' . $word_spacing . ', ' . $char_spacing . ');'\r\n    )\r\n);\r\n```\r\nYou forgot to use `$root = $this;` or even better if you update it to look like the rest:\r\n\r\n```\r\n$root = $this;\r\narray_walk($lines, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {\r\n    $val = $root->getFontMetrics()->getTextWidth($str, addslashes($font), $size, $word_spacing, $char_spacing);\r\n});\r\n```\r\n\r\nAnd there is 2 switch control structures. I suppose they are duplicated, maybe of them are deprecated.\r\n"},"comment":{"url":"https://api.github.com/repos/dompdf/dompdf/issues/comments/200111154","html_url":"https://github.com/dompdf/dompdf/issues/1136#issuecomment-200111154","issue_url":"https://api.github.com/repos/dompdf/dompdf/issues/1136","id":200111154,"user":{"login":"bsweeney","id":485897,"avatar_url":"https://avatars.githubusercontent.com/u/485897?v=3","gravatar_id":"","url":"https://api.github.com/users/bsweeney","html_url":"https://github.com/bsweeney","followers_url":"https://api.github.com/users/bsweeney/followers","following_url":"https://api.github.com/users/bsweeney/following{/other_user}","gists_url":"https://api.github.com/users/bsweeney/gists{/gist_id}","starred_url":"https://api.github.com/users/bsweeney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsweeney/subscriptions","organizations_url":"https://api.github.com/users/bsweeney/orgs","repos_url":"https://api.github.com/users/bsweeney/repos","events_url":"https://api.github.com/users/bsweeney/events{/privacy}","received_events_url":"https://api.github.com/users/bsweeney/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T01:24:59Z","updated_at":"2016-03-23T01:24:59Z","body":"The two switch structures have always been there. They're not duplicated; the first block gets the min width, the second block gets the max width. The coding style is maybe prone to error. I'll have to walk back through the history to see why that one instance of `array_walk` is different."}}