Page MenuHomePhorge

Correct PHPDoc @return value of methods that can return null
ClosedPublic

Authored by aklapper on Sat, Aug 24, 20:41.

Details

Summary

Make the PHPDoc @return say so when the method can also return null instead of an, array, string, or int.
(In case of getCommandHelp(), return an empty string as child implementations do return strings.)

Test Plan

Read the code; run static code analysis.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper retitled this revision from Correct PHPDoc @return value that method can return null to Correct PHPDoc @return value of methods that can return null.Sun, Aug 25, 12:47
src/workflow/ArcanistWorkflow.php
293 ↗(On Diff #2424)

I agree but probably we should update also something else, like this check that originally was a "not empty, not null, not objects without a toString()" check and instead now it's just "not null":

https://we.phorge.it/source/arcanist/browse/master/src/workflow/ArcanistWorkflow.php;995072b31fff5c7d77bcb353d25df819bfd3798a$157

(that line was changed during b50a646a3f49)

The question may be: is there any Workflow out of there without an help command?

If the answer is "maybe yes" let's update ArcanistWorkflow.php and adopt:

  • phutil_nonempty_stringlike() - if an help may return an object with __toString() (that renders text?)
  • phutil_nonempty_string() - if we are sure that it only returns null + string

Leave out special case src/workflow/ArcanistWorkflow.php for now

@valerio.bozzolan: Let's please move that case to a separate issue - thanks! :)

This revision is now accepted and ready to land.Thu, Sep 5, 12:10
This revision was landed with ongoing or failed builds.Thu, Sep 5, 12:55
This revision was automatically updated to reflect the committed changes.