-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4668680
Showing
34 changed files
with
1,795 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml,*.yaml,*.neon] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
* text=auto | ||
|
||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.github export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/README.md export-ignore | ||
/ecs.php export-ignore | ||
/tests export-ignore | ||
/phpstan.neon export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "composer" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
labels: | ||
- "dependencies" | ||
- "composer" | ||
versioning-strategy: "widen" | ||
open-pull-requests-limit: 5 | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
labels: | ||
- "dependencies" | ||
- "github-actions" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
php: [8.3, 8.4] | ||
stability: [prefer-lowest, prefer-stable] | ||
|
||
name: PHP${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
|
||
- name: Execute tests | ||
run: vendor/bin/pest --colors=always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Static Analysis | ||
|
||
on: [push] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
phpstan: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache Composer dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Cache phpstan results | ||
uses: actions/cache@v4 | ||
with: | ||
path: .phpstan-cache | ||
key: "result-cache-${{ github.run_id }}" # always write a new cache | ||
restore-keys: | | ||
result-cache- | ||
- name: Run phpstan | ||
run: vendor/bin/phpstan analyse -c phpstan.dist.neon --no-progress --error-format=github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
vendor | ||
composer.lock | ||
.vscode | ||
.env | ||
.DS_Store | ||
.phpstan-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# json-schema | ||
|
||
A PHP library for fluently building and validating JSON Schemas. | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require cortex/json-schema | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
$schema = ObjectSchema::make('user') | ||
->description('User schema') | ||
->properties( | ||
StringSchema::make('name'), | ||
StringSchema::make('email'), | ||
); | ||
|
||
$schema->toArray(); | ||
``` | ||
|
||
```json | ||
{ | ||
"type": "object", | ||
"title": "user", | ||
"description": "User schema", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"email": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"name": "cortexphp/json-schema", | ||
"description": "A fluent JSON Schema builder for PHP", | ||
"keywords": [ | ||
"json", | ||
"schema", | ||
"cortex" | ||
], | ||
"homepage": "https://github.com/cortexphp/json-schema", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Sean Tymon", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.3", | ||
"opis/json-schema": "^2.3" | ||
}, | ||
"require-dev": { | ||
"pestphp/pest": "^3.0", | ||
"phpstan/phpstan": "^2.0", | ||
"rector/rector": "^2.0", | ||
"symplify/easy-coding-standard": "^12.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Cortex\\JsonSchema\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Cortex\\JsonSchema\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "pest", | ||
"ecs": "ecs check --fix", | ||
"rector": "rector process", | ||
"stan": "phpstan analyse", | ||
"format": [ | ||
"@rector", | ||
"@ecs" | ||
], | ||
"check": [ | ||
"@format", | ||
"@test", | ||
"@stan" | ||
] | ||
}, | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PhpCsFixer\Fixer\Import\OrderedImportsFixer; | ||
use Symplify\EasyCodingStandard\Config\ECSConfig; | ||
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer; | ||
use Symplify\EasyCodingStandard\ValueObject\Option; | ||
use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer; | ||
use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer; | ||
use PhpCsFixer\Fixer\Comment\SingleLineCommentSpacingFixer; | ||
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer; | ||
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer; | ||
use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer; | ||
use PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer; | ||
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; | ||
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer; | ||
use PhpCsFixer\Fixer\Whitespace\BlankLineBetweenImportGroupsFixer; | ||
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer; | ||
use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; | ||
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff; | ||
|
||
return ECSConfig::configure() | ||
->withPaths([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]) | ||
->withRootFiles() | ||
->withSpacing(indentation: Option::INDENTATION_SPACES) | ||
->withPreparedSets( | ||
psr12: true, | ||
common: true, | ||
cleanCode: true, | ||
strict: true, | ||
) | ||
->withPhpCsFixerSets( | ||
php83Migration: true, | ||
) | ||
->withRules([ | ||
NotOperatorWithSuccessorSpaceFixer::class, | ||
RemovePHPStormAnnotationFixer::class, | ||
SingleLineCommentSpacingFixer::class, | ||
NoTrailingWhitespaceInCommentFixer::class, | ||
BlankLineBetweenImportGroupsFixer::class, | ||
SingleLineEmptyBodyFixer::class, | ||
]) | ||
->withConfiguredRule(FunctionDeclarationFixer::class, [ | ||
'closure_fn_spacing' => FunctionDeclarationFixer::SPACING_NONE, | ||
]) | ||
->withConfiguredRule(TrailingCommaInMultilineFixer::class, [ | ||
'after_heredoc' => true, | ||
'elements' => [ | ||
TrailingCommaInMultilineFixer::ELEMENTS_ARGUMENTS, | ||
TrailingCommaInMultilineFixer::ELEMENTS_ARRAYS, | ||
TrailingCommaInMultilineFixer::ELEMENTS_PARAMETERS, | ||
], | ||
]) | ||
->withConfiguredRule(OrderedImportsFixer::class, [ | ||
'sort_algorithm' => OrderedImportsFixer::SORT_LENGTH, | ||
'imports_order' => [ | ||
OrderedImportsFixer::IMPORT_TYPE_CLASS, | ||
OrderedImportsFixer::IMPORT_TYPE_FUNCTION, | ||
OrderedImportsFixer::IMPORT_TYPE_CONST, | ||
], | ||
]) | ||
->withConfiguredRule(ClassAttributesSeparationFixer::class, [ | ||
'elements' => [ | ||
'property' => ClassAttributesSeparationFixer::SPACING_ONE, | ||
'method' => ClassAttributesSeparationFixer::SPACING_ONE, | ||
'trait_import' => ClassAttributesSeparationFixer::SPACING_NONE, | ||
], | ||
]) | ||
->withConfiguredRule(ClassDefinitionFixer::class, [ | ||
'inline_constructor_arguments' => false, | ||
'space_before_parenthesis' => true, | ||
]) | ||
->withConfiguredRule(PhpdocSeparationFixer::class, [ | ||
'groups' => [ | ||
['deprecated', 'link', 'see', 'since'], | ||
['author', 'copyright', 'license'], | ||
['category', 'package', 'subpackage'], | ||
['property', 'property-read', 'property-write'], | ||
['param'], | ||
['throws'], | ||
['return'], | ||
], | ||
]) | ||
->withConfiguredRule(BlankLineBeforeStatementFixer::class, [ | ||
'statements' => ['return', 'throw', 'if', 'switch', 'do', 'yield', 'try'], | ||
]) | ||
->withSkip([ | ||
OrderedClassElementsFixer::class, | ||
AssignmentInConditionSniff::class, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameters: | ||
level: 8 | ||
paths: | ||
- src | ||
tmpDir: .phpstan-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
Oops, something went wrong.