diff --git a/.gitattributes b/.gitattributes
index 6c24c19c..6a9d2280 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -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
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..77a41d26
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
+version: 2
+updates:
+ - package-ecosystem: composer
+ directory: /
+ schedule:
+ interval: weekly
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml
index 28818d8c..ba64aeff 100644
--- a/.github/workflows/code-style.yml
+++ b/.github/workflows/code-style.yml
@@ -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
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 2c82f288..8a238bc4 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -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
@@ -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 }}"
@@ -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
diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml
index 20c54421..73fc61ae 100644
--- a/.github/workflows/phpstan.yml
+++ b/.github/workflows/phpstan.yml
@@ -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
diff --git a/.gitignore b/.gitignore
index 677fbc19..f2ff2476 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php
similarity index 92%
rename from .php_cs.dist
rename to .php-cs-fixer.dist.php
index 704f437b..7e769b35 100644
--- a/.php_cs.dist
+++ b/.php-cs-fixer.dist.php
@@ -1,6 +1,6 @@
setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
@@ -14,4 +14,3 @@
]
])
;
-
diff --git a/Makefile b/Makefile
index 197a87fd..6295bbaf 100755
--- a/Makefile
+++ b/Makefile
@@ -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
@@ -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
@@ -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
@@ -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
diff --git a/README.md b/README.md
index 280a0f9d..8593b9b3 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -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
...
diff --git a/composer.json b/composer.json
index ca863c40..45a65ab3 100755
--- a/composer.json
+++ b/composer.json
@@ -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"
diff --git a/docker-compose.yml b/docker-compose.yml
index 92b101f5..cab97990 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,4 +1,3 @@
-version: "3"
services:
php:
build:
@@ -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"
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
new file mode 100644
index 00000000..4d738c9b
--- /dev/null
+++ b/phpstan.neon.dist
@@ -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
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 484250ce..5ee25ac4 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,30 +1,18 @@
-
-
- ./tests
-
-
-
-
- ./src
-
-
-
-
- ./src
-
-
- ./vendor
- ./tests
-
-
+ colors="true"
+ stopOnFailure="false">
+
+
+ ./tests
+
+
+
+
+ ./src
+
+
diff --git a/phpunit11.xml.dist b/phpunit11.xml.dist
deleted file mode 100644
index 972a3f32..00000000
--- a/phpunit11.xml.dist
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- ./tests
-
-
-
-
- ./src
-
-
- ./vendor
- ./tests
-
-
-
diff --git a/src/ReferenceContext.php b/src/ReferenceContext.php
index 712538d6..9b993d1c 100644
--- a/src/ReferenceContext.php
+++ b/src/ReferenceContext.php
@@ -163,9 +163,9 @@ private function reduceDots($path)
*/
private function dirname($path)
{
- $pos = mb_strrpos(str_replace('\\', '/', $path), '/');
+ $pos = strrpos(str_replace('\\', '/', $path), '/');
if ($pos !== false) {
- return mb_substr($path, 0, $pos);
+ return substr($path, 0, $pos);
}
return '';
}
diff --git a/src/json/JsonPointer.php b/src/json/JsonPointer.php
index 0e1f75e4..e5ac5fab 100644
--- a/src/json/JsonPointer.php
+++ b/src/json/JsonPointer.php
@@ -107,11 +107,11 @@ public function evaluate($jsonDocument)
foreach ($this->getPath() as $part) {
if (is_array($currentReference)) {
-// if (!preg_match('~^([1-9]*[0-9]|-)$~', $part)) {
-// throw new NonexistentJsonPointerReferenceException(
-// "Failed to evaluate pointer '$this->_pointer'. Invalid pointer path '$part' for Array at path '$currentPath'."
-// );
-// }
+ //if (!preg_match('~^([1-9]*[0-9]|-)$~', $part)) {
+ // throw new NonexistentJsonPointerReferenceException(
+ // "Failed to evaluate pointer '$this->_pointer'. Invalid pointer path '$part' for Array at path '$currentPath'."
+ // );
+ //}
if ($part === '-' || !array_key_exists($part, $currentReference)) {
throw new NonexistentJsonPointerReferenceException(
"Failed to evaluate pointer '$this->_pointer'. Array has no member $part at path '$currentPath'."
diff --git a/tests/ReaderTest.php b/tests/ReaderTest.php
index 927ec9b6..e6bcf89a 100644
--- a/tests/ReaderTest.php
+++ b/tests/ReaderTest.php
@@ -99,11 +99,7 @@ public function testSymfonyYamlBugHunt()
$inlineYamlExample = $openapi->paths['/']->get->responses['200']->content['application/json']->example;
- if (method_exists($this, 'assertIsArray')) {
- $this->assertIsArray($inlineYamlExample);
- } else {
- $this->assertInternalType('array', $inlineYamlExample);
- }
+ $this->assertIsArray($inlineYamlExample);
$expectedArray = json_decode(<< /etc/dpkg/dpkg.cfg.d/02apt-speedup && \
echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache
RUN apt-get update && \
- apt-get -y install \
- gnupg2 && \
- apt-key update && \
- apt-get update && \
apt-get install -y --no-install-recommends \
libzip-dev \
- libonig-dev \
vim \
git \
- unzip\
- libxml2-dev \
- curl \
- libcurl4-openssl-dev \
- libssl-dev \
- --no-install-recommends && \
- apt-get clean && \
- rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
- && pecl install xdebug-3.1.5 \
- && docker-php-ext-enable xdebug \
- && docker-php-ext-install \
- zip \
- curl \
- mbstring
+ unzip \
+ curl && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
+ pecl install xdebug && \
+ docker-php-ext-enable xdebug && \
+ docker-php-ext-install zip
# Install composer
ENV COMPOSER_ALLOW_SUPERUSER=1 \
diff --git a/tests/json/JsonPointerTest.php b/tests/json/JsonPointerTest.php
index af54ffcb..c63a05f6 100644
--- a/tests/json/JsonPointerTest.php
+++ b/tests/json/JsonPointerTest.php
@@ -2,6 +2,7 @@
use cebe\openapi\json\JsonPointer;
use cebe\openapi\json\JsonReference;
+use PHPUnit\Framework\Attributes\DataProvider;
class JsonPointerTest extends \PHPUnit\Framework\TestCase
{
@@ -22,17 +23,13 @@ public static function encodeDecodeData()
];
}
- /**
- * @dataProvider encodeDecodeData
- */
+ #[DataProvider('encodeDecodeData')]
public function testEncode($encoded, $decoded)
{
$this->assertEquals($encoded, JsonPointer::encode($decoded));
}
- /**
- * @dataProvider encodeDecodeData
- */
+ #[DataProvider('encodeDecodeData')]
public function testDecode($encoded, $decoded)
{
$this->assertEquals($decoded, JsonPointer::decode($encoded));
@@ -80,7 +77,6 @@ public static function rfcExamples()
["/m~0n" , "#/m~0n" , 8],
];
foreach ($return as $example) {
- $example[3] = self::rfcJsonDocument();
yield $example;
}
}
@@ -89,12 +85,10 @@ public static function allExamples()
{
yield from self::rfcExamples();
- yield ["/a#b" , "#/a%23b" , 16, '{"a#b": 16}'];
+ yield ["/a#b" , "#/a%23b" , 16];
}
- /**
- * @dataProvider allExamples
- */
+ #[DataProvider('allExamples')]
public function testUriEncoding($jsonPointer, $uriJsonPointer, $expectedEvaluation)
{
$pointer = new JsonPointer($jsonPointer);
@@ -112,9 +106,7 @@ public function testUriEncoding($jsonPointer, $uriJsonPointer, $expectedEvaluati
$this->assertSame("somefile.json$uriJsonPointer", $reference->getReference());
}
- /**
- * @dataProvider rfcExamples
- */
+ #[DataProvider('rfcExamples')]
public function testEvaluation($jsonPointer, $uriJsonPointer, $expectedEvaluation)
{
$document = json_decode(self::rfcJsonDocument());
diff --git a/tests/spec/CallbackTest.php b/tests/spec/CallbackTest.php
index 1f466bde..ded33b23 100644
--- a/tests/spec/CallbackTest.php
+++ b/tests/spec/CallbackTest.php
@@ -2,10 +2,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Callback;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Callback
- */
+#[CoversClass(\cebe\openapi\spec\Callback::class)]
class CallbackTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/ComponentsTest.php b/tests/spec/ComponentsTest.php
index 6418c340..f664d67b 100644
--- a/tests/spec/ComponentsTest.php
+++ b/tests/spec/ComponentsTest.php
@@ -2,10 +2,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Components;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Components
- */
+#[CoversClass(\cebe\openapi\spec\Components::class)]
class ComponentsTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/HeaderTest.php b/tests/spec/HeaderTest.php
index eeced273..7ceada8d 100644
--- a/tests/spec/HeaderTest.php
+++ b/tests/spec/HeaderTest.php
@@ -2,10 +2,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Header;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Header
- */
+#[CoversClass(\cebe\openapi\spec\Header::class)]
class HeaderTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/InfoTest.php b/tests/spec/InfoTest.php
index 932e5e0a..e185155d 100644
--- a/tests/spec/InfoTest.php
+++ b/tests/spec/InfoTest.php
@@ -4,12 +4,11 @@
use cebe\openapi\spec\Contact;
use cebe\openapi\spec\Info;
use cebe\openapi\spec\License;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Info
- * @covers \cebe\openapi\spec\Contact
- * @covers \cebe\openapi\spec\License
- */
+#[CoversClass(\cebe\openapi\spec\Info::class)]
+#[CoversClass(\cebe\openapi\spec\Contact::class)]
+#[CoversClass(\cebe\openapi\spec\License::class)]
class InfoTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/LinkTest.php b/tests/spec/LinkTest.php
index ea373b69..df270704 100644
--- a/tests/spec/LinkTest.php
+++ b/tests/spec/LinkTest.php
@@ -2,10 +2,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Link;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Link
- */
+#[CoversClass(\cebe\openapi\spec\Link::class)]
class LinkTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/MediaTypeTest.php b/tests/spec/MediaTypeTest.php
index 65b3e755..230cb456 100644
--- a/tests/spec/MediaTypeTest.php
+++ b/tests/spec/MediaTypeTest.php
@@ -6,11 +6,11 @@
use cebe\openapi\spec\OpenApi;
use cebe\openapi\spec\Reference;
use Symfony\Component\Yaml\Yaml;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
-/**
- * @covers \cebe\openapi\spec\MediaType
- * @covers \cebe\openapi\spec\Example
- */
+#[CoversClass(\cebe\openapi\spec\MediaType::class)]
+#[CoversClass(\cebe\openapi\spec\Example::class)]
class MediaTypeTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
@@ -47,11 +47,7 @@ public function testRead()
$this->assertInstanceOf(Reference::class, $mediaType->schema);
- if (method_exists($this, 'assertIsArray')) {
- $this->assertIsArray($mediaType->examples);
- } else {
- $this->assertInternalType('array', $mediaType->examples);
- }
+ $this->assertIsArray($mediaType->examples);
$this->assertCount(3, $mediaType->examples);
$this->assertArrayHasKey('cat', $mediaType->examples);
@@ -112,9 +108,7 @@ public static function badEncodingProvider()
// The last one can be supported in future, but now SpecBaseObjects::__construct() requires array explicitly
}
- /**
- * @dataProvider badEncodingProvider
- */
+ #[DataProvider('badEncodingProvider')]
public function testPathsCanNotBeCreatedFromBullshit($config, $expectedException)
{
$this->expectException(\cebe\openapi\exceptions\TypeErrorException::class);
diff --git a/tests/spec/OpenApiTest.php b/tests/spec/OpenApiTest.php
index 36a9046d..3b0338c5 100755
--- a/tests/spec/OpenApiTest.php
+++ b/tests/spec/OpenApiTest.php
@@ -3,10 +3,10 @@
use cebe\openapi\spec\OpenApi;
use cebe\openapi\Reader;
use Symfony\Component\Yaml\Yaml;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
-/**
- * @covers \cebe\openapi\spec\OpenApi
- */
+#[CoversClass(\cebe\openapi\spec\OpenApi::class)]
class OpenApiTest extends \PHPUnit\Framework\TestCase
{
public function testEmpty()
@@ -53,11 +53,7 @@ public function testReadPetStore()
// servers
- if (method_exists($this, 'assertIsArray')) {
- $this->assertIsArray($openapi->servers);
- } else {
- $this->assertInternalType('array', $openapi->servers);
- }
+ $this->assertIsArray($openapi->servers);
$this->assertCount(1, $openapi->servers);
foreach ($openapi->servers as $server) {
@@ -192,9 +188,7 @@ public static function specProvider()
}
}
- /**
- * @dataProvider specProvider
- */
+ #[DataProvider('specProvider')]
public function testSpecs($openApiFile)
{
if (strtolower(substr($openApiFile, -5, 5)) === '.json') {
diff --git a/tests/spec/OperationTest.php b/tests/spec/OperationTest.php
index 6e30566f..b918cee0 100644
--- a/tests/spec/OperationTest.php
+++ b/tests/spec/OperationTest.php
@@ -3,11 +3,10 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Operation;
use cebe\openapi\spec\ExternalDocumentation;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Operation
- * @covers \cebe\openapi\spec\ExternalDocumentation
- */
+#[CoversClass(\cebe\openapi\spec\Operation::class)]
+#[CoversClass(\cebe\openapi\spec\ExternalDocumentation::class)]
class OperationTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/ParameterTest.php b/tests/spec/ParameterTest.php
index 14557f8c..ed6c9366 100644
--- a/tests/spec/ParameterTest.php
+++ b/tests/spec/ParameterTest.php
@@ -2,10 +2,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Parameter;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Parameter
- */
+#[CoversClass(\cebe\openapi\spec\Parameter::class)]
class ParameterTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php
index b901aa71..0d857a87 100644
--- a/tests/spec/PathTest.php
+++ b/tests/spec/PathTest.php
@@ -7,11 +7,11 @@
use cebe\openapi\spec\Reference;
use cebe\openapi\spec\Response;
use cebe\openapi\spec\Responses;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
-/**
- * @covers \cebe\openapi\spec\Paths
- * @covers \cebe\openapi\spec\PathItem
- */
+#[CoversClass(\cebe\openapi\spec\Paths::class)]
+#[CoversClass(\cebe\openapi\spec\PathItem::class)]
class PathTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
@@ -97,9 +97,7 @@ public static function badPathsConfigProvider()
// The last one can be supported in future, but now SpecBaseObjects::__construct() requires array explicitly
}
- /**
- * @dataProvider badPathsConfigProvider
- */
+ #[DataProvider('badPathsConfigProvider')]
public function testPathsCanNotBeCreatedFromBullshit($config, $expectedException)
{
$this->expectException(\cebe\openapi\exceptions\TypeErrorException::class);
diff --git a/tests/spec/ReferenceTest.php b/tests/spec/ReferenceTest.php
index 6ee6c939..44fbfd12 100644
--- a/tests/spec/ReferenceTest.php
+++ b/tests/spec/ReferenceTest.php
@@ -8,10 +8,9 @@
use cebe\openapi\spec\Response;
use cebe\openapi\spec\Schema;
use cebe\openapi\spec\Example;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Reference
- */
+#[CoversClass(\cebe\openapi\spec\Reference::class)]
class ReferenceTest extends \PHPUnit\Framework\TestCase
{
public function testResolveInDocument()
diff --git a/tests/spec/RequestBodyTest.php b/tests/spec/RequestBodyTest.php
index 6e7e12cf..279a9c65 100644
--- a/tests/spec/RequestBodyTest.php
+++ b/tests/spec/RequestBodyTest.php
@@ -4,11 +4,10 @@
use cebe\openapi\spec\MediaType;
use cebe\openapi\spec\RequestBody;
use cebe\openapi\spec\Encoding;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\RequestBody
- * @covers \cebe\openapi\spec\Encoding
- */
+#[CoversClass(\cebe\openapi\spec\RequestBody::class)]
+#[CoversClass(\cebe\openapi\spec\Encoding::class)]
class RequestBodyTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/ResponseTest.php b/tests/spec/ResponseTest.php
index be240bcd..d2009c86 100644
--- a/tests/spec/ResponseTest.php
+++ b/tests/spec/ResponseTest.php
@@ -4,11 +4,11 @@
use cebe\openapi\spec\MediaType;
use cebe\openapi\spec\Response;
use cebe\openapi\spec\Responses;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
-/**
- * @covers \cebe\openapi\spec\Response
- * @covers \cebe\openapi\spec\Responses
- */
+#[CoversClass(\cebe\openapi\spec\Response::class)]
+#[CoversClass(\cebe\openapi\spec\Responses::class)]
class ResponseTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
@@ -183,9 +183,7 @@ public static function badResponseProvider()
// The last one can be supported in future, but now SpecBaseObjects::__construct() requires array explicitly
}
- /**
- * @dataProvider badResponseProvider
- */
+ #[DataProvider('badResponseProvider')]
public function testPathsCanNotBeCreatedFromBullshit($config, $expectedException)
{
$this->expectException(\cebe\openapi\exceptions\TypeErrorException::class);
diff --git a/tests/spec/SchemaTest.php b/tests/spec/SchemaTest.php
index 580dfefc..6825c8d9 100644
--- a/tests/spec/SchemaTest.php
+++ b/tests/spec/SchemaTest.php
@@ -6,11 +6,11 @@
use cebe\openapi\spec\Reference;
use cebe\openapi\spec\Schema;
use cebe\openapi\spec\Type;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
-/**
- * @covers \cebe\openapi\spec\Schema
- * @covers \cebe\openapi\spec\Discriminator
- */
+#[CoversClass(\cebe\openapi\spec\Schema::class)]
+#[CoversClass(\cebe\openapi\spec\Discriminator::class)]
class SchemaTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
@@ -252,9 +252,7 @@ public static function badSchemaProvider()
// The last one can be supported in future, but now SpecBaseObjects::__construct() requires array explicitly
}
- /**
- * @dataProvider badSchemaProvider
- */
+ #[DataProvider('badSchemaProvider')]
public function testPathsCanNotBeCreatedFromBullshit($config, $expectedException)
{
$this->expectException(\cebe\openapi\exceptions\TypeErrorException::class);
diff --git a/tests/spec/SecuritySchemeTest.php b/tests/spec/SecuritySchemeTest.php
index 5e14d5f7..151b602f 100644
--- a/tests/spec/SecuritySchemeTest.php
+++ b/tests/spec/SecuritySchemeTest.php
@@ -5,13 +5,12 @@
use cebe\openapi\spec\OAuthFlows;
use cebe\openapi\spec\SecurityRequirement;
use cebe\openapi\spec\SecurityScheme;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\SecurityScheme
- * @covers \cebe\openapi\spec\OAuthFlows
- * @covers \cebe\openapi\spec\OAuthFlow
- * @covers \cebe\openapi\spec\SecurityRequirement
- */
+#[CoversClass(\cebe\openapi\spec\SecurityScheme::class)]
+#[CoversClass(\cebe\openapi\spec\OAuthFlows::class)]
+#[CoversClass(\cebe\openapi\spec\OAuthFlow::class)]
+#[CoversClass(\cebe\openapi\spec\SecurityRequirement::class)]
class SecuritySchemeTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/ServerTest.php b/tests/spec/ServerTest.php
index ead1dc9d..87c8e195 100644
--- a/tests/spec/ServerTest.php
+++ b/tests/spec/ServerTest.php
@@ -3,11 +3,10 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Server;
use cebe\openapi\spec\ServerVariable;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Server
- * @covers \cebe\openapi\spec\ServerVariable
- */
+#[CoversClass(\cebe\openapi\spec\Server::class)]
+#[CoversClass(\cebe\openapi\spec\ServerVariable::class)]
class ServerTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/TagTest.php b/tests/spec/TagTest.php
index 07bc7594..68cfbb3e 100644
--- a/tests/spec/TagTest.php
+++ b/tests/spec/TagTest.php
@@ -3,10 +3,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\ExternalDocumentation;
use cebe\openapi\spec\Tag;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Tag
- */
+#[CoversClass(\cebe\openapi\spec\Tag::class)]
class TagTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
diff --git a/tests/spec/XmlTest.php b/tests/spec/XmlTest.php
index b24687dd..35f41a78 100644
--- a/tests/spec/XmlTest.php
+++ b/tests/spec/XmlTest.php
@@ -2,10 +2,9 @@
use cebe\openapi\Reader;
use cebe\openapi\spec\Xml;
+use PHPUnit\Framework\Attributes\CoversClass;
-/**
- * @covers \cebe\openapi\spec\Xml
- */
+#[CoversClass(\cebe\openapi\spec\Xml::class)]
class XmlTest extends \PHPUnit\Framework\TestCase
{
public function testRead()