Change record: Data types must be compliant with the PHPDoc Type syntax as documented by PHPStan

While I think most or all of the types we use should still be compliant, we definitely have a lot of potential for improvement where we use, e.g., array or string[] but more specific types could be used and would certainly help developers working with this module.

Issue fork search_api-3539930

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

drunken monkey created an issue. See original summary.

neerajsingh made their first commit to this issue’s fork.

neerajsingh’s picture

Status: Active » Needs review

Created a MR with, updates to doc comments for array. This needs to be reviewed for any further data type updates.

drunken monkey’s picture

Thanks, that’s a great start!
However, just looking at Index and IndexInterface I saw a bunch of more places where types were too unspecific (and even found a bug, #3541714: Fix Index::setProcessors() to not assume $processors is keyed by plugin ID, though that‘s beside the point). Not really sure how we can get close to a complete MR for this. Seems like a ton of work, and very hard to review and validate. But just doing this piecemeal is also a bit unsatisfactory (and hard to not lose track).

Suggestions are welcome.

drunken monkey’s picture

Status: Needs review » Fixed

Cleaned up the rest of Index and IndexInterface and then just merged this as a first step.

Judging by git grep -lE '@(param|var|return) (array( |$)|.*\[\])', there are now still 178 files with … 623 (potentially) suboptimal type hints left. I think form or render arrays can probably keep the simple array type hint, but probably there’s no other place where we cannot improve this (or TYPE[]) to array<KEY_TYPE, TYPE> or list<TYPE>.

So, maybe child issues for separate batches of these files, or maybe based on parent directory? What would be a good batch size?
I don’t want to divide this too finely and just create a huge flood of contrib credits, but it is tedious work and I don’t think anyone is willing to create or review a single MR for 50 files of this.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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