Skip to content

Commit

Permalink
Use object instead of stdClass
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Oct 23, 2024
1 parent b353218 commit d7c2f5c
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 57 deletions.
11 changes: 5 additions & 6 deletions app/Module/RecentChangesModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Psr\Http\Message\ServerRequestInterface;
use stdClass;

use function extract;
use function view;
Expand Down Expand Up @@ -118,18 +117,18 @@ public function getBlock(Tree $tree, int $block_id, string $context, array $conf

switch ($sortStyle) {
case 'name':
$rows = $rows->sort(static fn (stdClass $x, stdClass $y): int => GedcomRecord::nameComparator()($x->record, $y->record));
$rows = $rows->sort(static fn (object $x, object $y): int => GedcomRecord::nameComparator()($x->record, $y->record));
$order = [[1, 'asc']];
break;

case 'date_asc':
$rows = $rows->sort(static fn (stdClass $x, stdClass $y): int => $x->time <=> $y->time);
$rows = $rows->sort(static fn (object $x, object $y): int => $x->time <=> $y->time);
$order = [[2, 'asc']];
break;

default:
case 'date_desc':
$rows = $rows->sort(static fn (stdClass $x, stdClass $y): int => $y->time <=> $x->time);
$rows = $rows->sort(static fn (object $x, object $y): int => $y->time <=> $x->time);
$order = [[2, 'desc']];
break;
}
Expand Down Expand Up @@ -286,7 +285,7 @@ public function editBlockConfiguration(Tree $tree, int $block_id): string
* @param Tree $tree Changes for which tree
* @param int $days Number of days
*
* @return Collection<array-key,stdClass> List of records with changes
* @return Collection<array-key,object> List of records with changes
*/
private function getRecentChangesFromDatabase(Tree $tree, int $days): Collection
{
Expand Down Expand Up @@ -318,7 +317,7 @@ private function getRecentChangesFromDatabase(Tree $tree, int $days): Collection
* @param Tree $tree Changes for which tree
* @param int $days Number of days
*
* @return Collection<array-key,stdClass> List of records with changes
* @return Collection<array-key,object> List of records with changes
*/
private function getRecentChangesFromGenealogy(Tree $tree, int $days): Collection
{
Expand Down
7 changes: 3 additions & 4 deletions app/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
use ReflectionException;
use ReflectionMethod;
use ReflectionNamedType;
use stdClass;

use function count;
use function in_array;
Expand Down Expand Up @@ -1059,7 +1058,7 @@ public function statsDeath(string|null $color_from = null, string|null $color_to
* @param int $year1
* @param int $year2
*
* @return array<array<stdClass>>
* @return array<array<object>>
*/
public function statsAgeQuery(string $related = 'BIRT', string $sex = 'BOTH', int $year1 = -1, int $year2 = -1): array
{
Expand Down Expand Up @@ -1657,7 +1656,7 @@ public function oldestMarriageMaleAge(string $show_years = ''): string
* @param int $year1
* @param int $year2
*
* @return array<stdClass>
* @return array<object>
*/
public function statsMarrAgeQuery(string $sex, int $year1 = -1, int $year2 = -1): array
{
Expand Down Expand Up @@ -2005,7 +2004,7 @@ public function averageChildren(): string
* @param int $year1
* @param int $year2
*
* @return array<stdClass>
* @return array<object>
*/
public function statsChildrenQuery(int $year1 = -1, int $year2 = -1): array
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartAge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use stdClass;

use function round;
use function view;
Expand All @@ -53,7 +52,7 @@ public function __construct(CenturyService $century_service, Tree $tree)
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartBirth.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;
use stdClass;

use function count;
use function view;
Expand Down Expand Up @@ -56,7 +55,7 @@ public function __construct(CenturyService $century_service, ColorService $color
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use stdClass;

/**
* A chart showing the average number of children by century.
Expand All @@ -49,7 +48,7 @@ public function __construct(CenturyService $century_service, Tree $tree)
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartDeath.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;
use stdClass;

use function count;
use function view;
Expand Down Expand Up @@ -56,7 +55,7 @@ public function __construct(CenturyService $century_service, ColorService $color
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartDivorce.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;
use stdClass;

use function count;
use function view;
Expand Down Expand Up @@ -56,7 +55,7 @@ public function __construct(CenturyService $century_service, ColorService $color
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartMarriage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Support\Collection;
use stdClass;

use function count;
use function view;
Expand Down Expand Up @@ -56,7 +55,7 @@ public function __construct(CenturyService $century_service, ColorService $color
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Google/ChartMarriageAge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use stdClass;

use function round;
use function view;
Expand All @@ -53,7 +52,7 @@ public function __construct(CenturyService $century_service, Tree $tree)
/**
* Returns the related database records.
*
* @return Collection<array-key,stdClass>
* @return Collection<array-key,object>
*/
private function queryRecords(): Collection
{
Expand Down
7 changes: 3 additions & 4 deletions app/Statistics/Repository/FamilyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\JoinClause;
use stdClass;

use function arsort;
use function asort;
Expand Down Expand Up @@ -553,7 +552,7 @@ public function topAgeBetweenSiblingsList(int $total = 10, string $one = ''): st
* @param int $year1
* @param int $year2
*
* @return array<stdClass>
* @return array<object>
*/
public function statsChildrenQuery(int $year1 = -1, int $year2 = -1): array
{
Expand Down Expand Up @@ -1386,7 +1385,7 @@ public function ageBetweenSpousesFMList(int $total = 10): string
* @param int $year1
* @param int $year2
*
* @return array<stdClass>
* @return array<object>
*/
public function statsMarrAgeQuery(string $sex, int $year1 = -1, int $year2 = -1): array
{
Expand Down Expand Up @@ -1416,7 +1415,7 @@ public function statsMarrAgeQuery(string $sex, int $year1 = -1, int $year2 = -1)

return $query
->get()
->map(static function (stdClass $row): stdClass {
->map(static function (object $row): object {
$row->age = (int) $row->age;

return $row;
Expand Down
3 changes: 1 addition & 2 deletions app/Statistics/Repository/IndividualRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\JoinClause;
use stdClass;

use function array_key_exists;
use function array_keys;
Expand Down Expand Up @@ -796,7 +795,7 @@ public function statsDeath(string|null $color_from = null, string|null $color_to
* @param int $year1
* @param int $year2
*
* @return array<stdClass>
* @return array<object>
*/
public function statsAgeQuery(string $related = 'BIRT', string $sex = 'BOTH', int $year1 = -1, int $year2 = -1): array
{
Expand Down
Loading

0 comments on commit d7c2f5c

Please sign in to comment.