Skip to content

Add sniff to require use statements#342

Merged
othercorey merged 2 commits into
5.0from
othercorey-patch-1
Aug 28, 2021
Merged

Add sniff to require use statements#342
othercorey merged 2 commits into
5.0from
othercorey-patch-1

Conversation

@othercorey

Copy link
Copy Markdown
Contributor

@othercorey othercorey added this to the 5.0 milestone Aug 25, 2021
@dereuromark

Copy link
Copy Markdown
Member

You might want to exclude certain parts here, the downside would be otherwise that any ... const/func would autofix to use statement:

use const JSON_ERROR_NONE;

and we didn't decide yet to spam the use block with also constants, functions and CO :)
For now this should probably be limited to class/interface/trait references only.

@dereuromark

dereuromark commented Aug 25, 2021

Copy link
Copy Markdown
Member

It also blindly converts e.g.

// @see \...\TransferToEntityMapper::mapEntity()

into a use statement, also killing the original docblock..
which is just bonkers, that's a docblock and shouldn't be touched.
So I guess it has some small bugs that also need solving first.

I opened up a ticket for now slevomat/coding-standard#1265
But I would be careful with adding this one, as it can also effect projects or plugin code

@othercorey

Copy link
Copy Markdown
Contributor Author

I didn't see that happen in any of the type changes I made, but there's no rush while your issue is resolved.

@othercorey

Copy link
Copy Markdown
Contributor Author

Looks like the slevomat bug was patched. Is this ok now?

@ADmad

ADmad commented Aug 28, 2021

Copy link
Copy Markdown
Member

Don't want things like use const JSON_ERROR_NONE;.

@othercorey

Copy link
Copy Markdown
Contributor Author

Don't want things like use const JSON_ERROR_NONE;.

I believe that can be disabled with allowFallbackGlobalConstants

@othercorey othercorey merged commit e098e1f into 5.0 Aug 28, 2021
@othercorey othercorey deleted the othercorey-patch-1 branch August 28, 2021 19:34
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.

3 participants