# HG changeset patch # User luka # Date 1727138114 14400 # Node ID c969ed13c57072f32e3093df1eb3602130095568 # Parent 7ee152c2247846fd92ce72339deba2b0016a9a25 Changes for various files diff -r 7ee152c22478 -r c969ed13c570 .php-cs-fixer.cache --- a/.php-cs-fixer.cache Wed Apr 24 20:11:52 2024 -0400 +++ b/.php-cs-fixer.cache Mon Sep 23 20:35:14 2024 -0400 @@ -1,1 +1,1 @@ -{"php":"8.2.7","version":"3.19.1","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":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"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"},"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},"hashes":{"src\/Generator\/BaseGenerator.php":"409aadd181fbd4f216fe31f4f42ca3e2","src\/Replacer.php":"c6b5f421259f41016014c00270ca001c","src\/MagicForgerServiceProvider.php":"e56f92adc0181e9b7681de8ca8aca6eb","src\/Generator\/Controller\/ControllerGenerator.php":"075e65a43e5ecc55fbc4dcd7636dfcc1","src\/Generator\/Generator.php":"794271f48bed8f156878fc36a25ff60f","src\/Generator\/Replacer.php":"5a7f98d22504edb6aba92b061ddd9803","src\/Generator\/Model\/ModelGenerator.php":"e78c07fc13bd9c379991e8b01b13c672"}} +{"php":"8.3.6","version":"3.50.0","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"single_line":true},"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"function_declaration":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_hidden_params":true,"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_braces":{"namespaces":true},"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration_for_default_null_value":true,"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"ordered_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":{"order":["param","return","throws"]},"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]]},"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"cast_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":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"]},"return_type_declaration":true,"short_scalar_cast":true,"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,"indentation_type":true,"line_ending":true,"lowercase_keywords":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_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true},"hashes":{"src\/Generator\/Route\/RouteGenerator.php":"02bf90516b88a1b0b00a84afb10d8a45","src\/Generator\/Controller\/ControllerGenerator.php":"717cdb9124e7e4afe4a28e17b94089e9","src\/Generator\/Model\/ModelGenerator.php":"31743678bf017f63680db19e9682df45","src\/Generator\/Generator.php":"c7cd32166a24be83f6575d33f6c4ba80","src\/Generator\/Requests\/UpdateRequestGenerator.php":"63475513d258b0727637db19629d4ac6","src\/Generator\/Requests\/RequestGenerator.php":"93fbc04a1ea18b794ee7f24902ae9cc1","src\/Generator\/Requests\/StoreRequestGenerator.php":"42bac2b426288d9a08216dfc5fe45faf","src\/Generator\/BaseGenerator.php":"c0aa37a727252383bc28aebf7a0019ec","src\/MagicForgerServiceProvider.php":"00c1321ad894d1e0807036dbe9114bf2","src\/Replacer\/Replacer.php":"8165ff2f53f676c7f603e3e26f92bc5a","src\/Replacer\/TableReplacer.php":"4d020ea0b4263f2d791db91d32f3ebf3","src\/Helpers\/FileModifier.php":"6e3206a2e4bc2a2a16526dce99229e2f","src\/ConfigHelper.php":"561978e5bf67eb27a3c1ce2d65805b4d"}} \ No newline at end of file diff -r 7ee152c22478 -r c969ed13c570 src/ConfigHelper.php --- a/src/ConfigHelper.php Wed Apr 24 20:11:52 2024 -0400 +++ b/src/ConfigHelper.php Mon Sep 23 20:35:14 2024 -0400 @@ -17,7 +17,6 @@ /** * Set up configuration path. - * @return void */ public static function setup_config_path(string $base_path): void { @@ -26,8 +25,6 @@ /** * Get configuration path. - * - * @return string */ protected static function get_config_path(): string { @@ -36,7 +33,6 @@ /** * Write configuration into a file. - * @return void */ public static function write_config(): void { @@ -51,7 +47,6 @@ /** * Read configuration from a file. - * @return void */ public static function read_config(): void { @@ -61,7 +56,6 @@ /** * Print configuration. - * @return void */ public static function print_config(): void { @@ -76,6 +70,7 @@ * @see https://www.php.net/manual/en/function.var-export.php * * @param bool $return + * * @return string|string[]|null */ public static function varexport(mixed $expression, $return = false): string|array|null @@ -93,12 +88,12 @@ } else { echo $export; } - return null; + + return null; } /** * Format the given file. - * @return void */ protected static function format_file(string $path): void { @@ -108,7 +103,7 @@ /** * Set up tables. */ - public static function set_up_tables(): Collection + public static function set_up_tables(): Collection { $schema = \DB::connection()->getDoctrineSchemaManager(); $tables = collect($schema->listTableNames())->all(); @@ -181,7 +176,6 @@ * * @param array $priority * @param array $merged - * @return void */ private static function merge_array_priority(&$priority, $merged): void { diff -r 7ee152c22478 -r c969ed13c570 src/Generator/Model/ModelGenerator.php --- a/src/Generator/Model/ModelGenerator.php Wed Apr 24 20:11:52 2024 -0400 +++ b/src/Generator/Model/ModelGenerator.php Mon Sep 23 20:35:14 2024 -0400 @@ -51,7 +51,7 @@ * Resolve the fully-qualified path to the stub. * * @param string $stub - * + * * @return string */ protected function resolveStubPath($stub) diff -r 7ee152c22478 -r c969ed13c570 src/Helpers/FileModifier.php --- a/src/Helpers/FileModifier.php Wed Apr 24 20:11:52 2024 -0400 +++ b/src/Helpers/FileModifier.php Mon Sep 23 20:35:14 2024 -0400 @@ -19,80 +19,55 @@ { private $contents; - /** - * @var mixed - */ public $file_path; - - /** - * @param mixed $file_path - */ public function __construct($file_path) { $this->get_file_contents($file_path); $this->file_path = $file_path; } - - /** - * @param mixed $file_path - * @return void - */ public function get_file_contents($file_path): void { - //TODO: there needs to be more/any error checking - $f = fopen($file_path, "r"); + // TODO: there needs to be more/any error checking + $f = fopen($file_path, 'r'); $this->contents = fread($f, filesize($file_path)); fclose($f); } - - /** - * @param mixed $file_path - */ public function write_to_path($file_path = null): void { $file_path = $file_path ?? $this->file_path; - $f = fopen($file_path, "w"); + $f = fopen($file_path, 'w'); fwrite($f, $this->contents); fclose($f); } - /** - * Replaces the replacement point with the value in the current contents - * - * @param mixed $value - * @param mixed $replacement_point + * Replaces the replacement point with the value in the current contents. */ public function replace($value, $replacement_point): void { $this->contents = str_replace($replacement_point, $value, $this->contents); } - /** - * Inserts the value above the insert point in the current contents - * - * @param mixed $value - * @param mixed $insert_point - * @return void + * Inserts the value above the insert point in the current contents. */ public function insert($value, $insert_point): void { - //seperate on new lines into an array + // seperate on new lines into an array $file_arr = explode("\n", $this->contents); $temp_arr = []; - foreach($file_arr as $line) { - if(str_contains($line, $insert_point)) { + foreach ($file_arr as $line) { + if (str_contains($line, $insert_point)) { $temp_arr[] = $value; } $temp_arr[] = $line; } - $this->contents = implode("\n",$temp_arr); + $this->contents = implode("\n", $temp_arr); } } diff -r 7ee152c22478 -r c969ed13c570 src/Replacer/Replacer.php --- a/src/Replacer/Replacer.php Wed Apr 24 20:11:52 2024 -0400 +++ b/src/Replacer/Replacer.php Mon Sep 23 20:35:14 2024 -0400 @@ -52,7 +52,7 @@ return $target; } - public function get_available_replacements() + public function get_available_replacements(): array { $table_name = $this->getTableInput(); $replacements = [ @@ -118,42 +118,42 @@ // Namespaces // // ////////////////////////////////////////// - public function getRootNamespace() + public function getRootNamespace(): string { return $this->laravel->getNamespace(); } - public function getModelNamespace(string $name = '') + public function getModelNamespace(string $name = ''): string { return $this->getRootNamespace().'Models'; } - public function getNamespacedModel(string $name = '') + public function getNamespacedModel(string $name = ''): string { return $this->getModelNamespace().'\\'.$this->model_name($name); } - public function getControllerNamespace(string $name = '') + public function getControllerNamespace(string $name = ''): string { return $this->getRootNamespace().'Http\\Controllers'; } - public function getRequestNamespace(string $name) + public function getRequestNamespace(string $name): string { return $this->getRootNamespace().'Http\\Requests\\'.$this->model_name($name); } - public function getStoreRequestNamespace(string $name) + public function getStoreRequestNamespace(string $name): string { return $this->getRequestNamespace($name); } - public function getUpdateRequestNamespace(string $name) + public function getUpdateRequestNamespace(string $name): string { return $this->getRequestNamespace($name); } - public function getRequestUses(string $name) + public function getRequestUses(string $name): string { return implode("\n", [ 'use '.$this->getRequestNamespace($name).'\\'.$this->store_request_name($name).';', @@ -161,7 +161,7 @@ ]); } - public function getRouteNamespace(string $name = '') + public function getRouteNamespace(string $name = ''): string { return $this->getRootNamespace().'Http\\Controllers'; } diff -r 7ee152c22478 -r c969ed13c570 src/Replacer/TableReplacer.php --- a/src/Replacer/TableReplacer.php Wed Apr 24 20:11:52 2024 -0400 +++ b/src/Replacer/TableReplacer.php Mon Sep 23 20:35:14 2024 -0400 @@ -19,7 +19,7 @@ { } - protected function getValuesForCreation() + protected function getValuesForCreation(): string { $insert = ''; foreach ($this->get_columns() as $column) { @@ -29,7 +29,7 @@ return $insert; } - protected function getAttributes() + protected function getAttributes(): string { $insert = ''; foreach ($this->get_columns() as $column) { @@ -39,7 +39,7 @@ return $insert; } - protected function getValuesForValidation() + protected function getValuesForValidation(): string { $insert = ''; foreach ($this->get_columns() as $column) { @@ -69,8 +69,8 @@ $replacements = [ '// {{ valuesForCreation }}' => self::getValuesForCreation(), '# {{ atributeInsertPoint }}' => self::getAttributes(), - '// {{ valuesForValidation }}' => self::getValuesForValidation(), - ]; + '// {{ valuesForValidation }}' => self::getValuesForValidation(), + ]; foreach ($replacements as $key => &$replacement) { $replacement = $replacement."\n".$key;