Skip to content

Commit be5d95f

Browse files
committed
+ .phpcs.xml to use rule PSR12 instead of the default rule PEAR and manually ignore vendor & bootstrap/cache when running phpc{s,bf} as it doesn't support .gitignore: squizlabs/PHP_CodeSniffer#2242
* add one space before self-closing tags @ phpunit.xml & psalm.xml * fix all violation of PHPStorm inspection `Unnecessary fully qualified name` $ ./vendor/bin/phpcbf . && ./vendor/bin/pint @ be
1 parent 37dbe24 commit be5d95f

File tree

8 files changed

+39
-28
lines changed

8 files changed

+39
-28
lines changed

.github/workflows/be_base.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616
- uses: ./.github/actions/be
17-
# https://github.com/staabm/annotate-pull-request-from-checkstyle
1817
- run: >
1918
./vendor/bin/phpstan analyse --error-format=checkstyle
2019
| tee >(cs2pr --notices-as-warnings --graceful-warnings --prepend-filename --prepend-source)
20+
# https://github.com/staabm/annotate-pull-request-from-checkstyle
2121
shell: bash
2222
2323
psalm:
@@ -65,4 +65,5 @@ jobs:
6565
steps:
6666
- uses: actions/checkout@v4
6767
- uses: ./.github/actions/be
68-
- run: ./vendor/bin/phpmd . github cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor # https://github.com/phpmd/phpmd/issues/506
68+
# https://github.com/phpmd/phpmd/issues/506
69+
- run: ./vendor/bin/phpmd . github cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor

be/.phpcs.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<rule ref="PSR12" />
4+
<arg name="extensions" value="php" />
5+
<exclude-pattern>*.blade.php</exclude-pattern>
6+
<exclude-pattern>_ide_helper*.php</exclude-pattern>
7+
<!-- https://github.com/squizlabs/PHP_CodeSniffer/issues/2242 -->
8+
<exclude-pattern>vendor/*</exclude-pattern>
9+
<exclude-pattern>bootstrap/cache/*</exclude-pattern>
10+
</ruleset>

be/app/Helper.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ public static function jsonDecode(string $json, bool $assoc = true)
149149
}
150150

151151
public static function xmlResponse(string|\Stringable $xml): \Illuminate\Http\Response
152-
{ // https://laracasts.com/discuss/channels/laravel/syntax-error-unexpected-identifier-version-1
152+
{
153+
// https://laracasts.com/discuss/channels/laravel/syntax-error-unexpected-identifier-version-1
153154
return response('<?xml version="1.0" encoding="UTF-8"?>' . "\n$xml")
154155
->withHeaders(['Content-Type' => 'text/xml']);
155156
}

be/app/Http/Controllers/ThreadsSitemap.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class ThreadsSitemap extends Controller
1313
public static int $maxUrls = 50000;
1414

1515
public function query(Http\Request $request, int $fid): Http\Response
16-
{ // https://stackoverflow.com/questions/59554777/laravel-how-to-set-default-value-in-validator-at-post-registeration/78707950#78707950
16+
{
17+
// https://stackoverflow.com/questions/59554777/laravel-how-to-set-default-value-in-validator-at-post-registeration/78707950#78707950
1718
['cursor' => $cursor] = $request->validate([
1819
'cursor' => 'integer',
1920
]) + ['cursor' => 0];

be/app/Http/PostsQuery/BaseQuery.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public function reOrderNestedPosts(Collection $nestedPosts): array
362362
* @param string $childPostTypePluralName
363363
* @return Collection<int, Collection<string, mixed|Collection<int, Collection<string, mixed>>>>
364364
*/
365-
$setSortingKeyFromCurrentAndChildPosts = function (Collection $curPost, string $childPostTypePluralName): \Illuminate\Support\Collection {
365+
$setSortingKeyFromCurrentAndChildPosts = function (Collection $curPost, string $childPostTypePluralName): Collection {
366366
/** @var Collection<int, Collection<string, mixed>> $childPosts sorted child posts */
367367
$childPosts = $curPost[$childPostTypePluralName];
368368
$curPost[$childPostTypePluralName] = $childPosts->values(); // reset keys
@@ -394,12 +394,12 @@ public function reOrderNestedPosts(Collection $nestedPosts): array
394394

395395
return $curPost;
396396
};
397-
$sortBySortingKey = fn(Collection $posts): \Illuminate\Support\Collection => $posts
397+
$sortBySortingKey = fn(Collection $posts): Collection => $posts
398398
->sortBy(fn(Collection $i) => $i['sortingKey'], descending: $this->orderByDesc);
399399
$removeSortingKey = /**
400-
* @psalm-return \Illuminate\Support\Collection<array-key, \Illuminate\Support\Collection>
400+
* @psalm-return Collection<array-key, Collection>
401401
*/
402-
static fn(Collection $posts): \Illuminate\Support\Collection => $posts
402+
static fn(Collection $posts): Collection => $posts
403403
->map(fn(Collection $i) => $i->except('sortingKey'));
404404
$ret = $removeSortingKey($sortBySortingKey(
405405
$nestedPosts->map(

be/app/Http/PostsQuery/IndexQuery.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ public function query(QueryParams $params, ?string $cursor): self
4646
->selectRaw("{$fid} AS fid, COUNT(*) AS count")
4747
->where($postIDName, $postID))
4848
->reduce(/**
49-
* @return \Illuminate\Contracts\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
50-
*
51-
* @psalm-return \Illuminate\Contracts\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Query\Builder
49+
* @return BuilderContract|EloquentBuilder|QueryBuilder
50+
* @psalm-return BuilderContract|EloquentBuilder<\Illuminate\Database\Eloquent\Model>|QueryBuilder
5251
*/
53-
static fn(?BuilderContract $acc, EloquentBuilder|QueryBuilder $cur): \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Contracts\Database\Query\Builder =>
54-
$acc === null ? $cur : $acc->union($cur),
52+
static fn(?BuilderContract $acc, EloquentBuilder|QueryBuilder $cur): EloquentBuilder|QueryBuilder|BuilderContract => $acc === null ? $cur : $acc->union($cur),
5553
)
5654
->get()
5755
->where('count', '!=', 0);

be/phpunit.xml

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
@@ -18,16 +18,16 @@
1818
</include>
1919
</source>
2020
<php>
21-
<env name="APP_ENV" value="testing"/>
22-
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
23-
<env name="BCRYPT_ROUNDS" value="4"/>
24-
<env name="CACHE_STORE" value="array"/>
25-
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
26-
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
27-
<env name="MAIL_MAILER" value="array"/>
28-
<env name="PULSE_ENABLED" value="false"/>
29-
<env name="QUEUE_CONNECTION" value="sync"/>
30-
<env name="SESSION_DRIVER" value="array"/>
31-
<env name="TELESCOPE_ENABLED" value="false"/>
21+
<env name="APP_ENV" value="testing" />
22+
<env name="APP_MAINTENANCE_DRIVER" value="file" />
23+
<env name="BCRYPT_ROUNDS" value="4" />
24+
<env name="CACHE_STORE" value="array" />
25+
<!-- <env name="DB_CONNECTION" value="sqlite" /> -->
26+
<!-- <env name="DB_DATABASE" value=":memory:" /> -->
27+
<env name="MAIL_MAILER" value="array" />
28+
<env name="PULSE_ENABLED" value="false" />
29+
<env name="QUEUE_CONNECTION" value="sync" />
30+
<env name="SESSION_DRIVER" value="array" />
31+
<env name="TELESCOPE_ENABLED" value="false" />
3232
</php>
3333
</phpunit>

be/psalm.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
findUnusedCode="true"
1010
>
1111
<projectFiles>
12-
<directory name="app"/>
12+
<directory name="app" />
1313
<ignoreFiles>
14-
<directory name="vendor"/>
14+
<directory name="vendor" />
1515
</ignoreFiles>
1616
</projectFiles>
1717
<plugins>
18-
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
18+
<pluginClass class="Psalm\LaravelPlugin\Plugin" />
1919
</plugins>
2020
</psalm>

0 commit comments

Comments
 (0)