Closed llaville closed 4 months ago
Tests with https://github.com/llaville/php-compatinfo/releases/tag/7.1.3 on following source code.
<?php
class Test {
public function __construct(public readonly string $prop) {
}
}
analyser:run
command returns with console reporter
[OK] Requires PHP 8.0.0alpha1 (min)
and on details with rule reporter
Stats
-----
PHP 70 : 1 rule(s) found
PHP 80 : 1 rule(s) found
Rules
-----
code : CA7008
description : Parameters Type Declaration 'string' is available since PHP 7.0.0
sniff : ParamTypeDeclarationSniff
methods : (1)
Test\__construct
code : CA8003
description : Constructor property promotion is available since PHP 8.0.0
sniff : PropertyPromotionSniff
methods : (1)
Test\__construct
While CA8102
rule should also be detected
Verifications are now done. Closing this report
Bug report category
Summary
Constructor readonly properties not detected as a PHP 8.1 feature. Learn more with https://php.watch/versions/8.1/readonly#constructor-readonly
Expected behaviour
Detect constructor
readonly
properties withBartlett\CompatInfo\Application\Sniffs\Classes\ReadonlyPropertySniff
Actual behaviour
Only class property in AST (with
Node\Stmt\Property
) is analysed. Should also analyse in AST (the param list ofNode\FunctionLike
)