Title: resolveDeprecatedTag incorrectly grabs multiline deprecation messages · Issue #25 · phpstan/phpdoc-parser · GitHub
Open Graph Title: resolveDeprecatedTag incorrectly grabs multiline deprecation messages · Issue #25 · phpstan/phpdoc-parser
X Title: resolveDeprecatedTag incorrectly grabs multiline deprecation messages · Issue #25 · phpstan/phpdoc-parser
Description: Identified in phpstan/phpstan#1983 I provided some faulty logic in \PHPStan\PhpDoc\PhpDocNodeResolver::resolveDeprecatedTag. The $key value is always 0, not the original index of the key amongst its neighbors. The goal was to take the cu...
Open Graph Description: Identified in phpstan/phpstan#1983 I provided some faulty logic in \PHPStan\PhpDoc\PhpDocNodeResolver::resolveDeprecatedTag. The $key value is always 0, not the original index of the key amongst it...
X Description: Identified in phpstan/phpstan#1983 I provided some faulty logic in \PHPStan\PhpDoc\PhpDocNodeResolver::resolveDeprecatedTag. The $key value is always 0, not the original index of the key amongst it...
Opengraph URL: https://github.com/phpstan/phpdoc-parser/issues/25
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"resolveDeprecatedTag incorrectly grabs multiline deprecation messages","articleBody":"Identified in https://github.com/phpstan/phpstan/pull/1983\r\n\r\nI provided some faulty logic in \\PHPStan\\PhpDoc\\PhpDocNodeResolver::resolveDeprecatedTag. The `$key` value is always `0`, not the original index of the key amongst its neighbors. The goal was to take the current key and find all entries below it, rebuilding the multiple line message.\r\n\r\n```\r\n\tprivate function resolveDeprecatedTag(PhpDocNode $phpDocNode, NameScope $nameScope): ?\\PHPStan\\PhpDoc\\Tag\\DeprecatedTag\r\n\t{\r\n\t\tforeach ($phpDocNode->getDeprecatedTagValues() as $key => $deprecatedTagValue) {\r\n\t\t\t$totalChildren = count($phpDocNode->children);\r\n\t\t\t/** @var \\PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocTextNode[] $textNodes */\r\n\t\t\t$textNodes = array_filter($phpDocNode->children, static function (PhpDocChildNode $child): bool {\r\n\t\t\t\treturn $child instanceof PhpDocTextNode;\r\n\t\t\t});\r\n\t\t\t$deprecatedMessage = $deprecatedTagValue->description;\r\n\t\t\tif (count($textNodes) > 0) {\r\n\t\t\t\tfor ($i = $key; $i \u003c $totalChildren; $i++) {\r\n\t\t\t\t\t// Skip invalid children.\r\n\t\t\t\t\tif (!isset($textNodes[$i])) {\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t$textNodeText = trim($textNodes[$i]->text);\r\n\t\t\t\t\t// Break at the first empty new line, as this is probably\r\n\t\t\t\t\t// leading to a new tag and no longer part of the multiline\r\n\t\t\t\t\t// deprecation message.\r\n\t\t\t\t\tif ($textNodeText === '') {\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t$deprecatedMessage .= ' ' . $textNodeText;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t$deprecatedMessage = trim($deprecatedMessage);\r\n\t\t\treturn new DeprecatedTag($deprecatedMessage === '' ? null : $deprecatedMessage);\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t}\r\n```","author":{"url":"https://github.com/mglaman","@type":"Person","name":"mglaman"},"datePublished":"2019-04-24T13:33:11Z","url":"https://github.com/phpstan/phpdoc-parser/issues/25"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:494f8cfa-c2ab-859c-6fac-da6f07eaf936 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9CCE:2AB36C:38C05B:4D6156:6B006D1C |
| html-safe-nonce | 802b60fc92fa98b2400620260f4dbd8ea92b377caa350b7b2192ca7c84cee5f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0NFOjJBQjM2QzozOEMwNUI6NEQ2MTU2OjZCMDA2RDFDIiwidmlzaXRvcl9pZCI6IjY1NDYxNjIxNDgxNTY5MjcyNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 198bba4a029f6a8178c5a1c201bb9c320ca1b67a633c478aba2b56c3fed5ffcf |
| hovercard-subject-tag | issue:436699994 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/phpstan/phpdoc-parser/25/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55e4c8c1178d0efbcd36bf6cde78ca3551f91dad5eb8c11b59f0d4ea4b727652/phpstan/phpdoc-parser/issues/25 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55e4c8c1178d0efbcd36bf6cde78ca3551f91dad5eb8c11b59f0d4ea4b727652/phpstan/phpdoc-parser/issues/25 |
| og:image:alt | Identified in phpstan/phpstan#1983 I provided some faulty logic in \PHPStan\PhpDoc\PhpDocNodeResolver::resolveDeprecatedTag. The $key value is always 0, not the original index of the key amongst it... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mglaman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| turbo-cache-control | no-preview |
| go-import | github.com/phpstan/phpdoc-parser git https://github.com/phpstan/phpdoc-parser.git |
| octolytics-dimension-user_id | 16435710 |
| octolytics-dimension-user_login | phpstan |
| octolytics-dimension-repository_id | 111290081 |
| octolytics-dimension-repository_nwo | phpstan/phpdoc-parser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 111290081 |
| octolytics-dimension-repository_network_root_nwo | phpstan/phpdoc-parser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width