From 67a7024633854774de777ff9bdc0328dbc4b4c82 Mon Sep 17 00:00:00 2001 From: Enzo Innocenzi Date: Wed, 11 Dec 2024 17:36:33 +0100 Subject: [PATCH] refactor: remove default front-end scaffolding --- .php-cs-fixer.dist.php | 100 +++++++++++++++++++++++++++++++++-- README.md | 4 +- app/HomeController.php | 6 +-- app/home.view.php | 43 +++++++++++---- app/main.css | 3 -- composer.json | 2 +- package.json | 9 ---- public/index.php | 6 ++- tailwind.config.js | 12 ----- tests/HomeControllerTest.php | 5 +- 10 files changed, 142 insertions(+), 48 deletions(-) delete mode 100644 app/main.css delete mode 100644 package.json delete mode 100644 tailwind.config.js diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 4a8727f..3d89ee4 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,6 +1,11 @@ in([ __DIR__ . '/app', __DIR__ . '/tests', @@ -9,14 +14,67 @@ ->ignoreDotFiles(true) ->ignoreVCS(true); -return (new PhpCsFixer\Config()) +return (new Config()) ->setRules([ '@PSR12' => true, + '@PHP84Migration' => true, + 'ordered_attributes' => true, + 'ordered_traits' => true, + 'attribute_empty_parentheses' => true, + 'yoda_style' => [ + 'equal' => false, + 'identical' => false, + 'less_and_greater' => false, + ], + 'get_class_to_class_keyword' => true, + 'cast_spaces' => true, + 'single_space_around_construct' => true, + 'heredoc_indentation' => true, + 'types_spaces' => true, + 'single_quote' => true, + 'no_short_bool_cast' => true, + 'explicit_string_variable' => true, + 'no_extra_blank_lines' => [ + 'tokens' => [ + 'case', + 'continue', + 'curly_brace_block', + 'default', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'switch', + 'throw', + 'use', + ], + ], 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'ordered_imports' => [ + 'sort_algorithm' => 'alpha', + 'imports_order' => [ + 'class', + 'function', + 'const', + ], + ], 'no_unused_imports' => true, + 'no_unneeded_import_alias' => true, + 'blank_line_between_import_groups' => false, + 'single_import_per_statement' => true, + 'no_leading_import_slash' => true, + 'fully_qualified_strict_types' => [ + 'import_symbols' => true, + 'phpdoc_tags' => [], + ], + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => true, + ], 'not_operator_with_successor_space' => true, - 'trailing_comma_in_multiline' => true, + 'trailing_comma_in_multiline' => [ + 'elements' => ['arrays', 'arguments', 'parameters', 'match'], + ], 'phpdoc_scalar' => true, 'unary_operator_spaces' => true, 'binary_operator_spaces' => true, @@ -36,5 +94,37 @@ ], 'single_trait_insert_per_statement' => true, 'declare_strict_types' => true, + 'no_empty_comment' => true, + 'no_empty_phpdoc' => true, + + // Test styling + 'php_unit_data_provider_name' => [ + 'prefix' => 'provide_', + 'suffix' => '_cases', + ], + 'php_unit_data_provider_return_type' => true, + 'php_unit_data_provider_static' => [ + 'force' => true, + ], + 'php_unit_dedicate_assert_internal_type' => true, + 'php_unit_internal_class' => true, + 'php_unit_method_casing' => [ + 'case' => 'snake_case', + ], + 'php_unit_expectation' => [ + 'target' => 'newest', + ], + 'php_unit_mock' => [ + 'target' => 'newest', + ], + 'php_unit_mock_short_will_return' => true, + 'php_unit_set_up_tear_down_visibility' => true, + 'php_unit_size_class' => false, + 'php_unit_test_annotation' => [ + 'style' => 'prefix', + ], + 'php_unit_test_case_static_method_calls' => [ + 'call_type' => 'this', + ], ]) - ->setFinder($finder); \ No newline at end of file + ->setFinder($finder); diff --git a/README.md b/README.md index 13b284a..a4fe51b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ```php composer create-project tempest/app cd -npm run dev +php tempest serve ``` -Read all about Tempest in [the docs](https://github.com/tempestphp/tempest-docs/blob/master/01-getting-started.md). \ No newline at end of file +Read all about Tempest in [the docs](https://github.com/tempestphp/tempest-docs/blob/master/01-getting-started.md). diff --git a/app/HomeController.php b/app/HomeController.php index edddad8..aa96df4 100644 --- a/app/HomeController.php +++ b/app/HomeController.php @@ -4,11 +4,9 @@ namespace App; -use Tempest\Http\Get; - -use function Tempest\view; - +use Tempest\Router\Get; use Tempest\View\View; +use function Tempest\view; final readonly class HomeController { diff --git a/app/home.view.php b/app/home.view.php index 29be20a..28a4dc2 100644 --- a/app/home.view.php +++ b/app/home.view.php @@ -1,13 +1,38 @@ - Tempest - - - + Tempest + + + - - -

Tempest

- + +
+
+ + + + + +
+
+ +

Tempest

+

The modern PHP framework that gets out of your way. Focus on your application code, not on framework quirks.

+ + +
+
+
+
- \ No newline at end of file + diff --git a/app/main.css b/app/main.css deleted file mode 100644 index bd6213e..0000000 --- a/app/main.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; \ No newline at end of file diff --git a/composer.json b/composer.json index 1321c8a..038d85c 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "./tempest discovery:generate" ], "phpunit": "vendor/bin/phpunit --display-warnings --display-skipped --display-deprecations --display-errors --display-notices", - "csfixer": "vendor/bin/php-cs-fixer fix --allow-risky=yes", + "csfixer": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --allow-risky=yes", "phpstan": "vendor/bin/phpstan analyse tests app", "qa": [ "composer csfixer", diff --git a/package.json b/package.json deleted file mode 100644 index 55f176e..0000000 --- a/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "scripts": { - "dev": "npx tailwindcss -i ./app/main.css -o ./public/main.css --watch", - "build": "npx tailwindcss -i ./app/main.css -o ./public/main.css" - }, - "devDependencies": { - "tailwindcss": "^3.4.1" - } -} diff --git a/public/index.php b/public/index.php index 7017300..c08ea3e 100644 --- a/public/index.php +++ b/public/index.php @@ -1,9 +1,11 @@ run(); -exit; \ No newline at end of file +exit; diff --git a/tailwind.config.js b/tailwind.config.js deleted file mode 100644 index e2686e7..0000000 --- a/tailwind.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: [ - "./app/**/*.{view.php,html,js}" - ], - theme: { - extend: {}, - }, - mode: 'jit', - plugins: [], -} - diff --git a/tests/HomeControllerTest.php b/tests/HomeControllerTest.php index 7635a04..cbf5801 100644 --- a/tests/HomeControllerTest.php +++ b/tests/HomeControllerTest.php @@ -4,7 +4,10 @@ namespace Tests; -class HomeControllerTest extends IntegrationTestCase +/** + * @internal + */ +final class HomeControllerTest extends IntegrationTestCase { public function test_index(): void {