Skip to content

Commit 7fffe3d

Browse files
Refactoring, bump dependencies and drop old behaviour support (#618)
* WIP * WIP * WIP * WIP * Apply fixes from StyleCI * WIP * Apply fixes from StyleCI * WIP * Apply fixes from StyleCI * drop php7.4 support * dependencies * dependencies * WIP * covers attributes * Apply fixes from StyleCI * ci * wip * WIP * update tests * update tests * Apply fixes from StyleCI * update tests * update tests * update tests * update tests * update tests * Apply fixes from StyleCI * Add test * use actions/cache@v4 * Use only swagger-php:5 * Apply fixes from StyleCI * wWIP * WIP * Apply fixes from StyleCI * WIP * WIP * php 8.2 * Apply fixes from StyleCI * php 8.2 * php 8.2 * php 8.2 * php 8.2 * php 8.2 * php 8.2 * php 8.2 * phpstan level 4 * phpstan level 4 * phpstan level 6 * Apply fixes from StyleCI * phpstan level 7 * Apply fixes from StyleCI * phpstan level 8 * Apply fixes from StyleCI * add analyse to CI workflow * add analyse to CI workflow * add analyse to CI workflow * Laravel 12.0 support --------- Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent b16d753 commit 7fffe3d

29 files changed

+710
-655
lines changed

.codeclimate.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
languages:
22
PHP: true
3-
engines:
3+
plugins:
44
phpcodesniffer:
55
enabled: true
6+
config:
7+
standard: "PSR1,PSR2"
68
phpmd:
79
enabled: true
810
ratings:
@@ -12,4 +14,4 @@ exclude_paths:
1214
- test/**/*
1315
- vendor/**/*
1416
- resoufces/**/*
15-
- config/**/*
17+
- config/**/*

.github/workflows/test-config.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
17-
l5-swagger-flags: ['latest', 'swagger-php-3', 'swagger-ui-3']
16+
php: [ '8.2', '8.3' ]
17+
l5-swagger-flags: ['swagger-php-latest']
1818

1919
name: PHP ${{ matrix.php }} - ${{ matrix.l5-swagger-flags }}
2020

@@ -30,7 +30,7 @@ jobs:
3030

3131
- name: Cache Composer packages
3232
id: composer-cache
33-
uses: actions/cache@v2
33+
uses: actions/cache@v4
3434
with:
3535
path: vendor
3636
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
@@ -40,14 +40,6 @@ jobs:
4040
- name: Install dependencies
4141
run: composer update --no-interaction --no-progress --prefer-dist --prefer-stable
4242

43-
- name: Require Swagger PHP 3.*
44-
run: composer require 'zircote/swagger-php:3.*' --no-interaction --no-update
45-
if: matrix.l5-swagger-flags == 'swagger-php-3'
46-
47-
- name: Require Swagger UI 3.*
48-
run: composer require 'swagger-api/swagger-ui:3.*' --no-interaction --no-update
49-
if: matrix.l5-swagger-flags == 'swagger-ui-3'
50-
5143
- name: Prepare enviroment
5244
run: |
5345
sudo chown -R $USER:$USER .
@@ -64,11 +56,14 @@ jobs:
6456
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
6557
chmod +x ./cc-test-reporter
6658
./cc-test-reporter before-build
67-
if: matrix.php == '8.3' && matrix.l5-swagger-flags == 'latest'
59+
if: matrix.php == '8.3' && matrix.l5-swagger-flags == 'swagger-php-latest'
6860

6961
- name: Run test suite
7062
run: composer run-script phpunit
7163

64+
- name: Run phpStan
65+
run: composer run-script analyse
66+
7267
- name: Publish code coverage
7368
env:
7469
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
@@ -77,12 +72,12 @@ jobs:
7772
cp ${{github.workspace}}/tests/storage/logs/test-reports/clover.xml ${{github.workspace}}/clover.xml
7873
./cc-test-reporter after-build -t clover --exit-code 0
7974
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ${{github.workspace}}/clover.xml
80-
if: matrix.php == '8.3' && matrix.l5-swagger-flags == 'latest' && github.event_name != 'pull_request'
75+
if: matrix.php == '8.3' && matrix.l5-swagger-flags == 'swagger-php-latest' && github.event_name != 'pull_request'
8176

8277
- name: Publish coveralls report
8378
env:
8479
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8580
run: |
8681
cp ${{github.workspace}}/tests/storage/logs/test-reports/clover.xml ${{github.workspace}}/clover.xml
8782
vendor/bin/php-coveralls --coverage_clover=clover.xml -v
88-
if: matrix.php == '8.3' && matrix.l5-swagger-flags == 'latest'
83+
if: matrix.php == '8.3' && matrix.l5-swagger-flags == 'swagger-php-latest'

.travis.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ RUN apt-get update && apt-get install -y \
2424
# Clear cache
2525
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
2626

27-
# RUN pecl install memcached
28-
2927
RUN pecl install -f xdebug \
3028
&& docker-php-ext-enable xdebug
3129

composer.json

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@
1818
"email": "darius@matulionis.lt"
1919
}
2020
],
21-
"require": {
22-
"php": "^7.2 || ^8.0",
23-
"laravel/framework": "^11.0 || ^10.0 || ^9.0 || >=8.40.0 || ^7.0",
24-
"zircote/swagger-php": "^3.2.0 || ^4.0.0",
25-
"swagger-api/swagger-ui": "^3.0 || >=4.1.3",
26-
"symfony/yaml": "^5.0 || ^6.0 || ^7.0",
27-
"ext-json": "*",
28-
"doctrine/annotations": "^1.0 || ^2.0"
29-
},
30-
"require-dev": {
31-
"phpunit/phpunit": "^11.0 || ^10.0 || ^9.5",
32-
"mockery/mockery": "1.*",
33-
"orchestra/testbench": "^9.0 || ^8.0 || 7.* || ^6.15 || 5.*",
34-
"php-coveralls/php-coveralls": "^2.0"
35-
},
3621
"autoload": {
3722
"psr-4": {
3823
"L5Swagger\\": "src"
@@ -46,6 +31,22 @@
4631
"Tests\\": "tests"
4732
}
4833
},
34+
"require": {
35+
"php": "^8.2",
36+
"laravel/framework": "^12.0 || ^11.0",
37+
"zircote/swagger-php": "^5.0.0",
38+
"swagger-api/swagger-ui": ">=5.18.3",
39+
"symfony/yaml": "^5.0 || ^6.0 || ^7.0",
40+
"ext-json": "*",
41+
"doctrine/annotations": "^1.0 || ^2.0"
42+
},
43+
"require-dev": {
44+
"phpunit/phpunit": "^11.0",
45+
"mockery/mockery": "1.*",
46+
"orchestra/testbench": "^10.0 || ^9.0 || ^8.0 || 7.* || ^6.15 || 5.*",
47+
"php-coveralls/php-coveralls": "^2.0",
48+
"phpstan/phpstan": "^2.1"
49+
},
4950
"extra": {
5051
"laravel": {
5152
"providers": [
@@ -59,6 +60,7 @@
5960
"minimum-stability": "dev",
6061
"prefer-stable": true,
6162
"scripts": {
62-
"phpunit": "vendor/bin/phpunit --testdox"
63+
"phpunit": "vendor/bin/phpunit --testdox",
64+
"analyse": "vendor/bin/phpstan analyse --memory-limit=256M"
6365
}
6466
}

docker/php/php.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,6 @@ xdebug.remote_handler = dbgp
19211921
xdebug.discover_client_host = 0
19221922
xdebug.show_error_trace = 1
19231923

1924-
[memcached]
1925-
extension=memcached.so
1926-
19271924
; Local Variables:
19281925
; tab-width: 4
19291926
; End:

phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
- tests/Unit
6+
ignoreErrors:
7+
- identifier: argument.templateType

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
<include>
2525
<directory suffix=".php">src/</directory>
2626
</include>
27+
<exclude>
28+
<file>src/routes.php</file>
29+
</exclude>
2730
</source>
2831
</phpunit>

src/ConfigFactory.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
class ConfigFactory
88
{
99
/**
10-
* Get documentation config.
10+
* Retrieves and merges the configuration for the specified documentation.
1111
*
12-
* @param string|null $documentation
13-
* @return array
12+
* @param string|null $documentation The name of the documentation configuration to retrieve.
13+
* If null, the default documentation configuration is used.
14+
* @return array<string, mixed> The merged configuration for the specified documentation.
1415
*
15-
* @throws L5SwaggerException
16+
* @throws L5SwaggerException If the specified documentation configuration is not found.
1617
*/
1718
public function documentationConfig(?string $documentation = null): array
1819
{
@@ -30,6 +31,14 @@ public function documentationConfig(?string $documentation = null): array
3031
return $this->mergeConfig($defaults, $documentations[$documentation]);
3132
}
3233

34+
/**
35+
* Merges two configuration arrays recursively, with the values from the second array
36+
* overriding those in the first array when keys overlap.
37+
*
38+
* @param array<string, mixed> $defaults The default configuration array.
39+
* @param array<string, mixed> $config The configuration array to merge into the defaults.
40+
* @return array<string, mixed> The merged configuration array.
41+
*/
3342
private function mergeConfig(array $defaults, array $config): array
3443
{
3544
$merged = $defaults;
@@ -49,7 +58,13 @@ private function mergeConfig(array $defaults, array $config): array
4958
return $merged;
5059
}
5160

52-
private function isAssociativeArray($value): bool
61+
/**
62+
* Determines whether a given value is an associative array.
63+
*
64+
* @param mixed $value The value to be checked.
65+
* @return bool True if the value is an associative array, false otherwise.
66+
*/
67+
private function isAssociativeArray(mixed $value): bool
5368
{
5469
return is_array($value) && count(array_filter(array_keys($value), 'is_string')) > 0;
5570
}

src/Console/GenerateDocsCommand.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@ public function __construct()
2828
protected $description = 'Regenerate docs';
2929

3030
/**
31-
* Execute the console command.
32-
*
3331
* @param GeneratorFactory $generatorFactory
34-
* @return void
3532
*
3633
* @throws L5SwaggerException
3734
*/
38-
public function handle(GeneratorFactory $generatorFactory)
35+
public function handle(GeneratorFactory $generatorFactory): void
3936
{
4037
$all = $this->option('all');
4138

4239
if ($all) {
40+
/** @var array<string> $documentations */
4341
$documentations = array_keys(config('l5-swagger.documentations', []));
4442

4543
foreach ($documentations as $documentation) {
@@ -59,12 +57,15 @@ public function handle(GeneratorFactory $generatorFactory)
5957
}
6058

6159
/**
62-
* @param GeneratorFactory $generatorFactory
63-
* @param string $documentation
60+
* Generates documentation using the specified generator factory.
61+
*
62+
* @param GeneratorFactory $generatorFactory The factory used to create the documentation generator.
63+
* @param string $documentation The name or identifier of the documentation to be generated.
64+
* @return void
6465
*
6566
* @throws L5SwaggerException
6667
*/
67-
private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation)
68+
private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation): void
6869
{
6970
$this->info('Regenerating docs '.$documentation);
7071

0 commit comments

Comments
 (0)