Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/actions/setup-php-composer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
php-version:
description: 'PHP version to use'
required: false
default: '8.3'
default: '8.4'
coverage:
description: 'Coverage driver to use (none, xdebug, pcov)'
required: false
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.4, 8.5]
php: [8.4, 8.5]
stability: [prefer-lowest, prefer-stable]
include:
- os: ubuntu-latest
php: 8.5
stability: prefer-stable
mutation: true

name: PHP${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -30,18 +35,18 @@ jobs:
uses: ./.github/actions/setup-php-composer
with:
php-version: ${{ matrix.php }}
coverage: pcov
coverage: ${{ matrix.mutation && 'pcov' || 'none' }}
stability: ${{ matrix.stability }}

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Execute tests with mutation
if: ${{ matrix.os == 'ubuntu-latest' }}
run: vendor/bin/pest --colors=always --mutate --parallel --min=80

- name: Execute tests
if: ${{ matrix.os != 'ubuntu-latest' }}
if: ${{ ! matrix.mutation }}
run: vendor/bin/pest --colors=always

- name: Execute tests with mutation
if: ${{ matrix.mutation }}
run: vendor/bin/pest --colors=always --mutate --parallel --min=80
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- ✅ **Validation** - Validate data against schemas with detailed error messages
- 🤝 **Conditional Schemas** - Support for if/then/else, allOf, anyOf, and not conditions
- 🔄 **Reflection** - Generate schemas from PHP classes, enums, and closures — including docblock array generics and constructor property promotion
- 💪 **Type Safety** - Built with PHP 8.3+ features and strict typing
- 💪 **Type Safety** - Built with PHP 8.4+ features and strict typing
- 🔍 **Version-Aware Features** - Automatic validation of version-specific features with helpful error messages

## JSON Schema Version Support
Expand All @@ -29,7 +29,7 @@ This package supports multiple JSON Schema specification versions with automatic

## Requirements

- PHP 8.3+
- PHP 8.4+

## Installation

Expand Down
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@
}
],
"require": {
"php": "^8.3",
"php": "^8.4",
"ext-json": "*",
"opis/json-schema": "^2.4",
"opis/json-schema": "^2.5",
"phpstan/phpdoc-parser": "^2.3"
},
"require-dev": {
"pestphp/pest": "^4.1.4",
"pestphp/pest-plugin-type-coverage": "^4.0.3",
"pestphp/pest": "^5.0",
"pestphp/pest-plugin-phpstan": "^5.0",
"pestphp/pest-plugin-rector": "^5.0",
"pestphp/pest-plugin-type-coverage": "^5.0",
"phpstan/phpstan": "^2.1.32",
"phpstan/phpstan-strict-rules": "^2.0",
"rector/rector": "^2.2",
"symplify/easy-coding-standard": "^13.0"
"symplify/easy-coding-standard": "~13.1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -43,7 +45,7 @@
}
},
"scripts": {
"test": "pest",
"test": "pest --parallel",
"ecs": "ecs check --fix",
"ecs:check": "ecs check",
"rector": "rector process",
Expand Down
2 changes: 1 addition & 1 deletion docs/json-schema/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ icon: 'terminal'

## Requirements

- PHP 8.3+
- PHP 8.4+
- Composer for dependency management

## Installation Steps
Expand Down
6 changes: 3 additions & 3 deletions docs/json-schema/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ icon: 'book-open'
href="/json-schema/installation"
icon="shield"
>
Built with PHP 8.3+ features and strict typing for reliable, maintainable code.
Built with PHP 8.4+ features and strict typing for reliable, maintainable code.
</Card>
<Card
title="Conditional Schemas"
Expand Down Expand Up @@ -70,7 +70,7 @@ icon: 'book-open'

## About This Package

This PHP package provides a fluent, type-safe way to build and validate JSON Schemas. Built with PHP 8.3+ features and strict typing, it supports multiple JSON Schema specification versions with automatic feature validation.
This PHP package provides a fluent, type-safe way to build and validate JSON Schemas. Built with PHP 8.4+ features and strict typing, it supports multiple JSON Schema specification versions with automatic feature validation.

## Quick Example

Expand Down Expand Up @@ -109,7 +109,7 @@ if ($schema->isValid($data)) {
```

<Note>
This package requires PHP 8.3 or higher and uses modern PHP features for optimal performance and developer experience.
This package requires PHP 8.4 or higher and uses modern PHP features for optimal performance and developer experience.
</Note>

## Supported Schema Types
Expand Down
19 changes: 19 additions & 0 deletions docs/json-schema/schema-types/object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ $productSchema = Schema::object('product')
```
</Accordion>

## Named Properties

When the property key should not come from the schema title, use `property()` to set the name explicitly. You can also mark properties as required in bulk with `requireProperties()`:

```php
$userSchema = Schema::object('user')
->property('name', Schema::string()->minLength(1), required: true)
->property('email', Schema::string()->format(SchemaFormat::Email), required: true)
->property('bio', Schema::string()->maxLength(500));

// Or mark required properties separately
$configSchema = Schema::object('config')
->property('host', Schema::string())
->property('port', Schema::integer())
->requireProperties('host', 'port');
```

`property()` is especially useful when converting from raw JSON Schema, where property keys are independent of any `title` metadata.

## Property Titles

Property names are defined by the schema constructor argument, while `title()` is metadata and only included when it differs from the property name:
Expand Down
2 changes: 1 addition & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
cleanCode: true,
)
->withPhpCsFixerSets(
php83Migration: true,
php84Migration: true,
)
->withRules([
NotOperatorWithSuccessorSpaceFixer::class,
Expand Down
2 changes: 2 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/pestphp/pest-plugin-phpstan/extension.neon

parameters:
level: 10
paths:
- src
- tests
tmpDir: .phpstan-cache
checkBenevolentUnionTypes: true
8 changes: 7 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Pest\Rector\Set\PestSetList;

return RectorConfig::configure()
->withPaths([
Expand All @@ -14,7 +15,12 @@
importDocBlockNames: false,
removeUnusedImports: true,
)
->withPhpSets()
->withPhpSets(
php84: true,
)
->withSets([
PestSetList::CODING_STYLE,
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
Expand Down
Loading