Problem/Motivation

From #3575324: Add return type documentation to ResourceTestBase

We want to add @return void to inform humans and PHPStan that a method should not return a value, but we cannot add an actual return type yet because downstream code needs to update first.

However, just adding @return void results in MissingReturnComment from FunctionCommentSniff: "Description for the @return value is missing", so we need to add a somewhat pointless description of "Returns nothing."

Steps to reproduce

Proposed resolution

Allow a missing description if the @return type is void.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork coder-3575389

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

klausi’s picture

Hm, I think you should not document return void, right? The coding standards say "Functions without return values must not have @return documentation.". https://project.pages.drupalcode.org/coding_standards/php/documentation/...

Ah I see, you want to do it for PHPStan ... I agree that the coding standards sentence does not make sense anyway, let people document that a functions returns void, by all means.

So I think we can do this!

longwave’s picture

This will also help with #3486376: Extend Symfony DebugClassLoader to report missing cross-module @return types where @return void in core will notify modules that they should add void return types and that core intends to in the future.

  • klausi committed 9fcf1a15 on 9.x
    feat(FunctionComment): Allow omitting return description for the void...
klausi’s picture

Version: 8.3.x-dev » 9.x-dev
Status: Active » Fixed

Merged, thanks for reporting!

I'm not planning to release this on Coder 8, let me know if you need it there. But I think Drupal core can just upgrade to Coder 9.

I'm also planning to release Coder 9.0 soon.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

klausi’s picture

Component: Coder Sniffer » Code

Actually released Coder 9.0.0 now - happy upgrading!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.