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
Branch
phpdocCanReturnNull
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 1565
Build 1565: arc lint + arc unit

Unit TestsFailed

TimeTest
689 msArcanistBundleTestCase::testGitRepository
EXCEPTION (Exception): Expected patch and actual patch for 5dec8bf28557f078d1987c4e8cfb53d08310f522 differ. Wrote actual patch to '/var/www/html/phorge/arcanist/src/parser/__tests__/patches//5dec8bf28557f078d1987c4e8cfb53d08310f522.gitpatch.real'. #0 /var/www/html/phorge/arcanist/src/parser/__tests__/ArcanistBundleTestCase.php(85): ArcanistBundleTestCase->runGitRepositoryTests(Object(PhutilDirectoryFixture)) #1 /var/www/html/phorge/arcanist/src/unit/engine/phutil/PhutilTestCase.php(639): ArcanistBundleTestCase->testGitRepository()
76 msAbstractDirectedGraphTestCase::testCyclicGraph
1 assertion(s) passed.
76 msAbstractDirectedGraphTestCase::testEdgeLoadFailure
1 assertion(s) passed.
76 msAbstractDirectedGraphTestCase::testNonTreeGraph
1 assertion(s) passed.
76 msAbstractDirectedGraphTestCase::testNoncyclicGraph
1 assertion(s) passed.
View Full Test Results (1 Failed · 210 Passed)

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

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.