diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..79c3e0d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +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] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c848b9c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,16 @@ +/art export-ignore +/docs export-ignore +/tests export-ignore +/types +/scripts export-ignore +/.github export-ignore +/.php_cs export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +phpstan.neon.dist export-ignore +phpunit.xml.dist export-ignore +rector.php export-ignore +CHANGELOG.md export-ignore +CONTRIBUTING.md export-ignore +README.md export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..0f791b1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,5 @@ +# These are supported funding model platforms + +github: nunomaduro +patreon: nunomaduro +custom: https://www.paypal.com/paypalme/enunomaduro diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml new file mode 100644 index 0000000..393394e --- /dev/null +++ b/.github/workflows/formats.yml @@ -0,0 +1,49 @@ +name: Formats + +on: ['push', 'pull_request'] + +jobs: + ci: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [8.2] + dependency-version: [prefer-lowest, prefer-stable] + + name: Formats P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, mbstring, zip + coverage: pcov + + - name: Get Composer cache directory + id: composer-cache + shell: bash + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer- + + - name: Install Composer dependencies + run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist + + - name: Coding Style Checks + run: composer test:lint + + - name: Type Checks + run: composer test:types diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f60fcec --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: Tests + +on: ['push', 'pull_request'] + +jobs: + ci: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + php: ['8.2', '8.3'] + dependency-version: [prefer-lowest, prefer-stable] + + name: Tests P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, mbstring, zip + coverage: none + + - name: Get Composer cache directory + id: composer-cache + shell: bash + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer- + + - name: Install Composer dependencies + run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist + + - name: Integration Tests + run: php ./vendor/bin/pest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f019b25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/.phpunit.result.cache +/.phpunit.cache +/.php-cs-fixer.cache +/.php-cs-fixer.php +/composer.lock +/phpunit.xml +/vendor/ +*.swp +*.swo +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..15dd6ee --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] +- Adds first version diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d2ceb41 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# CONTRIBUTING + +Contributions are welcome, and are accepted via pull requests. +Please review these guidelines before submitting any pull requests. + +## Process + +1. Fork the project +1. Create a new branch +1. Code, test, commit and push +1. Open a pull request detailing your changes. Make sure to follow the [template](.github/PULL_REQUEST_TEMPLATE.md) + +## 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 +``` + +Check types: +```bash +composer test:types +``` + +Unit tests: +```bash +composer test:unit +``` diff --git a/LICENSE.md b/LICENSE.md new file mode 100755 index 0000000..14b90ed --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Nuno Maduro + +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 index 8337712..11d9192 100644 --- a/README.md +++ b/README.md @@ -1 +1,32 @@ -// +

+ Skeleton Php +

+ GitHub Workflow Status (master) + Total Downloads + Latest Version + License +

+

+ +------ + +> This library is a **work in progress**. Please, do not use it in production. + +Laravel Reflection package is a simple package that provides extended functional helpers for your Laravel application. + +## Installation + +> **Requires [PHP 8.2+](https://php.net/releases/)** + +You may use [Composer](https://getcomposer.org) to install Laravel Reflection into your Laravel project: + +```bash +composer require pinkary-project/laravel-reflection +``` + +## Usage +Coming soon... + +------ + +**Laravel Reflection** was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** and open-sourced under the **[MIT license](https://opensource.org/licenses/MIT)**. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..20a81d3 --- /dev/null +++ b/composer.json @@ -0,0 +1,65 @@ +{ + "name": "pinkary-project/laravel-reflection", + "description": "Laravel Reflection package is a simple package that provides extended functional helpers for your Laravel application.", + "keywords": ["laravel", "helpers", "php"], + "license": "MIT", + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "require": { + "php": "^8.2.0" + }, + "require-dev": { + "another-library/type-guard": "dev-main", + "laravel/framework": "^11.0", + "laravel/pint": "^1.15.0", + "orchestra/testbench": "^9.0.0", + "pestphp/pest": "^3.0.0", + "pestphp/pest-plugin-type-coverage": "3.x-dev", + "phpstan/phpstan": "^1.10.66", + "rector/rector": "^1.0.3", + "symfony/var-dumper": "^6.4.0|^7.0.4" + }, + "autoload": { + "psr-4": { + "PinkaryProject\\LaravelReflection\\": "src/" + }, + "files": [ + "src/Functions.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "allow-plugins": { + "pestphp/pest-plugin": true + } + }, + "scripts": { + "refacto": "rector", + "lint": "pint", + "refactor": "rector", + "test:lint": "pint --test", + "test:refactor": "rector --dry-run", + "test:types": "phpstan analyse", + "test:type-coverage": "pest --type-coverage --min=100", + "test:unit": "pest --coverage --min=100", + "test": [ + "@test:lint", + "@test:refactor", + "@test:types", + "@test:type-coverage", + "@test:unit" + ] + } +} diff --git a/docs/example.jpg b/docs/example.jpg new file mode 100644 index 0000000..2f4e9d7 Binary files /dev/null and b/docs/example.jpg differ diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..b8af2d7 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +parameters: + level: max + paths: + - src + - types + + reportUnmatchedIgnoredErrors: true diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..35ce165 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + ./src + + + + + ./tests + + + diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..d4c8c61 --- /dev/null +++ b/pint.json @@ -0,0 +1,58 @@ +{ + "preset": "laravel", + "rules": { + "array_push": true, + "backtick_to_shell_exec": true, + "date_time_immutable": true, + "declare_strict_types": true, + "lowercase_keywords": true, + "lowercase_static_reference": true, + "final_class": true, + "final_internal_class": true, + "final_public_method_for_abstract_class": true, + "fully_qualified_strict_types": true, + "global_namespace_import": { + "import_classes": true, + "import_constants": true, + "import_functions": true + }, + "mb_str_functions": true, + "modernize_types_casting": true, + "new_with_parentheses": false, + "no_superfluous_elseif": true, + "no_useless_else": true, + "no_multiple_statements_per_line": true, + "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" + }, + "ordered_interfaces": true, + "ordered_traits": true, + "protected_to_private": true, + "self_accessor": true, + "self_static_accessor": true, + "strict_comparison": true, + "visibility_required": true + } +} diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..f5f65f6 --- /dev/null +++ b/rector.php @@ -0,0 +1,25 @@ +withPaths([ + __DIR__.'/src', + __DIR__.'/tests', + __DIR__.'/types', + ]) + ->withSkip([ + AddOverrideAttributeToOverriddenMethodsRector::class, + ]) + ->withPreparedSets( + deadCode: true, + codeQuality: true, + typeDeclarations: true, + privatization: true, + earlyReturn: true, + strictBooleans: true, + ) + ->withPhpSets(); diff --git a/src/Extend.php b/src/Extend.php new file mode 100644 index 0000000..58e9c02 --- /dev/null +++ b/src/Extend.php @@ -0,0 +1,33 @@ + + */ + public function models(): array + { + $models = type(glob(modelPath().'/*.php'))->asArray(); + + return collect($models) + ->map(fn ($file) => 'App\Models\\'.basename($file, '.php')) + ->toArray(); + } +} diff --git a/src/Functions.php b/src/Functions.php new file mode 100644 index 0000000..86bc5a7 --- /dev/null +++ b/src/Functions.php @@ -0,0 +1,16 @@ +path('Models'); // @phpstan-ignore-line + } +} diff --git a/tests/ArchTest.php b/tests/ArchTest.php new file mode 100644 index 0000000..23b863b --- /dev/null +++ b/tests/ArchTest.php @@ -0,0 +1,5 @@ +in(__DIR__); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..23b863b --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,5 @@ +in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..0f05a7a --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,11 @@ +