Reformat files

This commit is contained in:
Timothy Warren 2023-07-21 10:35:15 -04:00
parent 80bb63fdd6
commit 0909a5e499
101 changed files with 2738 additions and 2836 deletions

View File

@ -11,6 +11,7 @@ $finder = Finder::create()
return (new Config()) return (new Config())
->setRiskyAllowed(TRUE) ->setRiskyAllowed(TRUE)
->setFinder($finder) ->setFinder($finder)
->setIndent(' ')
->setRules([ ->setRules([
'align_multiline_comment' => false, 'align_multiline_comment' => false,
'array_indentation' => true, 'array_indentation' => true,
@ -21,17 +22,15 @@ return (new Config())
'binary_operator_spaces' => [ 'binary_operator_spaces' => [
'default' => 'single_space', 'default' => 'single_space',
'operators' => [ 'operators' => [
'=' => 'align_single_space_minimal', '=' => NULL,
'=>' => 'align_single_space_minimal', '&' => NULL,
'||' => 'align_single_space_minimal', ]
'.=' => 'align_single_space_minimal',
],
], ],
'blank_line_after_namespace' => true, 'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => false, 'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => [ 'blank_line_before_statement' => [
'statements' => [ 'statements' => [
'case', // 'case',
'continue', 'continue',
'declare', 'declare',
'default', 'default',
@ -49,12 +48,9 @@ return (new Config())
'yield_from', 'yield_from',
], ],
], ],
'braces' => [ 'blank_lines_before_namespace' => [
'allow_single_line_anonymous_class_with_empty_body' => true, 'min_line_breaks' => 2,
'allow_single_line_closure' => true, 'max_line_breaks' => 2,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'next',
], ],
'cast_spaces' => ['space' => 'single'], 'cast_spaces' => ['space' => 'single'],
'class_attributes_separation' => [ 'class_attributes_separation' => [
@ -89,7 +85,16 @@ return (new Config())
'compact_nullable_typehint' => true, 'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'], 'concat_space' => ['spacing' => 'one'],
'constant_case' => ['case' => 'upper'], 'constant_case' => ['case' => 'upper'],
'control_structure_continuation_position' => ['position' => 'same_line'], 'control_structure_braces' => true,
'control_structure_continuation_position' => ['position' => 'next_line'],
'curly_braces_position' => [
'allow_single_line_anonymous_functions' => true,
'allow_single_line_empty_anonymous_classes' => true,
'anonymous_functions_opening_brace' => 'same_line',
'classes_opening_brace' => 'same_line',
'control_structures_opening_brace' => 'next_line_unless_newline_at_signature_end',
'functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
],
'date_time_immutable' => false, 'date_time_immutable' => false,
'declare_equal_normalize' => ['space' => 'none'], 'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true, 'declare_parentheses' => true,
@ -108,23 +113,20 @@ return (new Config())
'empty_loop_body' => ['style' => 'braces'], 'empty_loop_body' => ['style' => 'braces'],
'empty_loop_condition' => ['style' => 'while'], 'empty_loop_condition' => ['style' => 'while'],
'encoding' => true, 'encoding' => true,
'ereg_to_preg' => true,
'error_suppression' => [ 'error_suppression' => [
'mute_deprecation_error' => true, 'mute_deprecation_error' => true,
'noise_remaining_usages' => false, 'noise_remaining_usages' => false,
'noise_remaining_usages_exclude' => [], 'noise_remaining_usages_exclude' => [],
], ],
'escape_implicit_backslashes' => [ 'escape_implicit_backslashes' => [
'double_quoted' => true, 'double_quoted' => false,
'heredoc_syntax' => true, 'heredoc_syntax' => false,
'single_quoted' => false, 'single_quoted' => false,
], ],
'explicit_indirect_variable' => true, 'explicit_indirect_variable' => false,
'explicit_string_variable' => true, 'explicit_string_variable' => false,
'final_class' => false, 'final_class' => false,
'final_internal_class' => [ 'final_internal_class' => [
'annotation_exclude' => ['@no-final'],
'annotation_include' => ['@internal'],
'consider_absent_docblock_as_internal_class' => false, 'consider_absent_docblock_as_internal_class' => false,
], ],
'final_public_method_for_abstract_class' => false, 'final_public_method_for_abstract_class' => false,
@ -143,29 +145,16 @@ return (new Config())
'pi', 'pi',
], ],
], ],
'function_typehint_space' => true, 'general_phpdoc_annotation_remove' => false,
'general_phpdoc_annotation_remove' => [ 'general_phpdoc_tag_rename' => false,
'annotations' => [
'author',
'package',
'subpackage',
],
],
'general_phpdoc_tag_rename' => [
'case_sensitive' => false,
'fix_annotation' => true,
'fix_inline' => true,
'replacements' => ['inheritDocs' => 'inheritDoc'],
],
'get_class_to_class_keyword' => false, 'get_class_to_class_keyword' => false,
'global_namespace_import' => [ 'global_namespace_import' => [
'import_constants' => false, 'import_constants' => true,
'import_functions' => false, 'import_functions' => true,
'import_classes' => true, 'import_classes' => true,
], ],
'group_import' => true, 'group_import' => true,
'header_comment' => false, // false by default 'header_comment' => false, // false by default
'heredoc_indentation' => ['indentation' => 'start_plus_one'],
'heredoc_to_nowdoc' => true, 'heredoc_to_nowdoc' => true,
'implode_call' => true, 'implode_call' => true,
'include' => true, 'include' => true,
@ -205,7 +194,6 @@ return (new Config())
'no_binary_string' => true, 'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // conflicts with `single_blank_line_before_namespace`
'no_break_comment' => ['comment_text' => 'no break'], 'no_break_comment' => ['comment_text' => 'no break'],
'no_closing_tag' => true, 'no_closing_tag' => true,
'no_empty_comment' => true, 'no_empty_comment' => true,
@ -218,7 +206,6 @@ return (new Config())
'no_mixed_echo_print' => ['use' => 'echo'], 'no_mixed_echo_print' => ['use' => 'echo'],
'no_multiline_whitespace_around_double_arrow' => true, 'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true, 'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true, 'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true, 'no_singleline_whitespace_before_semicolons' => true,
'no_space_around_double_colon' => true, 'no_space_around_double_colon' => true,
@ -231,8 +218,7 @@ return (new Config())
'allow_unused_params' => true, 'allow_unused_params' => true,
'remove_inheritdoc' => false, 'remove_inheritdoc' => false,
], ],
'no_trailing_comma_in_list_call' => true, 'no_trailing_comma_in_singleline' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true, 'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true, 'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => true, 'no_trailing_whitespace_in_string' => true,
@ -261,18 +247,24 @@ return (new Config())
'no_whitespace_in_blank_line' => true, 'no_whitespace_in_blank_line' => true,
'non_printable_character' => ['use_escape_sequences_in_strings' => true], 'non_printable_character' => ['use_escape_sequences_in_strings' => true],
'normalize_index_brace' => true, 'normalize_index_brace' => true,
'not_operator_with_space' => false, 'not_operator_with_space' => true,
'not_operator_with_successor_space' => true, 'not_operator_with_successor_space' => true,
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'object_operator_without_whitespace' => true, 'object_operator_without_whitespace' => true,
'octal_notation' => false, // requires 8.1+
'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'], 'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'],
'ordered_class_elements' => [ 'ordered_class_elements' => [
'order' => [ 'order' => [
'use_trait', 'use_trait',
'constant', 'case',
'property', 'constant_public',
'method', 'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
], ],
'sort_algorithm' => 'none', 'sort_algorithm' => 'none',
], ],
@ -294,7 +286,7 @@ return (new Config())
'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'], 'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'],
'php_unit_expectation' => ['target' => 'newest'], 'php_unit_expectation' => ['target' => 'newest'],
'php_unit_fqcn_annotation' => true, 'php_unit_fqcn_annotation' => true,
'php_unit_internal_class' => ['types' => ['normal', 'final']], 'php_unit_internal_class' => ['types' => ['final']],
'php_unit_method_casing' => ['case' => 'camel_case'], 'php_unit_method_casing' => ['case' => 'camel_case'],
'php_unit_mock' => ['target' => 'newest'], 'php_unit_mock' => ['target' => 'newest'],
'php_unit_mock_short_will_return' => true, 'php_unit_mock_short_will_return' => true,
@ -305,14 +297,6 @@ return (new Config())
], ],
'php_unit_set_up_tear_down_visibility' => true, 'php_unit_set_up_tear_down_visibility' => true,
'php_unit_size_class' => false, 'php_unit_size_class' => false,
'php_unit_strict' => [
'assertions' => [
'assertAttributeEquals',
'assertAttributeNotEquals',
'assertEquals',
'assertNotEquals',
],
],
'php_unit_test_annotation' => ['style' => 'prefix'], 'php_unit_test_annotation' => ['style' => 'prefix'],
'php_unit_test_case_static_method_calls' => [ 'php_unit_test_case_static_method_calls' => [
'call_type' => 'this', 'call_type' => 'this',
@ -321,16 +305,7 @@ return (new Config())
'php_unit_test_class_requires_covers' => false, 'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => [ 'phpdoc_align' => [
'align' => 'vertical', 'align' => 'left'
'tags' => [
'method',
'param',
'property',
'return',
'throws',
'type',
'var',
],
], ],
'phpdoc_annotation_without_dot' => false, 'phpdoc_annotation_without_dot' => false,
'phpdoc_indent' => true, 'phpdoc_indent' => true,
@ -353,16 +328,8 @@ return (new Config())
'property' => 'multi', 'property' => 'multi',
], ],
'phpdoc_no_access' => true, 'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => [
'replacements' => [
'property-read' => 'property',
'property-write' => 'property',
'type' => 'var',
'link' => 'see',
],
],
'phpdoc_no_empty_return' => false, 'phpdoc_no_empty_return' => false,
'phpdoc_no_package' => true, 'phpdoc_no_package' => false,
'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true, 'phpdoc_order' => true,
'phpdoc_order_by_value' => [ 'phpdoc_order_by_value' => [
@ -403,7 +370,7 @@ return (new Config())
'str', 'str',
], ],
], ],
'phpdoc_separation' => true, 'phpdoc_separation' => false,
'phpdoc_single_line_var_spacing' => true, 'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => false, 'phpdoc_summary' => false,
'phpdoc_tag_casing' => ['tags' => ['inheritDoc']], 'phpdoc_tag_casing' => ['tags' => ['inheritDoc']],
@ -443,15 +410,14 @@ return (new Config())
'simplified_if_return' => true, 'simplified_if_return' => true,
'simplified_null_return' => false, 'simplified_null_return' => false,
'single_blank_line_at_eof' => true, 'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => ['elements' => ['const', 'property']], 'single_class_element_per_statement' => ['elements' => ['const', 'property']],
'single_import_per_statement' => false, 'single_import_per_statement' => false,
'single_line_after_imports' => true, 'single_line_after_imports' => true,
'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']], 'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']],
'single_line_throw' => false, 'single_line_throw' => false,
'single_quote' => ['strings_containing_single_quote_chars' => false], 'single_quote' => ['strings_containing_single_quote_chars' => false],
'single_space_after_construct' => [ 'single_space_around_construct' => [
'constructs' => [ 'constructs_followed_by_a_single_space' => [
'abstract', 'abstract',
'as', 'as',
'attribute', 'attribute',
@ -514,6 +480,7 @@ return (new Config())
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true], 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
'standardize_increment' => true, 'standardize_increment' => true,
'standardize_not_equals' => true, 'standardize_not_equals' => true,
'statement_indentation' => true,
'static_lambda' => true, 'static_lambda' => true,
'strict_comparison' => true, 'strict_comparison' => true,
'strict_param' => true, 'strict_param' => true,
@ -530,8 +497,9 @@ return (new Config())
'elements' => ['arrays'], 'elements' => ['arrays'],
], ],
'trim_array_spaces' => true, 'trim_array_spaces' => true,
'type_declaration_spaces' => ['elements' => ['function', 'property']],
'types_spaces' => ['space' => 'none'], 'types_spaces' => ['space' => 'none'],
'unary_operator_spaces' => true, 'unary_operator_spaces' => false,
'use_arrow_functions' => true, 'use_arrow_functions' => true,
'visibility_required' => ['elements' => ['const', 'method', 'property']], 'visibility_required' => ['elements' => ['const', 'method', 'property']],
'void_return' => false, // changes method signature 'void_return' => false, // changes method signature
@ -542,4 +510,4 @@ return (new Config())
'less_and_greater' => false, 'less_and_greater' => false,
'always_move_variable' => false, 'always_move_variable' => false,
], ],
]); ]);

View File

@ -1,13 +1,13 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
return [ return [
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => TRUE],
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => TRUE],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => TRUE],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => TRUE],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => TRUE, 'test' => TRUE],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => TRUE],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => TRUE],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => TRUE],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => TRUE],
]; ];

View File

@ -3,5 +3,5 @@
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', ['cache' => null]); $containerConfigurator->extension('framework', ['cache' => NULL]);
}; };

View File

@ -7,11 +7,11 @@ return static function (MonologConfig $config): void {
'type' => 'stream', 'type' => 'stream',
'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'path' => '%kernel.logs_dir%/%kernel.environment%.log',
'level' => 'debug', 'level' => 'debug',
'channels' => ['elements' => ['!event']] 'channels' => ['elements' => ['!event']],
]); ]);
$config->handler('console', [ $config->handler('console', [
'type' => 'console', 'type' => 'console',
'process_psr_3_messages' => false, 'process_psr_3_messages' => FALSE,
'channels' => ['elements' => ['!event', '!doctrine', '!console']] 'channels' => ['elements' => ['!event', '!doctrine', '!console']],
]); ]);
}; };

View File

@ -5,5 +5,5 @@ declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', ['router' => ['strict_requirements' => true]]); $containerConfigurator->extension('framework', ['router' => ['strict_requirements' => TRUE]]);
}; };

View File

@ -4,13 +4,13 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('web_profiler', [ $containerConfigurator->extension('web_profiler', [
'toolbar' => true, 'toolbar' => TRUE,
'intercept_redirects' => false 'intercept_redirects' => FALSE,
]); ]);
$containerConfigurator->extension('framework', [ $containerConfigurator->extension('framework', [
'profiler' => [ 'profiler' => [
'only_exceptions' => false 'only_exceptions' => FALSE,
] ],
]); ]);
}; };

View File

@ -15,7 +15,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'types' => ['money' => MoneyType::class], 'types' => ['money' => MoneyType::class],
'logging' => '%kernel.debug%', 'logging' => '%kernel.debug%',
'mapping_types' => ['bit' => 'boolean', 'money' => 'money'], 'mapping_types' => ['bit' => 'boolean', 'money' => 'money'],
'url' => '%env(DATABASE_URL)%' 'url' => '%env(DATABASE_URL)%',
], ],
'orm' => [ 'orm' => [
'auto_generate_proxy_classes' => '%kernel.debug%', 'auto_generate_proxy_classes' => '%kernel.debug%',
@ -27,8 +27,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'type' => 'attribute', 'type' => 'attribute',
'dir' => '%kernel.project_dir%/src/Entity', 'dir' => '%kernel.project_dir%/src/Entity',
'prefix' => 'App\Entity', 'prefix' => 'App\Entity',
'alias' => 'App'] 'alias' => 'App'],
] ],
] ],
]); ]);
}; };

View File

@ -4,5 +4,5 @@ use Symfony\Config\DoctrineMigrationsConfig;
return static function (DoctrineMigrationsConfig $doctrineMigrations): void { return static function (DoctrineMigrationsConfig $doctrineMigrations): void {
$doctrineMigrations->migrationsPath('App\\Migrations', '%kernel.project_dir%/src/Migrations') $doctrineMigrations->migrationsPath('App\\Migrations', '%kernel.project_dir%/src/Migrations')
->checkDatabasePlatform(true); ->checkDatabasePlatform(TRUE);
}; };

View File

@ -2,15 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
use Symfony\Config\FrameworkConfig;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\FrameworkConfig;
return static function (ContainerConfigurator $containerConfigurator, FrameworkConfig $config): void { return static function (ContainerConfigurator $containerConfigurator, FrameworkConfig $config): void {
$config->session(['handler_id' => null]); $config->session(['handler_id' => NULL]);
$config->secret('%env(APP_SECRET)%') $config->secret('%env(APP_SECRET)%')
->defaultLocale('en') ->defaultLocale('en')
->httpMethodOverride(true) ->httpMethodOverride(TRUE)
->phpErrors(['log' => true]) ->phpErrors(['log' => TRUE]);
;
}; };

View File

@ -8,17 +8,17 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'orm' => [ 'orm' => [
'metadata_cache_driver' => [ 'metadata_cache_driver' => [
'type' => 'service', 'type' => 'service',
'id' => 'doctrine.system_cache_provider' 'id' => 'doctrine.system_cache_provider',
], ],
'query_cache_driver' => [ 'query_cache_driver' => [
'type' => 'service', 'type' => 'service',
'id' => 'doctrine.system_cache_provider' 'id' => 'doctrine.system_cache_provider',
], ],
'result_cache_driver' => [ 'result_cache_driver' => [
'type' => 'service', 'type' => 'service',
'id' => 'doctrine.result_cache_provider' 'id' => 'doctrine.result_cache_provider',
] ],
] ],
]); ]);
$services = $containerConfigurator->services(); $services = $containerConfigurator->services();
@ -35,12 +35,12 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'cache' => [ 'cache' => [
'pools' => [ 'pools' => [
'doctrine.result_cache_pool' => [ 'doctrine.result_cache_pool' => [
'adapter' => 'cache.app' 'adapter' => 'cache.app',
], ],
'doctrine.system_cache_pool' => [ 'doctrine.system_cache_pool' => [
'adapter' => 'cache.system' 'adapter' => 'cache.system',
] ],
] ],
] ],
]); ]);
}; };

View File

@ -9,18 +9,18 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'type' => 'fingers_crossed', 'type' => 'fingers_crossed',
'action_level' => 'error', 'action_level' => 'error',
'handler' => 'nested', 'handler' => 'nested',
'excluded_404s' => ['^/'] 'excluded_404s' => ['^/'],
], ],
'nested' => [ 'nested' => [
'type' => 'stream', 'type' => 'stream',
'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'path' => '%kernel.logs_dir%/%kernel.environment%.log',
'level' => 'debug' 'level' => 'debug',
], ],
'console' => [ 'console' => [
'type' => 'console', 'type' => 'console',
'process_psr_3_messages' => false, 'process_psr_3_messages' => FALSE,
'channels' => ['!event', '!doctrine'] 'channels' => ['!event', '!doctrine'],
] ],
] ],
]); ]);
}; };

View File

@ -4,6 +4,6 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', [ $containerConfigurator->extension('framework', [
'router' => ['strict_requirements' => null] 'router' => ['strict_requirements' => NULL],
]); ]);
}; };

View File

@ -5,8 +5,8 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', [ $containerConfigurator->extension('framework', [
'router' => [ 'router' => [
'strict_requirements' => null, 'strict_requirements' => NULL,
'utf8' => true 'utf8' => TRUE,
] ],
]); ]);
}; };

View File

@ -1,36 +1,36 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
use Symfony\Config\SecurityConfig;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Config\SecurityConfig;
return static function (ContainerConfigurator $containerConfigurator, SecurityConfig $security): void { return static function (ContainerConfigurator $containerConfigurator, SecurityConfig $security): void {
$security->passwordHasher(PasswordAuthenticatedUserInterface::class, 'auto') $security->passwordHasher(PasswordAuthenticatedUserInterface::class, 'auto');
;
$containerConfigurator->extension('security', [ $containerConfigurator->extension('security', [
'providers' => [ 'providers' => [
'users_in_memory' => [ 'users_in_memory' => [
'memory' => null] 'memory' => NULL],
], ],
'firewalls' => [ 'firewalls' => [
'dev' => [ 'dev' => [
'pattern' => '^/(_(profiler|wdt)|css|images|js)/', 'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
'security' => false 'security' => FALSE,
], ],
'main' => [ 'main' => [
'lazy' => true, 'lazy' => TRUE,
'provider' => 'users_in_memory' 'provider' => 'users_in_memory',
]
], ],
'access_control' => null ],
'access_control' => NULL,
]); ]);
if ($containerConfigurator->env() === 'test') { if ($containerConfigurator->env() === 'test')
{
$security->passwordHasher(PasswordAuthenticatedUserInterface::class, [ $security->passwordHasher(PasswordAuthenticatedUserInterface::class, [
'algorithm' => 'auto', 'algorithm' => 'auto',
'cost' => 4, 'cost' => 4,
'time_cost' => 3, 'time_cost' => 3,
'memory_cost' => 10 'memory_cost' => 10,
]); ]);
} }
}; };

View File

@ -4,6 +4,6 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('sensio_framework_extra', [ $containerConfigurator->extension('sensio_framework_extra', [
'router' => ['annotations' => false] 'router' => ['annotations' => FALSE],
]); ]);
}; };

View File

@ -5,5 +5,5 @@ declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', ['test' => null]); $containerConfigurator->extension('framework', ['test' => NULL]);
}; };

View File

@ -5,5 +5,5 @@ declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('twig', ['strict_variables' => true]); $containerConfigurator->extension('twig', ['strict_variables' => TRUE]);
}; };

View File

@ -5,5 +5,5 @@ declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', ['validation' => ['not_compromised_password' => false]]); $containerConfigurator->extension('framework', ['validation' => ['not_compromised_password' => FALSE]]);
}; };

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void { return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('web_profiler', ['toolbar' => false, 'intercept_redirects' => false]); $containerConfigurator->extension('web_profiler', ['toolbar' => FALSE, 'intercept_redirects' => FALSE]);
$containerConfigurator->extension('framework', ['profiler' => ['collect' => false]]); $containerConfigurator->extension('framework', ['profiler' => ['collect' => FALSE]]);
}; };

View File

@ -7,7 +7,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'default_locale' => 'en', 'default_locale' => 'en',
'translator' => [ 'translator' => [
'default_path' => '%kernel.project_dir%/translations', 'default_path' => '%kernel.project_dir%/translations',
'fallbacks' => ['%locale%'] 'fallbacks' => ['%locale%'],
] ],
]); ]);
}; };

View File

@ -6,6 +6,5 @@ return static function (TwigConfig $config): void {
$config->formThemes(['form_custom_layout.html.twig']) $config->formThemes(['form_custom_layout.html.twig'])
->defaultPath('%kernel.project_dir%/templates') ->defaultPath('%kernel.project_dir%/templates')
->debug('%kernel.debug%') ->debug('%kernel.debug%')
->strictVariables('%kernel.debug%') ->strictVariables('%kernel.debug%');
;
}; };

View File

@ -1,5 +1,6 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
if (file_exists(dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php')) { if (file_exists(dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php'))
{
require dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php'; require dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php';
} }

View File

@ -4,7 +4,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use App\Maker\MakeCollectionCrud; use App\Maker\MakeCollectionCrud;
return function (ContainerConfigurator $configurator): void { return static function (ContainerConfigurator $configurator): void {
$parameters = $configurator->parameters(); $parameters = $configurator->parameters();
$parameters->set('locale', 'en'); $parameters->set('locale', 'en');

View File

@ -11,17 +11,20 @@ require dirname(__DIR__) . '/vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
if ($_SERVER['APP_DEBUG']) { if ($_SERVER['APP_DEBUG'])
{
umask(0000); umask(0000);
Debug::enable(); Debug::enable();
} }
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? FALSE) { if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? FALSE)
{
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST); Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
} }
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? FALSE) { if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? FALSE)
{
Request::setTrustedHosts([$trustedHosts]); Request::setTrustedHosts([$trustedHosts]);
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
@ -6,13 +6,11 @@ use App\Entity\BrandCategory;
use App\Form\BrandCategoryType; use App\Form\BrandCategoryType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand/category')] #[Route('/brand/category')]
class BrandCategoryController extends AbstractController class BrandCategoryController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = BrandCategory::class; protected const ENTITY = BrandCategory::class;

View File

@ -10,8 +10,7 @@ use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand')] #[Route('/brand')]
class BrandController extends AbstractController class BrandController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = Brand::class; protected const ENTITY = Brand::class;

View File

@ -2,10 +2,10 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Camera;
use App\Form\CameraType;
use App\Controller\ use App\Controller\
{DeleteFormTrait}; {DeleteFormTrait};
use App\Entity\Camera;
use App\Form\CameraType;
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException}; use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use LogicException; use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -17,8 +17,7 @@ use Symfony\Component\Routing\Annotation\Route;
* Camera controller. * Camera controller.
*/ */
#[Route(path: 'camera')] #[Route(path: 'camera')]
class CameraController extends AbstractController class CameraController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;

View File

@ -2,18 +2,17 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\CameraType;
use App\Form\CameraTypeType;
use App\Controller\ use App\Controller\
{DeleteFormTrait}; {DeleteFormTrait};
use App\Entity\CameraType;
use App\Form\CameraTypeType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'camera-type')] #[Route(path: 'camera-type')]
class CameraTypeController extends AbstractController class CameraTypeController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;

View File

@ -6,8 +6,7 @@ use App\Entity\Chipset;
use App\Form\ChipsetType; use App\Form\ChipsetType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/chipset')] #[Route('/chipset')]

View File

@ -6,8 +6,7 @@ use App\Entity\Cpu;
use App\Form\CpuType; use App\Form\CpuType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/cpu')] #[Route('/cpu')]
@ -35,8 +34,8 @@ class CpuController extends AbstractController {
$amd = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'AMD' && $cpu->isReceived()); $amd = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'AMD' && $cpu->isReceived());
$intel = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'Intel' && $cpu->isReceived()); $intel = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'Intel' && $cpu->isReceived());
$others = array_filter($items, static fn (Cpu $cpu) => ( ! in_array($cpu->getBrand()->getName(), ['AMD','Intel'])) && $cpu->isReceived()); $others = array_filter($items, static fn (Cpu $cpu) => ( ! in_array($cpu->getBrand()->getName(), ['AMD', 'Intel'], TRUE)) && $cpu->isReceived());
$notReceived = array_filter($items, static fn(CPU $cpu) => $cpu->isReceived() === FALSE); $notReceived = array_filter($items, static fn (CPU $cpu) => $cpu->isReceived() === FALSE);
return $this->render($template, [ return $this->render($template, [
'all' => [ 'all' => [

View File

@ -6,8 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response}; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController class DefaultController extends AbstractController {
{
#[Route(path: '/', name: 'homepage')] #[Route(path: '/', name: 'homepage')]
public function indexAction(Request $request): Response public function indexAction(Request $request): Response
{ {

View File

@ -4,8 +4,7 @@ namespace App\Controller;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
trait DeleteFormTrait trait DeleteFormTrait {
{
/** /**
* Creates a form to delete an entity. * Creates a form to delete an entity.
*/ */

View File

@ -4,8 +4,6 @@ namespace App\Controller;
use App\Entity\Film; use App\Entity\Film;
use App\Form\FilmType; use App\Form\FilmType;
use App\Controller\
{DeleteFormTrait};
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use LogicException; use LogicException;
@ -17,8 +15,7 @@ use Symfony\Component\Routing\Annotation\Route;
* Film controller. * Film controller.
*/ */
#[Route(path: 'film')] #[Route(path: 'film')]
class FilmController extends AbstractController class FilmController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;

View File

@ -2,10 +2,10 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Flash;
use App\Form\FlashType;
use App\Controller\ use App\Controller\
{DeleteFormTrait}; {DeleteFormTrait};
use App\Entity\Flash;
use App\Form\FlashType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
@ -15,8 +15,7 @@ use Symfony\Component\Routing\Annotation\Route;
* Flash controller. * Flash controller.
*/ */
#[Route(path: 'flash')] #[Route(path: 'flash')]
class FlashController extends AbstractController class FlashController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;

View File

@ -6,8 +6,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
trait FormControllerBase trait FormControllerBase {
{
public function __construct(private readonly EntityManagerInterface $entityManager) public function __construct(private readonly EntityManagerInterface $entityManager)
{ {
} }
@ -37,7 +36,8 @@ trait FormControllerBase
$form->handleRequest($request); $form->handleRequest($request);
// If creating the item // If creating the item
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid())
{
$this->entityManager->persist($item); $this->entityManager->persist($item);
$this->entityManager->flush(); $this->entityManager->flush();
@ -81,7 +81,8 @@ trait FormControllerBase
$templateKey => $item, $templateKey => $item,
]; ];
if (method_exists($this, 'createDeleteForm')) { if (method_exists($this, 'createDeleteForm'))
{
$deleteForm = $this->createDeleteForm($item); $deleteForm = $this->createDeleteForm($item);
$templateData['delete_form'] = $deleteForm->createView(); $templateData['delete_form'] = $deleteForm->createView();
} }
@ -101,7 +102,8 @@ trait FormControllerBase
$editForm->handleRequest($request); $editForm->handleRequest($request);
// If updating the item // If updating the item
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid())
{
$this->entityManager->persist($item); $this->entityManager->persist($item);
$this->entityManager->flush(); $this->entityManager->flush();
@ -114,17 +116,20 @@ trait FormControllerBase
'form' => $editForm->createView(), 'form' => $editForm->createView(),
]; ];
if (method_exists($this, 'createDeleteForm')) { if (method_exists($this, 'createDeleteForm'))
{
$deleteForm = $this->createDeleteForm($item); $deleteForm = $this->createDeleteForm($item);
$templateData['delete_form'] = $deleteForm->createView(); $templateData['delete_form'] = $deleteForm->createView();
} }
if (method_exists($this, 'createDeacquireForm')) { if (method_exists($this, 'createDeacquireForm'))
{
$deacquireForm = $this->createDeacquireForm($item); $deacquireForm = $this->createDeacquireForm($item);
$templateData['deacquire_form'] = $deacquireForm->createView(); $templateData['deacquire_form'] = $deacquireForm->createView();
} }
if (method_exists($this, 'createReacquireForm')) { if (method_exists($this, 'createReacquireForm'))
{
$reacquireForm = $this->createReacquireForm($item); $reacquireForm = $this->createReacquireForm($item);
$templateData['reacquire_form'] = $reacquireForm->createView(); $templateData['reacquire_form'] = $reacquireForm->createView();
} }
@ -180,7 +185,8 @@ trait FormControllerBase
protected function deleteCSRF(Request $request, mixed $item): RedirectResponse protected function deleteCSRF(Request $request, mixed $item): RedirectResponse
{ {
if ($this->isCsrfTokenValid('delete' . $item->getId(), $request->request->get('_token'))) { if ($this->isCsrfTokenValid('delete' . $item->getId(), $request->request->get('_token')))
{
$this->entityManager->remove($item); $this->entityManager->remove($item);
$this->entityManager->flush(); $this->entityManager->flush();
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
@ -6,13 +6,11 @@ use App\Entity\Fpu;
use App\Form\FpuType; use App\Form\FpuType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/fpu')] #[Route('/fpu')]
class FpuController extends AbstractController class FpuController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = Fpu::class; protected const ENTITY = Fpu::class;

View File

@ -11,8 +11,7 @@ use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu')] #[Route('/gpu')]
class GpuController extends AbstractController class GpuController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = Gpu::class; protected const ENTITY = Gpu::class;
@ -28,10 +27,10 @@ class GpuController extends AbstractController
public function index(): Response public function index(): Response
{ {
$items = $this->entityManager->getRepository(self::ENTITY)->findAll(); $items = $this->entityManager->getRepository(self::ENTITY)->findAll();
$acquiredItems = array_filter($items, fn (Gpu $item) => $item->isAcquired()); $acquiredItems = array_filter($items, static fn (Gpu $item) => $item->isAcquired());
$newItems = array_filter($items, fn ($item) => !$item->isAcquired()); $newItems = array_filter($items, static fn ($item) => ! $item->isAcquired());
$filter = fn (array $itemTypes) => array_filter($acquiredItems, fn (Gpu $item) => in_array($item->getCardKey(), $itemTypes)); $filter = static fn (array $itemTypes) => array_filter($acquiredItems, static fn (Gpu $item) => in_array($item->getCardKey(), $itemTypes, TRUE));
$cardTypes = SlotKey::getGroups(); $cardTypes = SlotKey::getGroups();
$pcieCardTypes = $cardTypes['PCI Express']; $pcieCardTypes = $cardTypes['PCI Express'];
@ -47,7 +46,7 @@ class GpuController extends AbstractController
'agp' => $filter($agpCardTypes), 'agp' => $filter($agpCardTypes),
'pci' => $filter($pciCardTypes), 'pci' => $filter($pciCardTypes),
'isa' => $filter($isaCardTypes), 'isa' => $filter($isaCardTypes),
] ],
]); ]);
} }

View File

@ -10,8 +10,7 @@ use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu-core')] #[Route('/gpu-core')]
class GpuCoreController extends AbstractController class GpuCoreController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = GpuCore::class; protected const ENTITY = GpuCore::class;
@ -57,7 +56,8 @@ class GpuCoreController extends AbstractController
#[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])] #[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])]
public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response
{ {
if ($this->isCsrfTokenValid('delete' . $gPUCore->getId(), $request->request->get('_token'))) { if ($this->isCsrfTokenValid('delete' . $gPUCore->getId(), $request->request->get('_token')))
{
$entityManager->remove($gPUCore); $entityManager->remove($gPUCore);
$entityManager->flush(); $entityManager->flush();
} }

View File

@ -2,10 +2,10 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Lenses;
use App\Form\LensesType;
use App\Controller\ use App\Controller\
{DeleteFormTrait}; {DeleteFormTrait};
use App\Entity\Lenses;
use App\Form\LensesType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
@ -16,8 +16,7 @@ use Symfony\Component\Routing\Annotation\Route;
* Lens controller. * Lens controller.
*/ */
#[Route(path: 'lens')] #[Route(path: 'lens')]
class LensesController extends AbstractController class LensesController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;
@ -90,10 +89,6 @@ class LensesController extends AbstractController
/** /**
* Moves a camera to the previouslyOwned table * Moves a camera to the previouslyOwned table
*
* @param Request $request
*
* @return RedirectResponse
*/ */
#[Route(path: '/{id}/deacquire', name: 'lens_deacquire', methods: ['POST'])] #[Route(path: '/{id}/deacquire', name: 'lens_deacquire', methods: ['POST'])]
public function deacquireAction(Request $request, Lenses $lens): RedirectResponse public function deacquireAction(Request $request, Lenses $lens): RedirectResponse

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedCamera; use App\Entity\PreviouslyOwnedCamera;
use App\Form\PreviouslyOwnedCameraType; use App\Form\PreviouslyOwnedCameraType;
use App\Controller\FormControllerBase;
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException}; use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use LogicException; use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -17,8 +16,7 @@ use UnexpectedValueException;
* Previouslyownedcamera controller. * Previouslyownedcamera controller.
*/ */
#[Route(path: 'previously-owned-camera')] #[Route(path: 'previously-owned-camera')]
class PreviouslyOwnedCameraController extends AbstractController class PreviouslyOwnedCameraController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = PreviouslyOwnedCamera::class; protected const ENTITY = PreviouslyOwnedCamera::class;
@ -68,12 +66,8 @@ class PreviouslyOwnedCameraController extends AbstractController
/** /**
* Moves a camera to the previouslyOwned table * Moves a camera to the previouslyOwned table
* *
* @param Request $request
*
* @throws LogicException * @throws LogicException
* @throws ORMInvalidArgumentException * @throws ORMInvalidArgumentException
*
* @return RedirectResponse
*/ */
#[Route(path: '/{id}/reacquire', name: 'previously-owned-camera_reacquire', methods: ['POST'])] #[Route(path: '/{id}/reacquire', name: 'previously-owned-camera_reacquire', methods: ['POST'])]
public function reacquireAction(Request $request, PreviouslyOwnedCamera $camera): RedirectResponse public function reacquireAction(Request $request, PreviouslyOwnedCamera $camera): RedirectResponse

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedFlash; use App\Entity\PreviouslyOwnedFlash;
use App\Form\PreviouslyOwnedFlashType; use App\Form\PreviouslyOwnedFlashType;
use App\Controller\FormControllerBase;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
@ -14,8 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
* Previouslyownedflash controller. * Previouslyownedflash controller.
*/ */
#[Route(path: 'previously-owned-flash')] #[Route(path: 'previously-owned-flash')]
class PreviouslyOwnedFlashController extends AbstractController class PreviouslyOwnedFlashController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = PreviouslyOwnedFlash::class; protected const ENTITY = PreviouslyOwnedFlash::class;

View File

@ -4,15 +4,13 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedLenses; use App\Entity\PreviouslyOwnedLenses;
use App\Form\PreviouslyOwnedLensesType; use App\Form\PreviouslyOwnedLensesType;
use App\Controller\FormControllerBase;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'previously-owned-lens')] #[Route(path: 'previously-owned-lens')]
class PreviouslyOwnedLensesController extends AbstractController class PreviouslyOwnedLensesController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = PreviouslyOwnedLenses::class; protected const ENTITY = PreviouslyOwnedLenses::class;

View File

@ -1,17 +1,15 @@
<?php <?php declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
use App\Entity\Socket; use App\Entity\Socket;
use App\Form\SocketTypeForm; use App\Form\SocketTypeForm;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route('/socket')] #[Route('/socket')]
class SocketController extends AbstractController class SocketController extends AbstractController {
{
use FormControllerBase; use FormControllerBase;
protected const ENTITY = Socket::class; protected const ENTITY = Socket::class;

View File

@ -2,13 +2,12 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\{ArrayCollection, Collection};
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'brand', schema: 'collection')] #[ORM\Table(name: 'brand', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
#[ORM\UniqueConstraint(name: 'brand_unq', columns: ["name"])] #[ORM\UniqueConstraint(name: 'brand_unq', columns: ['name'])]
class Brand { class Brand {
use GetSet; use GetSet;

View File

@ -10,8 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'camera', schema: 'collection')] #[ORM\Table(name: 'camera', schema: 'collection')]
#[ORM\Entity(repositoryClass: CameraRepository::class)] #[ORM\Entity(repositoryClass: CameraRepository::class)]
class Camera class Camera {
{
use GetSet; use GetSet;
use CameraBase; use CameraBase;

View File

@ -9,8 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
* *
* Shared columns for camera, and previously_owned_camera tables * Shared columns for camera, and previously_owned_camera tables
*/ */
trait CameraBase trait CameraBase {
{
use PurchasePrice; use PurchasePrice;
#[ORM\ManyToOne(targetEntity: 'CameraType')] #[ORM\ManyToOne(targetEntity: 'CameraType')]
@ -36,7 +35,7 @@ trait CameraBase
private bool $isWorking; private bool $isWorking;
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]
private ?string $notes = null; private ?string $notes = NULL;
#[ORM\Column(name: 'serial', type: 'string', length: 20, nullable: FALSE)] #[ORM\Column(name: 'serial', type: 'string', length: 20, nullable: FALSE)]
private string $serial; private string $serial;

View File

@ -10,8 +10,7 @@ use Stringable;
*/ */
#[ORM\Table(name: 'camera_type', schema: 'collection')] #[ORM\Table(name: 'camera_type', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class CameraType implements Stringable class CameraType implements Stringable {
{
use GetSet; use GetSet;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]

View File

@ -2,8 +2,8 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\Common\Collections\{ArrayCollection, Collection};
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\{Collection, ArrayCollection};
#[ORM\Table(name: 'chipset', schema: 'collection')] #[ORM\Table(name: 'chipset', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]

View File

@ -3,7 +3,7 @@
namespace App\Entity; namespace App\Entity;
use App\Enum\CpuArchitecture; use App\Enum\CpuArchitecture;
use Doctrine\Common\Collections\{Collection, ArrayCollection}; use Doctrine\Common\Collections\{ArrayCollection, Collection};
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Table('cpu', schema: 'collection')] #[ORM\Table('cpu', schema: 'collection')]
@ -43,9 +43,9 @@ class Cpu {
#[ORM\Column('part_number', type: 'string')] #[ORM\Column('part_number', type: 'string')]
private string $partNumber; private string $partNumber;
#[ORM\Column('lot_number', type: 'string', nullable: TRUE, options: array( #[ORM\Column('lot_number', type: 'string', nullable: TRUE, options: [
'comment' => 'The CPU lot number, such as s-spec for Intel CPUs' 'comment' => 'The CPU lot number, such as s-spec for Intel CPUs',
))] ])]
private ?string $lotNumber; private ?string $lotNumber;
#[ORM\Column('micro_architecture', type: 'string', nullable: TRUE)] #[ORM\Column('micro_architecture', type: 'string', nullable: TRUE)]
@ -54,14 +54,14 @@ class Cpu {
#[ORM\Column('codename', type: 'string', nullable: TRUE)] #[ORM\Column('codename', type: 'string', nullable: TRUE)]
private ?string $codeName = ''; private ?string $codeName = '';
#[ORM\Column('base_speed', type: 'integer', options: array( #[ORM\Column('base_speed', type: 'integer', options: [
'comment' => 'The stock speed of the cpu in MHz' 'comment' => 'The stock speed of the cpu in MHz',
))] ])]
private int $baseSpeed; private int $baseSpeed;
#[ORM\Column('boost_speed', type: 'integer', nullable: true, options: array( #[ORM\Column('boost_speed', type: 'integer', nullable: TRUE, options: [
'comment' => 'The max boost speed of the cpu in MHz, if applicable' 'comment' => 'The max boost speed of the cpu in MHz, if applicable',
))] ])]
private ?int $boostSpeed; private ?int $boostSpeed;
#[ORM\Column('cores', type: 'integer')] #[ORM\Column('cores', type: 'integer')]
@ -70,15 +70,15 @@ class Cpu {
#[ORM\Column('threads', type: 'integer')] #[ORM\Column('threads', type: 'integer')]
private int $threads = 1; private int $threads = 1;
#[ORM\Column('igp', type: 'string', nullable: true, options: array( #[ORM\Column('igp', type: 'string', nullable: TRUE, options: [
'comment' => 'The name of the integrated graphics processor' 'comment' => 'The name of the integrated graphics processor',
))] ])]
private ?string $igp; private ?string $igp;
#[ORM\Column('voltage', type: 'float', nullable: true)] #[ORM\Column('voltage', type: 'float', nullable: TRUE)]
private ?float $voltage; private ?float $voltage;
#[ORM\Column('tdp', type: 'integer', nullable: true)] #[ORM\Column('tdp', type: 'integer', nullable: TRUE)]
private ?int $tdp; private ?int $tdp;
#[ORM\Column('process_node', type: 'integer', nullable: TRUE)] #[ORM\Column('process_node', type: 'integer', nullable: TRUE)]
@ -87,89 +87,89 @@ class Cpu {
#[ORM\Column('count', type: 'integer')] #[ORM\Column('count', type: 'integer')]
private int $count = 1; private int $count = 1;
#[ORM\Column('usable', type: 'boolean', options: array( #[ORM\Column('usable', type: 'boolean', options: [
'comment' => 'Whether the chip is working, and can be used with other hardware I have' 'comment' => 'Whether the chip is working, and can be used with other hardware I have',
))] ])]
private bool $usable = true; private bool $usable = TRUE;
#[ORM\Column('received', type: 'boolean', options: array( #[ORM\Column('received', type: 'boolean', options: [
'comment' => "Whether I have the chip in my possession (instead of in shipping)" 'comment' => 'Whether I have the chip in my possession (instead of in shipping)',
))] ])]
private bool $received = true; private bool $received = TRUE;
#[ORM\Column('link', type: 'string')] #[ORM\Column('link', type: 'string')]
private string $link; private string $link;
#[ORM\Column('notes', type: 'text', nullable: true)] #[ORM\Column('notes', type: 'text', nullable: TRUE)]
private ?string $notes = ''; private ?string $notes = '';
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// CPU Cache // CPU Cache
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
#[ORM\Column('l1_data_count', type:'integer', nullable: true, options: array( #[ORM\Column('l1_data_count', type: 'integer', nullable: TRUE, options: [
'comment' => 'The number of L1 data caches on the package, usually the same as the number of cores' 'comment' => 'The number of L1 data caches on the package, usually the same as the number of cores',
))] ])]
private ?int $L1dCount = null; private ?int $L1dCount = NULL;
#[ORM\Column('l1_data_size', type: 'integer', nullable: true, options: array( #[ORM\Column('l1_data_size', type: 'integer', nullable: TRUE, options: [
'comment' => 'The size of each Level 1 data cache in KB' 'comment' => 'The size of each Level 1 data cache in KB',
))] ])]
private ?int $L1dSize = null; private ?int $L1dSize = NULL;
#[ORM\Column('l1_data_way', type: 'integer', nullable: true)] #[ORM\Column('l1_data_way', type: 'integer', nullable: TRUE)]
private ?int $L1dWay = null; private ?int $L1dWay = NULL;
#[ORM\Column('l1_code_count', type:'integer', nullable: true, options: array( #[ORM\Column('l1_code_count', type: 'integer', nullable: TRUE, options: [
'comment' => 'The number of L1 instruction caches on the package, usually the same as the number of cores' 'comment' => 'The number of L1 instruction caches on the package, usually the same as the number of cores',
))] ])]
private ?int $L1cCount = null; private ?int $L1cCount = NULL;
#[ORM\Column('l1_code_size', type: 'integer', nullable: true, options: array( #[ORM\Column('l1_code_size', type: 'integer', nullable: TRUE, options: [
'comment' => 'The size of each Level 1 instruction cache in KB' 'comment' => 'The size of each Level 1 instruction cache in KB',
))] ])]
private ?int $L1cSize = null; private ?int $L1cSize = NULL;
#[ORM\Column('l1_code_way', type: 'integer', nullable: true)] #[ORM\Column('l1_code_way', type: 'integer', nullable: TRUE)]
private ?int $L1cWay = null; private ?int $L1cWay = NULL;
#[ORM\Column('l1_unified_count', type:'integer', nullable: true, options: array( #[ORM\Column('l1_unified_count', type: 'integer', nullable: TRUE, options: [
'comment' => 'The number of L1 caches on the package, usually the same as the number of cores' 'comment' => 'The number of L1 caches on the package, usually the same as the number of cores',
))] ])]
private ?int $L1uCount = null; private ?int $L1uCount = NULL;
#[ORM\Column('l1_unified_size', type: 'integer', nullable: true, options: array( #[ORM\Column('l1_unified_size', type: 'integer', nullable: TRUE, options: [
'comment' => 'The size of each Level 1 unified cache in KB' 'comment' => 'The size of each Level 1 unified cache in KB',
))] ])]
private ?int $L1uSize = null; private ?int $L1uSize = NULL;
#[ORM\Column('l1_unified_way', type: 'integer', nullable: true)] #[ORM\Column('l1_unified_way', type: 'integer', nullable: TRUE)]
private ?int $L1uWay = null; private ?int $L1uWay = NULL;
#[ORM\Column('l2_count', type: 'integer', options: array( #[ORM\Column('l2_count', type: 'integer', options: [
'comment' => 'The number of L2 caches on the package, usually the same as the number of cores' 'comment' => 'The number of L2 caches on the package, usually the same as the number of cores',
))] ])]
private int $L2Count = 1; private int $L2Count = 1;
#[ORM\Column('l2_size', type: 'integer', nullable: true, options: array( #[ORM\Column('l2_size', type: 'integer', nullable: TRUE, options: [
'comment' => 'The size of each Level 2 cache in KB' 'comment' => 'The size of each Level 2 cache in KB',
))] ])]
private ?int $L2Size; private ?int $L2Size;
#[ORM\Column('l2_way', type: 'integer', nullable: true)] #[ORM\Column('l2_way', type: 'integer', nullable: TRUE)]
private ?int $L2Way; private ?int $L2Way;
#[ORM\Column('l3_count', type: 'integer', options: array( #[ORM\Column('l3_count', type: 'integer', options: [
'comment' => 'The number of L3 caches on the package' 'comment' => 'The number of L3 caches on the package',
))] ])]
private int $L3Count = 0; private int $L3Count = 0;
#[ORM\Column('l3_size', type: 'integer', nullable: true, options: array( #[ORM\Column('l3_size', type: 'integer', nullable: TRUE, options: [
'comment' => 'The size of each Level 3 cache in KB' 'comment' => 'The size of each Level 3 cache in KB',
))] ])]
private ?int $L3Size; private ?int $L3Size;
#[ORM\Column('l3_way', type: 'integer', nullable: true)] #[ORM\Column('l3_way', type: 'integer', nullable: TRUE)]
private ?int $L3Way; private ?int $L3Way;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -2,7 +2,6 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
@ -10,8 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'film', schema: 'collection')] #[ORM\Table(name: 'film', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class Film class Film {
{
use GetSet; use GetSet;
#[ORM\Id] #[ORM\Id]

View File

@ -6,8 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'film_format', schema: 'collection')] #[ORM\Table(name: 'film_format', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class FilmFormat class FilmFormat {
{
use GetSet; use GetSet;
#[ORM\Id] #[ORM\Id]

View File

@ -9,8 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'flash', schema: 'collection')] #[ORM\Table(name: 'flash', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class Flash class Flash {
{
use GetSet; use GetSet;
use FlashBase; use FlashBase;

View File

@ -4,8 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
trait FlashBase trait FlashBase {
{
use PurchasePrice; use PurchasePrice;
#[ORM\Column(name: 'brand', type: 'string', nullable: FALSE)] #[ORM\Column(name: 'brand', type: 'string', nullable: FALSE)]

View File

@ -33,7 +33,7 @@ class Fpu {
#[ORM\Column(name: 'clock_speed', type: 'integer')] #[ORM\Column(name: 'clock_speed', type: 'integer')]
private int $clockSpeed = 33; private int $clockSpeed = 33;
#[ORM\Column(name: 'count', nullable: FALSE, options: array('default' => 1))] #[ORM\Column(name: 'count', nullable: FALSE, options: ['default' => 1])]
private int $count = 1; private int $count = 1;
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]

View File

@ -2,8 +2,7 @@
namespace App\Entity; namespace App\Entity;
use App\Enum\CardBus; use App\Enum\{CardBus, SlotKey};
use App\Enum\SlotKey;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'gpu', schema: 'collection')] #[ORM\Table(name: 'gpu', schema: 'collection')]
@ -41,10 +40,10 @@ class Gpu {
name: 'card_key', name: 'card_key',
type: 'string', type: 'string',
enumType: SlotKey::class, enumType: SlotKey::class,
options: array( options: [
'comment' => "The shape of the card connector", 'comment' => 'The shape of the card connector',
'default' => "PCIe x16" 'default' => 'PCIe x16',
) ]
)] )]
private SlotKey $cardKey = SlotKey::PCIE_X16; private SlotKey $cardKey = SlotKey::PCIE_X16;
@ -53,67 +52,67 @@ class Gpu {
type: 'string', type: 'string',
nullable: TRUE, nullable: TRUE,
enumType: CardBus::class, enumType: CardBus::class,
options: array('comment' => "The type of electrical bus this card uses") options: ['comment' => 'The type of electrical bus this card uses']
)] )]
private ?CardBus $busInterface; private ?CardBus $busInterface;
#[ORM\Column( #[ORM\Column(
name: 'slot_span', name: 'slot_span',
options: array( options: [
'comment' => "How many expansion slots the card occupies", 'comment' => 'How many expansion slots the card occupies',
'default' => 1, 'default' => 1,
), ],
)] )]
private int $slotSpan = 1; private int $slotSpan = 1;
#[ORM\Column(name: 'molex_power', options: array('default' => 0))] #[ORM\Column(name: 'molex_power', options: ['default' => 0])]
private int $molexPower = 0; private int $molexPower = 0;
#[ORM\Column(name: 'pcie_6_pin', options: array('default' => 0))] #[ORM\Column(name: 'pcie_6_pin', options: ['default' => 0])]
private int $pcie6power = 0; private int $pcie6power = 0;
#[ORM\Column(name: 'pcie_8_pin', options: array('default' => 0))] #[ORM\Column(name: 'pcie_8_pin', options: ['default' => 0])]
private int $pcie8power = 0; private int $pcie8power = 0;
#[ORM\Column( #[ORM\Column(
name: 'tdp', name: 'tdp',
nullable: TRUE, nullable: TRUE,
options: array('comment' => "Thermal Design Power (in Watts)") options: ['comment' => 'Thermal Design Power (in Watts)']
)] )]
private ?int $tdp = 0; private ?int $tdp = 0;
#[ORM\Column( #[ORM\Column(
name: 'base_clock', name: 'base_clock',
nullable: TRUE, nullable: TRUE,
options: array('comment' => "Base speed of the gpu core, in MHz") options: ['comment' => 'Base speed of the gpu core, in MHz']
)] )]
private ?int $baseClock; private ?int $baseClock;
#[ORM\Column( #[ORM\Column(
name: 'boost_clock', name: 'boost_clock',
nullable: TRUE, nullable: TRUE,
options: array('comment' => "GPU core boost clock, in MHz") options: ['comment' => 'GPU core boost clock, in MHz']
)] )]
private ?int $boostClock; private ?int $boostClock;
#[ORM\Column( #[ORM\Column(
name: 'memory_clock', name: 'memory_clock',
nullable: TRUE, nullable: TRUE,
options: array('comment' => "Clock speed of the VRAM, in MHz") options: ['comment' => 'Clock speed of the VRAM, in MHz']
)] )]
private ?int $memoryClock; private ?int $memoryClock;
#[ORM\Column( #[ORM\Column(
name: 'memory_size', name: 'memory_size',
nullable: TRUE, nullable: TRUE,
options: array('comment' => 'VRAM size, in MiB') options: ['comment' => 'VRAM size, in MiB']
)] )]
private ?int $memorySize; private ?int $memorySize;
#[ORM\Column( #[ORM\Column(
name: 'memory_bus', name: 'memory_bus',
nullable: TRUE, nullable: TRUE,
options: array("comment" => 'The width of the memory bus in bits') options: ['comment' => 'The width of the memory bus in bits']
)] )]
private ?int $memoryBus; private ?int $memoryBus;
@ -156,10 +155,10 @@ class Gpu {
#[ORM\Column(name: 'link', nullable: TRUE)] #[ORM\Column(name: 'link', nullable: TRUE)]
private ?string $link; private ?string $link;
#[ORM\Column(name: 'count', nullable: FALSE, options: array('default' => 1))] #[ORM\Column(name: 'count', nullable: FALSE, options: ['default' => 1])]
private int $count = 1; private int $count = 1;
#[ORM\Column(name: 'acquired', nullable: FALSE, options: array('default' => TRUE))] #[ORM\Column(name: 'acquired', nullable: FALSE, options: ['default' => TRUE])]
private bool $acquired; private bool $acquired;
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]

View File

@ -4,8 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
trait LensTrait trait LensTrait {
{
use PurchasePrice; use PurchasePrice;
#[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: TRUE)] #[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: TRUE)]

View File

@ -10,8 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'lenses', schema: 'collection')] #[ORM\Table(name: 'lenses', schema: 'collection')]
#[ORM\Entity(repositoryClass: LensesRepository::class)] #[ORM\Entity(repositoryClass: LensesRepository::class)]
class Lenses class Lenses {
{
use GetSet; use GetSet;
use LensTrait; use LensTrait;

View File

@ -2,8 +2,8 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\Common\Collections\{ArrayCollection, Collection};
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\{Collection, ArrayCollection};
#[ORM\Table(name: 'motherboard', schema: 'collection')] #[ORM\Table(name: 'motherboard', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
@ -41,7 +41,7 @@ class Motherboard {
#[ORM\Column('link', type: 'string')] #[ORM\Column('link', type: 'string')]
private string $link; private string $link;
#[ORM\Column('notes', type: 'text', nullable: true)] #[ORM\Column('notes', type: 'text', nullable: TRUE)]
private ?string $notes = ''; private ?string $notes = '';
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -10,8 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'previously_owned_camera', schema: 'collection')] #[ORM\Table(name: 'previously_owned_camera', schema: 'collection')]
#[ORM\Entity(repositoryClass: CameraRepository::class)] #[ORM\Entity(repositoryClass: CameraRepository::class)]
class PreviouslyOwnedCamera class PreviouslyOwnedCamera {
{
use GetSet; use GetSet;
use CameraBase; use CameraBase;

View File

@ -9,8 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'previously_owned_flash', schema: 'collection')] #[ORM\Table(name: 'previously_owned_flash', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class PreviouslyOwnedFlash class PreviouslyOwnedFlash {
{
use GetSet; use GetSet;
use FlashBase; use FlashBase;

View File

@ -10,8 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
#[ORM\Table(name: 'previously_owned_lenses', schema: 'collection')] #[ORM\Table(name: 'previously_owned_lenses', schema: 'collection')]
#[ORM\Entity(repositoryClass: LensesRepository::class)] #[ORM\Entity(repositoryClass: LensesRepository::class)]
class PreviouslyOwnedLenses class PreviouslyOwnedLenses {
{
use GetSet; use GetSet;
use LensTrait; use LensTrait;

View File

@ -4,8 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
trait PurchasePrice trait PurchasePrice {
{
#[ORM\Column(name: 'purchase_price', type: 'money', nullable: TRUE)] #[ORM\Column(name: 'purchase_price', type: 'money', nullable: TRUE)]
private ?string $purchasePrice = NULL; private ?string $purchasePrice = NULL;
@ -18,7 +17,8 @@ trait PurchasePrice
public function getPurchasePrice(): string public function getPurchasePrice(): string
{ {
if (empty($this->purchasePrice)) { if (empty($this->purchasePrice))
{
return '0'; return '0';
} }

View File

@ -26,9 +26,9 @@ enum CardBus: string {
public static function getGroups(): array public static function getGroups(): array
{ {
$filter = static fn (string $starts_with) => $filter = static fn (string $starts_with) => array_filter(
array_filter(self::cases(), fn (CardBus $case) => self::cases(),
str_starts_with($case->name, $starts_with) static fn (CardBus $case) => str_starts_with($case->name, $starts_with)
); );
$pcie = $filter('PCIE_'); $pcie = $filter('PCIE_');
@ -36,8 +36,8 @@ enum CardBus: string {
$pci = $filter('PCI_'); $pci = $filter('PCI_');
$isa = $filter('ISA_'); $isa = $filter('ISA_');
$pcie16 = array_filter($pcie, fn (CardBus $case) => str_ends_with($case->name, '_16')); $pcie16 = array_filter($pcie, static fn (CardBus $case) => str_ends_with($case->name, '_16'));
$pcieOther = array_udiff($pcie, $pcie16, fn ($a, $b) => $a->name <=> $b->name); $pcieOther = array_udiff($pcie, $pcie16, static fn ($a, $b) => $a->name <=> $b->name);
return [ return [
'PCI Express x16' => $pcie16, 'PCI Express x16' => $pcie16,

View File

@ -30,20 +30,22 @@ enum SlotKey: string {
public static function getCases(): array public static function getCases(): array
{ {
$cases = self::cases(); $cases = self::cases();
return array_map(static fn(UnitEnum $case) => $case->name, $cases);
return array_map(static fn (UnitEnum $case) => $case->name, $cases);
} }
public static function getValues(): array public static function getValues(): array
{ {
$cases = self::cases(); $cases = self::cases();
return array_map(static fn(UnitEnum $case) => $case->value, $cases);
return array_map(static fn (UnitEnum $case) => $case->value, $cases);
} }
public static function getGroups(): array public static function getGroups(): array
{ {
$filter = static fn (string $starts_with) => $filter = static fn (string $starts_with) => array_filter(
array_filter(self::cases(), fn (SlotKey $case) => self::cases(),
str_starts_with($case->name, $starts_with) static fn (SlotKey $case) => str_starts_with($case->name, $starts_with)
); );
return [ return [
@ -68,7 +70,7 @@ enum SlotKey: string {
self::ISA_16, self::ISA_16,
self::ISA_8, self::ISA_8,
self::ISA_VLB, self::ISA_VLB,
] ],
]; ];
} }
} }

View File

@ -2,14 +2,12 @@
namespace App\Form; namespace App\Form;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\{EntityRepository, QueryBuilder};
use Doctrine\ORM\QueryBuilder;
trait BrandCategoryTrait { trait BrandCategoryTrait {
public static function filterBrands(string $filter): callable public static function filterBrands(string $filter): callable
{ {
return static fn(EntityRepository $e) => return static fn (EntityRepository $e) => $e->createQueryBuilder('b')
$e->createQueryBuilder('b')
->join('b.categories', 'bc') ->join('b.categories', 'bc')
->where('bc.name=:name') ->where('bc.name=:name')
->orderBy('b.name', 'ASC') ->orderBy('b.name', 'ASC')

View File

@ -1,19 +1,16 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\BrandCategory; use App\Entity\BrandCategory;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class BrandCategoryType extends AbstractType class BrandCategoryType extends AbstractType {
{
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder
->add('name') ->add('name');
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -2,15 +2,11 @@
namespace App\Form; namespace App\Form;
use App\Entity\Brand; use App\Entity\{Brand, BrandCategory};
use Symfony\Component\Form\{AbstractType, FormBuilderInterface}; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use App\Entity\BrandCategory;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class BrandType extends AbstractType class BrandType extends AbstractType {
{
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder

View File

@ -9,8 +9,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class CameraType extends AbstractType class CameraType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -8,8 +8,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class CameraTypeType extends AbstractType class CameraTypeType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -1,16 +1,13 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\Brand; use App\Entity\{Brand, Chipset};
use App\Entity\Chipset;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class ChipsetType extends AbstractType class ChipsetType extends AbstractType {
{
use BrandCategoryTrait; use BrandCategoryTrait;
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
@ -22,8 +19,7 @@ class ChipsetType extends AbstractType
]) ])
->add('name') ->add('name')
->add('parts') ->add('parts')
->add('link') ->add('link');
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -1,15 +1,12 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\Brand; use App\Entity\{Brand, Cpu};
use App\Entity\Cpu;
use App\Enum\CpuArchitecture; use App\Enum\CpuArchitecture;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\{EnumType, UrlType};
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use UnitEnum; use UnitEnum;
@ -21,7 +18,7 @@ class CpuType extends AbstractType {
$builder $builder
->add('architecture', EnumType::class, [ ->add('architecture', EnumType::class, [
'class' => CpuArchitecture::class, 'class' => CpuArchitecture::class,
'choice_label' => fn(UnitEnum $choice): string => $choice->value, 'choice_label' => static fn (UnitEnum $choice): string => $choice->value,
'choices' => CpuArchitecture::getGroups(), 'choices' => CpuArchitecture::getGroups(),
]) ])
->add('brand', EntityType::class, [ ->add('brand', EntityType::class, [
@ -37,50 +34,50 @@ class CpuType extends AbstractType {
->add('codeName') ->add('codeName')
// Cache Stuff // Cache Stuff
->add('L1dCount', null, [ ->add('L1dCount', NULL, [
'label' => 'L1 Data Cache(s)', 'label' => 'L1 Data Cache(s)',
]) ])
->add('L1dSize', null, [ ->add('L1dSize', NULL, [
'label' => 'L1 Data Size KB' 'label' => 'L1 Data Size KB',
]) ])
->add('L1dWay', null, [ ->add('L1dWay', NULL, [
'label' => 'L1 Data (x-way)' 'label' => 'L1 Data (x-way)',
]) ])
->add('L1cCount', null, [ ->add('L1cCount', NULL, [
'label' => 'L1 Instruction Cache(s)', 'label' => 'L1 Instruction Cache(s)',
]) ])
->add('L1cSize', null, [ ->add('L1cSize', NULL, [
'label' => 'L1 Instruction Size KB' 'label' => 'L1 Instruction Size KB',
]) ])
->add('L1cWay', null, [ ->add('L1cWay', NULL, [
'label' => 'L1 Instruction (x-way)' 'label' => 'L1 Instruction (x-way)',
]) ])
->add('L1uCount', null, [ ->add('L1uCount', NULL, [
'label' => 'L1 Unified Cache(s)', 'label' => 'L1 Unified Cache(s)',
]) ])
->add('L1uSize', null, [ ->add('L1uSize', NULL, [
'label' => 'L1 Unified Cache Size: KB' 'label' => 'L1 Unified Cache Size: KB',
]) ])
->add('L1uWay', null, [ ->add('L1uWay', NULL, [
'label' => 'L1 Unified (x-way)' 'label' => 'L1 Unified (x-way)',
]) ])
->add('L2Count', null, [ ->add('L2Count', NULL, [
'label' => 'L2 Cache(s)' 'label' => 'L2 Cache(s)',
]) ])
->add('L2Size', null, [ ->add('L2Size', NULL, [
'label' => 'L2 Cache Size KB (per unit)' 'label' => 'L2 Cache Size KB (per unit)',
]) ])
->add('L2Way', null, [ ->add('L2Way', NULL, [
'label' => 'L2 Cache (x-way)' 'label' => 'L2 Cache (x-way)',
]) ])
->add('L3Count', null, [ ->add('L3Count', NULL, [
'label' => 'L3 Cache(s)' 'label' => 'L3 Cache(s)',
]) ])
->add('L3Size', null, [ ->add('L3Size', NULL, [
'label' => 'L3 Cache Size KB (per unit)' 'label' => 'L3 Cache Size KB (per unit)',
]) ])
->add('L3Way', null, [ ->add('L3Way', NULL, [
'label' => 'L3 Cache (x-way)' 'label' => 'L3 Cache (x-way)',
]) ])
->add('baseSpeed') ->add('baseSpeed')
@ -95,8 +92,7 @@ class CpuType extends AbstractType {
->add('usable') ->add('usable')
->add('received') ->add('received')
->add('link', UrlType::class) ->add('link', UrlType::class)
->add('notes') ->add('notes');
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -7,8 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\{AbstractType, FormBuilderInterface}; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class FilmType extends AbstractType class FilmType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -8,8 +8,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class FlashType extends AbstractType class FlashType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -1,18 +1,14 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\Brand; use App\Entity\{Brand, Fpu, Socket};
use App\Entity\Fpu;
use App\Entity\Socket;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class FpuType extends AbstractType class FpuType extends AbstractType {
{
use BrandCategoryTrait; use BrandCategoryTrait;
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
@ -20,7 +16,7 @@ class FpuType extends AbstractType
$builder $builder
->add('socket', EntityType::class, [ ->add('socket', EntityType::class, [
'class' => Socket::class, 'class' => Socket::class,
'query_builder' => static fn(EntityRepository $e) => $e->createQueryBuilder('s')->orderBy('s.name', 'ASC'), 'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('s')->orderBy('s.name', 'ASC'),
]) ])
->add('brand', EntityType::class, [ ->add('brand', EntityType::class, [
'class' => Brand::class, 'class' => Brand::class,
@ -30,8 +26,7 @@ class FpuType extends AbstractType
->add('model') ->add('model')
->add('clockSpeed') ->add('clockSpeed')
->add('count') ->add('count')
->add('notes') ->add('notes');
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -3,13 +3,11 @@
namespace App\Form; namespace App\Form;
use App\Entity\{Brand, GpuCore}; use App\Entity\{Brand, GpuCore};
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\{AbstractType, FormBuilderInterface}; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class GPUCoreType extends AbstractType class GPUCoreType extends AbstractType {
{
use BrandCategoryTrait; use BrandCategoryTrait;
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
@ -35,4 +33,3 @@ class GPUCoreType extends AbstractType
]); ]);
} }
} }

View File

@ -2,8 +2,8 @@
namespace App\Form; namespace App\Form;
use App\Enum\{CardBus, SlotKey};
use App\Entity\{Brand, Gpu, GpuCore}; use App\Entity\{Brand, Gpu, GpuCore};
use App\Enum\{CardBus, SlotKey};
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\ use Symfony\Component\Form\
@ -24,7 +24,7 @@ class GpuType extends AbstractType {
->add('modelName') ->add('modelName')
->add('gpuCore', EntityType::class, [ ->add('gpuCore', EntityType::class, [
'class' => GpuCore::class, 'class' => GpuCore::class,
'query_builder' => static fn(EntityRepository $e) => $e->createQueryBuilder('gc')->orderBy('gc.brand', 'ASC')->orderBy('gc.name', 'ASC'), 'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('gc')->orderBy('gc.brand', 'ASC')->orderBy('gc.name', 'ASC'),
'placeholder' => 'Unknown', 'placeholder' => 'Unknown',
'empty_data' => NULL, 'empty_data' => NULL,
'required' => FALSE, 'required' => FALSE,
@ -40,12 +40,12 @@ class GpuType extends AbstractType {
->add('cardKey', EnumType::class, [ ->add('cardKey', EnumType::class, [
'class' => SlotKey::class, 'class' => SlotKey::class,
'choices' => SlotKey::getGroups(), 'choices' => SlotKey::getGroups(),
'choice_label' => fn(UnitEnum $choice): string => $choice->value, 'choice_label' => static fn (UnitEnum $choice): string => $choice->value,
]) ])
->add('busInterface', EnumType::class, [ ->add('busInterface', EnumType::class, [
'class' => CardBus::class, 'class' => CardBus::class,
'choices' => CardBus::getGroups(), 'choices' => CardBus::getGroups(),
'choice_label' => fn(UnitEnum $choice): string => $choice->value, 'choice_label' => static fn (UnitEnum $choice): string => $choice->value,
]) ])
->add('slotSpan') ->add('slotSpan')
->add('molexPower', NULL, ['label' => 'Molex Power Connectors']) ->add('molexPower', NULL, ['label' => 'Molex Power Connectors'])

View File

@ -9,8 +9,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class LensesType extends AbstractType class LensesType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -8,8 +8,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class PreviouslyOwnedCameraType extends AbstractType class PreviouslyOwnedCameraType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -8,8 +8,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class PreviouslyOwnedFlashType extends AbstractType class PreviouslyOwnedFlashType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -8,8 +8,7 @@ use Symfony\Component\OptionsResolver\Exception\AccessException;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class PreviouslyOwnedLensesType extends AbstractType class PreviouslyOwnedLensesType extends AbstractType {
{
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -1,26 +1,23 @@
<?php <?php declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\Socket; use App\Entity\Socket;
use App\Enum\SocketType; use App\Enum\SocketType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class SocketTypeForm extends AbstractType class SocketTypeForm extends AbstractType {
{
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder
->add('name') ->add('name')
->add('otherName') ->add('otherName')
->add('pinCount') ->add('pinCount')
->add('type', EnumType::class,[ ->add('type', EnumType::class, [
'class' => SocketType::class, 'class' => SocketType::class,
]) ]);
;
} }
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void

View File

@ -18,16 +18,14 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
class Kernel extends BaseKernel class Kernel extends BaseKernel {
{
use MicroKernelTrait; use MicroKernelTrait;
protected function configureContainer( protected function configureContainer(
ContainerConfigurator $container, ContainerConfigurator $container,
LoaderInterface $loader, LoaderInterface $loader,
ContainerBuilder $builder ContainerBuilder $builder
): void ): void {
{
$configDir = $this->getConfigDir(); $configDir = $this->getConfigDir();
$container->import('../config/{packages}/*.yaml'); $container->import('../config/{packages}/*.yaml');

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of the Symfony MakerBundle package. * This file is part of the Symfony MakerBundle package.
@ -12,32 +12,23 @@
namespace App\Maker; namespace App\Maker;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Inflector\Inflector; use Doctrine\Inflector\{Inflector, InflectorFactory};
use Doctrine\Inflector\InflectorFactory; use Doctrine\ORM\{EntityManagerInterface, EntityRepository};
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper; use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper;
use Symfony\Bundle\MakerBundle\Generator;
use Symfony\Bundle\MakerBundle\InputConfiguration;
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker; use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer; use Symfony\Bundle\MakerBundle\Renderer\FormTypeRenderer;
use Symfony\Bundle\MakerBundle\Str;
use Symfony\Bundle\MakerBundle\Util\UseStatementGenerator; use Symfony\Bundle\MakerBundle\Util\UseStatementGenerator;
use Symfony\Bundle\MakerBundle\Validator; use Symfony\Bundle\MakerBundle\{ConsoleStyle, DependencyBuilder, Generator, InputConfiguration, Str, Validator};
use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\{InputArgument, InputInterface};
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Question\Question;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\{Request, Response};
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Csrf\CsrfTokenManager; use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validation;
@ -45,17 +36,16 @@ use Symfony\Component\Validator\Validation;
/** /**
* @author Sadicov Vladimir <sadikoff@gmail.com> * @author Sadicov Vladimir <sadikoff@gmail.com>
*/ */
final class MakeCollectionCrud extends AbstractMaker final class MakeCollectionCrud extends AbstractMaker {
{
private Inflector $inflector; private Inflector $inflector;
private string $controllerClassName; private string $controllerClassName;
private bool $generateTests = false; private bool $generateTests = FALSE;
public function __construct(private DoctrineHelper $doctrineHelper, private FormTypeRenderer $formTypeRenderer) public function __construct(private DoctrineHelper $doctrineHelper, private FormTypeRenderer $formTypeRenderer)
{ {
$this->inflector = InflectorFactory::create()->build(); $this->inflector = InflectorFactory::create()->build();
define('CRUD_TEMPLATE_PREFIX', __DIR__.'/../Resources/crud'); define('CRUD_TEMPLATE_PREFIX', __DIR__ . '/../Resources/crud');
} }
public static function getCommandName(): string public static function getCommandName(): string
@ -72,15 +62,15 @@ final class MakeCollectionCrud extends AbstractMaker
{ {
$command $command
->addArgument('entity-class', InputArgument::OPTIONAL, sprintf('The class name of the entity to create CRUD (e.g. <fg=yellow>%s</>)', Str::asClassName(Str::getRandomTerm()))) ->addArgument('entity-class', InputArgument::OPTIONAL, sprintf('The class name of the entity to create CRUD (e.g. <fg=yellow>%s</>)', Str::asClassName(Str::getRandomTerm())))
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeCrud.txt')) ->setHelp(file_get_contents(__DIR__ . '/../Resources/help/MakeCrud.txt'));
;
$inputConfig->setArgumentAsNonInteractive('entity-class'); $inputConfig->setArgumentAsNonInteractive('entity-class');
} }
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
{ {
if (null === $input->getArgument('entity-class')) { if (NULL === $input->getArgument('entity-class'))
{
$argument = $command->getDefinition()->getArgument('entity-class'); $argument = $command->getDefinition()->getArgument('entity-class');
$entities = $this->doctrineHelper->getEntitiesForAutocomplete(); $entities = $this->doctrineHelper->getEntitiesForAutocomplete();
@ -100,7 +90,7 @@ final class MakeCollectionCrud extends AbstractMaker
$defaultControllerClass $defaultControllerClass
); );
$this->generateTests = $io->confirm('Do you want to generate tests for the controller?. [Experimental]', false); $this->generateTests = $io->confirm('Do you want to generate tests for the controller?. [Experimental]', FALSE);
} }
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
@ -115,9 +105,10 @@ final class MakeCollectionCrud extends AbstractMaker
$repositoryVars = []; $repositoryVars = [];
$repositoryClassName = EntityManagerInterface::class; $repositoryClassName = EntityManagerInterface::class;
if (null !== $entityDoctrineDetails->getRepositoryClass()) { if (NULL !== $entityDoctrineDetails->getRepositoryClass())
{
$repositoryClassDetails = $generator->createClassNameDetails( $repositoryClassDetails = $generator->createClassNameDetails(
'\\'.$entityDoctrineDetails->getRepositoryClass(), '\\' . $entityDoctrineDetails->getRepositoryClass(),
'Repository\\', 'Repository\\',
'Repository' 'Repository'
); );
@ -138,14 +129,17 @@ final class MakeCollectionCrud extends AbstractMaker
); );
$iter = 0; $iter = 0;
do {
do
{
$formClassDetails = $generator->createClassNameDetails( $formClassDetails = $generator->createClassNameDetails(
$entityClassDetails->getRelativeNameWithoutSuffix().($iter ?: '').'Type', $entityClassDetails->getRelativeNameWithoutSuffix() . ($iter ?: '') . 'Type',
'Form\\', 'Form\\',
'Type' 'Type'
); );
++$iter; $iter++;
} while (class_exists($formClassDetails->getFullName())); }
while (class_exists($formClassDetails->getFullName()));
$entityVarPlural = lcfirst($this->inflector->pluralize($entityClassDetails->getShortName())); $entityVarPlural = lcfirst($this->inflector->pluralize($entityClassDetails->getShortName()));
$entityVarSingular = lcfirst($this->inflector->singularize($entityClassDetails->getShortName())); $entityVarSingular = lcfirst($this->inflector->singularize($entityClassDetails->getShortName()));
@ -169,7 +163,8 @@ final class MakeCollectionCrud extends AbstractMaker
$generator->generateController( $generator->generateController(
$controllerClassDetails->getFullName(), $controllerClassDetails->getFullName(),
CRUD_TEMPLATE_PREFIX . '/controller/Controller.tpl.php', CRUD_TEMPLATE_PREFIX . '/controller/Controller.tpl.php',
array_merge([ array_merge(
[
'use_statements' => $useStatements, 'use_statements' => $useStatements,
'entity_class_name' => $entityClassDetails->getShortName(), 'entity_class_name' => $entityClassDetails->getShortName(),
'form_class_name' => $formClassDetails->getShortName(), 'form_class_name' => $formClassDetails->getShortName(),
@ -224,15 +219,17 @@ final class MakeCollectionCrud extends AbstractMaker
], ],
]; ];
foreach ($templates as $template => $variables) { foreach ($templates as $template => $variables)
{
$generator->generateTemplate( $generator->generateTemplate(
$templatesPath.'/'.$template.'.html.twig', $templatesPath . '/' . $template . '.html.twig',
CRUD_TEMPLATE_PREFIX . '/templates/'.$template.'.tpl.php', CRUD_TEMPLATE_PREFIX . '/templates/' . $template . '.tpl.php',
$variables $variables
); );
} }
if ($this->generateTests) { if ($this->generateTests)
{
$testClassDetails = $generator->createClassNameDetails( $testClassDetails = $generator->createClassNameDetails(
$entityClassDetails->getRelativeNameWithoutSuffix(), $entityClassDetails->getRelativeNameWithoutSuffix(),
'Test\\Controller\\', 'Test\\Controller\\',
@ -248,12 +245,13 @@ final class MakeCollectionCrud extends AbstractMaker
$usesEntityManager = EntityManagerInterface::class === $repositoryClassName; $usesEntityManager = EntityManagerInterface::class === $repositoryClassName;
if ($usesEntityManager) { if ($usesEntityManager)
{
$useStatements->addUseStatement(EntityRepository::class); $useStatements->addUseStatement(EntityRepository::class);
} }
$generator->generateFile( $generator->generateFile(
'tests/Controller/'.$testClassDetails->getShortName().'.php', 'tests/Controller/' . $testClassDetails->getShortName() . '.php',
$usesEntityManager ? 'crud/test/Test.EntityManager.tpl.php' : 'crud/test/Test.tpl.php', $usesEntityManager ? 'crud/test/Test.EntityManager.tpl.php' : 'crud/test/Test.tpl.php',
[ [
'use_statements' => $useStatements, 'use_statements' => $useStatements,
@ -270,7 +268,8 @@ final class MakeCollectionCrud extends AbstractMaker
] ]
); );
if (!class_exists(WebTestCase::class)) { if ( ! class_exists(WebTestCase::class))
{
$io->caution('You\'ll need to install the `symfony/test-pack` to execute the tests for your new controller.'); $io->caution('You\'ll need to install the `symfony/test-pack` to execute the tests for your new controller.');
} }
} }

View File

@ -10,8 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/** /**
* Auto-generated Migration: Please modify to your needs! * Auto-generated Migration: Please modify to your needs!
*/ */
final class Version20221117193508 extends AbstractMigration final class Version20221117193508 extends AbstractMigration {
{
public function getDescription(): string public function getDescription(): string
{ {
return ''; return '';

View File

@ -7,8 +7,7 @@ use Doctrine\ORM\{EntityRepository};
use ReflectionObject; use ReflectionObject;
use Throwable; use Throwable;
abstract class AcquireRepository extends EntityRepository abstract class AcquireRepository extends EntityRepository {
{
abstract public function reacquire(mixed $currentRecord): void; abstract public function reacquire(mixed $currentRecord): void;
abstract public function deacquire(mixed $currentRecord): void; abstract public function deacquire(mixed $currentRecord): void;
@ -24,9 +23,11 @@ abstract class AcquireRepository extends EntityRepository
$old = new ReflectionObject($currentRecord); $old = new ReflectionObject($currentRecord);
$new = new ReflectionObject($newRecord); $new = new ReflectionObject($newRecord);
foreach ($old->getProperties() as $property) { foreach ($old->getProperties() as $property)
{
$propertyName = $property->getName(); $propertyName = $property->getName();
if ($new->hasProperty($propertyName)) { if ($new->hasProperty($propertyName))
{
$newProperty = $new->getProperty($propertyName); $newProperty = $new->getProperty($propertyName);
$newProperty->setAccessible(TRUE); $newProperty->setAccessible(TRUE);
$property->setAccessible(TRUE); $property->setAccessible(TRUE);
@ -34,11 +35,14 @@ abstract class AcquireRepository extends EntityRepository
} }
} }
try { try
{
$em->persist($newRecord); $em->persist($newRecord);
$em->remove($currentRecord); $em->remove($currentRecord);
$em->flush(); $em->flush();
} catch (Throwable) { }
catch (Throwable)
{
dump($newRecord); dump($newRecord);
} }
} }

View File

@ -5,8 +5,7 @@ namespace App\Repository;
use App\Entity\{Camera, PreviouslyOwnedCamera}; use App\Entity\{Camera, PreviouslyOwnedCamera};
use Doctrine\ORM\{ORMInvalidArgumentException}; use Doctrine\ORM\{ORMInvalidArgumentException};
class CameraRepository extends AcquireRepository class CameraRepository extends AcquireRepository {
{
/** /**
* @throws ORMInvalidArgumentException * @throws ORMInvalidArgumentException
*/ */

View File

@ -5,8 +5,7 @@ namespace App\Repository;
use App\Entity\{Flash, PreviouslyOwnedFlash}; use App\Entity\{Flash, PreviouslyOwnedFlash};
use Doctrine\ORM\{ORMInvalidArgumentException}; use Doctrine\ORM\{ORMInvalidArgumentException};
class FlashRepository extends AcquireRepository class FlashRepository extends AcquireRepository {
{
/** /**
* @throws ORMInvalidArgumentException * @throws ORMInvalidArgumentException
*/ */

View File

@ -4,8 +4,7 @@ namespace App\Repository;
use App\Entity\{Lenses, PreviouslyOwnedLenses}; use App\Entity\{Lenses, PreviouslyOwnedLenses};
class LensesRepository extends AcquireRepository class LensesRepository extends AcquireRepository {
{
public function deacquire(mixed $currentRecord): void public function deacquire(mixed $currentRecord): void
{ {
$currentRecord->setFormerlyOwned(TRUE) $currentRecord->setFormerlyOwned(TRUE)

View File

@ -32,9 +32,12 @@ class <?= $class_name ?> extends AbstractController {
<?php endif ?> <?php endif ?>
<?= $generator->generateRouteForControllerMethod('/new', sprintf('%s_new', $route_name), ['GET', 'POST']) ?> <?= $generator->generateRouteForControllerMethod('/new', sprintf('%s_new', $route_name), ['GET', 'POST']) ?>
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?> <?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name))
{ ?>
public function new(Request $request, <?= $repository_class_name ?> $<?= $repository_var ?>): Response public function new(Request $request, <?= $repository_class_name ?> $<?= $repository_var ?>): Response
<?php } else { ?> <?php }
else
{ ?>
public function new(Request $request): Response public function new(Request $request): Response
<?php } ?> <?php } ?>
{ {
@ -48,9 +51,12 @@ class <?= $class_name ?> extends AbstractController {
} }
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}/edit', $entity_identifier), sprintf('%s_edit', $route_name), ['GET', 'POST']) ?> <?= $generator->generateRouteForControllerMethod(sprintf('/{%s}/edit', $entity_identifier), sprintf('%s_edit', $route_name), ['GET', 'POST']) ?>
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?> <?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name))
{ ?>
public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, <?= $repository_class_name ?> $<?= $repository_var ?>): Response public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, <?= $repository_class_name ?> $<?= $repository_var ?>): Response
<?php } else { ?> <?php }
else
{ ?>
public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
<?php } ?> <?php } ?>
{ {
@ -58,9 +64,12 @@ class <?= $class_name ?> extends AbstractController {
} }
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}', $entity_identifier), sprintf('%s_delete', $route_name), ['POST']) ?> <?= $generator->generateRouteForControllerMethod(sprintf('/{%s}', $entity_identifier), sprintf('%s_delete', $route_name), ['POST']) ?>
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?> <?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name))
{ ?>
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, <?= $repository_class_name ?> $<?= $repository_var ?>): Response public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, <?= $repository_class_name ?> $<?= $repository_var ?>): Response
<?php } else { ?> <?php }
else
{ ?>
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
<?php } ?> <?php } ?>
{ {

View File

@ -7,8 +7,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
class MoneyType extends Type class MoneyType extends Type {
{
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{ {
return 'MONEY'; return 'MONEY';

View File

@ -4,8 +4,7 @@ namespace App\ValueObject;
use Stringable; use Stringable;
class Money implements Stringable class Money implements Stringable {
{
private readonly float $value; private readonly float $value;
public function __construct(mixed $value) public function __construct(mixed $value)
@ -13,13 +12,13 @@ class Money implements Stringable
$this->value = (float) str_replace(['$', ','], '', (string) $value); $this->value = (float) str_replace(['$', ','], '', (string) $value);
} }
public function getValue(): float
{
return (float) str_replace(['$', ','], '', (string) $this->value);
}
public function __toString(): string public function __toString(): string
{ {
return (string) $this->getValue(); return (string) $this->getValue();
} }
public function getValue(): float
{
return (float) str_replace(['$', ','], '', (string) $this->value);
}
} }

View File

@ -4,8 +4,11 @@ use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';
if (file_exists(dirname(__DIR__) . '/config/bootstrap.php')) { if (file_exists(dirname(__DIR__) . '/config/bootstrap.php'))
{
require dirname(__DIR__) . '/config/bootstrap.php'; require dirname(__DIR__) . '/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) { }
elseif (method_exists(Dotenv::class, 'bootEnv'))
{
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
} }

View File

@ -2,7 +2,8 @@
function walk_array(callable $method, array $items): void function walk_array(callable $method, array $items): void
{ {
foreach ($items as $item) { foreach ($items as $item)
{
$method($item); $method($item);
} }
} }