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
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs.dist export-ignore
.php-cs-fixer.dist.php export-ignore
docker-compose.yml export-ignore
Makefile export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
phpunit11.xml.dist export-ignore
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: composer
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
11 changes: 8 additions & 3 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ jobs:
code-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.1
php-version: "8.2"
tools: cs2pr

- name: Install PHP-CS-Fixer
run: make php-cs-fixer.phar

- name: Check code style
run: make check-style
shell: bash
run: make -s check-style CS_ARGS=--format=checkstyle | cs2pr
102 changes: 21 additions & 81 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
pull_request:
branches: [ master ]

env:
# Composer refuses to install versions with security advisories, which includes the old
# symfony/yaml versions still allowed by composer.json. Remove when support for them is dropped.
COMPOSER_NO_BLOCKING: "1"

jobs:
phpunit:
name: Tests
Expand All @@ -19,105 +14,55 @@ jobs:
matrix:
os: [ubuntu-latest]
php:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
dependencies:
- "lowest"
- "highest"
symfony-yaml: ['^3.4', '^4', '^5', '^6', '^7', '^8']
symfony-yaml: ['^6.4', '^7.4', '^8.0']
include:
# composer.bat on Windows drops the caret of a version constraint
- os: "windows-latest"
php: "8.0"
php: "8.5"
dependencies: "highest"
symfony-yaml: '5.4.2'
symfony-yaml: '7.4.*'
- os: "macos-latest"
php: "8.0"
php: "8.5"
dependencies: "highest"
symfony-yaml: '^7.4'
# next PHP version: reports problems early, but does not fail the build
- os: "ubuntu-latest"
php: "8.6"
dependencies: "highest"
symfony-yaml: '^5'
symfony-yaml: '^8.0'
experimental: true
exclude:
# symfony/yaml v5 does not run on PHP 7.1
- php: '7.1'
symfony-yaml: '^5'
# symfony/yaml v6 does not run on PHP 7.*
- php: '7.1'
symfony-yaml: '^6'
- php: '7.2'
symfony-yaml: '^6'
- php: '7.3'
symfony-yaml: '^6'
- php: '7.4'
symfony-yaml: '^6'
# symfony/yaml v7 does not run on PHP 7.*
- php: '7.1'
symfony-yaml: '^7'
- php: '7.2'
symfony-yaml: '^7'
- php: '7.3'
symfony-yaml: '^7'
- php: '7.4'
symfony-yaml: '^7'
# symfony/yaml v7 does not run on PHP 8.0 & 8.1
- php: '8.0'
symfony-yaml: '^7'
- php: '8.1'
symfony-yaml: '^7'
# symfony/yaml v8 does not run on PHP 7.*
- php: '7.1'
symfony-yaml: '^8'
- php: '7.2'
symfony-yaml: '^8'
- php: '7.3'
symfony-yaml: '^8'
- php: '7.4'
symfony-yaml: '^8'
# symfony/yaml v8 does not run on PHP < 8.4
- php: '8.0'
symfony-yaml: '^8'
- php: '8.1'
symfony-yaml: '^8'
- php: '8.2'
symfony-yaml: '^8.0'
- php: '8.3'
symfony-yaml: '^8'
# symfony/yaml v3.4 is not compatible with PHP 8.0 but has no upper-bound, so it installs on it
- php: '8.0'
symfony-yaml: '^3.4'
- php: '8.1'
symfony-yaml: '^3.4'
- php: '8.3'
symfony-yaml: '^3.4'
- php: '8.4'
symfony-yaml: '^3.4'
symfony-yaml: '^8.0'

runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental == true }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
coverage: none
tools: composer:v2

- name: Require specific symfony/yaml version
run: "composer require symfony/yaml:'${{ matrix.symfony-yaml }}' --no-interaction --ansi --no-install"

- name: Require newer phpunit/phpunit version
run: "composer require phpunit/phpunit '^9.5' --dev --no-interaction --ansi --no-install"
if: matrix.php == '8.1'

- name: Require newer phpunit/phpunit version
run: "composer require phpunit/phpunit '^11.4' --dev --no-interaction --ansi --no-install"
if: matrix.php >= '8.3'

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v4"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand All @@ -126,11 +71,6 @@ jobs:

- name: PHPUnit tests
run: make test
if: matrix.php < '8.3'

- name: PHPUnit tests
run: make test-debug
if: matrix.php >= '8.3'

- name: Code coverage
run: make coverage
6 changes: 3 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.1"
php-version: "8.2"
tools: composer:v2

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v4"

- name: PHPStan analysis
run: make stan
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/composer.lock
/composer.phar

/.php_cs.cache
/.phpunit.result.cache
/.php-cs-fixer.cache
/.phpunit.cache
/.idea
xdebug_remote.log
php-cs-fixer.phar
3 changes: 1 addition & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
Expand All @@ -14,4 +14,3 @@
]
])
;

24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ XDEBUG=0
PHPARGS=-dmemory_limit=512M
XPHPARGS=
ifeq ($(XDEBUG),1)
XPHPARGS=-dzend_extension=xdebug.so -dxdebug.remote_enable=1 -dxdebug.remote_autostart=1
XPHPARGS=-dzend_extension=xdebug.so -dxdebug.mode=debug -dxdebug.start_with_request=yes
endif

# Run make with IN_DOCKER=1 to run php commands in a docker container
DOCKER_PHP=
IN_DOCKER=0
CS_ARGS=
PHP_CS_FIXER_VERSION=v3.95.28
PHP_CS_FIXER_SHA256=44dd8aa9b83163b4913bc39d3e26ba94221ffa03957d000e9aec252f656b0f60
ifeq ($(IN_DOCKER),1)
DOCKER_PHP=docker compose run --rm php
endif
Expand All @@ -28,11 +31,11 @@ all:


check-style: php-cs-fixer.phar
PHP_CS_FIXER_IGNORE_ENV=1 ./php-cs-fixer.phar fix src/ --diff --dry-run
PHP_CS_FIXER_IGNORE_ENV=1 ./php-cs-fixer.phar fix src/ --diff --dry-run $(CS_ARGS)

fix-style: php-cs-fixer.phar
$(DOCKER_PHP) vendor/bin/indent --tabs composer.json
$(DOCKER_PHP) vendor/bin/indent --spaces .php_cs.dist
$(DOCKER_PHP) vendor/bin/indent --spaces .php-cs-fixer.dist.php
$(DOCKER_PHP) ./php-cs-fixer.phar fix src/ --diff

install: composer.lock
Expand All @@ -41,12 +44,12 @@ install: composer.lock
test: unit test-recursion.json test-recursion2.yaml test-recursion3_index.yaml test-empty-maps.json test-const.json

unit:
$(DOCKER_PHP) php $(PHPARGS) $(XPHPARGS) vendor/bin/phpunit --verbose --colors=always $(TESTCASE)
$(DOCKER_PHP) php $(PHPARGS) $(XPHPARGS) vendor/bin/phpunit --colors=always $(TESTCASE)

test-debug: unit-debug test-recursion.json test-recursion2.yaml test-recursion3_index.yaml test-empty-maps.json test-const.json

unit-debug:
$(DOCKER_PHP) php $(PHPARGS) $(XPHPARGS) vendor/bin/phpunit --debug --testdox --colors=always -c phpunit11.xml.dist $(TESTCASE)
$(DOCKER_PHP) php $(PHPARGS) $(XPHPARGS) vendor/bin/phpunit --debug --testdox --colors=always $(TESTCASE)

# test specific JSON files in tests/spec/data/
# e.g. test-recursion will run validation on tests/spec/data/recursion.json
Expand All @@ -64,16 +67,19 @@ stan:
$(DOCKER_PHP) php $(PHPARGS) vendor/bin/phpstan analyse -l 5 src

php-cs-fixer.phar:
wget -q https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.7/php-cs-fixer.phar && chmod +x php-cs-fixer.phar
wget -q https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/$(PHP_CS_FIXER_VERSION)/php-cs-fixer.phar -O $@.tmp
echo "$(PHP_CS_FIXER_SHA256) $@.tmp" | sha256sum -c -
mv $@.tmp $@
chmod +x $@

# find spec classes that are not mentioned in tests with @covers yet
# find spec classes that are not mentioned in tests with #[CoversClass] yet
coverage: .php-openapi-covA .php-openapi-covB
diff $^
.INTERMEDIATE: .php-openapi-covA .php-openapi-covB
.php-openapi-covA:
grep -rhPo '@covers .+' tests |cut -c 28- |sort > $@
grep -rhoE 'CoversClass\([^)]+::class' tests | sed -E 's/.*[\]([A-Za-z]+)::class/\1/' | sort > $@
.php-openapi-covB:
grep -rhPo '^class \w+' src/spec/ | awk '{print $$2}' |grep -v '^Type$$' | sort > $@
grep -rhoE '^class [A-Za-z0-9_]+' src/spec/ | awk '{print $$2}' |grep -v '^Type$$' | sort > $@

.PHONY: all check-style fix-style install test lint coverage

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Supported OpenAPI versions:

## Requirements

- PHP 7.1 or higher (works fine with PHP 8)
- PHP 8.2 or higher

## Used by

Expand Down Expand Up @@ -267,7 +267,7 @@ $errors = $openapi->getErrors();

You may use the docker environment for local development:

docker-compose build
docker compose build
make IN_DOCKER=1 install
make IN_DOCKER=1 test
...
Expand Down
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,20 @@
"source": "https://github.com/DEVizzent/cebe-php-openapi"
},
"require": {
"php": ">=7.1.0",
"php": "^8.2",
"ext-json": "*",
"symfony/yaml": "^3.4 || ^4 || ^5 || ^6 || ^7 || ^8",
"justinrainbow/json-schema": "^5.2 || ^6.0"
"symfony/yaml": "^6.4 || ^7.4 || ^8.0",
"justinrainbow/json-schema": "^6.0"
},
"require-dev": {
"cebe/indent": "*",
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4 || ^11.4",
"phpunit/phpunit": "^11.5 || ^12.0 || ^13.0",

"oai/openapi-specification-3.0": "3.0.3",

"mermade/openapi3-examples": "1.0.0",
"apis-guru/openapi-directory": "1.0.0",
"phpstan/phpstan": "^0.12.0"
},
"conflict": {
"symfony/yaml": "3.4.0 - 3.4.4 || 4.0.0 - 4.4.17 || 5.0.0 - 5.1.9 || 5.2.0"
"phpstan/phpstan": "^2.0"
},
"replace": {
"cebe/php-openapi":"1.7.0"
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
php:
build:
Expand All @@ -14,7 +13,7 @@ services:
- TIMEZONE=UTC
- IN_DOCKER=docker
- PHP_XDEBUG_ENABLED=1
- XDEBUG_CONFIG="remote_host=host.docker.internal"
- XDEBUG_CONFIG="client_host=host.docker.internal"
- PHP_IDE_CONFIG="serverName=Docker"
extra_hosts:
- "host.docker.internal:host-gateway"
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
# Spec data comes from YAML and JSON at runtime, so PHPDoc types are not guaranteed
# and the runtime checks based on them must stay.
treatPhpDocTypesAsCertain: false
Loading
Loading