Skip to content

Commit

Permalink
Merge pull request #31 from spatie/php8-support
Browse files Browse the repository at this point in the history
Php8 support
  • Loading branch information
Nielsvanpach authored Dec 2, 2020
2 parents 60fbf20 + e65eb3b commit 13e679f
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 55 deletions.
File renamed without changes.
23 changes: 23 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
composer.lock
vendor
.php_cs.cache
40 changes: 40 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->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);
33 changes: 0 additions & 33 deletions .scrutinizer.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 6 additions & 6 deletions src/BaseUrlSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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');
}

Expand Down

0 comments on commit 13e679f

Please sign in to comment.