Skip to content

Commit 2b64b5b

Browse files
author
serega
committed
```
refactor: Improve type safety and resolve static analysis warnings Addresses PHPStan errors and warnings across entities and the security controller by enforcing strict type hints and best practices. - **User.php**: Applied `readonly` and initialization (`= null`) to `$id` to satisfy PHP 8.1 rules for auto-generated Doctrine IDs. Added explicit array type hints (`array<string>`) and `type: json` for `$roles`. - **ApiToken.php**: Added explicit array type hints for `$scopes` property and methods. Implemented the `\Stringable` interface. - **SecurityController.php**: Added explicit type hints (`?User`, `JsonResponse`, `void`) to parameters and return types. Removed all remaining code comments. ```
1 parent 892bc0d commit 2b64b5b

17 files changed

Lines changed: 2063 additions & 60 deletions

.github/workflows/lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
matrix:
1616
php-version: [ '8.1', '8.2' ]
1717

18+
defaults:
19+
run:
20+
working-directory: app # 👈 all commands will run from /app
21+
1822
steps:
1923
- name: Checkout repository
2024
uses: actions/checkout@v4
@@ -35,7 +39,7 @@ jobs:
3539
uses: actions/cache@v4
3640
with:
3741
path: ~/.composer/cache/files
38-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
42+
key: ${{ runner.os }}-composer-${{ hashFiles('app/composer.lock') }}
3943
restore-keys: |
4044
${{ runner.os }}-composer-
4145

app/.env.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999

app/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ phpstan.neon
1717
/.phpcs-cache
1818
/phpcs.xml
1919
###< squizlabs/php_codesniffer ###
20+
21+
###> phpunit/phpunit ###
22+
/phpunit.xml
23+
/.phpunit.cache/
24+
###< phpunit/phpunit ###

app/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535
},
3636
"require-dev": {
3737
"phpstan/phpstan": "^2.1",
38+
"phpstan/phpstan-doctrine": "^2.0",
39+
"phpunit/phpunit": "^10.5",
3840
"squizlabs/php_codesniffer": "*",
3941
"symfony/debug-bundle": "6.3.*",
4042
"symfony/maker-bundle": "^1.50",
43+
"symfony/phpunit-bridge": "^7.3",
4144
"symfony/stopwatch": "6.3.*",
4245
"symfony/web-profiler-bundle": "6.3.*",
4346
"zenstruck/foundry": "^1.34"

0 commit comments

Comments
 (0)