Describe the bug
Fatal error when a method has a line in DocBlock "@param $code" (Doctrine standard).
Fatal error: Uncaught TypeError: SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct(): Argument #5 ($contentNode) must be of type ?PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode, PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31
Stack trace:
thrown in /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php on line 31
Code sample
/**
* @param $code
*
* @return bool
*/
private function interpretStatus($code)
{
switch ($code) {
case '1':
case '2':
case '3':
case '4':
case '6':
return '1';
case '7':
case '9':
return '0';
}
return false;
}
Custom ruleset
To reproduce
Steps to reproduce the behavior:
Create a file called test.php with the code sample above...
Run phpcs --standard=Doctrine test.php ...
See error message displayed
PHPCS output here
Expected behavior
I'd expect to receive feedback on the sniffed file.
Versions (please complete the following information):
OS: [e.g., Windows 10, MacOS 10.15]
PHP: [e.g., 7.2, 7.4]
PHPCS: [e.g., 3.5.5, master]
Standard: [e.g., PSR2, PSR12, Squiz]
Additional context
Add any other context about the problem here.
Describe the bug Fatal error when a method has a line in DocBlock "@param $code" (Doctrine standard).
Fatal error: Uncaught TypeError: SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct(): Argument #5 ($contentNode) must be of type ?PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode, PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31 Stack trace:
0 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(357): SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation->__construct('@param', 14, 16, '$code', Object(PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode))
1 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/SniffLocalCache.php(42): SlevomatCodingStandard\Helpers\AnnotationHelper::SlevomatCodingStandard\Helpers{closure}()
2 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/SniffLocalCache.php(31): SlevomatCodingStandard\Helpers\SniffLocalCache::setIfNotCached(0, '/Users/kirilcve...', Object(Closure))
3 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php(372): SlevomatCodingStandard\Helpers\SniffLocalCache::getAndSetIfNotCached(Object(PHP_CodeSniffer\Files\LocalFile), 'annotations-9', Object(Closure))
4 /Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/ReferenceUsedNamesOnlySniff.php(680): SlevomatCodingStandard\Helpers\AnnotationHelper::getAnnotations(Object(PHP_CodeSniffer\Files\LocalFile), 9)
5 /Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/ReferenceUsedNamesOnlySniff.php(145): SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff->getReferences(Object(PHP_CodeSniffer\Files\LocalFile), 0)
6 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 0)
7 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
8 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php(628): PHP_CodeSniffer\Files\LocalFile->process()
9 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php(434): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
10 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
11 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
12 /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/bin/phpcs(120): include('/System/Volumes...')
13 {main}
thrown in /System/Volumes/Data/Users/kirilcvetkov/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php on line 31
Code sample
Custom ruleset
To reproduce Steps to reproduce the behavior:
test.php
with the code sample above...phpcs --standard=Doctrine test.php ...
Expected behavior I'd expect to receive feedback on the sniffed file.
Versions (please complete the following information):
Additional context Add any other context about the problem here.