Skip to content

Commit

Permalink
Add Laravel 10 Support (#1)
Browse files Browse the repository at this point in the history
* feat: Add Laravel 10 Support

* fix: remove phpunit.cache results folder

* chore: restore Laravel 9 support

* chore: Lint

chore: Normalize composer.json

* fix: docblock

fix: run-tests workflow

* fix: Styling

* minor improvements

* chore: exclude specific matrix configuration

* fix: exclusions

* fix: run-tests split into two jobs

* fix: versions

* fix: reintroduce PHP 8.1 to strategy matrices
  • Loading branch information
sweptsquash authored Feb 16, 2023
1 parent 6e1067b commit 8ccf234
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@0.1.0
uses: aglipanci/laravel-pint-action@2.1.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
59 changes: 50 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ on:
branches: [main]

jobs:
test:
test-laravel-9:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.0, 8.1]
laravel: [9.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
php: [8.1, 8.2]
laravel: ['9.*']
phpunit: ['9.5.8']
testbench: ['7.22.0']
collision: ['6.4']
stability: [prefer-lowest,prefer-stable]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -40,8 +40,49 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "nunomaduro/collision:~${{ matrix.collision }}" "orchestra/testbench:~${{ matrix.testbench }}" "phpunit/phpunit:~${{ matrix.phpunit }}" --dev --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/phpunit --no-coverage

test-laravel-10:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
laravel: ['10.*']
phpunit: ['10.0']
testbench: ['8.0']
collision: ['7.0.2']
stability: [prefer-lowest,prefer-stable]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- 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, fileinfo
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 require "nunomaduro/collision:~${{ matrix.collision }}" "orchestra/testbench:~${{ matrix.testbench }}" "phpunit/phpunit:~${{ matrix.phpunit }}" --dev --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --no-coverage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
.phpunit.cache/
60 changes: 31 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
{
"name": "antoninmasek/laravel-hashids",
"description": "Simple Laravel wrapper around Hashids library.",
"license": "MIT",
"keywords": [
"antoninmasek",
"laravel",
"laravel-hashids"
],
"homepage": "https://github.com/antoninmasek/laravel-hashids",
"license": "MIT",
"authors": [
{
"name": "Antonín Mašek",
"email": "[email protected]",
"role": "Developer"
}
],
"homepage": "https://github.com/antoninmasek/laravel-hashids",
"require": {
"php": "^8.0|^8.1",
"hashids/hashids": "^4.1",
"illuminate/contracts": "^9.0",
"spatie/laravel-package-tools": "^1.9.2"
"php": "^8.1 || ^8.2",
"hashids/hashids": "^5.0",
"illuminate/contracts": "^9.0 || ^10.0",
"spatie/laravel-package-tools": "^1.14.1"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^6.0",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"spatie/laravel-ray": "^1.26"
"ergebnis/composer-normalize": "^2.29",
"laravel/pint": "^1.5",
"nunomaduro/collision": "^6.0 || ^7.0.2",
"nunomaduro/larastan": "^2.4.0",
"orchestra/testbench": "^7.0 || ^8.0",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.1.1",
"phpstan/phpstan-phpunit": "^1.3.4",
"phpunit/phpunit": "^9.5 || ^10.0",
"spatie/laravel-ray": "^1.32.2"
},
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"AntoninMasek\\Hashids\\": "src"
Expand All @@ -42,27 +45,26 @@
"AntoninMasek\\Hashids\\Tests\\": "tests"
}
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
"phpstan/extension-installer": true,
"ergebnis/composer-normalize": true
},
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"AntoninMasek\\Hashids\\HashidsServiceProvider"
],
"aliases": {
"Hashids": "AntoninMasek\\Hashids\\Facades\\Hashids"
}
},
"providers": [
"AntoninMasek\\Hashids\\HashidsServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit --no-coverage",
"test-coverage": "vendor/bin/phpunit --coverage"
}
}
53 changes: 25 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="AntoninMasek Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<testsuites>
<testsuite name="AntoninMasek Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
7 changes: 2 additions & 5 deletions src/Hashids.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public function minLength(int $minLength = null): static
}

/**
* @param mixed ...$numbers
* @return string
* @param string|array<int, string> $numbers
*/
public function encode(...$numbers): string
{
Expand All @@ -51,7 +50,7 @@ public function encode(...$numbers): string

/**
* @param string $hash
* @return array<int>
* @return array<int, string>
*/
public function decode($hash): array
{
Expand All @@ -61,7 +60,6 @@ public function decode($hash): array

/**
* @param string $str
* @return string
*/
public function encodeHex($str): string
{
Expand All @@ -71,7 +69,6 @@ public function encodeHex($str): string

/**
* @param string $hash
* @return string
*/
public function decodeHex($hash): string
{
Expand Down

0 comments on commit 8ccf234

Please sign in to comment.