Problem/Motivation

I've stumbled over the following inspection in the PHPStorm plugin "Php Inspections ​(EA Extended)​" called "promote ->willReturn*".

This points out PHPUnit MockObject ->expects()->will() which have $this->returnValue (and friends) as a stub and replaces them with ->expects()->willReturn() (and friends).

I think at the very least it improves readability.

Remaining tasks

  • Patch/MR
  • Review
  • Commit
  • Rejoice

Issue fork drupal-3220128

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

Spokje created an issue. See original summary.

spokje’s picture

Assigned: spokje » Unassigned
Status: Active » Closed (duplicate)

Ah, I knew I saw it somewhere but couldn't find it with the search! Thanks @mondrake!

mondrake’s picture

Status: Closed (duplicate) » Active

Nono, that one does not address this... this is a followup to that, rather. Work still to do :)

spokje’s picture

Ah, misunderstood (again!) Thanks @mondrake (again! :)

spokje’s picture

Title: ->willReturn(...) would make more sense here (and friends) » [PP-1]->willReturn(...) would make more sense here (and friends)
Assigned: Unassigned » spokje

Postponed until [##3217717] gets committed, to prevent double work.

spokje’s picture

Status: Active » Postponed
spokje’s picture

Title: [PP-1]->willReturn(...) would make more sense here (and friends) » ->willReturn(...) would make more sense here (and friends)
Status: Postponed » Needs work
mondrake’s picture

mondrake’s picture

Status: Needs work » Active
spokje’s picture

Status: Active » Needs work

@mondrake (and others): Any idea on how to scope this one?

If we try to do this all in one patch we're looking at a huge one (although negative in lines count).
Splitting off all more specific willReturn(...) (like willReturnMap() in one sub-issue (there aren't much of them) can be a start.

But even after that only the willReturn() ones will still be huge (read HUGE).

longwave’s picture

We could either convert this to a meta, get willReturnMap in first and then figure out scoping for the rest, or accept this will be a disruptive patch and schedule it for the next beta window (mid November).

spokje’s picture

As much as I don't like it, I think @longwave is right:

- Split off all the little ones like willReturnMap into a sub-issue, so those can get in.
- Make this one, with the only remaining willReturns, a "disruptive patch" for 9.4-beta

spokje’s picture

Title: ->willReturn(...) would make more sense here (and friends) » [META] ->willReturn(...) would make more sense here (and friends)
Status: Needs work » Postponed

Let's make this a [meta] (for now) and make a sub-issue to get all "friends" except ->willReturn itself in first.

I highly doubt this will make a big enough dent into this (currently) 450KB patch to make this a non-disruptive patch, but at least we'll be able to get something in before we get to 9.4-beta.

spokje’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

spokje’s picture

Assigned: spokje » Unassigned

immaculatexavier’s picture

Assigned: Unassigned » immaculatexavier
spokje’s picture

@immaculatexavier: Thanks for wanting to work on this, but this is a [META] issue, all the work is done in the child issues.

immaculatexavier’s picture

Assigned: immaculatexavier » Unassigned

Okay @Spokje. I am unassigning.

spokje’s picture

Status: Active » Fixed

Closing this [META] since all sub-issues are committed now.

Status: Fixed » Closed (fixed)

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