Skip to content
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
16 changes: 4 additions & 12 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
php-version: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
dependencies: [highest]
include:
- php-version: "7.2"
dependencies: lowest
# - php-version: "8.5"
# dependencies: highest
# experimental: true
- php-version: "8.5"
dependencies: ignore
experimental: true

steps:
- name: "Checkout"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

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

## [6.5.0] - 2025-08-29
### Changed
Expand Down
4 changes: 3 additions & 1 deletion src/JsonSchema/Uri/Retrievers/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public function retrieve($uri)
$this->fetchMessageBody($response);
$this->fetchContentType($response);

curl_close($ch);
if (PHP_VERSION_ID < 80000) {
curl_close($ch);
}

return $this->messageBody;
}
Expand Down
20 changes: 11 additions & 9 deletions src/JsonSchema/Uri/Retrievers/FileGetContents.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ public function retrieve($uri)
}

$this->messageBody = $response;

if (function_exists('http_get_last_response_headers')) {
// Use http_get_last_response_headers() for BC compatibility with PHP 8.5+
// Use http_get_last_response_headers() for compatibility with PHP 8.5+
// where $http_response_header is deprecated.
$http_response_header = http_get_last_response_headers();
$httpResponseHeaders = http_get_last_response_headers();
} else {
/** @phpstan-ignore nullCoalesce.variable ($http_response_header can non-existing when no http request was done) */
$httpResponseHeaders = $http_response_header ?? [];
}
if (!empty($http_response_header)) {
// $http_response_header cannot be tested, because it's defined in the method's local scope
// See http://php.net/manual/en/reserved.variables.httpresponseheader.php for more info.
$this->fetchContentType($http_response_header); // @codeCoverageIgnore
} else { // @codeCoverageIgnore
// Could be a "file://" url or something else - fake up the response

if (!empty($httpResponseHeaders)) {
$this->fetchContentType($httpResponseHeaders);
} else {
$this->contentType = null;
}

Expand All @@ -73,7 +75,7 @@ public function retrieve($uri)
*
* @return bool Whether the Content-Type header was found or not
*/
private function fetchContentType(array $headers)
private function fetchContentType(array $headers): bool
{
foreach (array_reverse($headers) as $header) {
if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
Expand Down
8 changes: 6 additions & 2 deletions tests/Constraints/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public function testValidateTypeNameWording($nameWording): void
$t = new TypeConstraint();
$r = new \ReflectionObject($t);
$m = $r->getMethod('validateTypeNameWording');
$m->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$m->setAccessible(true);
}

$m->invoke($t, $nameWording);
$this->expectNotToPerformAssertions();
Expand All @@ -107,7 +109,9 @@ public function testInvalidateTypeNameWording(): void
$t = new TypeConstraint();
$r = new \ReflectionObject($t);
$m = $r->getMethod('validateTypeNameWording');
$m->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$m->setAccessible(true);
}

$this->expectException('\UnexpectedValueException');
$this->expectExceptionMessage("No wording for 'notAValidTypeName' available, expected wordings are: [an integer, a number, a boolean, an object, an array, a string, a null]");
Expand Down
6 changes: 4 additions & 2 deletions tests/SchemaStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,13 @@ public function testNoDoubleResolve(): void
$uriRetriever->retrieve('test/schema')->willReturn($schemaOne)->shouldBeCalled();

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

$r = new \ReflectionObject($s);
$p = $r->getProperty('schemas');
$p->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$p->setAccessible(true);
}
$schemas = $p->getValue($s);

$this->assertEquals(
Expand Down
4 changes: 3 additions & 1 deletion tests/Uri/Retrievers/FileGetContentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function testContentType(): void

$reflector = new \ReflectionObject($res);
$fetchContentType = $reflector->getMethod('fetchContentType');
$fetchContentType->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$fetchContentType->setAccessible(true);
}

$this->assertTrue($fetchContentType->invoke($res, ['Content-Type: application/json']));
$this->assertFalse($fetchContentType->invoke($res, ['X-Some-Header: whateverValue']));
Expand Down
16 changes: 12 additions & 4 deletions tests/Uri/UriRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,15 @@ private function mockRetriever($schema): void
$retrieverMock = $this->getRetrieverMock($schema);

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

$retriever = new \ReflectionProperty(\JsonSchema\Constraints\Factory::class, 'uriRetriever');
$retriever->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$retriever->setAccessible(true);
}
$retriever->setValue($factory, $retrieverMock);
}

Expand Down Expand Up @@ -362,12 +366,16 @@ public function testSchemaCache(): void

// inject a schema cache value
$schemaCache = $reflector->getProperty('schemaCache');
$schemaCache->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$schemaCache->setAccessible(true);
}
$schemaCache->setValue($retriever, ['local://test/uri' => 'testSchemaValue']);

// retrieve from schema cache
$loadSchema = $reflector->getMethod('loadSchema');
$loadSchema->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$loadSchema->setAccessible(true);
}
$this->assertEquals(
'testSchemaValue',
$loadSchema->invoke($retriever, 'local://test/uri')
Expand Down