diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index b5a03e8..bbfc81f 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.2.7","version":"3.20.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"curly_braces_position":{"allow_single_line_empty_anonymous_classes":true},"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Commands\/GenerateRulesCommand.php":"a500ac55c779ee5246dd3e77417d4fe2","src\/LaravelSchemaRulesServiceProvider.php":"c368b1f24fdf572c8c5da6d90e4fe8f9","src\/Resolvers\/SchemaRulesResolverMySql.php":"6ce5e561e87b6885fe800a331b3a832f","src\/Resolvers\/SchemaRulesResolverPgSql.php":"fa8d9ec3061744b5e48b5f3207fcb5ee","src\/Resolvers\/SchemaRulesResolverSqlite.php":"3a790800d813e42ada906e20fc70a399","src\/Resolvers\/SchemaRulesResolverInterface.php":"c40de2c178467b5a592a80fab75d4e37","src\/Exceptions\/FailedToCreateRequestClassException.php":"88d97c20dfda22508445696a600edd8f","src\/Exceptions\/UnsupportedDbDriverException.php":"55e1f4f48764869ea78e5444357e7a3a","src\/Exceptions\/ColumnDoesNotExistException.php":"e1b74bfac1771e4ae77962805adb3173","src\/Exceptions\/MultipleTablesSuppliedException.php":"44534013008741de6a024fd8c0fc62e2","src\/Exceptions\/TableDoesNotExistException.php":"d19bb30aab5ede9920cc925f9d4b3cde","tests\/TestCase.php":"17d5b78ef193fff416305ee717483177","tests\/Pest.php":"71da07894ee59b1ebc0e98d205618731","tests\/SchemaRulesTest.php":"90e6c084c25da8aab935b3e50a5eba4e"}} \ No newline at end of file +{"php":"8.2.7","version":"3.20.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"curly_braces_position":{"allow_single_line_empty_anonymous_classes":true},"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Commands\/GenerateRulesCommand.php":"efe430d939ae29e942fd34608d465458","src\/LaravelSchemaRulesServiceProvider.php":"7e21700c24396b1b3ae4093f5a611a34","src\/Resolvers\/SchemaRulesResolverMySql.php":"c50b48648ad7adbc48b871e9f4c9dff2","src\/Resolvers\/SchemaRulesResolverPgSql.php":"4a3570d5b48c8e007966c392522b4771","src\/Resolvers\/SchemaRulesResolverSqlite.php":"f6d30cd50082722c8991f8afeaf6bbbd","src\/Resolvers\/SchemaRulesResolverInterface.php":"c40de2c178467b5a592a80fab75d4e37","src\/Exceptions\/FailedToCreateRequestClassException.php":"88d97c20dfda22508445696a600edd8f","src\/Exceptions\/UnsupportedDbDriverException.php":"55e1f4f48764869ea78e5444357e7a3a","src\/Exceptions\/ColumnDoesNotExistException.php":"e1b74bfac1771e4ae77962805adb3173","src\/Exceptions\/MultipleTablesSuppliedException.php":"44534013008741de6a024fd8c0fc62e2","src\/Exceptions\/TableDoesNotExistException.php":"d19bb30aab5ede9920cc925f9d4b3cde","tests\/TestCase.php":"17d5b78ef193fff416305ee717483177","tests\/Pest.php":"71da07894ee59b1ebc0e98d205618731","tests\/SchemaRulesTest.php":"2279a35708710e8a0a78b4edfc8f0095","src\/Resolvers\/BaseSchemaRulesResolver.php":"85f5dcca23e897416d93b4830437a445","src\/Contracts\/SchemaRulesResolverInterface.php":"0661d95c8ab20c86180132b20002e8b9"}} \ No newline at end of file diff --git a/src/Commands/GenerateRulesCommand.php b/src/Commands/GenerateRulesCommand.php index 8fef207..f5f9339 100644 --- a/src/Commands/GenerateRulesCommand.php +++ b/src/Commands/GenerateRulesCommand.php @@ -10,11 +10,11 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; +use LaracraftTech\LaravelSchemaRules\Contracts\SchemaRulesResolverInterface; use LaracraftTech\LaravelSchemaRules\Exceptions\ColumnDoesNotExistException; use LaracraftTech\LaravelSchemaRules\Exceptions\FailedToCreateRequestClassException; use LaracraftTech\LaravelSchemaRules\Exceptions\MultipleTablesSuppliedException; use LaracraftTech\LaravelSchemaRules\Exceptions\TableDoesNotExistException; -use LaracraftTech\LaravelSchemaRules\Contracts\SchemaRulesResolverInterface; class GenerateRulesCommand extends Command { diff --git a/src/LaravelSchemaRulesServiceProvider.php b/src/LaravelSchemaRulesServiceProvider.php index 79f2966..c7fdbde 100644 --- a/src/LaravelSchemaRulesServiceProvider.php +++ b/src/LaravelSchemaRulesServiceProvider.php @@ -3,8 +3,8 @@ namespace LaracraftTech\LaravelSchemaRules; use LaracraftTech\LaravelSchemaRules\Commands\GenerateRulesCommand; -use LaracraftTech\LaravelSchemaRules\Exceptions\UnsupportedDbDriverException; use LaracraftTech\LaravelSchemaRules\Contracts\SchemaRulesResolverInterface; +use LaracraftTech\LaravelSchemaRules\Exceptions\UnsupportedDbDriverException; use LaracraftTech\LaravelSchemaRules\Resolvers\SchemaRulesResolverMySql; use LaracraftTech\LaravelSchemaRules\Resolvers\SchemaRulesResolverPgSql; use LaracraftTech\LaravelSchemaRules\Resolvers\SchemaRulesResolverSqlite; diff --git a/src/Resolvers/BaseSchemaRulesResolver.php b/src/Resolvers/BaseSchemaRulesResolver.php index 43d9007..fdc43db 100644 --- a/src/Resolvers/BaseSchemaRulesResolver.php +++ b/src/Resolvers/BaseSchemaRulesResolver.php @@ -7,7 +7,6 @@ abstract class BaseSchemaRulesResolver implements SchemaRulesResolverInterface { - private string $table; private array $columns; @@ -58,12 +57,11 @@ protected function columns() return $this->columns; } - abstract protected function isAutoIncrement($column) : bool; + abstract protected function isAutoIncrement($column): bool; - abstract protected function getField($column) : string; + abstract protected function getField($column): string; abstract protected function getColumnsDefinitionsFromTable(); abstract protected function generateColumnRules(stdClass $column): array; - } diff --git a/src/Resolvers/SchemaRulesResolverMySql.php b/src/Resolvers/SchemaRulesResolverMySql.php index 3dc22cc..dd92bef 100644 --- a/src/Resolvers/SchemaRulesResolverMySql.php +++ b/src/Resolvers/SchemaRulesResolverMySql.php @@ -9,7 +9,6 @@ class SchemaRulesResolverMySql extends BaseSchemaRulesResolver implements SchemaRulesResolverInterface { - public static array $integerTypes = [ 'tinyint' => [ 'unsigned' => ['0', '255'], @@ -140,14 +139,13 @@ protected function generateColumnRules(stdClass $column): array return $columnRules; } - protected function isAutoIncrement($column) : bool + protected function isAutoIncrement($column): bool { return $column->Extra === 'auto_increment'; } - protected function getField($column) : string + protected function getField($column): string { return $column->Field; } - } diff --git a/src/Resolvers/SchemaRulesResolverPgSql.php b/src/Resolvers/SchemaRulesResolverPgSql.php index 732b5ab..7eebaaf 100644 --- a/src/Resolvers/SchemaRulesResolverPgSql.php +++ b/src/Resolvers/SchemaRulesResolverPgSql.php @@ -9,7 +9,6 @@ class SchemaRulesResolverPgSql extends BaseSchemaRulesResolver implements SchemaRulesResolverInterface { - public static array $integerTypes = [ 'smallint' => ['-32768', '32767'], 'integer' => ['-2147483648', '2147483647'], @@ -120,14 +119,13 @@ protected function generateColumnRules(stdClass $column): array return $columnRules; } - protected function isAutoIncrement($column) : bool + protected function isAutoIncrement($column): bool { return Str::contains($column->column_default, 'nextval'); } - protected function getField($column) : string + protected function getField($column): string { return $column->column_name; } - } diff --git a/src/Resolvers/SchemaRulesResolverSqlite.php b/src/Resolvers/SchemaRulesResolverSqlite.php index 2cabaf9..af7b4c7 100644 --- a/src/Resolvers/SchemaRulesResolverSqlite.php +++ b/src/Resolvers/SchemaRulesResolverSqlite.php @@ -9,7 +9,6 @@ class SchemaRulesResolverSqlite extends BaseSchemaRulesResolver implements SchemaRulesResolverInterface { - protected function getColumnsDefinitionsFromTable() { @@ -73,12 +72,12 @@ protected function generateColumnRules(stdClass $column): array return $columnRules; } - protected function isAutoIncrement($column) : bool + protected function isAutoIncrement($column): bool { return $column->pk; } - protected function getField($column) : string + protected function getField($column): string { return $column->name; } diff --git a/tests/SchemaRulesTest.php b/tests/SchemaRulesTest.php index 0438f37..0f0b29c 100644 --- a/tests/SchemaRulesTest.php +++ b/tests/SchemaRulesTest.php @@ -2,10 +2,10 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use LaracraftTech\LaravelSchemaRules\Contracts\SchemaRulesResolverInterface; use LaracraftTech\LaravelSchemaRules\Exceptions\ColumnDoesNotExistException; use LaracraftTech\LaravelSchemaRules\Exceptions\MultipleTablesSuppliedException; use LaracraftTech\LaravelSchemaRules\Exceptions\TableDoesNotExistException; -use LaracraftTech\LaravelSchemaRules\Contracts\SchemaRulesResolverInterface; use LaracraftTech\LaravelSchemaRules\Resolvers\SchemaRulesResolverMySql; beforeEach(function () {