Skip to content

Commit 4f65a2c

Browse files
Quentin SchmickalbanhJamesFreeman
authored
Laravel 9 (#314)
* Updated to allow Laravel 9 usage; Updated CI to do a matrix of versions * Updated typing * Laravel 9 tests and styling fixed (#327) * allow constraints * fix contract break * reverted types to get tests to pass * remove unneeded element Co-authored-by: James Freeman <[email protected]> * Laravel 9 style fixes (#330) * Handle null is_active Co-authored-by: Alban Horrocks <[email protected]> Co-authored-by: James Freeman <[email protected]>
1 parent 60cb88f commit 4f65a2c

37 files changed

+225
-177
lines changed

.github/workflows/laravel.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,37 @@ on: [push, pull_request]
44

55
jobs:
66
laravel-tests:
7-
runs-on: ubuntu-latest
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
os: [ ubuntu-latest ]
12+
php: [ 8.0, 8.1 ]
13+
laravel: [ 9.* ]
14+
stability: [ prefer-stable ]
15+
include:
16+
- laravel: 9.*
17+
testbench: ^7.0
18+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
19+
820
steps:
921
- uses: actions/checkout@v2
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
27+
coverage: none
1028
- name: Cache dependencies
1129
uses: actions/cache@v2
1230
with:
1331
path: ~/.composer/cache/files
1432
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
1533
restore-keys: |
1634
${{ runner.os }}-composer-
17-
- name: Install Dependencies
18-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
35+
- name: Install dependencies
36+
run: |
37+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
38+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
1939
- name: Execute tests (Unit and Feature tests) via PHPUnit
2040
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ _ide_helper.php
66
.DS_Store
77
.idea
88
*.sketch
9+
.phpunit.result.cache

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.3",
19+
"php": "^8.0.0|^8.1.0",
2020
"ext-json": "*",
2121
"doctrine/dbal": "^3.1",
22-
"illuminate/bus": "^8.11",
23-
"illuminate/console": "^8.11",
24-
"illuminate/contracts": "^8.11",
25-
"illuminate/database": "^8.11",
26-
"illuminate/events": "^8.11",
27-
"illuminate/notifications": "^8.11",
22+
"illuminate/bus": "^8.11|^9.0",
23+
"illuminate/console": "^8.11|^9.0",
24+
"illuminate/contracts": "^8.11|^9.0",
25+
"illuminate/database": "^8.11|^9.0",
26+
"illuminate/events": "^8.11|^9.0",
27+
"illuminate/notifications": "^8.11|^9.0",
2828
"laravelcollective/html": "^6.0"
2929
},
3030
"require-dev": {
3131
"mockery/mockery": "^1.0",
32-
"orchestra/database": "^6.0",
33-
"orchestra/testbench" : "^6.0",
32+
"orchestra/database": "^6.0|^7.0",
33+
"orchestra/testbench" : "^6.0|^7.0",
3434
"phpunit/phpunit": "^9.0"
3535
},
3636
"suggest": {

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- totem
1515

1616
db:
17-
image: mysql:8.0.20
17+
image: mysql/mysql-server:8.0.27
1818
container_name: totem-db
1919
restart: unless-stopped
2020
environment:

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.3.29-fpm
1+
FROM arm64v8/php:8.1.0-fpm
22

33
# Install system dependencies
44
RUN apt-get update && apt-get install -y \

src/Contracts/TaskInterface.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,71 @@
22

33
namespace Studio\Totem\Contracts;
44

5+
use Illuminate\Database\Eloquent\Builder;
6+
use Illuminate\Database\Eloquent\Collection;
7+
use Studio\Totem\Task;
8+
59
interface TaskInterface
610
{
711
/**
812
* Returns Eloquent Builder.
913
*
10-
* @return \Illuminate\Database\Eloquent\Builder
14+
* @return Builder
1115
*/
12-
public function builder();
16+
public function builder(): Builder;
1317

1418
/**
1519
* Returns a task by its primary key.
1620
*
17-
* @param int|\Studio\Totem\Task $id
18-
* @return \Studio\Totem\Task
21+
* @param int|Task $id
22+
* @return Task
1923
*/
20-
public function find($id);
24+
public function find(Task|int $id);
2125

2226
/**
2327
* Returns all tasks.
2428
*
25-
* @return \Illuminate\Database\Eloquent\Collection
29+
* @return Collection
2630
*/
27-
public function findAll();
31+
public function findAll(): Collection;
2832

2933
/**
3034
* Returns all active tasks.
3135
*
32-
* @return \Illuminate\Database\Eloquent\Collection
36+
* @return Collection
3337
*/
34-
public function findAllActive();
38+
public function findAllActive(): Collection;
3539

3640
/**
3741
* Creates a new task with the given data.
3842
*
3943
* @param array $input
40-
* @return \Studio\Totem\Task
44+
* @return Task|bool
4145
*/
42-
public function store(array $input);
46+
public function store(array $input): Task|bool;
4347

4448
/**
4549
* Updates the given task with the given data.
4650
*
4751
* @param array $input
48-
* @param \Studio\Totem\Task $task
49-
* @return \Studio\Totem\Task
52+
* @param Task $task
53+
* @return Task
5054
*/
51-
public function update(array $input, $task);
55+
public function update(array $input, Task $task): Task;
5256

5357
/**
5458
* Deletes the given task.
5559
*
56-
* @param int|\Studio\Totem\Task $id
60+
* @param int|Task $id
5761
* @return bool
5862
*/
59-
public function destroy($id);
63+
public function destroy(Task|int $id): bool;
6064

6165
/**
6266
* Executes the given task.
6367
*
64-
* @param int|\Studio\Totem\Task $id
65-
* @return bool
68+
* @param int|Task $id
69+
* @return Task
6670
*/
67-
public function execute($id);
71+
public function execute(Task|int $id): Task;
6872
}

src/Events/BroadcastingEvent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class BroadcastingEvent extends TaskEvent implements ShouldBroadcast
1313
/**
1414
* Get the channels the event should broadcast on.
1515
*
16-
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel
16+
* @return PrivateChannel
1717
*/
18-
public function broadcastOn()
18+
public function broadcastOn(): PrivateChannel
1919
{
2020
return new PrivateChannel(config('totem.broadcasting.channel'));
2121
}
@@ -25,7 +25,7 @@ public function broadcastOn()
2525
*
2626
* @return bool
2727
*/
28-
public function broadcastWhen()
28+
public function broadcastWhen(): bool
2929
{
3030
return config('totem.broadcasting.enabled');
3131
}

src/Events/Creating.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Studio\Totem\Events;
44

5-
use Illuminate\Broadcasting\Channel;
65
use Illuminate\Broadcasting\InteractsWithSockets;
76
use Illuminate\Broadcasting\PrivateChannel;
87
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
@@ -16,7 +15,7 @@ class Creating implements ShouldBroadcast
1615
/**
1716
* @var array
1817
*/
19-
private $input;
18+
private array $input;
2019

2120
/**
2221
* Create a new event instance.
@@ -31,9 +30,9 @@ public function __construct(array $input)
3130
/**
3231
* Get the channels the event should broadcast on.
3332
*
34-
* @return Channel|array
33+
* @return PrivateChannel
3534
*/
36-
public function broadcastOn()
35+
public function broadcastOn(): PrivateChannel
3736
{
3837
return new PrivateChannel('channel-name');
3938
}

src/Events/Deleted.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ class Deleted extends Event
66
{
77
/**
88
* Create a new event instance.
9-
*
10-
* @param array $input
11-
* @param Task $task
129
*/
1310
public function __construct()
1411
{

src/Events/Executed.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class Executed extends BroadcastingEvent
1111
* Executed constructor.
1212
*
1313
* @param Task $task
14-
* @param string $started
14+
* @param string|float|int $started
15+
* @param $output
1516
*/
1617
public function __construct(Task $task, $started, $output)
1718
{

0 commit comments

Comments
 (0)