Skip to content

Enhancement: Enable void_return fixer - #661

Merged
kamil-tekiela merged 2 commits into
php:masterfrom
localheinz:feature/void-return
Dec 5, 2023
Merged

Enhancement: Enable void_return fixer#661
kamil-tekiela merged 2 commits into
php:masterfrom
localheinz:feature/void-return

Conversation

@localheinz

@localheinzlocalheinz commented Jul 15, 2022

Copy link
Copy Markdown
Contributor

This pull request

  • enables the (risky) void_return fixer
  • runs make coding-standards

Follows #559.

💁‍♂️ For reference, see https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v3.4.0/doc/rules/function_notation/void_return.rst.

@localheinz
localheinz marked this pull request as ready for review July 15, 2022 11:31
Comment threadsrc/UserNotes/Sorter.php Outdated
private $ageWeight = 2;

public function sort(array &$notes) {
public function sort(array &$notes): void {

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The method does not return anything.

publicfunctionsort(array &$notes) {
// First we make a pass over the data to get the min and max values
// for data normalization.
$this->findMinMaxValues($notes);
$this->voteFactor = $this->maxVote - $this->minVote
? (1 - .3)/ ($this->maxVote - $this->minVote)
: .5;
$this->ageFactor = $this->maxAge - $this->minAge
? 1 / ($this->maxAge - $this->minAge)
: .5;
$this->ageFactor *= $this->ageWeight;
// Second we loop through to calculate sort priority using the above numbers
$this->calcSortPriority($notes);
// Third we sort the data.
uasort($notes, array($this, 'factorSort'));
}

Comment threadsrc/UserNotes/Sorter.php Outdated
Comment threadsrc/UserNotes/Sorter.php Outdated
}

private function findMinMaxValues(array &$notes) {
private function findMinMaxValues(array &$notes): void {

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The method does not return anything.

privatefunctionfindMinMaxValues(array &$notes) {
$count = count($notes);
if ($count <= 0) {
return;
}
$note = array_shift($notes);
$note['score'] = $net = ($note['votes']['up'] - $note['votes']['down']);
$note['total'] = $totalVotes = ($note['votes']['up'] + $note['votes']['down']);
$note['rating'] = $totalVotes > 0
? $note['votes']['up'] / $totalVotes
: .5;
$this->minVote = $this->maxVote = $net;
$this->minAge = $this->maxAge = $age = $note['xwhen'];
$first = $note;
foreach ($notesas &$note) {
$note['score'] = $net = ($note['votes']['up'] - $note['votes']['down']);
$note['total'] = $totalVotes = ($note['votes']['up'] + $note['votes']['down']);
$note['rating'] = $totalVotes > 0
? $note['votes']['up'] / $totalVotes
: .5;
$age = $note['xwhen'];
$this->maxVote = max($this->maxVote, $net);
$this->minVote = min($this->minVote, $net);
$this->maxAge = max($this->maxAge, $age);
$this->minAge = min($this->minAge, $age);
}
array_unshift($notes, $first);
}

@localheinz
localheinzforce-pushed the feature/void-return branch 2 times, most recently from 09a4679 to 921a5ebCompareJuly 15, 2022 13:23
@phpphp deleted a comment from melizzzSep 16, 2022
@kamil-tekiela

Copy link
Copy Markdown
Member

Can you please resolve conflicts?

@derickr

Copy link
Copy Markdown
Member

This still has conflicts :-)

@localheinz

Copy link
Copy Markdown
ContributorAuthor

Rebased!

@kamil-tekiela

Copy link
Copy Markdown
Member

Thanks. This should be fine.

@localheinz
localheinz deleted the feature/void-return branch December 5, 2023 14:59
@localheinz

Copy link
Copy Markdown
ContributorAuthor

Thank you, @derickr and @kamil-tekiela!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@localheinz@kamil-tekiela@derickr@morrisonlevi@saundefined