2424use function array_merge ;
2525use function array_unique ;
2626use function array_values ;
27- use function bindec ;
2827use function explode ;
2928use function hex2bin ;
3029use function is_string ;
8281 */
8382final class Schema extends AbstractPdoSchema
8483{
84+ /**
85+ * Define the abstract column type as `bit`.
86+ */
87+ public const TYPE_BIT = 'bit ' ;
88+
8589 /**
8690 * @var array The mapping from physical column types (keys) to abstract column types (values).
8791 *
@@ -90,9 +94,9 @@ final class Schema extends AbstractPdoSchema
9094 * @psalm-var string[]
9195 */
9296 private array $ typeMap = [
93- 'bit ' => self ::TYPE_INTEGER ,
94- 'bit varying ' => self ::TYPE_INTEGER ,
95- 'varbit ' => self ::TYPE_INTEGER ,
97+ 'bit ' => self ::TYPE_BIT ,
98+ 'bit varying ' => self ::TYPE_BIT ,
99+ 'varbit ' => self ::TYPE_BIT ,
96100 'bool ' => self ::TYPE_BOOLEAN ,
97101 'boolean ' => self ::TYPE_BOOLEAN ,
98102 'box ' => self ::TYPE_STRING ,
@@ -790,11 +794,7 @@ protected function findColumns(TableSchemaInterface $table): bool
790794 $ loadColumnSchema ->defaultValue (new Expression ($ defaultValue ));
791795 } elseif ($ loadColumnSchema ->getType () === 'boolean ' ) {
792796 $ loadColumnSchema ->defaultValue ($ defaultValue === 'true ' );
793- } elseif (is_string ($ defaultValue ) && preg_match ("/^B'(.*?)'::/ " , $ defaultValue , $ matches )) {
794- $ loadColumnSchema ->defaultValue (bindec ($ matches [1 ]));
795- } elseif (is_string ($ defaultValue ) && preg_match ("/^'(\d+)':: \"bit \"$/ " , $ defaultValue , $ matches )) {
796- $ loadColumnSchema ->defaultValue (bindec ($ matches [1 ]));
797- } elseif (is_string ($ defaultValue ) && preg_match ("/^'(.*?)'::/ " , $ defaultValue , $ matches )) {
797+ } elseif (is_string ($ defaultValue ) && preg_match ("/^B?'(.*?)'::/ " , $ defaultValue , $ matches )) {
798798 if ($ loadColumnSchema ->getType () === 'binary ' && str_starts_with ($ matches [1 ], '\\x ' )) {
799799 $ loadColumnSchema ->defaultValue (hex2bin (substr ($ matches [1 ], 2 )));
800800 } else {
@@ -904,6 +904,22 @@ protected function loadColumnSchema(array $info): ColumnSchemaInterface
904904 return $ column ;
905905 }
906906
907+ /**
908+ * Extracts the PHP type from an abstract DB type.
909+ *
910+ * @param ColumnSchemaInterface $column The column schema information.
911+ *
912+ * @return string The PHP type name.
913+ */
914+ protected function getColumnPhpType (ColumnSchemaInterface $ column ): string
915+ {
916+ if ($ column ->getType () === self ::TYPE_BIT ) {
917+ return self ::PHP_TYPE_INTEGER ;
918+ }
919+
920+ return parent ::getColumnPhpType ($ column );
921+ }
922+
907923 /**
908924 * Loads multiple types of constraints and returns the specified ones.
909925 *
0 commit comments