-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[PSR12] Add return type sniff #2118
Conversation
3171ea0
to
c62ae88
Compare
Hello, I hope this gets merged soon. Or the other PR that you mentioned on the comment.. what ever. Personally neither on this PR or on the other I see tests related about nullable return types. I hope I didn't missed them. I believe related tests should exist. |
c62ae88
to
e4f7600
Compare
Just a note that the auto-fixer for this does not correctly fix nullable return types: $ cat temp.php
<?php
function this(): ?string
{
return null;
}
$ phpcs temp.php --standard=PSR12 --report=diff
--- temp.php
+++ PHP_CodeSniffer
@@ -1,5 +1,5 @@
<?php
-function this(): ?string
+function this():?string
{
return null;
} The error messages are also a bit strange as they try to show what the content should be rather than the standard way of saying how much spacing is required. I'll have a look at changing both these things. |
I've had a deeper look into this code and I'd basically need to write the sniff to make it work the way I would expect. I appreciate the work people have done on this, but the code style, method of checking spacing, var names, unit tests all need changing if I'm going to accept it into the core and maintain it from now on. I started to make those changes and realised it would be faster to rewrite the sniff and tests, but I don't have the time to do that so I've removed it from the 3.4.0 milestone. |
Hi @gsherwood since this PR was closed, but no activity on #1219 either since 2018, is there another PR where this is being worked on? |
Not that I know of. |
OK, I went with Slevomat for time being so I think that solves it for most cases. |
Following on from the amazing work done by @akvankorlaar in #1219 this PR: