Skip to content

Commit 0fec30c

Browse files
author
serega
committed
fix(entity/User): Improve type hints for roles and Doctrine collections
Updated the @var docblocks for the $roles, $apiTokens, and $tasks properties to satisfy stricter static analysis checks (e.g., PHPStan/Psalm) regarding iterable and generic types. This resolves warnings about: Missing value type for array $roles (now specified as string[]). Missing generic types for Collection properties (now specified as Collection<int, Entity>).
1 parent b6661ff commit 0fec30c

35 files changed

Lines changed: 3578 additions & 93 deletions

.github/workflows/lint.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Lint (PHPStan + PHPCS)
2+
3+
# Run on pushes and pull requests to main and feature branches
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
lint:
12+
name: Lint (PHP ${{ matrix.php-version }})
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php-version: [ '8.1', '8.2' ] # adjust versions you want to test
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup PHP ${{ matrix.php-version }}
26+
uses: shivammathur/setup-php@v4
27+
with:
28+
php-version: ${{ matrix.php-version }}
29+
extensions: mbstring, json, xml, pdo, tokenizer
30+
coverage: none
31+
32+
- name: Validate composer.json
33+
run: composer validate --no-check-publish
34+
35+
- name: Get Composer Cache directory
36+
id: composer-cache
37+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
39+
- name: Cache Composer dependencies
40+
uses: actions/cache@v4
41+
with:
42+
path: ${{ steps.composer-cache.outputs.dir }}
43+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-composer-
46+
47+
- name: Install composer dependencies
48+
run: composer install --no-progress --no-suggest --prefer-dist --no-interaction
49+
50+
- name: Ensure make is installed (Ubuntu has make preinstalled)
51+
run: make --version
52+
53+
- name: Run lint (phpstan + phpcs)
54+
run: make lint
55+
working-directory: app
56+
57+
- name: Upload PHPCS report (optional)
58+
if: always()
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: phpcs-report
62+
path: phpcs-report.xml

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ API надає можливість:
88
- Видалити своє завдання.
99
- Відзначити своє завдання як виконане.
1010

11+
![api docs](docs/index-img.png)
12+
13+
14+
15+
![api docs](docs/login-img.png)
1116

1217

1318
## How to run

app/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@
88
/var/
99
/vendor/
1010
###< symfony/framework-bundle ###
11+
12+
###> phpstan/phpstan ###
13+
phpstan.neon
14+
###< phpstan/phpstan ###
15+
16+
###> squizlabs/php_codesniffer ###
17+
/.phpcs-cache
18+
/phpcs.xml
19+
###< squizlabs/php_codesniffer ###

app/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ===============================================
2+
# Makefile for PHP Static Analysis and Linting
3+
# ===============================================
4+
5+
# Path to vendor binaries
6+
VENDOR_BIN := vendor/bin
7+
8+
# Targets that do not produce files
9+
.PHONY: quality phpstan phpcs lint fix
10+
11+
# -----------------------------------------------
12+
# MAIN TARGETS
13+
# -----------------------------------------------
14+
15+
# Run all quality checks: PHPStan + PHP CodeSniffer
16+
quality: phpstan phpcs
17+
@echo "✨ Quality checks completed successfully."
18+
19+
# Alias 'lint' to run PHPStan and PHP CodeSniffer
20+
lint: phpstan phpcs
21+
@echo "🔍 Linting (PHPStan + PHPCS) completed successfully."
22+
23+
# -----------------------------------------------
24+
# INDIVIDUAL CHECKS
25+
# -----------------------------------------------
26+
27+
# Run PHPStan for static analysis
28+
phpstan:
29+
@echo "--- Running PHPStan Static Analysis ---"
30+
@$(VENDOR_BIN)/phpstan analyse --memory-limit=256M
31+
32+
# Run PHP CodeSniffer to detect style violations
33+
phpcs:
34+
@echo "--- Running PHP CodeSniffer (Style Check) ---"
35+
@$(VENDOR_BIN)/phpcs
36+
37+
# -----------------------------------------------
38+
# UTILITIES
39+
# -----------------------------------------------
40+
41+
# Automatically fix code style issues using PHPCBF
42+
fix:
43+
@echo "--- Running PHP Code Beautifier and Fixer (Auto-fix) ---"
44+
@$(VENDOR_BIN)/phpcbf

app/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
"symfony/yaml": "6.3.*"
3535
},
3636
"require-dev": {
37+
"phpstan/phpstan": "^2.1",
38+
"squizlabs/php_codesniffer": "*",
3739
"symfony/debug-bundle": "6.3.*",
3840
"symfony/maker-bundle": "^1.50",
3941
"symfony/stopwatch": "6.3.*",

app/composer.lock

Lines changed: 136 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/config/preload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

3-
if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) {
4-
require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php';
3+
if (file_exists(dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php')) {
4+
require dirname(__DIR__) . '/var/cache/prod/App_KernelProdContainer.preload.php';
55
}

app/config/services.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ services:
1919
- '../src/DependencyInjection/'
2020
- '../src/Entity/'
2121
- '../src/Kernel.php'
22-
22+
App\OpenApi\OpenApiFactory:
23+
decorates: 'api_platform.openapi.factory'
24+
arguments: ['@App\OpenApi\OpenApiFactory.inner']
2325
# add more service definitions when explicit configuration is needed
2426
# please note that last definitions always *replace* previous ones

app/phpcs.xml.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
6+
<arg name="basepath" value="."/>
7+
<arg name="cache" value=".phpcs-cache"/>
8+
<arg name="colors"/>
9+
<arg name="extensions" value="php"/>
10+
11+
<rule ref="PSR12"/>
12+
13+
<file>bin/</file>
14+
<file>config/</file>
15+
<file>public/</file>
16+
<file>src/</file>
17+
18+
</ruleset>

app/phpstan.dist.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- bin/
5+
- config/
6+
- public/
7+
- src/

0 commit comments

Comments
 (0)