Skip to content

Commit

Permalink
refactor(array-annotation): add annotation for array return type
Browse files Browse the repository at this point in the history
  • Loading branch information
DumbergerL committed Aug 1, 2024
1 parent c51957f commit cc8f219
Show file tree
Hide file tree
Showing 56 changed files with 189 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/out/GroupAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@
// Output: "Hello World"


var_dump( $meeting?->getStatistics()->getPresent());
var_dump( $meeting->getStatistics()->getPresent());
// Output: 2

var_dump( $meeting?->getStatistics()->getAbsent());
var_dump( $meeting->getStatistics()->getAbsent());
// Output: 1

var_dump( $meeting?->getStatistics()->getUnsure());
var_dump( $meeting->getStatistics()->getUnsure());
// Output: 0


Expand Down
1 change: 1 addition & 0 deletions src/Models/AbstractRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use CTApi\Exceptions\CTModelException;
use CTApi\Exceptions\CTRequestException;
use CTApi\Interfaces\UpdatableModel;
use CTApi\Models\Events\Event\Event;
use CTApi\Traits\Request\OrderByCondition;
use CTApi\Traits\Request\Pagination;
use CTApi\Traits\Request\WhereCondition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function __construct(
) {
}

/**
* @return Appointment[]
*/
public function get(): array
{
$options = [
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Calendars/Calendar/CalendarRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class CalendarRequest
{
/**
* @return Calendar[]
*/
public static function all(): array
{
return (new CalendarRequestBuilder())->all();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function __construct(array $resourceIds)
$this->resourceIds = $resourceIds;
}

/**
* @return ResourceBooking[]
*/
public function get(): array
{
$options = [];
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Calendars/Resource/ResourceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class ResourceRequest
{
/**
* @return Resource[]
*/
public static function all(): array
{
return (new ResourceRequestBuilder())->all();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Calendars/Resource/ResourceRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class ResourceRequestBuilder
{
/**
* @return Resource[]
*/
public function all(): array
{
$client = CTClient::getClient();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Common/DBField/DBFieldForKeysRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public function __construct(
) {
}

/**
* @return DBFieldValueContainer[]
*/
public function get(): array
{
$this->allDBFields = DBFieldRequest::all();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Common/DBField/DBFieldRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class DBFieldRequest
{
/**
* @return DBField[]
*/
public static function all(): array
{
$client = CTClient::getClient();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Common/File/FileRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ protected function getApiEndpoint(): string
return "/api/files/" . $this->domainType . "/" . $this->domainIdentifier;
}

/**
* @return File[]
*/
public function get(): array
{
$ctClient = CTClient::getClient();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Common/Search/SearchRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function whereDomainType(string $domainType)
return $this;
}

/**
* @return SearchResult[]
*/
public function get(): array
{
$options = [
Expand Down
6 changes: 6 additions & 0 deletions src/Models/Common/Tag/TagRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

class TagRequest
{
/**
* @return Tag[]
*/
public static function allPersonTags(): array
{
return (new TagRequestBuilder("persons"))->all();
}

/**
* @return Tag[]
*/
public static function allSongTags(): array
{
return (new TagRequestBuilder("songs"))->all();
Expand Down
11 changes: 10 additions & 1 deletion src/Models/Common/Tag/TagRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@

class TagRequestBuilder
{
private $tags = [];
/**
* @var Tag[]
*/
private array $tags = [];

public function __construct(
private string $type
) {
$this->tags = $this->retrieveData();
}

/**
* @return Tag[]
*/
private function retrieveData(): array
{
$client = CTClient::getClient();
Expand Down Expand Up @@ -50,6 +56,9 @@ public function findOrFail(int $id): Tag
return $tag;
}

/**
* @return Tag[]
*/
public function all(): array
{
return $this->tags;
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/Absence/AbsencePersonRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ protected function getModelClass(): string
return Absence::class;
}

/**
* @return Absence[]
*/
public function get(): array
{
$options = [];
Expand Down
8 changes: 7 additions & 1 deletion src/Models/Events/Event/EventAgenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class EventAgenda extends AbstractModel
protected ?string $eventStartPosition = null;
protected ?string $calendarId = null;
protected ?string $total = null;
/**
* @var EventAgendaItem[]
*/
protected array $items = [];


Expand All @@ -40,6 +43,9 @@ protected function fillArrayType(string $key, array $data): void
}
}

/**
* @return Song[]
*/
public function getSongs(): array
{
CTLog::getLog()->info('EventAgenda: Collect all songs from agenda.');
Expand Down Expand Up @@ -200,7 +206,7 @@ public function setTotal(?string $total): EventAgenda
}

/**
* @return array
* @return EventAgendaItem[]
*/
public function getItems(): array
{
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/Event/EventRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class EventRequest
{
/**
* @return Event[]
*/
public static function all(): array
{
return (new EventRequestBuilder())->all();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/Service/ServiceFromServiceGroupBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public function __construct(int $serviceGroupId)
$this->serviceGroupId = $serviceGroupId;
}

/**
* @return Service[]
*/
public function get(): array
{
$allServices = ServiceRequest::all();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/Service/ServiceGroupRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class ServiceGroupRequest
{
/**
* @return ServiceGroup[]
*/
public static function all(): array
{
return (new ServiceGroupRequestBuilder())->all();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/Service/ServiceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class ServiceRequest
{
/**
* @return Service[]
*/
public static function all(): array
{
return (new ServiceRequestBuilder())->all();
Expand Down
5 changes: 4 additions & 1 deletion src/Models/Events/Song/Song.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Song extends AbstractModel implements UpdatableModel
protected ?string $arrangementId = null;
protected ?string $name = null;
protected ?string $arrangement = null;
/**
* @var SongArrangement[]
*/
protected array $arrangements = [];
protected ?SongCategory $category = null;
protected ?string $category_id = null;
Expand Down Expand Up @@ -175,7 +178,7 @@ public function setArrangement(?string $arrangement): Song
}

/**
* @return array
* @return SongArrangement[]
*/
public function getArrangements(): array
{
Expand Down
10 changes: 8 additions & 2 deletions src/Models/Events/Song/SongArrangement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ class SongArrangement extends AbstractModel implements UpdatableModel
protected ?string $beat = null;
protected ?string $duration = null;
protected ?string $note = null;
/**
* @var File[]
*/
protected array $links = [];
/**
* @var File[]
*/
protected array $files = [];

public static function getModifiableAttributes(): array
Expand Down Expand Up @@ -243,7 +249,7 @@ public function setNote(?string $note): SongArrangement
}

/**
* @return array
* @return File[]
*/
public function getLinks(): array
{
Expand All @@ -261,7 +267,7 @@ public function setLinks(array $links): SongArrangement
}

/**
* @return array
* @return File[]
*/
public function getFiles(): array
{
Expand Down
9 changes: 9 additions & 0 deletions src/Models/Events/Song/SongArrangementRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

class SongArrangementRequestBuilder
{
/**
* @var SongArrangement[]
*/
private array $songArrangements = [];

/**
* @param SongArrangement[] $songArrangements
*/
public function __construct(array $songArrangements)
{
$this->songArrangements = $songArrangements;
}

/**
* @return SongArrangement[]
*/
public function get(): array
{
return $this->songArrangements;
Expand Down
4 changes: 4 additions & 0 deletions src/Models/Events/Song/SongCommentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*/
class SongCommentRequest
{
/**
* @param int $arrangementId
* @return SongComment[]
*/
public static function getForSongArrangement(int $arrangementId): array
{
$builder = new SongCommentRequestBuilder($arrangementId);
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/Song/SongRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class SongRequest
{
/**
* @return Song[]
*/
public static function all(): array
{
return (new SongRequestBuilder())->all();
Expand Down
4 changes: 4 additions & 0 deletions src/Models/Events/Song/SongTagRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace CTApi\Models\Events\Song;

use CTApi\Models\Common\Tag\Tag;
use CTApi\Models\Common\Tag\TagRequestBuilder;
use CTApi\Traits\Request\AjaxApi;
use CTApi\Utils\CTResponseUtil;
Expand All @@ -15,6 +16,9 @@ public function __construct(
) {
}

/**
* @return Tag[]
*/
public function get(): array
{
$songData = $this->getTagData();
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Events/SongStatistic/SongStatisticRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class SongStatisticRequest
{
/**
* @return SongStatistic[]
*/
public static function all(): array
{
return (new SongStatisticRequestBuilder())->all();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function find(string $arrangementId): ?SongStatistic
return null;
}

/**
* @return SongStatistic[]
*/
public function all(): array
{
$data = $this->getStatisticData();
Expand Down
5 changes: 4 additions & 1 deletion src/Models/Groups/Group/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Group extends AbstractModel
protected ?GroupInformation $information = null;
protected ?GroupSettings $settings = null;
protected array $followUp = [];
/**
* @var GroupRole[]
*/
protected array $roles = [];


Expand Down Expand Up @@ -259,7 +262,7 @@ public function setFollowUp(array $followUp): Group
}

/**
* @return array
* @return GroupRole[]
*/
public function getRoles(): array
{
Expand Down
Loading

0 comments on commit cc8f219

Please sign in to comment.