Moxio / php-codesniffer-sniffs

Custom sniffs for PHP_CodeSniffer
MIT License
17 stars 10 forks source link

Add base64_decode to the list of functions with a strict parameter #5

Closed dheineman closed 5 years ago

aboks commented 5 years ago

Thank you for your contribution!

I think this is a really useful addition. Personally I did not even know that base64_decode had a $strict-parameter, and given that the default behavior is not always desirable it makes sense to require an explicit 'opt-in' tot that.

I do think that this does not really fit into DisallowImplicitLooseComparisonSniff, as it is not actually about comparison of values. A separate sniff for this should only take a few lines though (see e.g. https://github.com/Moxio/php-codesniffer-sniffs/blob/master/Moxio/Sniffs/PHP/DisallowImplicitMicrotimeAsStringSniff.php), and will be even simpler than DisallowImplicitLooseComparisonSniff, which deals with variable numbers of parameters. What do you think about adding this as a separate DisallowImplicitLooseBase64DecodeSniff or something similar?

dheineman commented 5 years ago

Moving the base64_decode check to its own sniff makes sense. I updated the PR.

aboks commented 5 years ago

Thanks again! I merged the PR and released version 1.5.0 with this sniff.