Skip to content

Conversation

pwolanin
Copy link
Contributor

@pwolanin pwolanin commented Jun 6, 2019

See drupal.org #3059698

There is some related code already in squizlabs:

squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php

                if ($this->phpVersion >= 70200) {
                    if ($suggestedName === 'object') {
                        $suggestedTypeHint = 'object';
                    }
                }

@pwolanin pwolanin force-pushed the 3059698-object-typehint branch from dc6dcf6 to 3f5e5ca Compare June 6, 2019 14:41
Copy link
Collaborator

@klausi klausi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! I still think we should not do the PHP version checking, can you change this to always accept "object"?

if (PHP_VERSION_ID < 70200) {
return [
9 => 1,
14 => 1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not a good idea to have different test results per PHP version. Line 14 should never be flagged as error if the PHP type hint is object. We should just make "object" an acceptable type hint. People might run PHPCS on a lower PHP version and then get different results than on their CI or prod enviorinment. It is just an invitation for confusion.

@klausi
Copy link
Collaborator

klausi commented Jun 12, 2019

Committed a slightly different version, thanks!

@klausi klausi closed this Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants