From 053aa39a3e7362efc44cccc1a94c58213def54a5 Mon Sep 17 00:00:00 2001 From: Cesar Garcia Date: Fri, 6 Jan 2023 13:32:54 +0100 Subject: [PATCH] Add phpstan (#28) --- .github/workflows/phpstan.yml | 36 +++++++++++++++++++++++++++++++++++ .gitignore | 5 +++-- .php-cs-fixer.cache | 1 - composer.json | 3 ++- phpstan.neon.dist | 8 ++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/phpstan.yml delete mode 100644 .php-cs-fixer.cache create mode 100644 phpstan.neon.dist diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..fb32fd7 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,36 @@ +name: phpstan + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + phpstan: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: | + composer install + composer dump + - name: Run analyse phpstan + run: vendor/bin/phpstan analyse --error-format github \ No newline at end of file diff --git a/.gitignore b/.gitignore index ebdd73f..b29d261 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /vendor /build -composer.lock +/composer.lock /tests/tmp -/.phpunit.result.cache /phpunit.xml +/.phpunit.result.cache +/.php-cs-fixer.cache \ No newline at end of file diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index aa9e1fb..0000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.1.13","version":"3.13.2:v3.13.2#3952f08a81bd3b1b15e11c3de0b6bf037faa8496","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}},"php_unit_method_casing":{"case":"snake_case"}},"hashes":{"src\/Rotate.php":"a80c46b6c7bdef3dbd56d6ce7191292b","src\/Events\/RotateHasFailed.php":"d69d8e711ef6550a7275dfb5b32a9b55","src\/Events\/RotateWasSuccessful.php":"e88e3678428be57b05f43980b1217439","src\/Helpers\/Log.php":"0ff3c8c85f712c0aae31b38a26903b63","src\/RotateServiceProvider.php":"64408a85d6e71922059c1df2a9ad6a28","src\/Commands\/RotateCommand.php":"aaa17e708aad06d4756d30ef4d5aacb3","src\/Commands\/RotateFileCommand.php":"80df2e82ffa8663fc8fc1fe02d69c75b","tests\/Handlers\/RotativeHandlerTest.php":"961edbe17000a8980c0085a9a5c2a422","tests\/ScheduleTest.php":"d7502bf8a56866679c8fb71047111cc7","tests\/RotateTest.php":"58a70c0e6f1437df00dddd6d3d32d797","tests\/TestCase.php":"84fda5f256b496c1a15543433943287b","tests\/Commands\/RotateFileTest.php":"45bd41bc810e8bc099eaa60137183b98"}} \ No newline at end of file diff --git a/composer.json b/composer.json index ca995e5..80fda15 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "require-dev": { "orchestra/testbench": "^7.0", "phpunit/phpunit": "^9.5", - "friendsofphp/php-cs-fixer": "^3.13" + "friendsofphp/php-cs-fixer": "^3.13", + "nunomaduro/larastan": "^2.3" }, "autoload": { "psr-4": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..084079a --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,8 @@ +includes: + - ./vendor/nunomaduro/larastan/extension.neon + +parameters: + paths: + - src + - tests + level: 5 \ No newline at end of file