Skip to content

Commit 61416ad

Browse files
authored
Merge pull request #1761 from DerManoMann/v6
2 parents 416875b + c6f5cf0 commit 61416ad

File tree

169 files changed

+1228
-1283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+1228
-1283
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: true
1818
matrix:
1919
operating-system: [ ubuntu-latest ]
20-
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
20+
php: [ '8.2', '8.3', '8.4', '8.5' ]
2121
dependencies: [ 'lowest', 'highest' ]
2222

2323
name: PHP ${{ matrix.php }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies
@@ -38,9 +38,5 @@ jobs:
3838
dependency-versions: ${{ matrix.dependencies }}
3939
composer-options: "${{ matrix.composer-options }}"
4040

41-
- name: Require type-info-extras
42-
if: ${{ matrix.php >= '8.2' }}
43-
run: composer require radebatz/type-info-extras -W
44-
4541
- name: PHPUnit Tests
4642
run: bin/phpunit --configuration phpunit.xml.dist --coverage-text

.github/workflows/security-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: true
1616
matrix:
1717
operating-system: [ ubuntu-latest ]
18-
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
18+
php: [ '8.2', '8.3', '8.4', '8.5' ]
1919
dependencies: [ 'highest' ]
2020

2121
name: PHP ${{ matrix.php }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies

.php-cs-fixer.dist.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
'trim_array_spaces' => true,
6565
'single_space_around_construct' => true,
6666
'single_line_comment_spacing' => true,
67-
'fully_qualified_strict_types' => true,
67+
'fully_qualified_strict_types' => ['import_symbols' => true, 'leading_backslash_in_global_namespace' => true],
6868
'global_namespace_import' => ['import_classes' => false, 'import_constants' => null, 'import_functions' => null],
6969

7070
'nullable_type_declaration_for_default_null_value' => true,
@@ -89,5 +89,7 @@
8989
'phpdoc_no_empty_return' => true,
9090
'phpdoc_no_alias_tag' => true,
9191
'phpdoc_param_order' => true,
92+
93+
'php_unit_attributes' => true,
9294
])
9395
->setFinder($finder);

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Programmatically, the method `Generator::setVersion()` can be used to change the
3030

3131
## Requirements
3232

33-
`swagger-php` requires at least PHP 7.4 for annotations and PHP 8.1 for using attributes.
33+
`swagger-php` requires at least PHP 8.2.
3434

3535
## Installation (with [Composer](https://getcomposer.org))
3636

@@ -75,6 +75,9 @@ composer require doctrine/annotations
7575
Add annotations to your php files.
7676

7777
```php
78+
79+
use OpenApi\Annotations as OA;
80+
7881
/**
7982
* @OA\Info(title="My First API", version="0.1")
8083
*/
@@ -96,7 +99,7 @@ Generate always-up-to-date documentation.
9699
```php
97100
<?php
98101
require("vendor/autoload.php");
99-
$openapi = \OpenApi\Generator::scan(['/path/to/project']);
102+
$openapi = (new \OpenApi\Generator->generate(['/path/to/project']);
100103
header('Content-Type: application/x-yaml');
101104
echo $openapi->toYaml();
102105
```

bin/openapi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use OpenApi\Analysers\DocBlockAnnotationFactory;
66
use OpenApi\Analysers\ReflectionAnalyser;
77
use OpenApi\Annotations\OpenApi;
88
use OpenApi\Generator;
9-
use OpenApi\Util;
9+
use OpenApi\SourceFinder;
1010
use OpenApi\Loggers\ConsoleLogger;
1111

1212
if (class_exists(Generator::class) === false) {
@@ -224,7 +224,7 @@ $openapi = $generator
224224
->setVersion($options['version'])
225225
->setConfig($options['config'])
226226
->setAnalyser($analyser)
227-
->generate(Util::finder($paths, $exclude, $pattern));
227+
->generate(new SourceFinder($paths, $exclude, $pattern));
228228

229229
if ($options['output'] === false) {
230230
if (strtolower($options['format']) === 'json') {

composer.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@
4040
"minimum-stability": "stable",
4141
"extra": {
4242
"branch-alias": {
43-
"dev-master": "5.x-dev"
43+
"dev-master": "6.x-dev"
4444
}
4545
},
4646
"require": {
47-
"php": ">=7.4",
47+
"php": ">=8.2",
4848
"ext-json": "*",
4949
"nikic/php-parser": "^4.19 || ^5.0",
5050
"phpstan/phpdoc-parser": "^2.0",
5151
"psr/log": "^1.1 || ^2.0 || ^3.0",
52+
"radebatz/type-info-extras": "^1.0.2",
5253
"symfony/deprecation-contracts": "^2 || ^3",
5354
"symfony/finder": "^5.0 || ^6.0 || ^7.0",
5455
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
@@ -73,23 +74,21 @@
7374
"doctrine/annotations": "^2.0",
7475
"friendsofphp/php-cs-fixer": "^3.62.0",
7576
"phpstan/phpstan": "^1.6 || ^2.0",
76-
"phpunit/phpunit": "^9.0",
77-
"rector/rector": "^1.0 || ^2.0",
78-
"vimeo/psalm": "^4.30 || ^5.0"
77+
"phpunit/phpunit": "^10.5",
78+
"rector/rector": "^1.0 || ^2.0"
7979
},
8080
"conflict": {
8181
"symfony/process": ">=6, <6.4.14"
8282
},
8383
"suggest": {
84-
"radebatz/type-info-extras": "^1.0.2",
8584
"doctrine/annotations": "^2.0"
8685
},
8786
"scripts-descriptions": {
8887
"cs": "Fix all codestyle issues",
8988
"rector": "Automatic refactoring",
9089
"lint": "Test codestyle",
9190
"test": "Run all PHP, codestyle and rector tests",
92-
"analyse": "Run static analysis (phpstan/psalm)",
91+
"analyse": "Run static analysis (phpstan)",
9392
"spectral-examples": "Run spectral lint over all .yaml files in the docs/examples folder",
9493
"spectral-scratch": "Run spectral lint over all .yaml files in the tests/Fixtures/Scratch folder",
9594
"spectral": "Run all spectral tests",
@@ -112,8 +111,7 @@
112111
"@lint"
113112
],
114113
"analyse": [
115-
"export XDEBUG_MODE=off && phpstan analyse --memory-limit=2G",
116-
"export XDEBUG_MODE=off && psalm --threads=1"
114+
"export XDEBUG_MODE=off && phpstan analyse --memory-limit=3G"
117115
],
118116
"spectral-examples": "for ff in `find docs/examples -name '*.yaml'`; do npm run spectral lint $ff; done",
119117
"spectral-scratch": "for ff in `find tests/Fixtures/Scratch -name '*.yaml'`; do npm run spectral lint $ff; done",

docs/.vitepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function getGuideSidebar() {
2424
{
2525
text: 'Upgrading',
2626
items: [
27+
{ text: 'Migration from 5.x to 6.x', link: '/guide/migrating-to-v6' },
2728
{ text: 'Migration from 4.x to 5.x', link: '/guide/migrating-to-v5' },
2829
{ text: 'Migration from 3.x to 4.x', link: '/guide/migrating-to-v4' },
2930
{ text: 'Migration from 2.x to 3.x', link: '/guide/migrating-to-v3' },

docs/examples/processors/schema-query-parameter/SchemaQueryParameter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class SchemaQueryParameter
2525

2626
public function __invoke(Analysis $analysis): void
2727
{
28-
/** @var Operation[] $operations */
2928
$operations = $analysis->getAnnotationsOfType(Operation::class);
3029

3130
foreach ($operations as $operation) {
@@ -34,7 +33,7 @@ public function __invoke(Analysis $analysis): void
3433
throw new \InvalidArgumentException('Value of `x.' . self::REF . '` must be a string');
3534
}
3635

37-
$schema = $analysis->getSchemaForSource($operation->x[self::REF]);
36+
$schema = $analysis->getAnnotationForSource($operation->x[self::REF]);
3837
if (!$schema instanceof Schema) {
3938
throw new \InvalidArgumentException('Value of `x.' . self::REF . "` contains reference to unknown schema: `{$operation->x[self::REF]}`");
4039
}

docs/examples/specs/api/annotations/ProductController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public function getProduct(?int $product_id)
6868
* @OA\MediaType(
6969
* mediaType="application/json",
7070
* @OA\Schema(
71-
* type="array",
7271
* @OA\Items(ref="#/components/schemas/Product")
7372
* )
7473
* )

docs/examples/specs/api/attributes/ProductController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function getProduct(
4848
content: [new OAT\MediaType(
4949
mediaType: 'application/json',
5050
schema: new OAT\Schema(
51-
type: 'array',
5251
items: new OAT\Items(type: Product::class)
5352
)
5453
)]

0 commit comments

Comments
 (0)