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

Unknown type hint #4

Open
ghost opened this issue Feb 28, 2023 · 3 comments
Open

Unknown type hint #4

ghost opened this issue Feb 28, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Feb 28, 2023

When referring to type hinting, our standards say:

When using type hinting on classes, it is recommended to specify the particular interface the class implements rather than the class name itself.

And the following example is given:

/**
 * First parameter must be an object implementing the OtherClassInterface.
 */
public function test(OtherClassInterface $otherClass) {
  echo $otherClass->var;
}

And yet our FunctionCommentSniff doesn't account for this: https://github.com/backdrop-ops/phpcs/blob/main/Backdrop/Sniffs/Commenting/FunctionCommentSniff.php#L697-L704 It only accounts for stdClass, object and mixed...

As such, I'm getting the following error on the following code:

Unknown type hint "FileTransfer" found for $filetransfer

function authorize_run_operation(FileTransfer $filetransfer) {
@ghost ghost added the bug Something isn't working label Feb 28, 2023
@indigoxela
Copy link
Collaborator

@BWPanda are you interested in becoming a co-maintainer?

@ghost
Copy link
Author

ghost commented Feb 28, 2023

Hmm, yes and no... I plan to start using phpcs a lot more, so it'd be good if I had maintainer access in order to fix problems as I found them. But then I have no idea how to write/fix sniff files... So not sure.

@indigoxela
Copy link
Collaborator

But then I have no idea how to write/fix sniff files...

Guess what, I'm no specialist, either. 😏 We all learn as we go.

I'm using my own projects (modules) as reference, to avoid throwing out nagging, that hasn't been there before - because some (like me) might use phpcs in their PR workflow. But that's also something we could discuss and eventually adapt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant