Title: Table::getDisplayLines() can output excessive lines · Issue #164 · wp-cli/php-cli-tools · GitHub
Open Graph Title: Table::getDisplayLines() can output excessive lines · Issue #164 · wp-cli/php-cli-tools
X Title: Table::getDisplayLines() can output excessive lines · Issue #164 · wp-cli/php-cli-tools
Description: Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior I'm registering a table with this (simplified) code: $table...
Open Graph Description: Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior I'm registering a t...
X Description: Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior I'm registering...
Opengraph URL: https://github.com/wp-cli/php-cli-tools/issues/164
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Table::getDisplayLines() can output excessive lines","articleBody":"## Bug Report\r\n\r\n- [x] Yes, I reviewed the [contribution guidelines](https://make.wordpress.org/cli/handbook/contributing/).\r\n- [x] Yes, more specifically, I reviewed the guidelines on [how to write clear bug reports](https://make.wordpress.org/cli/handbook/bug-reports/).\r\n\r\n**Describe the current, buggy behavior**\r\n\r\nI'm registering a table with this (simplified) code:\r\n\r\n```php\r\n$table = new \\cli\\Table();\r\n$ascii = new \\cli\\table\\Ascii();\r\n$widths = [\r\n\t3, // this is the longest default date format: [24-Sep-2023 20:50:51 UTC]\r\n\t3, // this is the longest default type: PHP Fatal error\r\n\t5, // trigger the overflow and last column max width by defining a very long string length\r\n];\r\n\r\n$ascii->setWidths( $widths );\r\n$table->setRenderer( $ascii );\r\n\r\n$table->setHeaders( [ 'one', 'two', 'three' ] );\r\n\r\n$table->display();\r\n```\r\n\r\nMethod Table::() returns this data:\r\n\r\n```\r\narray:4 [▶\r\n 0 => \"+----------------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\"\r\n 1 => \"| One | Two | Three |\"\r\n 2 => \"+----------------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\"\r\n 3 => \"+----------------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\"\r\n]\r\n```\r\n\r\nAs you can see, array values for 2 and 3 are the same - bottom border.\r\n\r\nThis is because I output just the table, without rows (I plan to use `->addRow()` later). And because this code in this library:\r\n\r\n```php\r\nforeach ($this->_rows as $row) {\r\n\t$row = $this->_renderer->row($row);\r\n\t$row = explode( PHP_EOL, $row );\r\n\t$out = array_merge( $out, $row );\r\n}\r\n\r\nif (isset($border)) {\r\n\t$out[] = $border;\r\n}\r\n```\r\n\r\nDoes not check whether rows is actually not empty.\r\n\r\n**Describe what you would expect as the correct outcome**\r\n\r\nIf there is a header but no rows - we should display only 1 border.\r\n\r\n**Let us know what environment you are running this on**\r\n\r\n```\r\nOS: Darwin 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6000 arm64\r\nShell: /bin/zsh\r\nPHP binary: /opt/homebrew/Cellar/php/8.2.10/bin/php\r\nPHP version: 8.2.10\r\nphp.ini used: /opt/homebrew/etc/php/8.2/php.ini\r\nMySQL binary: \r\nMySQL version: \r\nSQL modes: \r\nWP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli\r\nWP-CLI vendor dir: phar://wp-cli.phar/vendor\r\nWP_CLI phar path: /Users/slaffik/Projects/[redacted]\r\nWP-CLI packages dir: /Users/slaffik/.wp-cli/packages/\r\nWP-CLI cache dir: /Users/slaffik/.wp-cli/cache\r\nWP-CLI global config: \r\nWP-CLI project config: \r\nWP-CLI version: 2.8.1\r\n\r\n```\r\n\r\n**Provide a possible solution**\r\n\r\nI will create a PR.\r\n","author":{"url":"https://github.com/slaFFik","@type":"Person","name":"slaFFik"},"datePublished":"2023-09-28T21:06:01Z","url":"https://github.com/wp-cli/php-cli-tools/issues/164"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:3f251c55-e821-12ed-6dcc-3d9c8e75fb92 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC66:18034D:3F7E025:53BBF93:6AFA3B27 |
| html-safe-nonce | 4eca87dc5ac0d87776e024b86e32b4af3a09f90255eab03873538831ee320ebb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzY2OjE4MDM0RDozRjdFMDI1OjUzQkJGOTM6NkFGQTNCMjciLCJ2aXNpdG9yX2lkIjoiMzAxNTAyNDU0MDU5MDQyMjgyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f7a20fe465bb74ed9d285b86a85106494c8e5741052f31d01cdd4ca5dd44b5fa |
| hovercard-subject-tag | issue:1918274160 |
| 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/wp-cli/php-cli-tools/164/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49d34263f6a56bd45892bae8ef3924d22d3b023233c1de86039a7f5a3801d4f9/wp-cli/php-cli-tools/issues/164 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49d34263f6a56bd45892bae8ef3924d22d3b023233c1de86039a7f5a3801d4f9/wp-cli/php-cli-tools/issues/164 |
| og:image:alt | Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior I'm registering a t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | slaFFik |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| go-import | github.com/wp-cli/php-cli-tools git https://github.com/wp-cli/php-cli-tools.git |
| octolytics-dimension-user_id | 1570774 |
| octolytics-dimension-user_login | wp-cli |
| octolytics-dimension-repository_id | 587642 |
| octolytics-dimension-repository_nwo | wp-cli/php-cli-tools |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587642 |
| octolytics-dimension-repository_network_root_nwo | wp-cli/php-cli-tools |
| 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 | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width