Skip to content

Commit 393bb25

Browse files
authored
Merge pull request #102 from DoclerLabs/generator-php-8
generator php 8
2 parents 75e15df + ef9fdca commit 393bb25

File tree

186 files changed

+3849
-2281
lines changed

Some content is hidden

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

186 files changed

+3849
-2281
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
tests:
99
runs-on: ubuntu-latest
1010

11-
name: Tests on PHP 7.4
11+
name: Tests on PHP 8.2
1212

1313
steps:
1414
- name: Checkout code
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup PHP
1818
uses: shivammathur/setup-php@v2
1919
with:
20-
php-version: 7.4
20+
php-version: 8.2
2121
tools: composer:v2
2222
coverage: pcov
2323

.php-cs-fixer.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
5+
$rules = [
6+
'@PSR2' => true,
7+
'array_syntax' => ['syntax' => 'short'],
8+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
9+
'no_blank_lines_after_class_opening' => true,
10+
'echo_tag_syntax' => ['format' => 'long'],
11+
'no_unused_imports' => true,
12+
'blank_line_after_opening_tag' => true,
13+
'not_operator_with_successor_space' => false,
14+
'no_useless_else' => true,
15+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
16+
'class_attributes_separation' => [
17+
'elements' => [
18+
'const' => 'one',
19+
'method' => 'one',
20+
'property' => 'one',
21+
],
22+
],
23+
'blank_line_before_statement' => [
24+
'statements' => ['break', 'continue', 'return', 'try'],
25+
],
26+
'no_alternative_syntax' => true,
27+
'phpdoc_add_missing_param_annotation' => true,
28+
'phpdoc_align' => ['align' => 'vertical'],
29+
'phpdoc_indent' => true,
30+
'phpdoc_no_package' => true,
31+
'phpdoc_order' => true,
32+
'phpdoc_separation' => true,
33+
'phpdoc_single_line_var_spacing' => true,
34+
'phpdoc_trim' => true,
35+
'phpdoc_var_without_name' => true,
36+
'phpdoc_to_comment' => false,
37+
'phpdoc_scalar' => [
38+
'types' => ['boolean', 'double', 'integer', 'real', 'str'],
39+
],
40+
'single_quote' => true,
41+
'ternary_operator_spaces' => true,
42+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
43+
'trim_array_spaces' => true,
44+
'no_leading_import_slash' => true,
45+
'declare_strict_types' => true,
46+
'single_line_after_imports' => true,
47+
'not_operator_with_space' => false,
48+
'no_spaces_inside_parenthesis' => true,
49+
'unary_operator_spaces' => true,
50+
'return_type_declaration' => ['space_before' => 'none'],
51+
'braces' => ['allow_single_line_closure' => true],
52+
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align_single_space_minimal']],
53+
'no_superfluous_phpdoc_tags' => true,
54+
'no_empty_phpdoc' => true,
55+
'no_extra_blank_lines' => true,
56+
];
57+
58+
return (new Config())
59+
->setRiskyAllowed(true)
60+
->setRules($rules)
61+
->setIndent(' ')
62+
->setUsingCache(false);

.php_cs.php renamed to .php-cs-fixer.php.dist

+17-28
Original file line numberDiff line numberDiff line change
@@ -11,69 +11,58 @@
1111
$rules = [
1212
'@PSR2' => true,
1313
'array_syntax' => ['syntax' => 'short'],
14-
'no_multiline_whitespace_before_semicolons' => true,
14+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
1515
'no_blank_lines_after_class_opening' => true,
16-
'no_short_echo_tag' => true,
16+
'echo_tag_syntax' => ['format' => 'long'],
1717
'no_unused_imports' => true,
1818
'blank_line_after_opening_tag' => true,
19-
'not_operator_with_successor_space' => true,
19+
'not_operator_with_successor_space' => false,
2020
'no_useless_else' => true,
21-
'ordered_imports' => [
22-
'sortAlgorithm' => 'alpha',
23-
],
21+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
2422
'class_attributes_separation' => [
25-
'elements' => ['const', 'method', 'property'],
23+
'elements' => [
24+
'const' => 'one',
25+
'method' => 'one',
26+
'property' => 'one',
27+
],
2628
],
2729
'blank_line_before_statement' => [
2830
'statements' => ['break', 'continue', 'return', 'try'],
2931
],
3032
'no_alternative_syntax' => true,
3133
'phpdoc_add_missing_param_annotation' => true,
32-
'phpdoc_align' => [
33-
'align' => 'vertical',
34-
],
34+
'phpdoc_align' => ['align' => 'vertical'],
3535
'phpdoc_indent' => true,
3636
'phpdoc_no_package' => true,
3737
'phpdoc_order' => true,
3838
'phpdoc_separation' => true,
3939
'phpdoc_single_line_var_spacing' => true,
4040
'phpdoc_trim' => true,
4141
'phpdoc_var_without_name' => true,
42-
'phpdoc_to_comment' => true,
42+
'phpdoc_to_comment' => false,
4343
'phpdoc_scalar' => [
4444
'types' => ['boolean', 'double', 'integer', 'real', 'str'],
4545
],
4646
'single_quote' => true,
4747
'ternary_operator_spaces' => true,
48-
'trailing_comma_in_multiline_array' => true,
48+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
4949
'trim_array_spaces' => true,
5050
'no_leading_import_slash' => true,
5151
'declare_strict_types' => true,
5252
'single_line_after_imports' => true,
53-
'header_comment' => [
54-
'header' => $header,
55-
],
53+
'header_comment' => ['header' => $header],
5654
'not_operator_with_space' => false,
5755
'no_spaces_inside_parenthesis' => true,
5856
'unary_operator_spaces' => true,
59-
'return_type_declaration' => [
60-
'space_before' => 'none',
61-
],
62-
'native_function_invocation' => [
63-
'include' => ['@all'],
64-
],
65-
'braces' => [
66-
'allow_single_line_closure' => true,
67-
],
68-
'binary_operator_spaces' => [
69-
'default' => 'align_single_space_minimal',
70-
],
57+
'return_type_declaration' => ['space_before' => 'none'],
58+
'braces' => ['allow_single_line_closure' => true],
59+
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align_single_space_minimal']],
7160
'no_superfluous_phpdoc_tags' => true,
7261
'no_empty_phpdoc' => true,
7362
'no_extra_blank_lines' => true,
7463
];
7564

76-
return Config::create()
65+
return (new Config())
7766
->setRiskyAllowed(true)
7867
->setRules($rules)
7968
->setIndent(' ')

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [10.4.0] - 2023.12.13
8+
### Added
9+
- Added generated code support for php 8.0
10+
### Changed
11+
- php-cs-fixer rules `not_operator_with_successor_space`, `phpdoc_to_comment`, `native_function_invocation`
12+
713
## [10.3.0] - 2023.12.08
814
### Added
915
- Added support for multiple responses

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.4-cli-alpine3.13 as dependencies
1+
FROM php:8.2-cli-alpine as dependencies
22

33
WORKDIR /dependencies
44

@@ -18,7 +18,7 @@ COPY composer.lock /dependencies
1818
RUN composer install \
1919
&& git config --global --add safe.directory /app
2020

21-
FROM php:7.4-cli-alpine3.13
21+
FROM php:8.2-cli-alpine
2222

2323
ARG API_CLIENT_GENERATOR_VERSION
2424
ENV API_CLIENT_GENERATOR_VERSION=$API_CLIENT_GENERATOR_VERSION

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cs: ## fix code style
1515
docker-compose run php vendor/bin/php-cs-fixer fix .
1616

1717
stan: ## statically analyse code
18-
docker-compose run php vendor/bin/phpstan analyse src
18+
docker-compose run php vendor/bin/phpstan --memory-limit=1G analyse
1919

2020
coverage: ## coverage for pipeline
2121
docker-compose run -e COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} -e GITHUB_REF=${GITHUB_REF} -e GITHUB_ACTIONS=${GITHUB_ACTIONS} -e GITHUB_RUN_ID=${GITHUB_RUN_ID} -e GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME} php vendor/bin/php-coveralls -v

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ API client generator is a console application capable of auto-generating a [PSR1
1313
## Why using it?
1414
- With generated client you are always sure that your OpenAPI specification is up-to-date.
1515
- Work with objects instead of raw data, it is OOP friendly.
16-
- Saves your time. You don't need to write data mappers youself to populate those objects with the data from the response.
16+
- Saves your time. You don't need to write data mappers yourself to populate those objects with the data from the response.
1717
- All the basic type validations in the request and the response done automatically.
1818
- Despite the fact the code is generated it's clear and readable, simple to debug and to reason about.
1919
- Highly configurable and extensible.
@@ -27,7 +27,7 @@ API client generator is a console application capable of auto-generating a [PSR1
2727
* application/json
2828
* application/x-www-form-urlencoded
2929
* application/xml
30-
- Supports new PHP versions synthax features.
30+
- Supports new PHP versions syntax features.
3131
- It is base client independent, you are free to choose any [existing PSR-18 compliant client](https://packagist.org/providers/psr/http-client-implementation). Just choose the one which you already use, so generated client would not cause any conflicts with your dependencies. Although not recommended, you can also use or build your own PSR-18 implementation, as the generated client depends on PSR interfaces only.
3232
- Applies code style rules to generated code, you can specify your own.
3333
- Generates README and composer.json files with possibility to use your own template.
@@ -74,9 +74,9 @@ The following environment variables are available:
7474
| `PACKAGE` | yes | | | group/some-api-client |
7575
| `OPENAPI ` | yes | | | /api/openapi.yaml |
7676
| `OUTPUT_DIR` | yes | | | /client |
77-
| `CODE_STYLE` | no | {path-to-repository}/.php_cs.php | | /client/myCodeStyle.php |
77+
| `CODE_STYLE` | no | {path-to-repository}/.php-cs-fixer.php.dist | | /client/myCodeStyle.php |
7878
| `SOURCE_DIR` | no | src | | src |
79-
| `CLIENT_PHP_VERSION` | no | 7.4 | 7.0, 7.1, 7.2, 7.3, 7.4 | 7.4 |
79+
| `CLIENT_PHP_VERSION` | no | 7.4 | 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 | 7.4 |
8080
| `COMPOSER_JSON_TEMPLATE_DIR` | no | {path-to-repository}/template/composer.json.twig | | /path/composer.json.twig |
8181
| `README_MD_TEMPLATE_DIR` | no | {path-to-repository}/template/README.md.twig | | /path/README.md.twig |
8282
| `HTTP_MESSAGE` | no | guzzle | guzzle, nyholm | nyholm |

bin/api-client-generator

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env php
2-
<?php declare(strict_types=1);
2+
<?php
3+
4+
declare(strict_types=1);
35

46
use DoclerLabs\ApiClientGenerator\Application;
57

68
require_once __DIR__ . '/../vendor/autoload.php';
79

8-
$application = new Application();
9-
10-
return $application->run();
10+
return (new Application())->run();

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
"api-client-generator"
1515
],
1616
"require": {
17-
"php": ">=7.4",
17+
"php": ">=8.2",
1818
"ext-dom": "*",
1919
"ext-json": "*",
2020
"ext-xml": "*",
2121
"cebe/php-openapi": "^1.4",
2222
"docler-labs/api-client-exception": "^1.0.1 || ^2.0",
23-
"friendsofphp/php-cs-fixer": "^2.16",
23+
"friendsofphp/php-cs-fixer": "^3.0",
2424
"guzzlehttp/psr7": "^1.6",
2525
"icecave/parity": "^3.0",
2626
"nikic/php-parser": "^4.10",
@@ -37,7 +37,7 @@
3737
"composer/composer": "^2.1",
3838
"mikey179/vfsstream": "^1.6",
3939
"php-coveralls/php-coveralls": "^2.2",
40-
"phpstan/phpstan": "^0.12.32",
40+
"phpstan/phpstan": "^1.10",
4141
"phpunit/phpunit": "^9.5",
4242
"roave/security-advisories": "dev-latest",
4343
"symfony/filesystem": "^5.1"

0 commit comments

Comments
 (0)