Page MenuHomePhorge

Add missing ArcanistWorkflow::runWorkflow method
ClosedPublic

Authored by amybones on Fri, May 30, 23:37.

Details

Summary

No definition of runWorkflow existed in ArcanistWorkflow, now it does and
now phpStan is happier. This also needed to correct the visibility of the phage
workflow.

Test Plan

See no more type errors in your IDE.

Additionally, try some workflows and see no regressions:

  • arc anoid: still works (yeeeh)
  • arc browse: still works e.g.
  • arc look: still works "You stand in the middle of the forest"
  • arc look remotes: still works: "At the far edge of the grove, you see remotes: origin"
  • arc shell: still works, your ~/profile is updated
  • arc lint: introduce a tab somewhere, still works
  • arc unit: still works; plus, break a unit test assertion (e.g. in ./src/__tests__/PhutilLibraryTestCase.php), the error is still reported
  • arc patch: still works; e.g. on top of this patch you run arc patch D26041 and it still works
  • arc land: we haven't tested this specific point but the author of this patch will land this patch sooner or later :^)

Diff Detail

Repository
rARC Arcanist
Branch
arc_run_workflow
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 2072
Build 2072: arc lint + arc unit

Event Timeline

Get rid of coverage errors :)

(This seems nice) Small question: Does it still work for you keeping the method as protected instead of public?

aklapper subscribed.

Running phpstan analyse, before this patch I get Call to an undefined method ArcanistWorkflow::runWorkflow(), after this patch I get Method ArcanistWorkflow::runWorkflow() invoked with 1 parameter, 0 required, both in src/workflow/ArcanistWorkflow.php:227. That looks like an improvement indeed.

(This seems nice) Small question: Does it still work for you keeping the method as protected instead of public?

Keeping it protected will throw Protected method PhageExecWorkflow::runWorkflow() overriding public method ArcanistWorkflow::runWorkflow() should also be public.

This revision is now accepted and ready to land.Sat, May 31, 11:56

Keeping it protected will throw Protected method PhageExecWorkflow::runWorkflow() overriding public method ArcanistWorkflow::runWorkflow() should also be public.

Exactly what I mean: this patch introduced a public method, but what about just introducing a protected method? and rollback src/phage/workflow/PhageExecWorkflow.php

Keeping it protected will throw Protected method PhageExecWorkflow::runWorkflow() overriding public method ArcanistWorkflow::runWorkflow() should also be public.

Exactly what I mean: this patch introduced a public method, but what about just introducing a protected method? and rollback src/phage/workflow/PhageExecWorkflow.php

Hmm.. I'm not totally sure that it makes sense to convert things to protected. Because phage is the only one defining the method as protected. An example
is here ArcanistLiberateWorkflow. I'm happy to switch everything over to protected but that's a larger change that will require more validation.

Running phpstan analyse, [...] Method ArcanistWorkflow::runWorkflow() invoked with 1 parameter, 0 required, both in src/workflow/ArcanistWorkflow.php:227. That looks like an improvement indeed.

Oh, I completely missed that error when I ran phpStan myself. I think probably it makes sense to update this diff to add that argument everywhere. Since that's the case, I retract my assessment about converting things to protected and will do that as well ๐Ÿ™‚

Update signature to protected and add missing argument everywhere.

This also add a doc signature so that it's known you're supposed to return an exit code from runWorkflow. I have not made any workflow that wasn't already doing this, do it.

To test this, I ran every workflow's help. This is not a complete test, but since all of the commands loaded successfully and printed help, this is likely sufficient testing. I have also done my best to confirm that runWorkflow is not called from anywhere but ArcanistWorkflow.

This revision is now accepted and ready to land.Mon, Jun 2, 23:20
amybones requested review of this revision.Mon, Jun 2, 23:21

(You are soo fast woow)

Thanks to your last change you highlighted that (apparently) nothing reads that argument runWorkflow(PhutilArgumentParser $args).

Checked from master:

grep -RF -- 'runWorkflow(' .
./src/toolset/workflow/ArcanistVersionWorkflow.php:  public function runWorkflow() {
./src/toolset/workflow/ArcanistAliasWorkflow.php:  public function runWorkflow() {
./src/toolset/workflow/ArcanistPromptsWorkflow.php:  public function runWorkflow() {
./src/toolset/workflow/ArcanistShellCompleteWorkflow.php:  public function runWorkflow() {
./src/phage/workflow/PhageExecWorkflow.php:  protected function runWorkflow() {
./src/workflow/ArcanistLandWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistDownloadWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistAnoidWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistLookWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistPasteWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistUpgradeWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistWorkflow.php:      $err = $this->runWorkflow($args);
./src/workflow/ArcanistCallConduitWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistMarkersWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistUploadWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistLiberateWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistWeldWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistInspectWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistAmendWorkflow.php:  public function runWorkflow() {
./src/workflow/ArcanistWorkWorkflow.php:  public function runWorkflow() {
./src/browse/workflow/ArcanistBrowseWorkflow.php:  public function runWorkflow() {

Given this situation, and if you kindly confirm since you explored this better than us lol, it seems to me that the root problem could be in the caller of ->runWorkflow($args), in fact see the first and the last highlighted lines:

https://we.phorge.it/source/arcanist/browse/master/src/workflow/ArcanistWorkflow.php;c739de1ef2f5598d34e0f02f046ea040a33133e7$221-227

So, premising that children classes are (probably) just reading these arguments by doing $this->getArgument() - that works thanks to line 221 already highlighted,

So:

  • keeping the method as protected
  • fixing the public methods, making them protected
  • ArcanistWorkflow.php: editing the new definition to be just runWorkflow() without arguments
  • ArcanistWorkflow.php: editing the caller to be ->runWorkflow()
  • restoring the introduction of the new argument where missing

What do you think about?

Additionally, this suggestion causes less code to be touched

src/workflow/ArcanistWorkflow.php
268

Maybe this? if nothing reads this argument, we can suppress it

(about my last phrase I just mean we can have everywhere protected function runWorkflow() and we can avoid to introduce the argument - so for example we could rollback the file PhageExecWorkflow.php ๐Ÿคฏ ๐Ÿคฏ ๐Ÿคฏ lol )

I personally think having the arguments passed into runWorkflow makes a bit more organizational sense (in that I have a horrible functional programming streak that says use arguments for everything lmao), but it does somewhat leak an abstraction by committing more to a particular argument parsing interface, which looks to have been part of the problem with the previous approach (using an array for arguments).

So, I'm happy to rollback adding the argument (and this time I'll wait a little longer before doing it hahahah!) However, I will say that it won't actually touch that much less code, since basically every method except PhageExecWorkflow was a public method rather than protected.

I'm not sure what you mean by:

[..snip..]

  • restoring the introduction of the new argument where missing

Can you clarify?

src/browse/workflow/ArcanistBrowseWorkflow.php
61

Can you clarify?

Sorry I just mean this, to keep this private, but we can avoid to introduce PhutilArgumentParser $unused.

src/workflow/ArcanistWorkflow.php
221

๐Ÿ‘€ Nice. We already have these args.

228

We can drop this argument ๐Ÿ˜Ž

amybones added inline comments.
src/browse/workflow/ArcanistBrowseWorkflow.php
61

ah, I understand now. Yes.

amybones marked an inline comment as done.

Okay. Let's drop the argument :)

One last cheeky improvement: add type hint to $arguments so that it's not inferred to be never when it's conditionally checked with is_array.

I've followed again the test plan (but arc land) and everything works, especially "arc anoid". Arc anoid keeps all my damn infrastructure up and running 24/7 so this patch can be approved.

With your next "arc land" you will conclude the test plan successfully. Thaaanks

This revision is now accepted and ready to land.Fri, Jun 6, 20:29