Skip to content

Commit 50277f3

Browse files
Update type hints for nullable properties in FileRepository, Json and SchemaParser classes.
1 parent bef3d07 commit 50277f3

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/FileRepository.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class FileRepository implements Countable, RepositoryInterface
4242
/**
4343
* Stub path
4444
*/
45-
protected string $stubPath;
45+
protected ?string $stubPath = null;
4646

4747
/**
4848
* URL Generator
@@ -136,9 +136,7 @@ public function scan(): array
136136
$modules = [];
137137

138138
foreach ($paths as $key => $path) {
139-
$manifests = $this->getFiles()->glob("{$path}/module.json");
140-
141-
is_array($manifests) || $manifests = [];
139+
$manifests = (array) $this->getFiles()->glob("{$path}/module.json");
142140

143141
foreach ($manifests as $manifest) {
144142
$json = Json::make($manifest);

src/Json.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Json
2121
/**
2222
* The attributes collection.
2323
*/
24-
protected Collection $attributes;
24+
protected ?Collection $attributes = null;
2525

2626
/**
2727
* The constructor.
@@ -110,7 +110,7 @@ public function decodeContents(): array
110110
*/
111111
public function getAttributes(): array
112112
{
113-
return $this->attributes ?? $this->decodeContents();
113+
return $this->attributes ? $this->attributes->toArray() : $this->decodeContents();
114114
}
115115

116116
/**

src/Support/Migrations/SchemaParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SchemaParser implements Arrayable
1919
/**
2020
* The migration schema.
2121
*/
22-
protected string $schema;
22+
protected ?string $schema;
2323

2424
/**
2525
* The relationship keys.
@@ -39,7 +39,7 @@ public function __construct(?string $schema = null)
3939
/**
4040
* Parse a string to array of formatted schema.
4141
*/
42-
public function parse(string $schema): array
42+
public function parse(?string $schema): array
4343
{
4444
$this->schema = $schema;
4545

0 commit comments

Comments
 (0)