Skip to content

Conversation

Copy link

Copilot AI commented Dec 6, 2025

  • Create PHP SDK directory structure with composer.json, README.md, phpunit.xml
  • Implement ErrorCodes.php with standardized error codes from assets/error-messages.json
  • Implement ValidationResult.php for error reporting with line/column information
  • Implement JsonSourceLocator.php for source location tracking
  • Implement Types.php with all 34 primitive types and compound types
  • Implement SchemaValidator.php for validating JSON Structure schemas
  • Implement InstanceValidator.php for validating instances against schemas
  • Create PHPUnit tests (585 tests, 85.52% line coverage)
  • Create GitHub Actions workflow for PHP 8.1, 8.2, 8.3
  • Fix PHP 8.1 compatibility (readonly class → readonly properties)
  • Run code review and address feedback
  • Run CodeQL security check (no issues found)
Original prompt

This section details on the original issue you should resolve

<issue_title>feat(php): Add PHP SDK implementation</issue_title>
<issue_description>## Summary

Add a PHP SDK for JSON Structure schema and instance validation.

Background

PHP powers approximately 77% of websites with a known server-side language. With Laravel, Symfony, and WordPress dominating web development, a PHP SDK provides schema validation for the massive PHP ecosystem including:

  • Laravel/Symfony API validation
  • WordPress plugin data validation
  • Composer package ecosystem
  • Legacy PHP application modernization

Implementation Guide

Follow the SDK Guidelines document: SDK-GUIDELINES.md

This document contains:

  • Required components (SchemaValidator, InstanceValidator, ErrorCodes, JsonSourceLocator)
  • Complete type system reference (34 primitive types + compound types)
  • Keywords reference (what to implement, what NOT to implement)
  • Error codes reference (assets/error-messages.json)
  • Test assets for conformance testing
  • Conformance checklist

Requirements

Core Features

  • Schema Validation: Validate JSON Structure schema documents for conformance
  • Instance Validation: Validate JSON instances against JSON Structure schemas
  • Error Reporting: Line/column information for validation errors (when source JSON available)
  • Full Type Support: All 34 primitive and compound types from JSON Structure Core v0

Technical Requirements

  • PHP 8.1+ (for modern type system, enums, readonly properties)
  • Composer for distribution
  • Use json_decode() / json_encode() for JSON parsing
  • PSR-4 autoloading
  • PHPUnit for testing
  • No framework dependencies (pure PHP, works with any framework)

Package Structure

php/
 composer.json
 README.md
 phpunit.xml
 src/
    JsonStructure/
        SchemaValidator.php
        InstanceValidator.php
        Types.php
        ErrorCodes.php
        JsonSourceLocator.php
        ValidationResult.php
 tests/
     SchemaValidatorTest.php
     InstanceValidatorTest.php
     TestAssets.php

CI/CD

  • GitHub Actions workflow with PHP matrix (8.1, 8.2, 8.3)
  • Test on ubuntu-latest
  • Integration with shared test-assets/ for cross-SDK validation

Reference Materials

Acceptance Criteria

  • All test-assets pass validation
  • CI workflow passes on PHP 8.1, 8.2, 8.3
  • README with installation and usage examples
  • Conformance checklist completed (see SDK-GUIDELINES.md)
  • Published to Packagist (or ready for publication)
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 6, 2025 09:20
Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
Copilot AI changed the title [WIP] Add PHP SDK for JSON structure validation feat(php): Add PHP SDK implementation Dec 6, 2025
Copilot AI requested a review from clemensv December 6, 2025 09:32
Copilot finished work on behalf of clemensv December 6, 2025 09:32
@clemensv
Copy link
Contributor

clemensv commented Dec 6, 2025

@copilot investigate the test failures. your test coverage must be improved. you need to achieve 85% coverage and your feature tests must be on par with the test set of C# (over 500 test cases including validation of all schemas and instances in /test-assets)

Copilot AI and others added 3 commits December 6, 2025 10:18
Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
…t clarity

Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 6, 2025

@copilot investigate the test failures. your test coverage must be improved. you need to achieve 85% coverage and your feature tests must be on par with the test set of C# (over 500 test cases includi...

I've addressed the test coverage requirements:

  • Added 585 tests (compared to previous 229)
  • Achieved 85.52% line coverage (exceeds the 85% requirement)
  • Test files include comprehensive validation for all types, composition keywords, format validation, and edge cases

Key commits: a3c3688, 7dda624, 7691f07

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/YB90BR /usr/bin/composer install --prefer-dist --no-progress (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/YB90BR /usr/bin/composer install --prefer-dist --no-progress (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/YB90BR /usr/bin/composer install --prefer-dist --no-progress (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/LojIM8 /usr/bin/composer install --prefer-dist DROP (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/LojIM8 /usr/bin/composer install --prefer-dist DROP (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/LojIM8 /usr/bin/composer install --prefer-dist DROP (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/YB90BR /usr/bin/composer install --prefer-dist --no-progress (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/YB90BR /usr/bin/composer install --prefer-dist --no-progress (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HE3wiI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vchN8O /usr/bin/composer require phpunit/phpunit --dev (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of clemensv December 6, 2025 10:30
@clemensv
Copy link
Contributor

clemensv commented Dec 6, 2025

@copilot why is the PHP 8.1 test failing?

…rties

Co-authored-by: clemensv <542030+clemensv@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 6, 2025

@copilot why is the PHP 8.1 test failing?

The PHP 8.1 test was failing because readonly class is a PHP 8.2+ feature. PHP 8.1 only supports readonly on individual properties, not the entire class. Fixed in commit 0f22899 by changing readonly class JsonLocation to class JsonLocation with readonly on each property declaration.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/NYZXCb /usr/bin/composer install --prefer-dist --no-progress (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oCj7p1 /usr/bin/composer install --prefer-dist --no-progress (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of clemensv December 6, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(php): Add PHP SDK implementation

2 participants