Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Fixed spaceship operator for php 5.6 (and minor fixes for phpunit tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothymarois committed Jul 14, 2018
1 parent f4158b3 commit 3d35763
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true" >
<testsuites name="Filebase Test Case">
<testsuites>
<testsuite name="All">
<directory>./tests</directory>
</testsuite>
Expand Down
13 changes: 10 additions & 3 deletions src/QueryLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,19 @@ protected function sort()
$propA = $a->field($orderBy);
$propB = $b->field($orderBy);


if (strnatcasecmp($propB, $propA) == strnatcasecmp($propA, $propB)) {
return 0;
}

if ($sortBy == 'DESC')
{
return strnatcasecmp($propB, $propA) <=> strnatcasecmp($propA, $propB);
return (strnatcasecmp($propB, $propA) < strnatcasecmp($propA, $propB)) ? -1 : 1;
}
else
{
return (strnatcasecmp($propA, $propB) < strnatcasecmp($propB, $propA)) ? -1 : 1;
}

return strnatcasecmp($propA, $propB) <=> strnatcasecmp($propB, $propA);

});

Expand Down

0 comments on commit 3d35763

Please sign in to comment.