Skip to content

Commit 6261631

Browse files
refactor: explicit nullable parameters (#4251)
1 parent 2caa541 commit 6261631

33 files changed

+66
-66
lines changed

src/Cache/MemoryCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MemoryCache implements CacheInterface
2020
/**
2121
* @param int|null $memoryLimit
2222
*/
23-
public function __construct(int $memoryLimit = null)
23+
public function __construct(?int $memoryLimit = null)
2424
{
2525
$this->memoryLimit = $memoryLimit;
2626
}

src/Cache/MemoryCacheDeprecated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MemoryCacheDeprecated implements CacheInterface
2020
/**
2121
* @param int|null $memoryLimit
2222
*/
23-
public function __construct(int $memoryLimit = null)
23+
public function __construct(?int $memoryLimit = null)
2424
{
2525
$this->memoryLimit = $memoryLimit;
2626
}

src/Concerns/Exportable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait Exportable
1717
*
1818
* @throws NoFilenameGivenException
1919
*/
20-
public function download(string $fileName = null, string $writerType = null, array $headers = null)
20+
public function download(?string $fileName = null, ?string $writerType = null, ?array $headers = null)
2121
{
2222
$headers = $headers ?? $this->headers ?? [];
2323
$fileName = $fileName ?? $this->fileName ?? null;
@@ -39,7 +39,7 @@ public function download(string $fileName = null, string $writerType = null, arr
3939
*
4040
* @throws NoFilePathGivenException
4141
*/
42-
public function store(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
42+
public function store(?string $filePath = null, ?string $disk = null, ?string $writerType = null, $diskOptions = [])
4343
{
4444
$filePath = $filePath ?? $this->filePath ?? null;
4545

@@ -65,7 +65,7 @@ public function store(string $filePath = null, string $disk = null, string $writ
6565
*
6666
* @throws NoFilePathGivenException
6767
*/
68-
public function queue(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
68+
public function queue(?string $filePath = null, ?string $disk = null, ?string $writerType = null, $diskOptions = [])
6969
{
7070
$filePath = $filePath ?? $this->filePath ?? null;
7171

src/Concerns/Importable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trait Importable
2828
*
2929
* @throws NoFilePathGivenException
3030
*/
31-
public function import($filePath = null, string $disk = null, string $readerType = null)
31+
public function import($filePath = null, ?string $disk = null, ?string $readerType = null)
3232
{
3333
$filePath = $this->getFilePath($filePath);
3434

@@ -48,7 +48,7 @@ public function import($filePath = null, string $disk = null, string $readerType
4848
*
4949
* @throws NoFilePathGivenException
5050
*/
51-
public function toArray($filePath = null, string $disk = null, string $readerType = null): array
51+
public function toArray($filePath = null, ?string $disk = null, ?string $readerType = null): array
5252
{
5353
$filePath = $this->getFilePath($filePath);
5454

@@ -68,7 +68,7 @@ public function toArray($filePath = null, string $disk = null, string $readerTyp
6868
*
6969
* @throws NoFilePathGivenException
7070
*/
71-
public function toCollection($filePath = null, string $disk = null, string $readerType = null): Collection
71+
public function toCollection($filePath = null, ?string $disk = null, ?string $readerType = null): Collection
7272
{
7373
$filePath = $this->getFilePath($filePath);
7474

@@ -89,7 +89,7 @@ public function toCollection($filePath = null, string $disk = null, string $read
8989
* @throws NoFilePathGivenException
9090
* @throws InvalidArgumentException
9191
*/
92-
public function queue($filePath = null, string $disk = null, string $readerType = null)
92+
public function queue($filePath = null, ?string $disk = null, ?string $readerType = null)
9393
{
9494
if (!$this instanceof ShouldQueue) {
9595
throw new InvalidArgumentException('Importable should implement ShouldQueue to be queued.');

src/Excel.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
public function download($export, string $fileName, string $writerType = null, array $headers = [])
82+
public function download($export, string $fileName, ?string $writerType = null, array $headers = [])
8383
{
8484
// Clear output buffer to prevent stuff being prepended to the Excel output.
8585
if (ob_get_length() > 0) {
@@ -99,7 +99,7 @@ public function download($export, string $fileName, string $writerType = null, a
9999
*
100100
* @param string|null $disk Fallback for usage with named properties
101101
*/
102-
public function store($export, string $filePath, string $diskName = null, string $writerType = null, $diskOptions = [], string $disk = null)
102+
public function store($export, string $filePath, ?string $diskName = null, ?string $writerType = null, $diskOptions = [], ?string $disk = null)
103103
{
104104
if ($export instanceof ShouldQueue) {
105105
return $this->queue($export, $filePath, $diskName ?: $disk, $writerType, $diskOptions);
@@ -120,7 +120,7 @@ public function store($export, string $filePath, string $diskName = null, string
120120
/**
121121
* {@inheritdoc}
122122
*/
123-
public function queue($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
123+
public function queue($export, string $filePath, ?string $disk = null, ?string $writerType = null, $diskOptions = [])
124124
{
125125
$writerType = FileTypeDetector::detectStrict($filePath, $writerType);
126126

@@ -149,7 +149,7 @@ public function raw($export, string $writerType)
149149
/**
150150
* {@inheritdoc}
151151
*/
152-
public function import($import, $filePath, string $disk = null, string $readerType = null)
152+
public function import($import, $filePath, ?string $disk = null, ?string $readerType = null)
153153
{
154154
$readerType = FileTypeDetector::detect($filePath, $readerType);
155155
$response = $this->reader->read($import, $filePath, $readerType, $disk);
@@ -164,7 +164,7 @@ public function import($import, $filePath, string $disk = null, string $readerTy
164164
/**
165165
* {@inheritdoc}
166166
*/
167-
public function toArray($import, $filePath, string $disk = null, string $readerType = null): array
167+
public function toArray($import, $filePath, ?string $disk = null, ?string $readerType = null): array
168168
{
169169
$readerType = FileTypeDetector::detect($filePath, $readerType);
170170

@@ -174,7 +174,7 @@ public function toArray($import, $filePath, string $disk = null, string $readerT
174174
/**
175175
* {@inheritdoc}
176176
*/
177-
public function toCollection($import, $filePath, string $disk = null, string $readerType = null): Collection
177+
public function toCollection($import, $filePath, ?string $disk = null, ?string $readerType = null): Collection
178178
{
179179
$readerType = FileTypeDetector::detect($filePath, $readerType);
180180

@@ -184,7 +184,7 @@ public function toCollection($import, $filePath, string $disk = null, string $re
184184
/**
185185
* {@inheritdoc}
186186
*/
187-
public function queueImport(ShouldQueue $import, $filePath, string $disk = null, string $readerType = null)
187+
public function queueImport(ShouldQueue $import, $filePath, ?string $disk = null, ?string $readerType = null)
188188
{
189189
return $this->import($import, $filePath, $disk, $readerType);
190190
}
@@ -197,7 +197,7 @@ public function queueImport(ShouldQueue $import, $filePath, string $disk = null,
197197
*
198198
* @throws \PhpOffice\PhpSpreadsheet\Exception
199199
*/
200-
protected function export($export, string $fileName, string $writerType = null): TemporaryFile
200+
protected function export($export, string $fileName, ?string $writerType = null): TemporaryFile
201201
{
202202
$writerType = FileTypeDetector::detectStrict($fileName, $writerType);
203203

src/Exceptions/NoFilePathGivenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NoFilePathGivenException extends InvalidArgumentException implements Larav
1515
public function __construct(
1616
$message = 'A filepath needs to be passed.',
1717
$code = 0,
18-
Throwable $previous = null
18+
?Throwable $previous = null
1919
) {
2020
parent::__construct($message, $code, $previous);
2121
}

src/Exceptions/NoFilenameGivenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NoFilenameGivenException extends InvalidArgumentException implements Larav
1515
public function __construct(
1616
$message = 'A filename needs to be passed in order to download the export',
1717
$code = 0,
18-
Throwable $previous = null
18+
?Throwable $previous = null
1919
) {
2020
parent::__construct($message, $code, $previous);
2121
}

src/Exceptions/NoTypeDetectedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NoTypeDetectedException extends Exception implements LaravelExcelException
1515
public function __construct(
1616
$message = 'No ReaderType or WriterType could be detected. Make sure you either pass a valid extension to the filename or pass an explicit type.',
1717
$code = 0,
18-
Throwable $previous = null
18+
?Throwable $previous = null
1919
) {
2020
parent::__construct($message, $code, $previous);
2121
}

src/Exceptions/UnreadableFileException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class UnreadableFileException extends Exception implements LaravelExcelException
1515
public function __construct(
1616
$message = 'File could not be read',
1717
$code = 0,
18-
Throwable $previous = null
18+
?Throwable $previous = null
1919
) {
2020
parent::__construct($message, $code, $previous);
2121
}

src/Exporter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface Exporter
1414
* @throws \PhpOffice\PhpSpreadsheet\Exception
1515
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
1616
*/
17-
public function download($export, string $fileName, string $writerType = null, array $headers = []);
17+
public function download($export, string $fileName, ?string $writerType = null, array $headers = []);
1818

1919
/**
2020
* @param object $export
@@ -27,7 +27,7 @@ public function download($export, string $fileName, string $writerType = null, a
2727
* @throws \PhpOffice\PhpSpreadsheet\Exception
2828
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
2929
*/
30-
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []);
30+
public function store($export, string $filePath, ?string $disk = null, ?string $writerType = null, $diskOptions = []);
3131

3232
/**
3333
* @param object $export
@@ -37,7 +37,7 @@ public function store($export, string $filePath, string $disk = null, string $wr
3737
* @param mixed $diskOptions
3838
* @return \Illuminate\Foundation\Bus\PendingDispatch
3939
*/
40-
public function queue($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []);
40+
public function queue($export, string $filePath, ?string $disk = null, ?string $writerType = null, $diskOptions = []);
4141

4242
/**
4343
* @param object $export

0 commit comments

Comments
 (0)