Skip to content

Commit 8b32012

Browse files
committed
Initial commit
0 parents  commit 8b32012

32 files changed

Lines changed: 1445 additions & 0 deletions

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/.github export-ignore
2+
/.gitignore export-ignore
3+
/.gitattributes export-ignore
4+
/phpunit.xml export-ignore
5+
/psalm.xml export-ignore
6+
/psalm.baseline.xml export-ignore
7+
/phpcs.xml export-ignore
8+
/.phive export-ignore
9+
/test export-ignore
10+
11+
*.php text eol=lf

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.buildpath
2+
/.project
3+
/.settings
4+
/composer.lock
5+
/.phpunit.cache
6+
/vendor
7+
/tools
8+
/.phpcs-cache

.phive/phars.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="phpunit" version="^10.0.0" installed="10.5.3" location="./tools/phpunit" copy="true"/>
4+
<phar name="psalm" version="^5.12.0" installed="5.17.0" location="./tools/psalm" copy="true"/>
5+
<phar name="phpcpd" version="^6.0.0" installed="6.0.3" location="./tools/phpcpd" copy="true"/>
6+
<phar name="composer-require-checker" version="^4.2.0" installed="4.8.0" location="./tools/composer-require-checker" copy="true"/>
7+
<phar name="phploc" version="^7.0.0" installed="7.0.2" location="./tools/phploc" copy="true"/>
8+
</phive>

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2023 Andreas Wahlen
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# JSON Schema Validator
2+
3+
Validates some [JSON Schema](https://json-schema.org/) files against the JSON Schema specification.
4+
5+
## Installation
6+
7+
8+
9+
## Usage
10+
11+
Just pass some JSON schema files or folders containing those like so:
12+
13+
```shell
14+
php validateJSONSchema.php schema-file1.json schema-file2.json schema-folder [...]
15+
```
16+
17+
## License
18+
19+
This library is licensed under the MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

bin/json-schema-validator

992 KB
Binary file not shown.

box.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"main": "src/validateJSONSchema.php",
3+
"output": "bin/json-schema-validator",
4+
"directories": [
5+
"resource",
6+
"src"
7+
],
8+
"force-autodiscovery": true,
9+
"algorithm": "SHA256",
10+
"banner": "JSON Schema Validator @git-version@ by Andreas Wahlen",
11+
"git-version": "git-version"
12+
}

composer.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "nerou/json-schema-validator",
3+
"version": "1.0.2",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Andreas Wahlen",
9+
"email": "andreas.wahlen@nerou.de",
10+
"role": "Developer",
11+
"homepage": "https://www.nerou.de"
12+
}
13+
],
14+
"require": {
15+
"php": ">=8.0 <8.4",
16+
"ext-json": "*",
17+
"opis/json-schema": "^2.3",
18+
"nerou/cli-parser": "^0.1.0"
19+
},
20+
"require-dev": {
21+
"squizlabs/php_codesniffer": ">=3.7"
22+
},
23+
"prefer-stable": true,
24+
"autoload": {
25+
"psr-4": {
26+
"": "src/"
27+
}
28+
},
29+
"bin": [
30+
"bin/json-schema-validator"
31+
],
32+
"scripts": {
33+
"phpcs": "./vendor/bin/phpcs",
34+
"phpcbf": "./vendor/bin/phpcbf",
35+
"phpunit": "./tools/phpunit test",
36+
"phpcpd": "./tools/phpcpd src",
37+
"psalm": "./tools/psalm --no-diff --use-baseline=psalm.baseline.xml --php-version=8.1",
38+
"psalm-stats": "./tools/psalm --no-diff --use-baseline=psalm.baseline.xml --php-version=8.1 --stats | grep -v 100",
39+
"update-psalm-baseline": "./tools/psalm --no-diff --set-baseline=psalm.baseline.xml",
40+
"require-checker": "./tools/composer-require-checker check",
41+
"lines": "./tools/phploc src",
42+
"build": "./vendor/bin/box compile",
43+
"tests": [
44+
"@phpcs",
45+
"@phpunit",
46+
"@phpcpd",
47+
"@psalm"
48+
]
49+
},
50+
"scripts-descriptions": {
51+
"phpcs": "Runs CodeSniffer for coding style tests.",
52+
"phpcbf": "Fixes marked violations found by phpcs/CodeSniffer.",
53+
"phpunit": "Runs unit/integration tests.",
54+
"phpcpd": "Runs copied code finder.",
55+
"psalm": "Runs static analysis.",
56+
"psalm-stats": "Print files with unsafe types based on psalm.",
57+
"update-psalm-baseline": "Updates baseline for psalm. CAUTION should not be run as a regular procedure!",
58+
"lines": "Gathers statistics about lines of code.",
59+
"build": "Build PHAR",
60+
"tests": "Runs all available tests."
61+
}
62+
}

phpcs.xml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
4+
5+
<arg name="basepath" value="."/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
<arg name="extensions" value="php"/>
9+
<arg name="parallel" value="10"/>
10+
<arg name="encoding" value="utf-8"/>
11+
<arg name="tab-width" value="4"/>
12+
<!-- Show progress -->
13+
<arg value="sp"/>
14+
15+
<file>src</file>
16+
17+
<rule ref="Generic">
18+
<exclude name="Generic.Arrays.ArrayIndent"/> <!-- see below -->
19+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
20+
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
21+
<exclude name="Generic.CodeAnalysis.EmptyStatement"/> <!-- see below -->
22+
<exclude name="Generic.CodeAnalysis.JumbledIncrementer"/>
23+
<exclude name="Generic.Commenting"/> <!-- see below -->
24+
<exclude name="Generic.Files.EndFileNoNewline"/>
25+
<exclude name="Generic.Files.LineLength"/>
26+
<exclude name="Generic.Files.LowercasedFilename"/>
27+
<exclude name="Generic.Formatting.DisallowMultipleStatements"/>
28+
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"/>
29+
<exclude name="Generic.Formatting.NoSpaceAfterCast"/>
30+
<exclude name="Generic.Formatting.SpaceBeforeCast"/>
31+
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
32+
<exclude name="Generic.Metrics.CyclomaticComplexity"/> <!-- see below -->
33+
<exclude name="Generic.NamingConventions.AbstractClassNamePrefix"/>
34+
<exclude name="Generic.NamingConventions.CamelCapsFunctionName"/>
35+
<exclude name="Generic.NamingConventions.InterfaceNameSuffix"/>
36+
<exclude name="Generic.NamingConventions.TraitNameSuffix"/>
37+
<exclude name="Generic.PHP.ClosingPHPTag"/>
38+
<exclude name="Generic.PHP.UpperCaseConstant"/>
39+
<exclude name="Generic.Strings.UnnecessaryStringConcat"/>
40+
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
41+
<exclude name="Generic.WhiteSpace.ScopeIndent"/> <!-- see below -->
42+
43+
<!-- temporary -->
44+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter"/>
45+
<exclude name="Generic.Metrics.NestingLevel"/>
46+
</rule>
47+
<rule ref="Generic.Arrays.ArrayIndent">
48+
<properties>
49+
<property name="indent" value="4"/>
50+
</properties>
51+
<type>warning</type>
52+
</rule>
53+
<rule ref="Generic.CodeAnalysis.EmptyStatement">
54+
<type>warning</type>
55+
</rule>
56+
<rule ref="Generic.Commenting">
57+
<type>warning</type>
58+
</rule>
59+
<rule ref="Generic.Formatting.SpaceAfterNot">
60+
<properties>
61+
<property name="spacing" value="0"/>
62+
</properties>
63+
</rule>
64+
<rule ref="Generic.Metrics.CyclomaticComplexity">
65+
<type>warning</type>
66+
<severity>2</severity>
67+
</rule>
68+
<rule ref="Generic.WhiteSpace.ScopeIndent">
69+
<properties>
70+
<property name="indent" value="4"/>
71+
<property name="tabIndent" value="false"/>
72+
</properties>
73+
</rule>
74+
75+
<rule ref="PSR1"/>
76+
77+
<rule ref="PSR12.Classes">
78+
<exclude name="PSR12.Classes.OpeningBraceSpace"/>
79+
<exclude name="PSR12.Classes.AnonClassDeclaration"/>
80+
</rule>
81+
<rule ref="PSR12.Functions"/>
82+
<rule ref="PSR12.Keywords"/>
83+
<rule ref="PSR12.Namespaces"/>
84+
85+
<rule ref="PEAR.Commenting.InlineComment"/>
86+
<rule ref="PEAR.Functions.ValidDefaultValue"/>
87+
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent">
88+
<properties>
89+
<property name="indent" value="4"/>
90+
</properties>
91+
</rule>
92+
93+
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
94+
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
95+
<rule ref="Squiz.Classes.SelfMemberReference"/>
96+
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
97+
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>
98+
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
99+
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
100+
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
101+
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
102+
<rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
103+
<rule ref="Squiz.Scope.StaticThisUsage"/>
104+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
105+
<rule ref="Squiz.Strings.EchoedStrings"/>
106+
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
107+
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
108+
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
109+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
110+
</ruleset>

phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
5+
colors="true"
6+
stderr="true"
7+
bootstrap="vendor/autoload.php"
8+
defaultTestSuite="test"
9+
cacheDirectory=".phpunit.cache">
10+
<coverage ignoreDeprecatedCodeUnits="true">
11+
<!-- pathCoverage="true" -->
12+
</coverage>
13+
<testsuites>
14+
<testsuite name="test">
15+
<directory>test/</directory>
16+
</testsuite>
17+
</testsuites>
18+
<source>
19+
<include>
20+
<directory>src/</directory>
21+
</include>
22+
</source>
23+
</phpunit>

0 commit comments

Comments
 (0)