Skip to content

Commit 9bbddf1

Browse files
committed
Add cs-fixer for PHP 8.4
1 parent cd2d0fb commit 9bbddf1

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.php-cs-fixer.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
$finder = PhpCsFixer\Finder::create()
5+
->in([
6+
__DIR__ . '/framework',
7+
__DIR__ . '/controllers',
8+
__DIR__ . '/models',
9+
__DIR__ . '/views',
10+
__DIR__ . '/util',
11+
__DIR__ . '/classes',
12+
])
13+
->name('*.php');
14+
15+
return (new PhpCsFixer\Config())
16+
->setFinder($finder)
17+
->setRules([
18+
'nullable_type_declaration_for_default_null_value' => true,
19+
]);
20+
21+
foreach ($finder as $file) {
22+
echo $file->getRealPath() . PHP_EOL;
23+
}

cs-fixer.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Upgrade PHP Web MVC Framework to PHP >= 8.4
2+
3+
You can fix/upgrade PHP WEB MVC Framework to PHP 8.4 by eliminating the:
4+
5+
**nullable_type_declaration_for_default_null_value**
6+
7+
used for backward compatibility with versions from PHP 7.1 to PHP 5.6.
8+
9+
To apply the fix if your runtime PHP enviroment is version is >= 7.1 run:
10+
11+
1)
12+
13+
```bash
14+
composer require --dev friendsofphp/php-cs-fixer
15+
```
16+
17+
2) If you are using PHP version 8.4 you must set the environment variable:
18+
19+
**PHP_CS_FIXER_IGNORE_ENV=1**
20+
21+
On Windows just modify the file
22+
23+
**.vendor\bin\php-cs-fixer.bat**
24+
25+
as follow:
26+
27+
```batch
28+
@ECHO OFF
29+
setlocal DISABLEDELAYEDEXPANSION
30+
SET BIN_TARGET=%~dp0/php-cs-fixer
31+
SET COMPOSER_RUNTIME_BIN_DIR=%~dp0
32+
SET PHP_CS_FIXER_IGNORE_ENV=1
33+
php "%BIN_TARGET%" %*
34+
```
35+
36+
3) To check only, run:
37+
```bash
38+
.\vendor\bin\php-cs-fixer check
39+
```
40+
4) To fix run
41+
```bash
42+
.\vendor\bin\php-cs-fixer check
43+
```
44+
45+
Note: after applying the fix you can only use PHP version >= 7.1

0 commit comments

Comments
 (0)