From cbb5118318706dc023eb8551b1f2628f395a6228 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 26 Jun 2026 01:55:03 +0900 Subject: refactor(symfony-table): model rows/cells with enums instead of PhpMixed The Table helper modeled a row's cells as PhpMixed and recovered the concrete TableCell/TableSeparator types via runtime instance_of, leaving the entire mixed/array bridge (to_row_vec, cell_colspan, row_get, ...) as todo!(). Replace that with proper Row/Cell enums: Row = HeaderDivider | Separator(TableSeparator) | Cells(Vec) Cell = Null | Value(String) | Cell(TableCell) | Separator(TableSeparator) The internal header/body boundary that PHP detects by object identity ($divider === $row) becomes the dedicated Row::HeaderDivider variant. Style arguments (PHP string|TableStyle) become a StyleName enum, so Table::new no longer panics in resolve_style's instance_of stub; TableStyle derives Clone so named styles resolve from the registry. PhpMixed-based callers (SymfonyStyle::table, render_table, auditor's sanitize) bridge via From for Cell/Row at the boundary. Un-ignores LicensesCommandTest text-format cases (4) and BaseDependencyCommandTest::why; output matches PHP exactly. Removes ~15 impl todo!()s in the Table helper. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/symfony/console/style/symfony_style.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console/style') diff --git a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs index a5508bf..a2a42e9 100644 --- a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs +++ b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs @@ -8,6 +8,7 @@ use crate::symfony::console::helper::Helper; use crate::symfony::console::helper::ProgressBar; use crate::symfony::console::helper::SymfonyQuestionHelper; use crate::symfony::console::helper::Table; +use crate::symfony::console::helper::table::{Cell, Row}; use crate::symfony::console::helper::TableCell; use crate::symfony::console::helper::TableSeparator; use crate::symfony::console::input::InputInterface; @@ -130,8 +131,8 @@ impl SymfonyStyle { pub fn horizontal_table(&mut self, headers: Vec, rows: Vec) { self.create_table() .set_horizontal(true) - .set_headers(headers) - .set_rows(rows) + .set_headers(headers.into_iter().map(Cell::from).collect()) + .set_rows(rows.into_iter().map(Row::from).collect()) .render(); self.new_line(1); @@ -272,7 +273,7 @@ impl SymfonyStyle { // PHP passes the cloned `TableStyle` instance directly; `set_style` here takes a // `PhpMixed` name/style. Phase B leaves the polymorphic style passing as a TODO. let _ = &style; - let _ = table.set_style(PhpMixed::String("symfony-style-guide".to_string())); + let _ = table.set_style("symfony-style-guide".into()); table } @@ -663,8 +664,8 @@ impl StyleInterface for SymfonyStyle { /// {@inheritdoc} fn table(&mut self, headers: Vec, rows: Vec) { self.create_table() - .set_headers(headers) - .set_rows(rows) + .set_headers(headers.into_iter().map(Cell::from).collect()) + .set_rows(rows.into_iter().map(Row::from).collect()) .render(); self.new_line(1); -- cgit v1.3.1