Skip to content

Commit da4879f

Browse files
committed
Merge branch '2020'
# Conflicts: # .gitattributes # .github/workflows/tests.yml # .gitignore # composer.json # src/ValidatorHelper.php
2 parents d1adee5 + 591bce5 commit da4879f

File tree

557 files changed

+48105
-7353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

557 files changed

+48105
-7353
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests/ export-ignore
22
phpunit.xml export-ignore
33
.gitattributes export-ignore
4-
.gitignore export-ignore
4+
.gitignore export-ignore
5+
.github export-ignore

.github/workflows/tests.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,24 @@ jobs:
1212
strategy:
1313
fail-fast: true
1414
matrix:
15-
php: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0]
16-
stability: [prefer-stable]
15+
php: [7.4, 8.0]
1716

1817
name: PHP ${{ matrix.php }}
1918

2019
steps:
2120
- name: Checkout code
2221
uses: actions/checkout@v2
2322

24-
- name: Cache dependencies
25-
uses: actions/cache@v1
26-
with:
27-
path: ~/.composer/cache/files
28-
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
29-
3023
- name: Setup PHP
3124
uses: shivammathur/setup-php@v2
3225
with:
3326
php-version: ${{ matrix.php }}
34-
extensions: bcmath, json, mbstring, intl
27+
extensions: bcmath, json, intl
28+
tools: composer:v2
3529
coverage: none
3630

37-
- name: Update composer
38-
run: composer self-update
39-
4031
- name: Install dependencies
41-
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
32+
run: composer update --no-interaction --no-progress
4233

4334
- name: Execute tests
4435
run: vendor/bin/phpunit --verbose

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ _site/
44
shared/
55
Gemfile.lock
66
composer.lock
7-
.phpunit.result.cache
7+
.phpunit.result.cache
8+
test.php

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Opis Json Schema
2-
Copyright 2018 Zindex Software
2+
Copyright 2018-2021 Zindex Software
33

44
This product includes software developed at
55
Zindex Software (http://zindex.software).

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,22 @@ Opis JSON Schema
88
Validate JSON documents
99
-----------
1010

11-
**Opis JSON Schema** is a PHP implementation for the [JSON Schema] standard (draft-07 and draft-06), that
11+
**Opis JSON Schema** is a PHP implementation for the [JSON Schema] standard (draft-2020-12, draft-2019-09, draft-07 and draft-06), that
1212
will help you validate all sorts of JSON documents, whether they are configuration files or a set
1313
of data sent to a RESTful API endpoint.
1414

1515

1616
**The library's key features:**
1717

18-
- Fast validation (you can set maximum number of errors for a validation)
19-
- Custom schema document [loaders](https://docs.opis.io/json-schema/1.x/php-loader.html)
20-
- Support for [if-then-else](https://docs.opis.io/json-schema/1.x/conditional-subschemas.html#if-then-else)
21-
- All [string formats](https://docs.opis.io/json-schema/1.x/formats.html#provided-formats) are supported
22-
- Support for custom [formats](https://docs.opis.io/json-schema/1.x/php-format.html)
23-
- Support for custom [media types](https://docs.opis.io/json-schema/1.x/php-media-type.html)
24-
- Support for [default value](https://docs.opis.io/json-schema/1.x/default-value.html)
25-
- Support for custom variables using [`$vars` keyword](https://docs.opis.io/json-schema/1.x/variables.html)
26-
- Support for custom filters using [`$filters` keyword](https://docs.opis.io/json-schema/1.x/filters.html)
27-
- Advanced schema reuse using [`$map` keyword](https://docs.opis.io/json-schema/1.x/mappers.html)
28-
- Support for [json pointers](https://docs.opis.io/json-schema/1.x/pointers.html) (absolute and relative pointers)
29-
- Support for [URI templates](https://docs.opis.io/json-schema/1.x/uri-template.html)
18+
- Supports all keywords from all drafts (draft-2020-12 down to draft-06)
19+
- Support for custom PHP filters using [`$filters` keyword](https://docs.opis.io/json-schema/2.x/filters.html)
20+
- Advanced schema reuse using [`$map` keyword](https://docs.opis.io/json-schema/2.x/mappers.html)
21+
- Intuitive schema composition using [slots](https://docs.opis.io/json-schema/2.x/slots.html)
22+
- Support for absolute & relative [json pointers](https://docs.opis.io/json-schema/2.x/pointers.html)
23+
- Support for [URI templates](https://docs.opis.io/json-schema/2.x/uri-template.html)
24+
- Support for [`$data` keyword](https://docs.opis.io/json-schema/2.x/data-keyword.html)
25+
- Support for [casting](https://docs.opis.io/json-schema/2.x/pragma.html#cast)
26+
- Support for custom [formats](https://docs.opis.io/json-schema/2.x/php-format.html) and [media types](https://docs.opis.io/json-schema/2.x/php-media-type.html)
3027

3128
### Documentation
3229

@@ -40,7 +37,7 @@ the library's own API.
4037

4138
### Requirements
4239

43-
* PHP ^7.0
40+
* PHP ^7.4 || ^8.0
4441

4542
## Installation
4643

@@ -56,12 +53,12 @@ Or you could directly reference it into your `composer.json` file as a dependenc
5653
```json
5754
{
5855
"require": {
59-
"opis/json-schema": "^1.0"
56+
"opis/json-schema": "^2.0"
6057
}
6158
}
6259
```
6360

64-
[documentation]: https://docs.opis.io/json-schema
61+
[documentation]: https://opis.io/json-schema
6562
[apache_license]: https://www.apache.org/licenses/LICENSE-2.0 "Apache License"
6663
[Packagist]: https://packagist.org/packages/opis/json-schema "Packagist"
6764
[Composer]: https://getcomposer.org "Composer"

autoload.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
<?php
22

3-
spl_autoload_register(function($class){
3+
spl_autoload_register(function ($class) {
44
$class = ltrim($class, '\\');
55
$dir = __DIR__ . '/src';
66
$namespace = 'Opis\JsonSchema';
7-
if(strpos($class, $namespace) === 0)
8-
{
7+
if (strpos($class, $namespace) === 0) {
98
$class = substr($class, strlen($namespace));
109
$path = '';
11-
if(($pos = strripos($class, '\\')) !== FALSE)
12-
{
10+
if (($pos = strripos($class, '\\')) !== false) {
1311
$path = str_replace('\\', '/', substr($class, 0, $pos)) . '/';
1412
$class = substr($class, $pos + 1);
1513
}
1614
$path .= str_replace('_', '/', $class) . '.php';
1715
$dir .= '/' . $path;
18-
if(file_exists($dir))
19-
{
16+
if (is_file($dir)) {
2017
include $dir;
2118
return true;
2219
}

composer.json

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "opis/json-schema",
3-
"description": "Json Schema Validator",
3+
"description": "Json Schema Validator for PHP",
44
"keywords": [
55
"json",
66
"schema",
7+
"json-schema",
78
"validation",
89
"validator"
910
],
10-
"homepage": "http://www.opis.io/json-schema",
11+
"homepage": "https://opis.io/json-schema",
1112
"license": "Apache-2.0",
1213
"authors": [
1314
{
@@ -20,18 +21,15 @@
2021
}
2122
],
2223
"require": {
23-
"php": ">=7.0"
24+
"php": "^7.4 || ^8.0",
25+
"ext-json": "*",
26+
"opis/string": "^2.0",
27+
"opis/uri": "^1.0"
2428
},
2529
"require-dev": {
26-
"opis/string": "^1.4",
2730
"ext-bcmath": "*",
28-
"ext-json": "*",
29-
"ext-mbstring": "*",
3031
"ext-intl": "*",
31-
"phpunit/phpunit": "^6.5 || ^7.0 || ^9.4"
32-
},
33-
"suggest": {
34-
"opis/string": "A standalone library for manipulating multibyte strings"
32+
"phpunit/phpunit": "^9.0"
3533
},
3634
"autoload": {
3735
"psr-4": {
@@ -41,12 +39,11 @@
4139
"autoload-dev": {
4240
"psr-4": {
4341
"Opis\\JsonSchema\\Test\\": "tests/"
44-
},
45-
"files": ["tests/functions.php"]
42+
}
4643
},
4744
"extra": {
4845
"branch-alias": {
49-
"dev-master": "1.0.x-dev"
46+
"dev-master": "2.x-dev"
5047
}
5148
}
5249
}

phpunit.xml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22
<testsuites>
33
<testsuite name="Schema">
44
<file>./tests/BasicTest.php</file>
5+
<file>./tests/BooleanTypeTest.php</file>
6+
<file>./tests/NullTypeTest.php</file>
7+
<file>./tests/IntegerTypeTest.php</file>
8+
<file>./tests/NumberTypeTest.php</file>
9+
<file>./tests/StringTypeTest.php</file>
10+
<file>./tests/ArrayTypeTest.php</file>
11+
<file>./tests/ObjectTypeTest.php</file>
12+
<file>./tests/MultipleTypesTest.php</file>
513
<file>./tests/RefTest.php</file>
6-
<file>./tests/TypesTest.php</file>
7-
<file>./tests/FilterTest.php</file>
8-
<file>./tests/MapTest.php</file>
14+
<file>./tests/MapperTest.php</file>
15+
<file>./tests/SlotTest.php</file>
16+
<file>./tests/FiltersTest.php</file>
17+
<file>./tests/DataTest.php</file>
18+
<file>./tests/PragmaTest.php</file>
19+
</testsuite>
20+
<testsuite name="Errors">
21+
<file>./tests/ErrorFormatterTest.php</file>
922
</testsuite>
1023
<testsuite name="Official">
11-
<file>./tests/OfficialDraft7.php</file>
12-
<file>./tests/OfficialDraft6.php</file>
24+
<file>./tests/OfficialDraft6Test.php</file>
25+
<file>./tests/OfficialDraft7Test.php</file>
26+
<file>./tests/OfficialDraft201909Test.php</file>
27+
<file>./tests/OfficialDraft202012Test.php</file>
1328
</testsuite>
1429
</testsuites>
1530
</phpunit>

src/IFormatContainer.php renamed to src/ContentEncoding.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
/* ===========================================================================
3-
* Copyright 2018 Zindex Software
2+
/* ============================================================================
3+
* Copyright 2020 Zindex Software
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -17,12 +17,12 @@
1717

1818
namespace Opis\JsonSchema;
1919

20-
interface IFormatContainer
20+
interface ContentEncoding
2121
{
2222
/**
23+
* @param string $value
2324
* @param string $type
24-
* @param string $name
25-
* @return IFormat|null
25+
* @return null|string
2626
*/
27-
public function get(string $type, string $name);
27+
public function decode(string $value, string $type): ?string;
2828
}

src/IFilter.php renamed to src/ContentMediaType.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
/* ===========================================================================
3-
* Copyright 2018 Zindex Software
2+
/* ============================================================================
3+
* Copyright 2020 Zindex Software
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -17,12 +17,12 @@
1717

1818
namespace Opis\JsonSchema;
1919

20-
interface IFilter
20+
interface ContentMediaType
2121
{
2222
/**
23-
* @param $data
24-
* @param array $args
23+
* @param string $content
24+
* @param string $media_type
2525
* @return bool
2626
*/
27-
public function validate($data, array $args): bool;
27+
public function validate(string $content, string $media_type): bool;
2828
}

0 commit comments

Comments
 (0)