Skip to content

Commit

Permalink
Fix docblocks for all to show that they are expected to receive an
Browse files Browse the repository at this point in the history
array of things
  • Loading branch information
Richard Quadling authored and Richard Quadling committed Oct 10, 2019
1 parent d4207ed commit 4fd15cd
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 88 deletions.
4 changes: 4 additions & 0 deletions bin/MethodDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private function generateMethodDocs($methods, $format, $skipParameterTest, $pref
}
}

if ($prefix === 'all' && strpos($type, 'null') === false && $parameterIndex === 0) {
$type = str_replace('|', '[]|', $type).'[]';
}

if ($prefix === 'nullOr' && strpos($type, 'null') === false && $parameterIndex === 0) {
$type .= '|null';
}
Expand Down
Loading

2 comments on commit 4fd15cd

@bendavies
Copy link

@bendavies bendavies commented on 4fd15cd Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rquadling can you please consider reverting this. [] is always an array but these methods accept anything that is \Traversable. This change triggers errors in psalm and phpstan when passing anything that is not a plain array to any all* method.

@bendavies
Copy link

@bendavies bendavies commented on 4fd15cd Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rquadling rather, all of these docblocks should be array|\Traversable

Please sign in to comment.