Skip to content

Reconsider the CS rule for returning null in functions #17201

Closed
@stof

Description

@stof

currently, our CS mandate to use return; to return null from a function.

But there is 2 different cases actually:

  • a function without any return value (returning void), for which return; makes sense
  • a function returning something or null, for which return null; would be more meaningful

The original discussion said that PHP had no concept of void and so that our CS should not distinguish these 2 cases (and so should have a single rule). But PHP 7.1 now has such concept: https://wiki.php.net/rfc/void_return_type

I think we should revisit this rule in our coding standards, to distinguish functions returning void and functions returning something or null.

what do you think ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions