Skip to content

Commit 7fa2a77

Browse files
committed
fix phpstan
1 parent a547c86 commit 7fa2a77

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

.github/workflows/CI.yaml

+21-21
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@ jobs:
6363
- name: Check source code for code style errors
6464
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --verbose --diff --dry-run
6565

66-
# phpstan:
67-
# name: 2️⃣ PHP 8.1 - PHPStan
68-
# runs-on: ubuntu-latest
69-
# needs:
70-
# - php_syntax_errors
71-
# steps:
72-
# - name: Checkout code
73-
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
74-
75-
# - name: Setup PHP
76-
# uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # 2.32.0
77-
# with:
78-
# php-version: 8.1
79-
# coverage: none
80-
# tools: phpstan
81-
82-
# - name: Install Composer dependencies
83-
# uses: ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # 3.1.0
84-
85-
# - name: Run PHPStan
86-
# run: vendor/bin/phpstan analyze
66+
phpstan:
67+
name: 2️⃣ PHP 8.4 - PHPStan
68+
runs-on: ubuntu-latest
69+
needs:
70+
- php_syntax_errors
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
74+
75+
- name: Setup PHP
76+
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # 2.32.0
77+
with:
78+
php-version: 8.4
79+
coverage: none
80+
tools: phpstan
81+
82+
- name: Install Composer dependencies
83+
uses: ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # 3.1.0
84+
85+
- name: Run PHPStan
86+
run: vendor/bin/phpstan analyze
8787

8888
tests:
8989
name: 2️⃣ PHP ${{ matrix.php-version }}

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ includes:
33
- vendor/lychee-org/phpstan-lychee/phpstan.neon
44

55
parameters:
6+
level: 3
67
paths:
78
- src
89
excludePaths:

src/Collection.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function linkNodes()
3737
$node->setRelation('parent', null);
3838
}
3939

40-
/** @var array<int,NodeModel> */
41-
$children = $groupedNodes->get($node->getKey(), []);
40+
/** @var array<int,NodeModel> */
41+
$children = $groupedNodes->get($node->getKey(), []); /** @phpstan-ignore varTag.type */
4242

4343
foreach ($children as $child) {
4444
$child->setRelation('parent', $node);
@@ -137,7 +137,7 @@ public function toFlatTree($root = false): Collection
137137
/** @var NodeModel */
138138
$first = $this->first();
139139
/** @var Collection<NodeModel> */
140-
$groupedNodes = $this->groupBy($first->getParentIdName());
140+
$groupedNodes = $this->groupBy($first->getParentIdName()); /** @phpstan-ignore varTag.type */
141141

142142
return $result->flattenTree($groupedNodes, $this->getRootNodeId($root)); /** @phpstan-ignore-line */
143143
}
@@ -153,7 +153,7 @@ public function toFlatTree($root = false): Collection
153153
protected function flattenTree(Collection $groupedNodes, $parentId): Collection
154154
{
155155
/** @var array<int,NodeModel> */
156-
$nodes = $groupedNodes->get($parentId, []);
156+
$nodes = $groupedNodes->get($parentId, []); /** @phpstan-ignore varTag.type */
157157
foreach ($nodes as $node) {
158158
$this->push($node);
159159

0 commit comments

Comments
 (0)