Php_codesniffer: Error! Method does not have parameter type hint for its parameter

Created on 16 Aug 2018  路  5Comments  路  Source: squizlabs/PHP_CodeSniffer

Hi,
I was Overriding postPersist method, in it's original definition it doesn't have any type hinting so I can't add any type hint to it.
I get an error because it's missing the type hint, so I tried to add typehint in phpDoc and it still getting me an error that my Method does not have parameter type hint for its parameter
type

Most helpful comment

I don't think these errors are coming from any included PHPCS sniffs. Can you please run PHPCS with the -s command line argument to show which sniff is generating the error. If it is a custom sniff, you'll need to report the issue to the creator of that sniff. But if it is an included sniff, I can look into it.

All 5 comments

I don't think these errors are coming from any included PHPCS sniffs. Can you please run PHPCS with the -s command line argument to show which sniff is generating the error. If it is a custom sniff, you'll need to report the issue to the creator of that sniff. But if it is an included sniff, I can look into it.

when I run it with -s I've got no error about typehinting

when I run it with -s I've got no error about typehinting

The -s command doesn't change any behaviour - it only adds an error code to the reports - so I'm not sure why you would get different results.

Try --report=source instead and see if that helps. If you have a 3.x version of PHPCS, add --no-cache as well just to be sure.

that's what I get
phpdoc

Thanks. That tells me that your error is coming from a custom sniff if the Slevmoat standard. You'll need to go and report this error over there as it is not something being generated by PHPCS itself or an included sniff.

The repo is here: https://github.com/slevomat/coding-standard

Thanks for running those tests for me.

Was this page helpful?
0 / 5 - 0 ratings