Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8.4 support #10

Merged
merged 3 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 5 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2', '8.3']
php-version: ['8.2', '8.3', '8.4']
dependency-versions: ['lowest', 'highest']
name: 'PHPUnit'
steps:
Expand All @@ -30,43 +30,8 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2', '8.3']
dependency-versions: ['lowest', 'highest']
name: 'Psalm'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none
- name: Composer
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: Psalm
run: vendor/bin/psalm --shepherd
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']
name: 'CS'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none
- name: Composer
uses: "ramsey/composer-install@v2"
- name: CS
run: vendor/bin/php-cs-fixer fix --diff --dry-run
uses: innmind/github-workflows/.github/workflows/cs.yml@main
with:
php-version: '8.2'
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"require-dev": {
"phpunit/phpunit": "~10.0",
"vimeo/psalm": "~5.23",
"vimeo/psalm": "~5.23|dev-master",
"innmind/coding-standard": "~2.0"
}
}
11 changes: 10 additions & 1 deletion src/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,20 @@ public static function maybeDecode(string $string): Maybe
public static function encode(mixed $content, int $options = 0, int $depth = 512): string
{
try {
return \json_encode(
$content = \json_encode(
$content,
$options | \JSON_THROW_ON_ERROR,
$depth,
);

if ($content === false) {
// This case should not happen since we use the option to throw
// on error. But Psalm doesn't understand that so we have to
// handle the `false` case.
throw new \JsonException;
}

return $content;
} catch (\JsonException $e) {
throw self::wrap($e);
}
Expand Down
Loading