diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..4cf285f --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: Check & fix styling + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs.dist --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..84bac4b --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,36 @@ +name: Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.0, 7.4, 7.3, 7.2] + stability: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Install dependencies + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 073e37a..b27dc32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build composer.lock vendor +.php_cs.cache diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..ac127a7 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,40 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline_array' => 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', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index c4f3059..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,33 +0,0 @@ -filter: - excluded_paths: [spec/*] -checks: - php: - code_rating: true - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true -tools: - external_code_coverage: false - php_analyzer: true - php_code_coverage: false - php_code_sniffer: - config: - standard: PSR2 - filter: - paths: ['src'] - php_loc: - enabled: true - excluded_dirs: [vendor, spec] - php_cpd: - enabled: true - excluded_dirs: [vendor, spec] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a294525..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - 7.4 - -before_script: - - travis_retry composer install --no-interaction --prefer-source - -script: - - vendor/bin/phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index ce28426..f24c6a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `url-signer` will be documented in this file +# 1.2.0 - 2020-12-02 + +- support PHP 8.0 + # 1.1.0 - 2020-07-20 - replace league/url with league/uri & league/uri-components (#25) diff --git a/README.md b/README.md index 38d33b4..d97cb8d 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen ## Contributing -Please see [CONTRIBUTING](CONTRIBUTING.md) for details. +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. ## Security diff --git a/composer.json b/composer.json index c4dc573..fec7ca7 100644 --- a/composer.json +++ b/composer.json @@ -19,12 +19,12 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2|^8.0", "league/uri": "^6.0", - "league/uri-components": "^2.2" + "league/uri-components": "dev-master" }, "require-dev": { - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^8.0|^9.0" }, "autoload": { "psr-4": { diff --git a/src/BaseUrlSigner.php b/src/BaseUrlSigner.php index b264d7b..b289dfd 100644 --- a/src/BaseUrlSigner.php +++ b/src/BaseUrlSigner.php @@ -108,11 +108,11 @@ public function validate($url) $expiration = $query[$this->expiresParameter]; - if (!$this->isFuture($expiration)) { + if (! $this->isFuture($expiration)) { return false; } - if (!$this->hasValidSignature($url)) { + if (! $this->hasValidSignature($url)) { return false; } @@ -128,11 +128,11 @@ public function validate($url) */ protected function isMissingAQueryParameter(array $query) { - if (!isset($query[$this->expiresParameter])) { + if (! isset($query[$this->expiresParameter])) { return true; } - if (!isset($query[$this->signatureParameter])) { + if (! isset($query[$this->signatureParameter])) { return true; } @@ -185,11 +185,11 @@ protected function getExpirationTimestamp($expiration) $expiration = (new DateTime())->modify((int) $expiration.' days'); } - if (!$expiration instanceof DateTime) { + if (! $expiration instanceof DateTime) { throw new InvalidExpiration('Expiration date must be an instance of DateTime or an integer'); } - if (!$this->isFuture($expiration->getTimestamp())) { + if (! $this->isFuture($expiration->getTimestamp())) { throw new InvalidExpiration('Expiration date must be in the future'); }