Skip to content

Commit a40d36f

Browse files
committed
Update to PHP 8.5
1 parent a73f026 commit a40d36f

6 files changed

Lines changed: 87 additions & 34 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
12-
php: [8.2, 8.3, 8.4]
13-
12+
php: [8.3, 8.4, 8.5]
1413

1514
name: P${{ matrix.php }} - ${{ matrix.os }}
1615

1716
steps:
1817
- name: Checkout code
19-
uses: actions/checkout@v5
18+
uses: actions/checkout@v6
2019

2120
- name: Setup PHP
2221
uses: shivammathur/setup-php@v2

.github/workflows/static-code-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest]
12-
php: [8.3]
12+
php: [8.4]
1313
stability: [prefer-stable]
1414

1515
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
1616

1717
steps:
1818
- name: Checkout code
19-
uses: actions/checkout@v5
19+
uses: actions/checkout@v6
2020

2121
- name: Setup PHP
2222
uses: shivammathur/setup-php@v2

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Changelog
22

3-
## 1.0.3 - WIP
3+
## 1.1.0 - 2026-01-02
4+
- Add Symfony HttpClient support for loading JSON from URL. Thanks to @sonnymilton
5+
- Update to PHP 8.5 support.
46
- Adding the `extractWhere()` method that allows you to recursively query data elements and extract all elements that match a given property/value pair.
57
- Fix `offsetAccess.invalidOffset` phpstan warning
8+
- Upgrade to `actions/checkout@v6` for GitHub Actions
69

710
## 1.0.2 - 2025-10-05
811
- Adding `getIntStrict()` method for returning strict int.

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^8.2|^8.3|^8.4",
21+
"php": "^8.3|^8.4|^8.5",
2222
"swaggest/json-schema": "^0.12.42",
2323
"symfony/http-client-contracts": "^3.4.4",
24-
"symfony/yaml": "^6.4|^7.1"
24+
"symfony/yaml": "^6.4|^7.1|^8.0"
2525
},
2626
"require-dev": {
2727
"laravel/pint": "^1.2",
28-
"pestphp/pest": "^3.0",
28+
"pestphp/pest": "^4.0",
2929
"phpstan/phpstan": "^2",
3030
"rector/rector": "^2",
31-
"symfony/http-client": "^7.4"
31+
"symfony/http-client": "^7.4|^8.0"
3232
},
3333
"suggest": {
3434
"symfony/http-client": "HTTP client implementation"
@@ -45,10 +45,15 @@
4545
},
4646
"scripts": {
4747
"all": [
48-
"@test", "@format", "@phpstan", "@rector"
48+
"@test",
49+
"@format",
50+
"@phpstan",
51+
"@rector"
4952
],
5053
"complete": [
51-
"@test-with-url", "@format", "@phpstan"
54+
"@test-with-url",
55+
"@format",
56+
"@phpstan"
5257
],
5358
"test": "vendor/bin/pest --exclude-group=url",
5459
"test-with-url": "vendor/bin/pest",

tests/Feature/BlockTest.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22

33
use HiFolks\DataType\Block;
44

5-
test('load JSON object HTTP', function (): void {
5+
test("load JSON object HTTP", function (): void {
66
$jsonString = file_get_contents("./tests/data/story.json");
77

88
$composerContent = Block::fromJsonString($jsonString);
99
expect($composerContent->get("story.name"))->toBe("Home");
10-
expect($composerContent->getBlock("story.content"))->toBeInstanceOf(Block::class);
10+
expect($composerContent->getBlock("story.content"))->toBeInstanceOf(
11+
Block::class,
12+
);
1113
expect($composerContent->get("story.content"))->toHaveKey("body");
1214
$bodyComponents = $composerContent->getBlock("story.content.body");
1315
expect($bodyComponents)->toHaveCount(10);
1416
expect($bodyComponents->get("0.headline"))->toBe("New banner");
1517
expect($bodyComponents->get("1.headline"))->toBe("Hello Everyone");
16-
expect($bodyComponents->get("2.headline"))->toBe("We don't know what we don't know.");
18+
expect($bodyComponents->get("2.headline"))->toBe(
19+
"We don't know what we don't know.",
20+
);
1721
expect($composerContent->get("cv"))->toBe(1717763755);
1822
});
1923

20-
21-
it('load JSON object', function (): void {
24+
it("load JSON object", function (): void {
2225
$file = "./composer.json";
2326
$composerContent = Block::fromJsonFile($file);
2427
expect($composerContent->get("name"))->toBe("hi-folks/data-block");
@@ -27,60 +30,62 @@
2730
expect($composerContent->get("authors.0.name"))->toBe("Test");
2831
});
2932

30-
it('export to array', function (): void {
33+
it("export to array", function (): void {
3134
$file = "./composer.json";
3235
$composerContent = Block::fromJsonFile($file);
3336
$array = $composerContent->toArray();
3437
expect($array)->toBeArray();
35-
expect($array)->toHaveKeys(["name","authors"]);
38+
expect($array)->toHaveKeys(["name", "authors"]);
3639
expect($array["authors"])->toHaveKeys([0]);
3740
expect($array["authors"][0])->toHaveKeys(["name"]);
3841
expect($array["authors"][0]["name"])->toBe("Roberto B.");
39-
4042
});
4143

42-
43-
it('load YAML object', function (): void {
44+
it("load YAML object", function (): void {
4445
$file = "./.github/workflows/run-tests.yml";
4546
$workflow = Block::fromYamlFile($file);
4647
expect($workflow->get("on"))->toBeArray();
4748
expect($workflow->get("on"))->toHaveCount(2);
4849
expect($workflow->get("on.0"))->toBe("push");
4950
expect($workflow->get("on.1"))->toBe("pull_request");
5051
expect($workflow->get("jobs.test.runs-on"))->toBe('${{ matrix.os }}');
51-
52-
5352
});
5453

55-
it('Convert Json to Yaml', function (): void {
54+
it("Convert Json to Yaml", function (): void {
5655
$file = "./composer.json";
5756
$composer1 = Block::fromJsonFile($file);
5857
$yaml = $composer1->toYaml();
5958
$composer2 = Block::fromYamlString($yaml);
6059
expect($composer2->get("name"))->toBe("hi-folks/data-block");
6160
expect($composer2->get("authors.0.name"))->toBe("Roberto B.");
62-
63-
6461
});
6562

66-
it('has some value', function (): void {
63+
it("has some value", function (): void {
6764
$file = "./composer.json";
6865
$composer = Block::fromJsonFile($file);
6966
expect($composer->getBlock("require"))->toBeInstanceOf(Block::class);
7067
expect($composer->getBlock("require.php"))->toBeInstanceOf(Block::class);
7168
expect($composer->get("require.php"))->toBeString();
7269

73-
expect($composer->getBlock("require")->has("^8.2|^8.3|^8.4"))->toBeTrue();
70+
expect($composer->getBlock("require")->has("^8.3|^8.4|^8.5"))->toBeTrue();
7471
expect($composer->getBlock("require")->hasKey("php"))->toBeTrue();
75-
expect($composer->getBlock("require-dev")->hasKey("pestphp/pest"))->toBeTrue();
72+
expect(
73+
$composer->getBlock("require-dev")->hasKey("pestphp/pest"),
74+
)->toBeTrue();
7675
});
7776

78-
it('tests some value for composer.lock', function (): void {
77+
it("tests some value for composer.lock", function (): void {
7978
$file = "./tests/data/dummy-composer.lock";
8079
$composer = Block::fromJsonFile($file);
8180
expect($composer->getBlock("packages"))->toBeInstanceOf(Block::class);
8281
expect($composer->getBlock("packages"))->toHaveCount(7);
83-
expect($composer->getBlock("packages")->where("dist.type", "zip"))->toHaveCount(7);
84-
expect($composer->getBlock("packages")->where("dist.type", "zip"))->toHaveCount(7);
85-
expect($composer->getBlock("packages")->where("source.type", "git"))->toHaveCount(7);
82+
expect(
83+
$composer->getBlock("packages")->where("dist.type", "zip"),
84+
)->toHaveCount(7);
85+
expect(
86+
$composer->getBlock("packages")->where("dist.type", "zip"),
87+
)->toHaveCount(7);
88+
expect(
89+
$composer->getBlock("packages")->where("source.type", "git"),
90+
)->toHaveCount(7);
8691
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
use HiFolks\DataType\Block;
5+
6+
class LoadJsonObjectHttpTest extends TestCase
7+
{
8+
public function testLoadJsonObjectHttp(): void
9+
{
10+
$jsonString = file_get_contents(__DIR__ . "/../data/story.json");
11+
12+
$composerContent = Block::fromJsonString($jsonString);
13+
14+
$this->assertSame("Home", $composerContent->get("story.name"));
15+
16+
$this->assertInstanceOf(
17+
Block::class,
18+
$composerContent->getBlock("story.content"),
19+
);
20+
21+
$this->assertArrayHasKey(
22+
"body",
23+
$composerContent->get("story.content"),
24+
);
25+
26+
$bodyComponents = $composerContent->getBlock("story.content.body");
27+
28+
$this->assertCount(10, $bodyComponents);
29+
30+
$this->assertSame("New banner", $bodyComponents->get("0.headline"));
31+
32+
$this->assertSame("Hello Everyone", $bodyComponents->get("1.headline"));
33+
34+
$this->assertSame(
35+
"We don't know what we don't know.",
36+
$bodyComponents->get("2.headline"),
37+
);
38+
39+
$this->assertSame(1717763755, $composerContent->get("cv"));
40+
}
41+
}

0 commit comments

Comments
 (0)