-
Notifications
You must be signed in to change notification settings - Fork 558
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
Conversation
src/UserNotes/Sorter.php
Outdated
@@ -15,7 +15,7 @@ class Sorter { | |||
private $ratingWeight = 60; | |||
private $ageWeight = 2; | |||
|
|||
public function sort(array &$notes) { | |||
public function sort(array &$notes): void { |
There was a problem hiding this comment.
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.
web-php/src/UserNotes/Sorter.php
Lines 18 to 37 in d8717d3
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')); | |
} |
src/UserNotes/Sorter.php
Outdated
@@ -75,7 +75,7 @@ private function factorSort($a, $b) { | |||
return -1; | |||
} | |||
|
|||
private function findMinMaxValues(array &$notes) { | |||
private function findMinMaxValues(array &$notes): void { |
There was a problem hiding this comment.
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.
web-php/src/UserNotes/Sorter.php
Lines 78 to 108 in d8717d3
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); | |
} |
09a4679
to
921a5eb
Compare
2b1a548
to
6871782
Compare
9d0faf3
to
543beb1
Compare
Can you please resolve conflicts? |
This still has conflicts :-) |
d4c6574
to
04b8215
Compare
Rebased! |
Thanks. This should be fine. |
Thank you, @derickr and @kamil-tekiela! |
This pull request
void_return
fixermake 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.