Skip to content

Commit 94071c7

Browse files
committed
Lint cleanup
1 parent f6db91e commit 94071c7

File tree

100 files changed

+8050
-2042
lines changed

Some content is hidden

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

100 files changed

+8050
-2042
lines changed

.github/workflows/docker-build.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Docker Build & Push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch: # manual trigger
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
# Checkout repo
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
# Setup QEMU (for multi-arch builds, e.g. amd64 + arm64)
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
29+
# Setup Buildx (required for caching & multi-platform)
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
# Login to registry (Docker Hub or GHCR)
34+
- name: Log in to Docker registry
35+
uses: docker/login-action@v3
36+
with:
37+
username: ${{ secrets.DOCKER_USERNAME }}
38+
password: ${{ secrets.DOCKER_PASSWORD }}
39+
# for GHCR use:
40+
# username: ${{ github.actor }}
41+
# password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
# Extract metadata for tags/labels
44+
- name: Extract Docker metadata
45+
id: meta
46+
uses: docker/metadata-action@v5
47+
with:
48+
images: |
49+
rxcod9/php-swoole-crud-microservice
50+
# ghcr.io/${{ github.repository_owner }}/php-swoole-crud-microservice
51+
tags: |
52+
type=ref,event=branch
53+
type=sha
54+
type=semver,pattern={{version}}
55+
latest
56+
57+
# Build & Push Docker image
58+
- name: Build and Push Docker image
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: .
62+
file: ./Dockerfile
63+
push: true
64+
platforms: linux/amd64,linux/arm64
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ composer.lock
4343

4444
# Docker
4545
docker-compose.override.yml
46-
.env.local
46+
.env.local
47+
.rector_cache

.php-cs-fixer.php

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
use PhpCsFixer\Config;
66
use PhpCsFixer\Finder;
77

8+
// Scan src/tests for PHP files, exclude vendor/build/node_modules
89
$finder = Finder::create()
910
->in([__DIR__ . '/src', __DIR__ . '/tests'])
1011
->name('*.php')
11-
->exclude(['vendor', 'build'])
12+
->exclude(['vendor', 'build', 'node_modules'])
1213
->ignoreDotFiles(true)
1314
->ignoreVCS(true);
1415

@@ -18,7 +19,11 @@
1819
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache')
1920
->setFinder($finder)
2021
->setRules([
22+
// ===================================
23+
// Base rules / PSR12 / PHP84 migration
24+
// ===================================
2125
'@PSR12' => true,
26+
'phpdoc_types' => ['groups' => []], // optional, keeps types short
2227
'@PHP84Migration' => true,
2328
'@DoctrineAnnotation' => true,
2429

@@ -30,58 +35,51 @@
3035
// Imports
3136
'ordered_imports' => ['sort_algorithm' => 'alpha'],
3237
'no_unused_imports' => true,
33-
'global_namespace_import' => [
34-
'import_constants' => true,
35-
'import_functions' => true,
36-
'import_classes' => true,
37-
],
3838

39-
// Arrays & Lists
39+
// Arrays & lists
4040
'array_syntax' => ['syntax' => 'short'],
4141
'list_syntax' => ['syntax' => 'short'],
4242
'trim_array_spaces' => true,
4343
'no_whitespace_before_comma_in_array' => true,
4444
'whitespace_after_comma_in_array' => true,
45-
'no_trailing_comma_in_singleline_array' => true, // aligns with PSR12
46-
47-
// Functions
45+
'no_trailing_comma_in_singleline_array' => true,
46+
'trailing_comma_in_multiline' => true,
4847
'nullable_type_declaration_for_default_null_value' => true,
4948
'no_unreachable_default_argument_value' => true,
50-
'native_function_invocation' => [
51-
'include' => ['@compiler_optimized'],
52-
'scope' => 'all'
53-
],
5449
'return_type_declaration' => ['space_before' => 'none'],
5550

56-
// Classes
57-
'class_attributes_separation' => ['elements' => ['method' => 'one']],
51+
// Classes & methods
52+
'class_attributes_separation' => ['elements' => ['method' => 'one']], // one blank line between methods
5853
'visibility_required' => ['elements' => ['property', 'method', 'const']],
59-
'self_accessor' => false,
54+
'self_accessor' => true,
6055
'no_null_property_initialization' => true,
6156

6257
// Operators & spacing
6358
'concat_space' => ['spacing' => 'one'],
6459
'binary_operator_spaces' => [
6560
'default' => 'single_space',
66-
'operators' => [
67-
'=' => 'align_single_space_minimal',
68-
'=>' => 'align_single_space_minimal',
69-
],
61+
'operators' => ['='=>'align_single_space_minimal','=>'=>'align_single_space_minimal']
7062
],
7163
'ternary_operator_spaces' => true,
7264

7365
// Strings
7466
'single_quote' => true,
75-
'escape_implicit_backslashes' => true,
76-
'string_implicit_backslashes' => ['single_quoted' => 'ignore'],
7767

78-
// Comments & Docs
79-
'phpdoc_align' => ['align' => 'left'],
80-
'phpdoc_to_comment' => false,
81-
'phpdoc_trim_consecutive_blank_line_separation' => true,
82-
'phpdoc_summary' => false,
68+
// ===================================
69+
// PHPDoc / Docblock alignment
70+
// ===================================
71+
// 'phpdoc_align' => ['align' => 'vertical'], // aligns all @param/@return
72+
// 'phpdoc_order' => true, // sort tags: param → return → throws
73+
// 'phpdoc_trim' => true, // remove extra spaces
74+
'phpdoc_no_empty_return' => false, // remove @return void
75+
'phpdoc_var_without_name' => true, // allow @var type without variable
76+
'phpdoc_add_missing_param_annotation' => true, // adds missing @param
77+
'phpdoc_scalar' => true, // use scalar types in docblocks
78+
'phpdoc_separation' => false, // enforce no blank lines between annotations
79+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], // allow mixed when required
80+
// 'no_blank_lines_before_namespace' => true, // ensures file doc is at top
8381

84-
// Misc
85-
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
86-
'fully_qualified_strict_types' => true,
82+
// Misc spacing & braces
83+
'no_extra_blank_lines' => ['tokens' => ['extra','curly_brace_block','square_brace_block','parenthesis_brace_block','throw','use','return']],
84+
'braces' => ['allow_single_line_closure' => true,'position_after_functions_and_oop_constructs' => 'same'],
8785
]);

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"license": "MIT",
66
"require": {
77
"monolog/monolog": "^3.6",
8+
"nesbot/carbon": "^3.10",
89
"promphp/prometheus_client_php": "^2.10",
910
"vlucas/phpdotenv": "^5.6"
1011
},
@@ -13,10 +14,13 @@
1314
"friendsofphp/php-cs-fixer": "^3.88",
1415
"pheromone/phpcs-security-audit": "^2.0",
1516
"phpcompatibility/php-compatibility": "^9.3",
17+
"phpdocumentor/reflection-docblock": "^5.6",
1618
"phpmd/phpmd": "^2.15",
19+
"phpstan/phpdoc-parser": "^2.3",
1720
"phpstan/phpstan": "^2.1",
1821
"phpstan/phpstan-strict-rules": "^2.0",
1922
"phpunit/phpunit": "^10.5",
23+
"rector/rector": "^2.1",
2024
"slevomat/coding-standard": "^8.20",
2125
"squizlabs/php_codesniffer": "^3.13",
2226
"swoole/ide-helper": "~5.0.0",
@@ -27,14 +31,15 @@
2731
"test": "vendor/bin/phpunit",
2832
"openapi:generate": "vendor/bin/openapi --output public/openapi.json src",
2933
"phpcbf": "vendor/bin/phpcbf -p ./src --encoding=utf-8 --standard=phpcs.xml --runtime-set testVersion 8.4 --parallel=1 --report=full",
30-
"phpcs": "vendor/bin/phpcs -p ./src --encoding=utf-8 --standard=phpcs.xml --runtime-set testVersion 8.4 --parallel=1 --report=full",
34+
"phpcs": "vendor/bin/phpcs ./src --encoding=utf-8 --standard=phpcs.xml --runtime-set testVersion 8.4 --parallel=1 --report=json",
3135
"phpmd": "vendor/bin/phpmd ./src text phpmd.xml --report-file=phpmd.csv",
3236
"phpstan": "vendor/bin/phpstan analyse --configuration=phpstan.neon --memory-limit=-1 -v"
3337
},
3438
"autoload": {
3539
"psr-4": {
3640
"App\\": "src/",
37-
"Tests\\": "tests/"
41+
"Tests\\": "tests/",
42+
"RectorRules\\": "tools/rector/"
3843
},
3944
"files": [
4045
"src/Support/helpers.php"

0 commit comments

Comments
 (0)