Skip to content
Merged
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
18 changes: 0 additions & 18 deletions .codeclimate.yml

This file was deleted.

34 changes: 21 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

strategy:
matrix:
php: ['8.0', '8.1', '8.3', '8.4', '8.5']
Expand All @@ -21,33 +25,37 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, json
extensions: mbstring
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}

- name: Install dependencies
run: composer update --no-interaction

# Run tests WITHOUT coverage on non-coverage matrix jobs
- name: Execute tests
if: ${{ ! matrix.coverage }}
run: |
./vendor/bin/phpunit --testdox
if: ${{ !matrix.coverage }}
run: ./vendor/bin/phpunit --testdox

- name: Upload the reports to codeclimate
# Run tests WITH Clover coverage for the coverage job
- name: Execute tests with coverage (Clover)
if: ${{ matrix.coverage }}
env:
XDEBUG_MODE: coverage
CC_TEST_REPORTER_ID: 5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1
uses: paambaati/codeclimate-action@v9
run: ./vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --testdox

- name: Upload coverage to Qlty
if: ${{ matrix.coverage }}
uses: qltysh/qlty-action/coverage@v2
with:
coverageCommand: |
./vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --testdox
oidc: true
files: build/logs/clover.xml

- name: Upload the reports to coveralls.io
if: ${{ matrix.coverage }}
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ env.COVERALLS_REPO_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
file: build/logs/clover.xml
format: clover
flag-name: Unit
allow-empty: false
allow-empty: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Latest Version](https://img.shields.io/packagist/v/wol-soft/php-json-schema-model-generator.svg)](https://packagist.org/packages/wol-soft/php-json-schema-model-generator)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.0-8892BF.svg)](https://php.net/)
[![Maintainability](https://api.codeclimate.com/v1/badges/7eb29e7366dc3d6a5f44/maintainability)](https://codeclimate.com/github/wol-soft/php-json-schema-model-generator/maintainability)
[![Maintainability](https://qlty.sh/gh/wol-soft/projects/php-json-schema-model-generator/maintainability.svg)](https://qlty.sh/gh/wol-soft/projects/php-json-schema-model-generator)
[![Build Status](https://github.com/wol-soft/php-json-schema-model-generator/actions/workflows/main.yml/badge.svg)](https://github.com/wol-soft/php-json-schema-model-generator/actions/workflows/main.yml)
[![Coverage Status](https://coveralls.io/repos/github/wol-soft/php-json-schema-model-generator/badge.svg?branch=master)](https://coveralls.io/github/wol-soft/php-json-schema-model-generator?branch=master)
[![MIT License](https://img.shields.io/packagist/l/wol-soft/php-json-schema-model-generator.svg)](https://github.com/wol-soft/php-json-schema-model-generator/blob/master/LICENSE)
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
],
"require": {
"symfony/polyfill-php81": "^1.28",
"wol-soft/php-json-schema-model-generator-production": "^0.19.0",
"wol-soft/php-micro-template": "^1.9.0",
"wol-soft/php-json-schema-model-generator-production": "dev-BuilderClassPostProcessor",
"wol-soft/php-micro-template": "^1.10.0",

"php": ">=8.0",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/combinedSchemas/allOf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Generated interface:

.. code-block:: php

public function setExample(float $example): self;
public function setExample(float $example): static;
public function getExample(): float;


Expand Down
2 changes: 1 addition & 1 deletion docs/source/combinedSchemas/anyOf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Generated interface:

.. code-block:: php

public function setExample(float $example): self;
public function setExample(float $example): static;
public function getExample(): float;


Expand Down
6 changes: 3 additions & 3 deletions docs/source/combinedSchemas/if.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Generated interface:

.. code-block:: php

public function setExample(float $example): self;
public function setExample(float $example): static;
public function getExample(): ?float;

Possible exception (in this case 50 was provided so the if condition succeeds but the then branch failed):
Expand Down Expand Up @@ -112,8 +112,8 @@ Generated interface:

.. code-block:: php

public function setCountry(string $country): self;
public function setCountry(string $country): static;
public function getCountry(): ?string;

public function setPostalCode(string $country): self;
public function setPostalCode(string $country): static;
public function getPostalCode(): ?string;
10 changes: 5 additions & 5 deletions docs/source/combinedSchemas/mergedProperty.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ Generated interface:
.. code-block:: php

# class Company
public function setCeo(?Company_Merged_CEO $example): self;
public function setCeo(Company_Merged_CEO $example): static;
public function getCeo(): ?Company_Merged_CEO;

# class Company_Merged_CEO
public function getName(): ?string
public function setName(?string $name): self
public function setName(string $name): static
public function getAge(): ?int
public function setAge(?int $name): self
public function setAge(int $name): static

If your composition is defined on object level the object will gain access to all properties of the combined schemas:

Expand Down Expand Up @@ -99,6 +99,6 @@ This schema will generate three classes as no merged property is created. The ma

# class CEO
public function getName(): ?string
public function setName(?string $name): self
public function setName(string $name): static
public function getAge(): ?int
public function setAge(?int $name): self
public function setAge(int $name): static
2 changes: 1 addition & 1 deletion docs/source/combinedSchemas/not.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Generated interface:

.. code-block:: php

public function setExample($example): self;
public function setExample($example): static;
public function getExample();


Expand Down
2 changes: 1 addition & 1 deletion docs/source/combinedSchemas/oneOf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Generated interface:

.. code-block:: php

public function setExample(float $example): self;
public function setExample(float $example): static;
public function getExample(): float;


Expand Down
8 changes: 4 additions & 4 deletions docs/source/complexTypes/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Generated interface:

.. code-block:: php

public function setExample(array $example): self;
public function setExample(array $example): static;
// As the property is not required it may be initialized with null. Consequently the return value is nullable
public function getExample(): ?array;

Expand Down Expand Up @@ -118,14 +118,14 @@ In this case the model generator will generate two classes: **Family** and **Mem
.. code-block:: php

// class Family
public function setMembers(array $members): self;
public function setMembers(array $members): static;
public function getMembers(): ?array;

// class Member
public function setName(string $name): self;
public function setName(string $name): static;
public function getName(): string;

public function setAge(int $age): self;
public function setAge(int $age): static;
public function getAge(): ?int;

The *getMembers* function of the class *Family* is type hinted with *@returns Member[]*. Consequently auto completion is available when developing something like:
Expand Down
6 changes: 3 additions & 3 deletions docs/source/complexTypes/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Enums can be used to define a set of constant values a property must accept.

.. hint::

If you define constraints via `enum` you may want to use the `EnumPostProcessor <../generator/postProcessor.html#enumpostprocessor>`__ to generate PHP enums.
If you define constraints via `enum` you may want to use the `EnumPostProcessor <../generator/builtin/enumPostProcessor.html>`__ to generate PHP enums.

.. code-block:: json

Expand All @@ -24,7 +24,7 @@ Generated interface:

.. code-block:: php

public function setExample(?string $example): self;
public function setExample(string $example): static;
public function getExample(): ?string;

Possible exceptions:
Expand Down Expand Up @@ -53,7 +53,7 @@ Generated interface (no typehints are generated as it's a mixed untyped enum. If

.. code-block:: php

public function setExample($example): self;
public function setExample($example): static;
public function getExample();

Possible exceptions:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/complexTypes/multiType.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Generated interface (doesn't contain type hints as multiple types are allowed):
.. code-block:: php

// $example will be type-annotated with `float|string`
public function setExample($example): self;
public function setExample($example): static;
// $example will be type-annotated with `float|string|null` (as the property isn't required)
public function getExample();

Expand Down Expand Up @@ -62,7 +62,7 @@ For each type given in the allowed types array additional validators may be adde
}
}

The property example will be type hinted with `float|string|string[]|null`.
The property example will be type hinted with `float|string|string[]`.
The validators are applied if the given input matches the corresponding type.
For example if an array **["Hello", 123, "Goodbye"]** is given the validation will fail as numbers aren't allowed in arrays:

Expand Down
30 changes: 15 additions & 15 deletions docs/source/complexTypes/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ Generated interface:
.. code-block:: php

// class Person
public function setName(string $name): self;
public function setName(string $name): static;
// As the property is not required it may be initialized with null. Consequently the return value is nullable
public function getName(): ?string;
public function setCar(Car $name): self;
public function setCar(Car $name): static;
public function getCar(): ?Car;

// class Car
public function setModel(string $name): self;
public function setModel(string $name): static;
public function getModel(): ?string;
public function setPs(int $name): self;
public function setPs(int $name): static;
public function getPs(): ?int;

Possible exceptions:
Expand Down Expand Up @@ -123,9 +123,9 @@ Generated interface:

.. code-block:: php

public function setUnderscorePropertyMinus(string $name): self;
public function setUnderscorePropertyMinus(string $name): static;
public function getUnderscorePropertyMinus(): ?string;
public function setCapsAndSpace100(string $name): self;
public function setCapsAndSpace100(string $name): static;
public function getCapsAndSpace100(): ?string;

If the name normalization results in an empty attribute name (eg. '__ -- __') an exception will be thrown.
Expand Down Expand Up @@ -162,7 +162,7 @@ Possible exceptions:

Properties defined in the `required` array but not defined in the `properties` will be added to the interface of the generated class.

A schema defining only the required property `example` consequently will provide the methods `getExample(): mixed` and `setExample(mixed $value): self`.
A schema defining only the required property `example` consequently will provide the methods `getExample(): mixed` and `setExample(mixed $value): static`.

Size
----
Expand Down Expand Up @@ -208,7 +208,7 @@ Using the keyword `additionalProperties` the object can be limited to not contai

.. hint::

If you define constraints via `additionalProperties` you may want to use the `AdditionalPropertiesAccessorPostProcessor <../generator/postProcessor.html#additionalpropertiesaccessorpostprocessor>`__ to access and modify your additional properties.
If you define constraints via `additionalProperties` you may want to use the `AdditionalPropertiesAccessorPostProcessor <../generator/builtin/additionalPropertiesAccessorPostProcessor.html>`__ to access and modify your additional properties.

.. code-block:: json

Expand Down Expand Up @@ -315,13 +315,13 @@ Generated interface:
.. code-block:: php

// class Family, arrays type hinted in docblocks with Family_Person[]
public function setMembers(array $members): self;
public function setMembers(array $members): static;
public function getMembers(): ?array;

// class Person, arrays type hinted in docblocks with Family_Person[]
public function setName(string $name): self;
public function setName(string $name): static;
public function getName(): ?string;
public function setChildren(array $name): self;
public function setChildren(array $name): static;
public function getChildren(): ?array;

Property Names
Expand Down Expand Up @@ -479,14 +479,14 @@ Generated interface:

// class CreditCardOwner
// base properties
public function setCreditCard(int $creditCard): self;
public function setCreditCard(int $creditCard): static;
public function getCreditCard(): ?int;

// inherited properties
// the inherited properties will not be type hinted as they may contain any value if credit_card isn't present.
public function setBillingAddress($billingAddress): self;
public function setBillingAddress($billingAddress): static;
public function getBillingAddress();
public function setDateOfBirth($dateOfBirth): self;
public function setDateOfBirth($dateOfBirth): static;
public function getDateOfBirth();

.. hint::
Expand Down Expand Up @@ -520,7 +520,7 @@ Using the keyword `patternProperties` further restrictions for properties matchi

.. hint::

If you define constraints via `patternProperties` you may want to use the `PatternPropertiesAccessorPostProcessor <../generator/postProcessor.html#patternpropertiesaccessorpostprocessor>`__ to access your pattern properties.
If you define constraints via `patternProperties` you may want to use the `PatternPropertiesAccessorPostProcessor <../generator/builtin/patternPropertiesAccessorPostProcessor.html>`__ to access your pattern properties.

.. code-block:: json

Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
# -- Project information -----------------------------------------------------

project = u'php-json-schema-model-generator'
copyright = u'2023, Enno Woortmann'
copyright = u'2025, Enno Woortmann'
author = u'Enno Woortmann'

# The short X.Y version
version = u'0.24'
version = u'0.26'
# The full version, including alpha/beta/rc tags
release = u'0.24.0'
release = u'0.26.0'


# -- General configuration ---------------------------------------------------
Expand Down
Loading