Skip to content

Laravel 9 #314

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

Merged
merged 12 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,37 @@ on: [push, pull_request]

jobs:
laravel-tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.0, 8.1 ]
laravel: [ 9.* ]
stability: [ prefer-stable ]
include:
- laravel: 9.*
testbench: ^7.0
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ _ide_helper.php
.DS_Store
.idea
*.sketch
.phpunit.result.cache
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
}
],
"require": {
"php": ">=7.3",
"php": "^8.0.0|^8.1.0",
"ext-json": "*",
"doctrine/dbal": "^3.1",
"illuminate/bus": "^8.11",
"illuminate/console": "^8.11",
"illuminate/contracts": "^8.11",
"illuminate/database": "^8.11",
"illuminate/events": "^8.11",
"illuminate/notifications": "^8.11",
"illuminate/bus": "^8.11|^9.0",
"illuminate/console": "^8.11|^9.0",
"illuminate/contracts": "^8.11|^9.0",
"illuminate/database": "^8.11|^9.0",
"illuminate/events": "^8.11|^9.0",
"illuminate/notifications": "^8.11|^9.0",
"laravelcollective/html": "^6.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/database": "^6.0",
"orchestra/testbench" : "^6.0",
"orchestra/database": "^6.0|^7.0",
"orchestra/testbench" : "^6.0|^7.0",
"phpunit/phpunit": "^9.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- totem

db:
image: mysql:8.0.20
image: mysql/mysql-server:8.0.27
container_name: totem-db
restart: unless-stopped
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.3.29-fpm
FROM arm64v8/php:8.1.0-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y \
Expand Down
42 changes: 23 additions & 19 deletions src/Contracts/TaskInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,71 @@

namespace Studio\Totem\Contracts;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Studio\Totem\Task;

interface TaskInterface
{
/**
* Returns Eloquent Builder.
*
* @return \Illuminate\Database\Eloquent\Builder
* @return Builder
*/
public function builder();
public function builder(): Builder;

/**
* Returns a task by its primary key.
*
* @param int|\Studio\Totem\Task $id
* @return \Studio\Totem\Task
* @param int|Task $id
* @return Task
*/
public function find($id);
public function find(Task|int $id);

/**
* Returns all tasks.
*
* @return \Illuminate\Database\Eloquent\Collection
* @return Collection
*/
public function findAll();
public function findAll(): Collection;

/**
* Returns all active tasks.
*
* @return \Illuminate\Database\Eloquent\Collection
* @return Collection
*/
public function findAllActive();
public function findAllActive(): Collection;

/**
* Creates a new task with the given data.
*
* @param array $input
* @return \Studio\Totem\Task
* @return Task|bool
*/
public function store(array $input);
public function store(array $input): Task|bool;

/**
* Updates the given task with the given data.
*
* @param array $input
* @param \Studio\Totem\Task $task
* @return \Studio\Totem\Task
* @param Task $task
* @return Task
*/
public function update(array $input, $task);
public function update(array $input, Task $task): Task;

/**
* Deletes the given task.
*
* @param int|\Studio\Totem\Task $id
* @param int|Task $id
* @return bool
*/
public function destroy($id);
public function destroy(Task|int $id): bool;

/**
* Executes the given task.
*
* @param int|\Studio\Totem\Task $id
* @return bool
* @param int|Task $id
* @return Task
*/
public function execute($id);
public function execute(Task|int $id): Task;
}
6 changes: 3 additions & 3 deletions src/Events/BroadcastingEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class BroadcastingEvent extends TaskEvent implements ShouldBroadcast
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel
* @return PrivateChannel
*/
public function broadcastOn()
public function broadcastOn(): PrivateChannel
{
return new PrivateChannel(config('totem.broadcasting.channel'));
}
Expand All @@ -25,7 +25,7 @@ public function broadcastOn()
*
* @return bool
*/
public function broadcastWhen()
public function broadcastWhen(): bool
{
return config('totem.broadcasting.enabled');
}
Expand Down
7 changes: 3 additions & 4 deletions src/Events/Creating.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Studio\Totem\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
Expand All @@ -16,7 +15,7 @@ class Creating implements ShouldBroadcast
/**
* @var array
*/
private $input;
private array $input;

/**
* Create a new event instance.
Expand All @@ -31,9 +30,9 @@ public function __construct(array $input)
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
* @return PrivateChannel
*/
public function broadcastOn()
public function broadcastOn(): PrivateChannel
{
return new PrivateChannel('channel-name');
}
Expand Down
3 changes: 0 additions & 3 deletions src/Events/Deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ class Deleted extends Event
{
/**
* Create a new event instance.
*
* @param array $input
* @param Task $task
*/
public function __construct()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Events/Executed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Executed extends BroadcastingEvent
* Executed constructor.
*
* @param Task $task
* @param string $started
* @param string|float|int $started
* @param $output
*/
public function __construct(Task $task, $started, $output)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Events/TaskEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TaskEvent extends Event
/**
* @var Task
*/
public $task;
public Task $task;

/**
* Constructor.
Expand Down
7 changes: 3 additions & 4 deletions src/Events/Updating.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Studio\Totem\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;
use Studio\Totem\Task;

Expand All @@ -11,7 +10,7 @@ class Updating extends BroadcastingEvent
/**
* @var array
*/
private $input;
private array $input;

/**
* Create a new event instance.
Expand All @@ -28,9 +27,9 @@ public function __construct(array $input, Task $task)
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
* @return PrivateChannel
*/
public function broadcastOn()
public function broadcastOn(): PrivateChannel
{
return new PrivateChannel('channel-name');
}
Expand Down
5 changes: 3 additions & 2 deletions src/Frequency.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Studio\Totem;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Studio\Totem\Traits\HasParameters;

class Frequency extends TotemModel
Expand All @@ -17,9 +18,9 @@ class Frequency extends TotemModel
];

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function task()
public function task(): BelongsTo
{
return $this->belongsTo(Task::class);
}
Expand Down
13 changes: 7 additions & 6 deletions src/Http/Controllers/ActiveTasksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Studio\Totem\Http\Controllers;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Studio\Totem\Contracts\TaskInterface;

Expand All @@ -10,7 +11,7 @@ class ActiveTasksController extends Controller
/**
* @var TaskInterface
*/
private $tasks;
private TaskInterface $tasks;

/**
* @param TaskInterface $tasks
Expand All @@ -25,10 +26,10 @@ public function __construct(TaskInterface $tasks)
/**
* Store a newly active task in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @param Request $request
* @return JsonResponse
*/
public function store(Request $request)
public function store(Request $request): JsonResponse
{
$task = $this->tasks->activate($request->all());

Expand All @@ -39,9 +40,9 @@ public function store(Request $request)
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
* @return JsonResponse
*/
public function destroy($id)
public function destroy(int $id): JsonResponse
{
$task = $this->tasks->deactivate($id);

Expand Down
6 changes: 4 additions & 2 deletions src/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace Studio\Totem\Http\Controllers;

use Illuminate\Http\RedirectResponse;

class DashboardController extends Controller
{
/**
* Single page application catch-all route.
*
* @return \Illuminate\Http\Response
* @return RedirectResponse
*/
public function index()
public function index(): RedirectResponse
{
return redirect()->route('totem.tasks.all');
}
Expand Down
4 changes: 3 additions & 1 deletion src/Http/Controllers/ExecuteTasksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class ExecuteTasksController extends Controller
/**
* @var TaskInterface
*/
private $tasks;
private TaskInterface $tasks;

/**
* @param TaskInterface $tasks
*/
public function __construct(TaskInterface $tasks)
{
parent::__construct();

$this->tasks = $tasks;
}

Expand Down
Loading