Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93e0ed7

Browse files
ci: Add PHP 8.5 to pipeline, ignoring dependencies and as experimental (#842)
This PR will - add PHP 8.5 to the continuous integration pipeline, ignoring platform dependencies - resolve deprecations for: - Reflection*::setAccessible - curl_close - $http_response_header Fixes #798
1 parent 3916d66 commit 93e0ed7

File tree

8 files changed

+45
-31
lines changed

8 files changed

+45
-31
lines changed

‎.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,14 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
php-version:
25-
- "7.2"
26-
- "7.3"
27-
- "7.4"
28-
- "8.0"
29-
- "8.1"
30-
- "8.2"
31-
- "8.3"
32-
- "8.4"
24+
php-version: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
3325
dependencies: [highest]
3426
include:
3527
- php-version: "7.2"
3628
dependencies: lowest
37-
# - php-version: "8.5"
38-
# dependencies: highest
39-
# experimental: true
29+
- php-version: "8.5"
30+
dependencies: ignore
31+
experimental: true
4032

4133
steps:
4234
- name: "Checkout"

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
- ### Changed
10+
- ci: Add PHP 8.5 to pipeline, ignoring dependencies and as experimental ([#842](https://github.com/jsonrainbow/json-schema/pull/842))
911

1012
## [6.5.0] - 2025年08月29日
1113
### Changed

‎src/JsonSchema/Uri/Retrievers/Curl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public function retrieve($uri)
5353
$this->fetchMessageBody($response);
5454
$this->fetchContentType($response);
5555

56-
curl_close($ch);
56+
if (PHP_VERSION_ID < 80000) {
57+
curl_close($ch);
58+
}
5759

5860
return $this->messageBody;
5961
}

‎src/JsonSchema/Uri/Retrievers/FileGetContents.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@ public function retrieve($uri)
5151
}
5252

5353
$this->messageBody = $response;
54+
5455
if (function_exists('http_get_last_response_headers')) {
55-
// Use http_get_last_response_headers() for BC compatibility with PHP 8.5+
56+
// Use http_get_last_response_headers() for compatibility with PHP 8.5+
5657
// where $http_response_header is deprecated.
57-
$http_response_header = http_get_last_response_headers();
58+
$httpResponseHeaders = http_get_last_response_headers();
59+
} else {
60+
/** @phpstan-ignore nullCoalesce.variable ($http_response_header can non-existing when no http request was done) */
61+
$httpResponseHeaders = $http_response_header ?? [];
5862
}
59-
if (!empty($http_response_header)) {
60-
// $http_response_header cannot be tested, because it's defined in the method's local scope
61-
// See http://php.net/manual/en/reserved.variables.httpresponseheader.php for more info.
62-
$this->fetchContentType($http_response_header); // @codeCoverageIgnore
63-
} else { // @codeCoverageIgnore
64-
// Could be a "file://" url or something else - fake up the response
63+
64+
if (!empty($httpResponseHeaders)) {
65+
$this->fetchContentType($httpResponseHeaders);
66+
} else {
6567
$this->contentType = null;
6668
}
6769

@@ -73,7 +75,7 @@ public function retrieve($uri)
7375
*
7476
* @return bool Whether the Content-Type header was found or not
7577
*/
76-
private function fetchContentType(array $headers)
78+
private function fetchContentType(array $headers): bool
7779
{
7880
foreach (array_reverse($headers) as $header) {
7981
if ($this->contentType = self::getContentTypeMatchInHeader($header)) {

‎tests/Constraints/TypeTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ public function testValidateTypeNameWording($nameWording): void
9696
$t = new TypeConstraint();
9797
$r = new \ReflectionObject($t);
9898
$m = $r->getMethod('validateTypeNameWording');
99-
$m->setAccessible(true);
99+
if (PHP_VERSION_ID < 80100) {
100+
$m->setAccessible(true);
101+
}
100102

101103
$m->invoke($t, $nameWording);
102104
$this->expectNotToPerformAssertions();
@@ -107,7 +109,9 @@ public function testInvalidateTypeNameWording(): void
107109
$t = new TypeConstraint();
108110
$r = new \ReflectionObject($t);
109111
$m = $r->getMethod('validateTypeNameWording');
110-
$m->setAccessible(true);
112+
if (PHP_VERSION_ID < 80100) {
113+
$m->setAccessible(true);
114+
}
111115

112116
$this->expectException('\UnexpectedValueException');
113117
$this->expectExceptionMessage("No wording for 'notAValidTypeName' available, expected wordings are: [an integer, a number, a boolean, an object, an array, a string, a null]");

‎tests/SchemaStorageTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,13 @@ public function testNoDoubleResolve(): void
290290
$uriRetriever->retrieve('test/schema')->willReturn($schemaOne)->shouldBeCalled();
291291

292292
$s = new SchemaStorage($uriRetriever->reveal());
293-
$schema = $s->addSchema('test/schema');
293+
$s->addSchema('test/schema');
294294

295295
$r = new \ReflectionObject($s);
296296
$p = $r->getProperty('schemas');
297-
$p->setAccessible(true);
297+
if (PHP_VERSION_ID < 80100) {
298+
$p->setAccessible(true);
299+
}
298300
$schemas = $p->getValue($s);
299301

300302
$this->assertEquals(

‎tests/Uri/Retrievers/FileGetContentsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function testContentType(): void
3131

3232
$reflector = new \ReflectionObject($res);
3333
$fetchContentType = $reflector->getMethod('fetchContentType');
34-
$fetchContentType->setAccessible(true);
34+
if (PHP_VERSION_ID < 80100) {
35+
$fetchContentType->setAccessible(true);
36+
}
3537

3638
$this->assertTrue($fetchContentType->invoke($res, ['Content-Type: application/json']));
3739
$this->assertFalse($fetchContentType->invoke($res, ['X-Some-Header: whateverValue']));

‎tests/Uri/UriRetrieverTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,15 @@ private function mockRetriever($schema): void
267267
$retrieverMock = $this->getRetrieverMock($schema);
268268

269269
$factory = new \ReflectionProperty(\JsonSchema\Constraints\BaseConstraint::class, 'factory');
270-
$factory->setAccessible(true);
270+
if (PHP_VERSION_ID < 80100) {
271+
$factory->setAccessible(true);
272+
}
271273
$factory = $factory->getValue($this->validator);
272274

273275
$retriever = new \ReflectionProperty(\JsonSchema\Constraints\Factory::class, 'uriRetriever');
274-
$retriever->setAccessible(true);
276+
if (PHP_VERSION_ID < 80100) {
277+
$retriever->setAccessible(true);
278+
}
275279
$retriever->setValue($factory, $retrieverMock);
276280
}
277281

@@ -362,12 +366,16 @@ public function testSchemaCache(): void
362366

363367
// inject a schema cache value
364368
$schemaCache = $reflector->getProperty('schemaCache');
365-
$schemaCache->setAccessible(true);
369+
if (PHP_VERSION_ID < 80100) {
370+
$schemaCache->setAccessible(true);
371+
}
366372
$schemaCache->setValue($retriever, ['local://test/uri' => 'testSchemaValue']);
367373

368374
// retrieve from schema cache
369375
$loadSchema = $reflector->getMethod('loadSchema');
370-
$loadSchema->setAccessible(true);
376+
if (PHP_VERSION_ID < 80100) {
377+
$loadSchema->setAccessible(true);
378+
}
371379
$this->assertEquals(
372380
'testSchemaValue',
373381
$loadSchema->invoke($retriever, 'local://test/uri')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /