Skip to content

Commit 7f2f618

Browse files
committed
Make phpstan type checks happy
1 parent 2a32573 commit 7f2f618

File tree

8 files changed

+30
-13
lines changed

8 files changed

+30
-13
lines changed

app/Http/Controllers/Dormitory/Printing/PrintJobController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ private function paginatorFrom(Builder $printJobs, array $columns)
179179
$paginator = TabulatorPaginator::from($printJobs)->sortable($columns)->filterable($columns)->paginate();
180180

181181
// Process the data before showing it in a table.
182+
// @phpstan-ignore-next-line
182183
$paginator->getCollection()->append([
183184
'translated_cost',
184185
'translated_state',

app/Models/FreePages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function printAccount()
7777

7878
/**
7979
* Wether the free pages are still available.
80-
* @return bool
80+
* @return Attribute
8181
*/
8282
protected function available(): Attribute
8383
{

app/Models/PrintAccount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function freePages()
6969

7070
/**
7171
* The free pages which are currently available. Sorts the free pages by their deadline.
72-
* @return Collection
72+
* @return Collection|FreePages[]
7373
*/
7474
public function availableFreePages()
7575
{
@@ -131,7 +131,7 @@ public function updateHistory(bool $useFreePages, int $cost)
131131
$availableFreePages = $this->availableFreePages()->where('amount', '>', 0);
132132

133133
// Subtract the pages from the free pages pool, as many free pages as necessary
134-
/** @var FreePages */
134+
/** @var FreePages $freePages */
135135
foreach ($availableFreePages as $freePages) {
136136
$subtractablePages = $freePages->calculateSubtractablePages($freePagesToSubtract);
137137
$freePages->subtractPages($subtractablePages);

app/Models/PrintAccountHistory.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
67

7-
// Note: the elements of this class should no be changed manually.
8+
// Note: the elements of this class should not be changed manually.
89
// Observers for updating entries are set up.
910
/**
1011
* App\Models\PrintAccountHistory
@@ -45,11 +46,21 @@ class PrintAccountHistory extends Model
4546
'modified_at',
4647
];
4748

49+
50+
/**
51+
* `User` whose balance is affected by this change.
52+
* @return BelongsTo
53+
*/
4854
public function user()
4955
{
5056
return $this->belongsTo(User::class);
5157
}
5258

59+
60+
/**
61+
* `User` who initiated this change.
62+
* @return BelongsTo
63+
*/
5364
public function modifier()
5465
{
5566
return $this->belongsTo(User::class, 'modified_by');

app/Models/PrintJob.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ class PrintJob extends Model
6262
'used_free_pages' => 'boolean',
6363
];
6464

65+
/**
66+
* `User` that sent this `PrintJob`.
67+
* @return BelongsTo
68+
*/
6569
public function user()
6670
{
6771
return $this->belongsTo(User::class);
@@ -116,7 +120,6 @@ public function translatedState(): Attribute
116120

117121
/**
118122
* Attemts to cancel the given `PrintJob`. Returns wether it was successful.
119-
* @param PrintJob $this
120123
* @return PrinterCancelResult
121124
*/
122125
public function cancel()

app/Models/Printer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function printJobs()
4949
* @param string $originalName
5050
* @param bool $twoSided
5151
* @param int $copyNumber
52-
* @return Model
52+
* @return PrintJob
5353
* @throws AuthenticationException
5454
* @throws PrinterException
5555
* @throws MassAssignmentException
@@ -73,13 +73,13 @@ public function createPrintJob(bool $useFreePages, int $cost, string $filePath,
7373
* @param bool $twoSided
7474
* @param int $copies
7575
* @param string $path
76-
* @return int The `jobId` belonging to the printjob
76+
* @return string The `jobId` belonging to the printjob
7777
* @throws PrinterException If the printing fails
7878
*/
7979
public function print(bool $twoSided, int $copies, string $path)
8080
{
8181
if (config('app.debug')) {
82-
return -1;
82+
return "not_submitted";
8383
}
8484
$jobId = null;
8585
try {
@@ -135,7 +135,7 @@ public function getCompletedPrintJobs()
135135
*/
136136
public function updateCompletedPrintJobs()
137137
{
138-
return DB::transaction(function () {
138+
DB::transaction(function () {
139139
PrintJob::where('state', PrintJobStatus::QUEUED)->whereIn(
140140
'job_id',
141141
$this->getCompletedPrintJobs()

app/Utils/PrinterHelper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use App\Models\Printer;
77
use App\Models\PrintJob;
88
use App\Utils\Process;
9+
use Illuminate\Contracts\Container\BindingResolutionException;
10+
use Psr\Container\NotFoundExceptionInterface;
11+
use Psr\Container\ContainerExceptionInterface;
912

1013
class PrinterHelper
1114
{
@@ -48,9 +51,9 @@ public static function getPageTypesNeeded(int $pages, bool $twoSided)
4851
/**
4952
* Returns the number of free pages needed to print with given configuration.
5053
* @param int $pages
51-
* @param mixed $copies
52-
* @param mixed $twoSided
53-
* @return int|float
54+
* @param int $copies
55+
* @param bool $twoSided
56+
* @return int
5457
*/
5558
public static function getFreePagesNeeded(int $pages, int $copies, bool $twoSided)
5659
{

app/Utils/Process.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function getOutput(string $debugOutput = ''): string
4949
/**
5050
* Get the exit code of the process.
5151
*
52-
* @param string $debugOutput
5352
* @return int|null
5453
*/
5554
public function getExitCode(): ?int

0 commit comments

Comments
 (0)