From f983ad8230b855f65467a681ac7ace3f65d16da3 Mon Sep 17 00:00:00 2001 From: Wendell Adriel Date: Mon, 6 May 2024 10:41:41 +0100 Subject: [PATCH] Initial structure --- .editorconfig | 15 ++++++ .gitattributes | 10 ++++ .github/FUNDING.yml | 4 ++ .github/workflows/tests.yml | 42 +++++++++++++++ .gitignore | 7 +++ CONTRIBUTING.md | 44 ++++++++++++++++ LICENSE | 21 ++++++++ README.md | 44 ++++++++++++++++ composer.json | 70 +++++++++++++++++++++++++ phpstan.neon | 6 +++ phpunit.xml | 18 +++++++ pint.json | 56 ++++++++++++++++++++ src/Providers/VirtueServiceProvider.php | 15 ++++++ workflows/tests.yml | 47 +++++++++++++++++ 14 files changed, 399 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .gitignore create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpstan.neon create mode 100644 phpunit.xml create mode 100644 pint.json create mode 100644 src/Providers/VirtueServiceProvider.php create mode 100644 workflows/tests.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6537ca4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..23f3149 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +/.github export-ignore +/art export-ignore +/tests export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +CONTRIBUTING.md export-ignore +phpstan.neon export-ignore +phpunit.xml export-ignore +pint.json export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d353202 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: [WendellAdriel] +custom: ["https://www.paypal.me/wendelladriel"] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..02bf4e6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + php: [8.3, 8.2] + laravel: [11.*] + dependency-version: [prefer-stable] + include: + - laravel: 11.* + testbench: 9.* + + name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.62.1" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: Code Style ๐Ÿ‘จโ€๐Ÿญ + run: composer test:lint + + - name: Pest Tests ๐Ÿงซ + run: composer test:unit + + - name: PHPStan ๐Ÿงช + run: composer test:static diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bbe7d65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +/vendor +/.idea +/.vagrant +/.phpstorm.* +composer.lock +.phpunit.result.cache \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..94d385c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,44 @@ +# CONTRIBUTING + +Contributions are welcome, and are accepted via pull requests. +Please review these guidelines before submitting any pull requests. + +For major changes, please open an issue first describing what you want to add/change. + +## Process + +1. Fork the project +2. Create a new branch +3. Code, test, commit and push +4. Open a pull request detailing your changes + +## Guidelines + +* Please ensure the coding style running `composer lint`. +* Send a coherent commit history, making sure each individual commit in your pull request is meaningful. +* You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts. +* Please remember that we follow [SemVer](http://semver.org/). + +## Setup + +Clone your fork, then install the dev dependencies: +```bash +composer install +``` +## Lint + +Lint your code: +```bash +composer lint +``` +## Tests + +Run all tests: +```bash +composer test +``` + +Unit tests: +```bash +composer test:unit +``` diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..491d388 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Wendell Adriel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e2c46e --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +
+ +

+

Virtue for Laravel

+ Extend the Laravel Framework with a collection of attributes +

+
+ +

+ Packagist + PHP from Packagist + Laravel Version + GitHub Workflow Status (main) +

+ +**Virtue** is a package that extends the Laravel Framework by providing a collection of attributes that you can use to +configure and extend the built-in classes of the framework. + +The focus of the package is to bring the power of the PHP 8 attributes to improve the DX on how to configure and extend +your Laravel applications. + +## Documentation +[![Docs Button]][Docs Link] [![DocsRepo Button]][DocsRepo Link] + +## Installation + +```bash +composer require wendelladriel/laravel-virtue +``` + +## Credits + +- [Wendell Adriel](https://github.com/WendellAdriel) +- [All Contributors](../../contributors) + +## Contributing + +Check the **[Contributing Guide](CONTRIBUTING.md)**. + + +[Docs Button]: https://img.shields.io/badge/Website-B30E2E?style=for-the-badge&logoColor=white&logo=GitBook +[Docs Link]: https://wendell-adriel.gitbook.io/laravel-virtue/ +[DocsRepo Button]: https://img.shields.io/badge/Repository-3884FF?style=for-the-badge&logoColor=white&logo=GitBook +[DocsRepo Link]: https://github.com/WendellAdriel/laravel-virtue-docs diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..871f9d8 --- /dev/null +++ b/composer.json @@ -0,0 +1,70 @@ +{ + "name": "wendelladriel/laravel-virtue", + "description": "Extend the Laravel Framework with a collection of attributes", + "type": "library", + "keywords": [ + "laravel", + "attributes", + "extend", + "configuration" + ], + "license": "MIT", + "autoload": { + "psr-4": { + "WendellAdriel\\Virtue\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "support": { + "issues": "https://github.com/WendellAdriel/laravel-virtue/issues", + "source": "https://github.com/WendellAdriel/laravel-virtue" + }, + "authors": [ + { + "name": "Wendell Adriel", + "email": "wendelladriel.ti@gmail.com" + } + ], + "require": { + "php": "^8.2", + "illuminate/database": "^11.0", + "illuminate/support": "^11.0" + }, + "require-dev": { + "larastan/larastan": "^2.0", + "laravel/pint": "^1.14", + "orchestra/testbench": "^8.0|^9.0", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-faker": "^2.0", + "phpstan/phpstan": "^1.10" + }, + "scripts": { + "lint": "pint", + "test:lint": "pint --test", + "test:unit": "./vendor/bin/pest --order-by random", + "test:static": "phpstan analyse --memory-limit 1G", + "test": [ + "@test:lint", + "@test:unit", + "@test:static" + ] + }, + "extra": { + "laravel": { + "providers": [ + "WendellAdriel\\Virtue\\Providers\\VirtueServiceProvider" + ] + } + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + }, + "minimum-stability": "stable", + "prefer-stable": true +} diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..b4b2661 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + + paths: + - src/ + + level: 9 diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..334be2e --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests + + + + + + + + + + ./src + + + diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..ba1ad05 --- /dev/null +++ b/pint.json @@ -0,0 +1,56 @@ +{ + "preset": "laravel", + "rules": { + "array_push": true, + "assign_null_coalescing_to_coalesce_equal": true, + "combine_consecutive_issets": true, + "combine_consecutive_unsets": true, + "concat_space": { + "spacing": "one" + }, + "declare_strict_types": true, + "explicit_indirect_variable": true, + "explicit_string_variable": true, + "global_namespace_import": true, + "method_argument_space": { + "on_multiline": "ensure_fully_multiline" + }, + "modernize_strpos": true, + "modernize_types_casting": true, + "new_with_braces": true, + "no_superfluous_elseif": true, + "no_useless_else": true, + "nullable_type_declaration_for_default_null_value": true, + "ordered_imports": { + "sort_algorithm": "alpha" + }, + "ordered_class_elements": { + "order": [ + "use_trait", + "case", + "constant", + "constant_public", + "constant_protected", + "constant_private", + "property_public", + "property_protected", + "property_private", + "construct", + "destruct", + "magic", + "phpunit", + "method_abstract", + "method_public_static", + "method_public", + "method_protected_static", + "method_protected", + "method_private_static", + "method_private" + ], + "sort_algorithm": "none" + }, + "strict_comparison": true, + "ternary_to_null_coalescing": true, + "use_arrow_functions": true + } +} diff --git a/src/Providers/VirtueServiceProvider.php b/src/Providers/VirtueServiceProvider.php new file mode 100644 index 0000000..b7b28a1 --- /dev/null +++ b/src/Providers/VirtueServiceProvider.php @@ -0,0 +1,15 @@ +=2.62.1" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: Code Style ๐Ÿ‘จโ€๐Ÿญ + run: composer test:lint + + - name: Pest Tests ๐Ÿงซ + run: composer test:unit + + - name: PHPStan ๐Ÿงช + run: composer test:static