Skip to content

Commit

Permalink
chore(listeners): Add type casts
Browse files Browse the repository at this point in the history
  • Loading branch information
zooley committed Mar 27, 2024
1 parent d33243b commit 4585744
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/Modules/Listeners/Activators/DatabaseActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private function writeDatabase(): void
/**
* Reads the json file that contains the activation statuses.
*
* @return array
* @return array<string,bool>
*/
private function readDatabase(): array
{
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Listeners/Entities/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getCacheTime()
* @param string $layout The layout name
* @return string
*/
public function getViewName($layout='index'): string
public function getViewName(string $layout='index'): string
{
return 'listener.' . $this->name . '::' . $layout;
}
Expand Down
29 changes: 16 additions & 13 deletions app/Modules/Listeners/Entities/ListenerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Events\Dispatcher;
use Illuminate\Support\Str;
use Illuminate\Support\Fluent;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Schema;
use App\Modules\Listeners\Models\Listener;
Expand Down Expand Up @@ -47,9 +48,9 @@ public function subscribe(): void
*
* @param string $folder Listener type
* @param string $element Listener element
* @return object collection
* @return Collection
*/
public function byType($folder, $element = null)
public function byType(string $folder, string $element = null): Collection
{
$listeners = $this->all()
->filter(function($value, $key) use ($folder, $element)
Expand Down Expand Up @@ -104,9 +105,9 @@ protected function subscribeListener(Listener $listener): void
/**
* Load all listeners.
*
* @return object Collection
* @return Collection
*/
public function all()
public function all(): Collection
{
static $listeners;

Expand All @@ -115,17 +116,19 @@ public function all()
return $listeners;
}

$listeners = Schema::hasTable('extensions') ? $this->allByDatabase() : $this->allByFile();
$listeners = Schema::hasTable('extensions')
? $this->allByDatabase()
: $this->allByFile();

return $listeners;
}

/**
* Load published listeners.
*
* @return object Collection
* @return Collection
*/
public function allEnabled()
public function allEnabled(): Collection
{
$levels = [];

Expand All @@ -151,9 +154,9 @@ public function allEnabled()
/**
* Load unpublished listeners.
*
* @return object Collection
* @return Collection
*/
public function allDisabled()
public function allDisabled(): Collection
{
$levels = [];

Expand All @@ -179,9 +182,9 @@ public function allDisabled()
/**
* Load published listeners by database.
*
* @return object Collection
* @return Collection
*/
public function allByDatabase()
public function allByDatabase(): Collection
{
$listeners = Listener::query()
->where('type', '=', 'listener')
Expand All @@ -207,9 +210,9 @@ public function allByDatabase()
/**
* Load published listeners by files.
*
* @return object Collection
* @return Collection
*/
public function allByFile()
public function allByFile(): Collection
{
$files = app('files')->glob(app_path('Listeners') . '/*/*/listener.json');

Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Listeners/Helpers/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class Admin
/**
* Returns an array of standard published state filter options.
*
* @return array
* @return array<int,\stdClass>
*/
public static function stateOptions(): array
{
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Listeners/Models/Fields/Listeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Listeners extends Select
/**
* Method to get a list of options for a list input.
*
* @return array An array of Html options.
* @return array<int,\stdClass|\Illuminate\Support\Fluent>
*/
protected function getOptions()
{
Expand Down
6 changes: 3 additions & 3 deletions app/Modules/Listeners/Models/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ public function move($delta, $where = ''): bool
/**
* Saves the manually set order of records.
*
* @param array $pks An array of primary key ids.
* @param array $order An array of order values.
* @param array<int,int> $pks An array of primary key ids.
* @param array<int,int> $order An array of order values.
* @return bool
*/
public static function saveOrder($pks = null, $order = null): bool
public static function saveOrder(array $pks = null, array $order = null): bool
{
if (empty($pks))
{
Expand Down

0 comments on commit 4585744

Please sign in to comment.