Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeHints.UnionTypeHintFormat seems to crash #1664

Closed
ghnp5 opened this issue Feb 16, 2024 · 3 comments
Closed

TypeHints.UnionTypeHintFormat seems to crash #1664

ghnp5 opened this issue Feb 16, 2024 · 3 comments
Labels

Comments

@ghnp5
Copy link

ghnp5 commented Feb 16, 2024

If I enable this sniff:

	<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
		<properties>
			<property name="enable" value="yes"/>
			<property name="shortNullable" value="yes"/>
		</properties>
	</rule>

I get this crash:

2024-02-16 07:38:35.992 [error] Error: { "vscodeOptions": { "tabWidth": 1 }, "result":
PHP Fatal error: Uncaught TypeError: SlevomatCodingStandard\Helpers\SniffSettingsHelper::isEnabledByPhpVersion(): Argument #1 ($value) must be of type ?bool, string given, called in F:\xxx\vendor\slevomat\coding-standard\SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff.php on line 70 and defined in F:\xxx\vendor\slevomat\coding-standard\SlevomatCodingStandard\Helpers\SniffSettingsHelper.php:80
Stack trace:
#0 F:\xxx\vendor\slevomat\coding-standard\SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff.php(70): SlevomatCodingStandard\Helpers\SniffSettingsHelper::isEnabledByPhpVersion()
#1 F:\xxx\vendor\squizlabs\php_codesniffer\src\Files\File.php(518): SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff->process()
#2 F:\xxx\vendor\squizlabs\php_codesniffer\src\Runner.php(632): PHP_CodeSniffer\Files\File->process()
#3 F:\xxx\vendor\squizlabs\php_codesniffer\src\Runner.php(438): PHP_CodeSniffer\Runner->processFile()
#4 F:\xxx\vendor\squizlabs\php_codesniffer\src\Runner.php(116): PHP_CodeSniffer\Runner->run()
#5 F:\xxx\vendor\squizlabs\php_codesniffer\bin\phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#6 F:\xxx\vendor\bin\phpcs(119): include('...')
#7 {main}
thrown in F:\xxx\vendor\slevomat\coding-standard\SlevomatCodingStandard\Helpers\SniffSettingsHelper.php on line 80

at executeCommand (c:\Users\xxx.vscode\extensions\wongjn.php-sniffer-1.3.0\lib\cli.js:151:29)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.phpcs (c:\Users\xxx.vscode\extensions\wongjn.php-sniffer-1.3.0\lib\runner.js:159:22)

Thank you.

@kukulich
Copy link
Contributor

value="yes" is not valid value for boolean options.

@ghnp5
Copy link
Author

ghnp5 commented Feb 16, 2024

value="yes" is not valid value for boolean options.

What should be the value, then? It's not clear in the documentation, and you're not being clear here either.

enable: either to enable or not this sniff. By default, it is enabled for PHP versions 8.0 or higher.

@ghnp5
Copy link
Author

ghnp5 commented Mar 10, 2024

Thank you very much for the answer 👍🏼

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants