|
161 | 161 | use Flow\ETL\Row\Entry\{BooleanEntry, DateEntry, DateTimeEntry, EnumEntry, FloatEntry, IntegerEntry, JsonEntry, ListEntry, MapEntry, StringEntry, StructureEntry, TimeEntry, UuidEntry, XMLElementEntry, XMLEntry}; |
162 | 162 | use Flow\ETL\Row\{Entry, EntryReference, Reference, References}; |
163 | 163 | use Flow\ETL\Row\Formatter\ASCIISchemaFormatter; |
164 | | -use Flow\ETL\Schema\{Definition}; |
165 | | -use Flow\ETL\Schema\Formatter\JsonSchemaFormatter; |
| 164 | +use Flow\ETL\Schema\{Definition, Formatter\PHPFormatter\TypeFormatter, Formatter\PHPFormatter\ValueFormatter}; |
| 165 | +use Flow\ETL\Schema\Formatter\{JsonSchemaFormatter, PHPSchemaFormatter}; |
166 | 166 | use Flow\ETL\Schema\Metadata; |
167 | 167 | use Flow\ETL\Schema\Validator\{EvolvingValidator, SelectiveValidator, StrictValidator}; |
168 | 168 | use Flow\ETL\Transformer\OrderEntries\{CombinedComparator, Comparator, NameComparator, Order, TypeComparator, TypePriorities}; |
@@ -1673,6 +1673,24 @@ function schema_to_json(Schema $schema, bool $pretty = false) : string |
1673 | 1673 | return (new JsonSchemaFormatter($pretty))->format($schema); |
1674 | 1674 | } |
1675 | 1675 |
|
| 1676 | +/** |
| 1677 | + * @param Schema $schema |
| 1678 | + */ |
| 1679 | +#[DocumentationDSL(module: Module::CORE, type: DSLType::HELPER)] |
| 1680 | +function schema_to_php(Schema $schema, ValueFormatter $valueFormatter = new ValueFormatter(), TypeFormatter $typeFormatter = new TypeFormatter()) : string |
| 1681 | +{ |
| 1682 | + return (new PHPSchemaFormatter($valueFormatter, $typeFormatter))->format($schema); |
| 1683 | +} |
| 1684 | + |
| 1685 | +/** |
| 1686 | + * @param Schema $schema |
| 1687 | + */ |
| 1688 | +#[DocumentationDSL(module: Module::CORE, type: DSLType::HELPER)] |
| 1689 | +function schema_to_ascii(Schema $schema, ?SchemaFormatter $formatter = null) : string |
| 1690 | +{ |
| 1691 | + return ($formatter ?? new ASCIISchemaFormatter())->format($schema); |
| 1692 | +} |
| 1693 | + |
1676 | 1694 | /** |
1677 | 1695 | * @param Schema $expected |
1678 | 1696 | * @param Schema $given |
@@ -1981,6 +1999,8 @@ function get_type(mixed $value) : Type |
1981 | 1999 |
|
1982 | 2000 | /** |
1983 | 2001 | * @param Schema $schema |
| 2002 | + * |
| 2003 | + * @deprecated Please use schema_to_ascii($schema) instead |
1984 | 2004 | */ |
1985 | 2005 | #[DocumentationDSL(module: Module::CORE, type: DSLType::SCHEMA)] |
1986 | 2006 | function print_schema(Schema $schema, ?SchemaFormatter $formatter = null) : string |
|
0 commit comments