Skip to content

Commit

Permalink
Merge pull request #31 from deligoez/php84-compatibility
Browse files Browse the repository at this point in the history
PHP 8.4 Compatibility
  • Loading branch information
deligoez authored Feb 26, 2025
2 parents 86f9248 + 4c1e372 commit 7949d84
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 104 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: tests
name: phpstan

on:
push:
branches:
- main
paths:
- **.php
- '**.php'
- composer.json
- .github/**
pull_request:
branches:
- main
paths:
- **.php
- '**.php'
- composer.json
- .github/**

Expand All @@ -24,25 +24,25 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2, 8.3]
php: [8.2, 8.3, 8.4]
laravel: ['10.*', '11.*', '12.*']
dependency-version: [prefer-lowest, prefer-stable]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
phpunit: 10.*
testbench: ^8.33
- laravel: 11.*
testbench: 9.*
phpunit: 11.*
testbench: ^9.0
- laravel: 12.*
testbench: 10.*
phpunit: '8.2'
testbench: ^10.0
exclude:
- php: 8.4
laravel: 10.*

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

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --dev
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --dev
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Validate composer.json and composer.lock
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
branches:
- main
paths:
- **.php
- '**.php'
- composer.json
- .github/**
pull_request:
branches:
- main
paths:
- **.php
- '**.php'
- composer.json
- .github/**

Expand All @@ -24,25 +24,25 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2, 8.3]
php: [8.2, 8.3, 8.4]
laravel: ['10.*', '11.*', '12.*']
dependency-version: [prefer-lowest, prefer-stable]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
phpunit: 10.*
testbench: ^8.33
- laravel: 11.*
testbench: 9.*
phpunit: 11.*
testbench: ^9.0
- laravel: 12.*
testbench: 10.*
phpunit: '8.2'
testbench: ^10.0
exclude:
- php: 8.4
laravel: 10.*

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

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --dev
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --dev
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Validate composer.json and composer.lock
Expand Down
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to `laravel-model-hashid` will be documented in this file.

## 2.5.0 - 2025-02-26
* Add support for Laravel 12 by @laravel-shift in #30
* Add support for PHP 8.4 by @frkcn in #31

## 2.4.1 - 2023-08-04
* Str use path fixed in Generator.php by @frkcn in https://github.com/deligoez/laravel-model-hashid/pull/20
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ You have complete control over your Hash Id length and style. Check out the conf

The table below shows the compatibility across Laravel, PHP, and this package's **current version**.

| Package Version | Laravel version | PHP version | Compatible |
|-----------------|-----------------|-------------|------------|
| ^2.0 | 9.* , 10.* | 8.1.* ||
| ^1.0 | 8.* | 8.0.* ||
| | 8.* | 7.4.* ||
| | 8.* | 7.3.* ||
| | 7.x | * ||
| Package Version | Laravel version | PHP version | Compatible |
|-----------------|------------------------|---------------------------|------------|
| ^2.0 | 9.* , 10.*, 11.*, 12.* | 8.1.*, 8.2*, 8.3.*, 8.4.* ||
| ^1.0 | 8.* | 8.0.* ||
| | 8.* | 7.4.* ||
| | 8.* | 7.3.* ||
| | 7.x | * ||

## Installation

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
"source": "https://github.com/deligoez/laravel-model-hashid"
},
"require": {
"php": "^8.2|^8.3",
"php": "^8.2|^8.3|^8.4",
"ext-mbstring": "*",
"hashids/hashids": "^4.1|^5.0",
"illuminate/contracts": "^9.0|^10.0|^11.0|^12.0"
},
"require-dev": {
"laravel/pint": "^1.10",
"nunomaduro/larastan": "^2.4",
"nunomaduro/collision": "^7.0|^8.6",
"nunomaduro/larastan": "^2.4|^3.0",
"orchestra/testbench": "^8.0|^9.0|^10.0",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.1.1|^2.0",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Deligoez Test Suite">
<directory>tests</directory>
Expand Down
56 changes: 19 additions & 37 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/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"
>
<testsuites>
<testsuite name="Deligoez Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<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/logs/tests.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Deligoez Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<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/logs/tests.xml"/>
</logging>
</phpunit>
14 changes: 7 additions & 7 deletions src/LaravelModelHashIdServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public function register(): void
*/
protected function bootMixins(): void
{
Builder::mixin(new FindByHashIdMixin());
Builder::mixin(new FindManyByHashIdMixin());
Builder::mixin(new FindOrFailByHashIdMixin());
Builder::mixin(new FindOrByHashIdMixin());
Builder::mixin(new FindOrNewByHashIdMixin());
Builder::mixin(new WhereHashIdMixin());
Builder::mixin(new WhereHashIdNotMixin());
Builder::mixin(new FindByHashIdMixin);
Builder::mixin(new FindManyByHashIdMixin);
Builder::mixin(new FindOrFailByHashIdMixin);
Builder::mixin(new FindOrByHashIdMixin);
Builder::mixin(new FindOrNewByHashIdMixin);
Builder::mixin(new WhereHashIdMixin);
Builder::mixin(new WhereHashIdNotMixin);
}
}
2 changes: 1 addition & 1 deletion src/Support/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function checkIfParameterDefined(string $parameter): void
public static function checkIfModelClassExist(Model|string $model): void
{
if (is_string($model) && !class_exists($model)) {
throw new ModelNotFoundException();
throw new ModelNotFoundException;
}
}
}
2 changes: 0 additions & 2 deletions src/Traits/HasHashId.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public function getHashIdAttribute(): ?string

/**
* Get the Raw Hash Id for the model.
*
* @return ?string
*/
public function getHashIdRawAttribute(): ?string
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Mixins/FindOrByHashIdMixinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function it_can_find_or_a_model_by_its_hash_id(): void

// 2️⃣.2️⃣ Act 🏋🏻‍
ModelA::findOrByHashId($model->hashId, function (): void {
throw new RuntimeException();
throw new RuntimeException;
});
}

Expand All @@ -59,7 +59,7 @@ public function it_can_find_or_fail_a_model_by_its_hash_id_from_specific_columns

// 2️⃣.2️⃣ Act 🏋🏻‍
ModelA::findOrByHashId($model->hashId, function (): void {
throw new RuntimeException();
throw new RuntimeException;
});
}
}
2 changes: 1 addition & 1 deletion tests/Support/HashIdModelConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function it_can_get_specific_config_via_model_instance_or_class_name(): v
Config::set(ConfigParameters::SEPARATOR, $modelSpecificSeparator, ModelA::class);

// 2. Act 🏋🏻‍
$modelSeparatorViaInstance = Config::get(ConfigParameters::SEPARATOR, new ModelA());
$modelSeparatorViaInstance = Config::get(ConfigParameters::SEPARATOR, new ModelA);
$modelSeparatorViaClassName = Config::get(ConfigParameters::SEPARATOR, ModelA::class);

// 3. Assert ✅
Expand Down
Loading

0 comments on commit 7949d84

Please sign in to comment.