Page MenuHomeDevCentral

Add missing parameters return type of each function
ClosedPublic

Authored by DorianWinty on May 27 2022, 20:54.
Tags
None
Referenced Files
F3747103: D2706.id7412.diff
Sat, Nov 16, 00:37
Unknown Object (File)
Tue, Nov 12, 14:59
Unknown Object (File)
Tue, Nov 12, 11:57
Unknown Object (File)
Tue, Nov 12, 04:01
Unknown Object (File)
Mon, Nov 11, 20:17
Unknown Object (File)
Mon, Nov 11, 12:25
Unknown Object (File)
Thu, Nov 7, 13:19
Unknown Object (File)
Sun, Nov 3, 21:07
Subscribers
None

Details

Summary

Some return type of function are missing.

Diff Detail

Repository
rNOTIF Notifications center
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningapp/Providers/RouteServiceProvider.php:24PHPCS.W.Generic.CodeAnalysis.UselessOverridingMethod.FoundGeneric.CodeAnalysis.UselessOverridingMethod.Found
Unit
Tests Passed
Branch
useRtnType

Event Timeline

app/Analyzers/DockerHub/BuildFailureEvent.php
22

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
68

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.

70

+ use Traversable;

276

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 ↗(On Diff #6890)

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 ↗(On Diff #6890)

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.