Skip to content

Commit 77dfe38

Browse files
Support (void) cast from PHP 8.5 (#336)
Co-authored-by: Jan Nedbal <[email protected]>
1 parent fa4054b commit 77dfe38

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: Setup PHP
2020
uses: shivammathur/setup-php@v2
2121
with:
22-
php-version: 8.4
22+
php-version: 8.5
2323
-
2424
name: Install dependencies
2525
run: composer install --no-progress --prefer-dist --no-interaction
@@ -34,7 +34,7 @@ jobs:
3434
fail-fast: false
3535
matrix:
3636
os: [ ubuntu-latest, windows-latest ]
37-
php-version: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
37+
php-version: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
3838
dependency-version: [ prefer-lowest, prefer-stable ]
3939
steps:
4040
-

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ includes:
1111
parameters:
1212
phpVersion:
1313
min: 70400
14-
max: 80499
14+
max: 80599
1515
internalErrorsCountLimit: 1
1616
paths:
1717
- src

src/Rule/ForbidCastRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use PhpParser\Node\Expr\Cast\Object_;
1313
use PhpParser\Node\Expr\Cast\String_;
1414
use PhpParser\Node\Expr\Cast\Unset_;
15+
use PhpParser\Node\Expr\Cast\Void_;
1516
use PHPStan\Analyser\Scope;
1617
use PHPStan\Rules\IdentifierRuleError;
1718
use PHPStan\Rules\Rule;
@@ -96,6 +97,10 @@ private function getCastString(Cast $node): string
9697
return '(unset)';
9798
}
9899

100+
if ($node instanceof Void_) {
101+
return '(void)';
102+
}
103+
99104
throw new LogicException('Unexpected Cast child: ' . get_class($node));
100105
}
101106

tests/Rule/data/ForbidCastRule/code.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ function test(
1212
(string) $mixed;
1313
(float) $mixed;
1414
(bool) $mixed;
15+
(void) $mixed;
1516
}

0 commit comments

Comments
 (0)