Skip to content

Commit

Permalink
* manually ignore vendor & bootstrap/cache when running phpcs as …
Browse files Browse the repository at this point in the history
…it doesn't support using `.gitignore`: squizlabs/PHP_CodeSniffer#2242 @ .github/workflows/be_base.yml

* fix all violation of PHPStorm inspection `Unnecessary fully qualified name` @ be
  • Loading branch information
n0099 committed Sep 15, 2024
1 parent 37dbe24 commit 6edb5c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/be_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/be
# https://github.com/staabm/annotate-pull-request-from-checkstyle
- run: >
./vendor/bin/phpstan analyse --error-format=checkstyle
| tee >(cs2pr --notices-as-warnings --graceful-warnings --prepend-filename --prepend-source)
# https://github.com/staabm/annotate-pull-request-from-checkstyle
shell: bash
psalm:
Expand All @@ -36,7 +36,8 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/be
- id: run
run: ./vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml .
# https://github.com/squizlabs/PHP_CodeSniffer/issues/2242
run: ./vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml --ignore=vendor/*,bootstrap/cache/* .
- if: always() && steps.run.outcome == 'failure'
run: cs2pr --notices-as-warnings --graceful-warnings --prepend-filename --prepend-source ./phpcs-report.xml

Expand Down Expand Up @@ -65,4 +66,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/be
- run: ./vendor/bin/phpmd . github cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor # https://github.com/phpmd/phpmd/issues/506
# https://github.com/phpmd/phpmd/issues/506
- run: ./vendor/bin/phpmd . github cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor
8 changes: 4 additions & 4 deletions be/app/Http/PostsQuery/BaseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function reOrderNestedPosts(Collection $nestedPosts): array
* @param string $childPostTypePluralName
* @return Collection<int, Collection<string, mixed|Collection<int, Collection<string, mixed>>>>
*/
$setSortingKeyFromCurrentAndChildPosts = function (Collection $curPost, string $childPostTypePluralName): \Illuminate\Support\Collection {
$setSortingKeyFromCurrentAndChildPosts = function (Collection $curPost, string $childPostTypePluralName): Collection {
/** @var Collection<int, Collection<string, mixed>> $childPosts sorted child posts */
$childPosts = $curPost[$childPostTypePluralName];
$curPost[$childPostTypePluralName] = $childPosts->values(); // reset keys
Expand Down Expand Up @@ -394,12 +394,12 @@ public function reOrderNestedPosts(Collection $nestedPosts): array

return $curPost;
};
$sortBySortingKey = fn(Collection $posts): \Illuminate\Support\Collection => $posts
$sortBySortingKey = fn(Collection $posts): Collection => $posts
->sortBy(fn(Collection $i) => $i['sortingKey'], descending: $this->orderByDesc);
$removeSortingKey = /**
* @psalm-return \Illuminate\Support\Collection<array-key, \Illuminate\Support\Collection>
* @psalm-return Collection<array-key, Collection>
*/
static fn(Collection $posts): \Illuminate\Support\Collection => $posts
static fn(Collection $posts): Collection => $posts
->map(fn(Collection $i) => $i->except('sortingKey'));
$ret = $removeSortingKey($sortBySortingKey(
$nestedPosts->map(
Expand Down
8 changes: 3 additions & 5 deletions be/app/Http/PostsQuery/IndexQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ public function query(QueryParams $params, ?string $cursor): self
->selectRaw("{$fid} AS fid, COUNT(*) AS count")
->where($postIDName, $postID))
->reduce(/**
* @return \Illuminate\Contracts\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*
* @psalm-return \Illuminate\Contracts\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Query\Builder
* @return BuilderContract|EloquentBuilder|QueryBuilder
* @psalm-return BuilderContract|EloquentBuilder<\Illuminate\Database\Eloquent\Model>|QueryBuilder
*/
static fn(?BuilderContract $acc, EloquentBuilder|QueryBuilder $cur): \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Contracts\Database\Query\Builder =>
$acc === null ? $cur : $acc->union($cur),
static fn(?BuilderContract $acc, EloquentBuilder|QueryBuilder $cur): EloquentBuilder|QueryBuilder|BuilderContract => $acc === null ? $cur : $acc->union($cur),
)
->get()
->where('count', '!=', 0);
Expand Down

0 comments on commit 6edb5c3

Please sign in to comment.