diff --git a/.gitattributes b/.gitattributes index 256ce94..470a9cc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,5 @@ -* text=auto -*.bat eol=crlf - /.github/ export-ignore -/test export-ignore -/spec export-ignore - -# Remove all dot files for export -.editorconfig export-ignore -.php_cs export-ignore -.travis.yml export-ignore - - -phpcs.xml export-ignore -phpspec.yml export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpcs.xml export-ignore diff --git a/.github/actions/composer/composer/determine-cache-directory/action.yaml b/.github/actions/composer/composer/determine-cache-directory/action.yaml new file mode 100644 index 0000000..4842e88 --- /dev/null +++ b/.github/actions/composer/composer/determine-cache-directory/action.yaml @@ -0,0 +1,16 @@ +# https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions +# https://getcomposer.org/doc/03-cli.md#composer-cache-dir + +name: "Determine composer cache directory" + +description: "Determines the composer cache directory and exports it as COMPOSER_CACHE_DIR environment variable" + +runs: + using: "composite" + + steps: + - name: "Determine composer cache directory" + shell: "bash" + run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV" diff --git a/.github/actions/composer/composer/install/action.yaml b/.github/actions/composer/composer/install/action.yaml new file mode 100644 index 0000000..bab262e --- /dev/null +++ b/.github/actions/composer/composer/install/action.yaml @@ -0,0 +1,22 @@ +# https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions + +name: "Install dependencies with composer" + +description: "Installs dependencies with composer" + +inputs: + dependencies: + description: "Which dependencies to install, one of \"lowest\", \"locked\", \"highest\"" + required: true + +runs: + using: "composite" + + steps: + - name: "Install ${{ inputs.dependencies }} dependencies with composer" + shell: "bash" + run: "${{ github.action_path }}/run.sh" + env: + COMPOSER_INSTALL_DEPENDENCIES: "${{ inputs.dependencies }}" diff --git a/.github/actions/composer/composer/install/run.sh b/.github/actions/composer/composer/install/run.sh new file mode 100755 index 0000000..a052ba6 --- /dev/null +++ b/.github/actions/composer/composer/install/run.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +dependencies="${COMPOSER_INSTALL_DEPENDENCIES}" + +if [[ ${dependencies} == "lowest" ]]; then + composer update --no-interaction --no-progress --prefer-lowest + + exit $? +fi + +if [[ ${dependencies} == "locked" ]]; then + composer install --no-interaction --no-progress + + exit $? +fi + +if [[ ${dependencies} == "highest" ]]; then + composer update --no-interaction --no-progress + + exit $? +fi + +echo "::error::The value for the \"dependencies\" input needs to be one of \"lowest\", \"locked\"', \"highest\"' - got \"${dependencies}\" instead." + +exit 1 diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 92a21b1..6141e96 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -6,14 +6,50 @@ on: # yamllint disable-line rule:truthy pull_request: null push: branches: - - "main" + - "master" jobs: - hello: - name: "Hello" + coding-standards: + name: "Coding Standards" runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "5.4" + + dependencies: + - "locked" + steps: - - name: "Say hello" - run: "echo 'Hello!'" + - name: "Checkout" + uses: "actions/checkout@v2.3.3" + + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@2.7.0" + with: + coverage: "none" + extensions: "${{ env.PHP_EXTENSIONS }}" + php-version: "${{ matrix.php-version }}" + + - name: "Validate composer.json and composer.lock" + run: "composer validate --strict" + + - name: "Determine composer cache directory" + uses: "./.github/actions/composer/composer/determine-cache-directory" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2.1.2" + with: + path: "${{ env.COMPOSER_CACHE_DIR }}" + key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" + + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" + + - name: "Run squizlabs/php_codesniffer" + run: "vendor/bin/phpcbf" diff --git a/.gitignore b/.gitignore index 9c4ee7f..0d234cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,3 @@ -# All dot (e.g. .htaccess) files # -####################### -.* -.*/* - -# OS generated files # -###################### -thumbs.db -Icon -Thumbs.db -tags -vendor.tags -tmtagsHistory - - -# IDE generated files # -####################### -.project -*.sublime-project -*.sublime-workspace -atlassian-ide-plugin.xml - -# PHP-specific files # -####################### -/vendor/* -/bin/* -/data/* -/build/* -composer.phar - -# Dot files we want to keep # -####################### -!/.git* -!/.php_cs -!/.editorconfig +/.build/ +/.notes/ +/vendor/ diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 47021f9..0000000 --- a/.php_cs +++ /dev/null @@ -1,34 +0,0 @@ -exclude('tests') - ->in(__DIR__) -; - -return Symfony\CS\Config\Config::create() - ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) - ->fixers(array( - 'blankline_after_open_tag', - 'concat_without_spaces', - 'duplicate_semicolon', - 'extra_empty_lines', - 'namespace_no_leading_whitespace', - 'no_blank_lines_after_class_opening', - 'no_empty_lines_after_phpdocs', - 'ordered_use', - 'phpdoc_indent', - 'phpdoc_scalar', - 'phpdoc_separation', - 'phpdoc_short_description', - 'phpdoc_trim', - 'phpdoc_type_to_var', - 'phpdoc_var_without_name', - 'remove_leading_slash_use', - 'remove_lines_between_uses', - 'single_line_after_imports', - 'spaces_before_semicolon', - 'trailing_spaces', - 'whitespacy_lines' - )) - ->finder($finder) -; diff --git a/README.md b/README.md index 00e98b3..5ad5942 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Teapot: Status Codes +[![Integrate](https://github.com/teapot-php/status-code/workflows/Integrate/badge.svg?branch=master)](https://github.com/teapot-php/status-code/actions) [![latest_stable_version_img]][latest_stable_version] [![latest_unstable_version_img]][latest_unstable_version] [![license_img]][license] diff --git a/composer.json b/composer.json index 756cefa..451c2d1 100644 --- a/composer.json +++ b/composer.json @@ -32,5 +32,8 @@ "exclude": [ "/*, !/src" ] + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.5.8" } } diff --git a/composer.lock b/composer.lock index 8afc67b..bf96586 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,66 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bd2d8b501ce9bfb05f746b4001ac9386", + "content-hash": "0f8d973b0dab7e0da004633f3c2b73c9", "packages": [], - "packages-dev": [], + "packages-dev": [ + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.8", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2020-10-23T02:01:07+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..4efdd7e --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,6 @@ + + + src/ + + + diff --git a/src/Vendor/RFC7238.php b/src/Vendor/RFC7238.php index 74e96ce..532b33e 100644 --- a/src/Vendor/RFC7238.php +++ b/src/Vendor/RFC7238.php @@ -8,7 +8,6 @@ namespace Teapot\StatusCode\Vendor; - class RFC7238 {