Page MenuHomeDevCentral

Add missing parameters return type of each function
ClosedPublic

Authored by DorianWinty on May 27 2022, 20:54.
Tags
None
Referenced Files
F2741784: D2706.diff
Thu, Mar 28, 02:08
F2741326: D2706.id6890.diff
Thu, Mar 28, 00:25
F2740038: D2706.id6890.diff
Wed, Mar 27, 19:44
F2739709: D2706.id7412.diff
Wed, Mar 27, 16:47
Unknown Object (File)
Wed, Mar 27, 03:55
Unknown Object (File)
Sat, Mar 23, 22:49
Unknown Object (File)
Fri, Mar 22, 10:48
Unknown Object (File)
Fri, Mar 22, 02:35
Subscribers
None

Details

Summary

Some return type of function are missing.

Diff Detail

Repository
rNOTIF Notifications center
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

app/Analyzers/DockerHub/BuildFailureEvent.php
20–21

When the only goal of @return is to give the type, we can remove them. The old phpdoc is now useless as we say the same thing directly in PHP code.

app/Analyzers/GitHub/Events/IssueCommentEvent.php
16

Here we can keep it because it gives extra info than just @return bool

app/Phabricator/PhabricatorStory.php
282

The documentation states @return string[], that's a hint we'll always return an array.

if $this->projects is null we call the attachProjects method. That method will assign a value [] at the first step, so we've an array to return.

app/Phabricator/ProjectsMap.php
66–67

According PHP documentation:

  1. class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable
  2. interface SeekableIterator extends Iterator
  3. interface Iterator extends Traversable

So an instance of the class ArrayIterator is a Traversable.

By documenting only Traversable, we only allow code calling this method to use foreach, and we keep the right to implement our iterator as we want.

68

+ use Traversable;

268

We can express the idea of array of arrays like this (in doc, not in PHP code).

DorianWinty marked 6 inline comments as done.

remove useless @return in phpDocs

dereckson requested changes to this revision.Sep 25 2022, 23:14

Return types are correct

phpdoc can be improved

app/Config/Reporting/ConfigReport.php
48 ↗(On Diff #6890)

This is used by static analysers (like phan) and IDEs to provide more information than just an array.

Hunt [] removal and restore them.

app/Console/Commands/ConfigShow.php
52

For example, that one could be good to remove, as we don't know what's in this array.

But we can also correctly document it, could be better to replace it by return foo[] where foo is the return value of $feature->toFancyArray()

app/Console/Commands/NotificationsPayload.php
220

https://www.php.net/manual/en/class.reflectionparameter.php

public getName(): string

So the return value will be string[]

app/Http/Controllers/Gate/GateController.php
108

Keep it

This revision now requires changes to proceed.Sep 25 2022, 23:14
DorianWinty marked 4 inline comments as done.

restore array phpDocs

This revision is now accepted and ready to land.Mar 25 2023, 11:36
This revision was landed with ongoing or failed builds.Mar 25 2023, 11:37
This revision was automatically updated to reflect the committed changes.