Skip to content

Enhancement: Enable void_return fixer #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

localheinz
Copy link
Contributor

@localheinz localheinz commented Jul 15, 2022

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
@@ -15,7 +15,7 @@ class Sorter {
private $ratingWeight = 60;
private $ageWeight = 2;

public function sort(array &$notes) {
public function sort(array &$notes): void {
Copy link
Contributor Author

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.

public function sort(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'));
}

@@ -75,7 +75,7 @@ private function factorSort($a, $b) {
return -1;
}

private function findMinMaxValues(array &$notes) {
private function findMinMaxValues(array &$notes): void {
Copy link
Contributor Author

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.

private function findMinMaxValues(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 ($notes as &$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 localheinz force-pushed the feature/void-return branch 2 times, most recently from 09a4679 to 921a5eb Compare July 15, 2022 13:23
@localheinz localheinz force-pushed the feature/void-return branch from 2b1a548 to 6871782 Compare August 22, 2022 17:18
@php php deleted a comment from melizzz Sep 16, 2022
@kamil-tekiela
Copy link
Member

Can you please resolve conflicts?

@derickr
Copy link
Member

derickr commented Nov 29, 2023

This still has conflicts :-)

@localheinz
Copy link
Contributor Author

Rebased!

@kamil-tekiela
Copy link
Member

Thanks. This should be fine.

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

Thank you, @derickr and @kamil-tekiela!

Sign up for free to 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