Skip to content

Commit b9b925c

Browse files
FIX "Implicitly marking parameter as nullable" issue (#83)
1 parent a323acd commit b9b925c

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

src/Exceptions/InvalidMarkInstanceException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
class InvalidMarkInstanceException extends Exception
99
{
10-
public function __construct($message = 'Must be a Mark instance', $code = 0, Throwable $previous = null)
10+
public function __construct($message = 'Must be a Mark instance', $code = 0, ?Throwable $previous = null)
1111
{
1212
parent::__construct($message, $code, $previous);
1313
}
1414

1515
public static function create(): self
1616
{
17-
return new self();
17+
return new self;
1818
}
1919
}

src/Exceptions/InvalidMarkValueException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
class InvalidMarkValueException extends Exception
99
{
10-
public function __construct($message = 'The given mark value is not allowed.', $code = 0, Throwable $previous = null)
10+
public function __construct($message = 'The given mark value is not allowed.', $code = 0, ?Throwable $previous = null)
1111
{
1212
parent::__construct($message, $code, $previous);
1313
}
1414

1515
public static function create(): self
1616
{
17-
return new self();
17+
return new self;
1818
}
1919
}

src/Exceptions/InvalidMarkableInstanceException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
class InvalidMarkableInstanceException extends Exception
99
{
10-
public function __construct($message = 'Model must be a valid markable instance', $code = 0, Throwable $previous = null)
10+
public function __construct($message = 'Model must be a valid markable instance', $code = 0, ?Throwable $previous = null)
1111
{
1212
parent::__construct($message, $code, $previous);
1313
}
1414

1515
public static function create(): self
1616
{
17-
return new self();
17+
return new self;
1818
}
1919
}

src/Mark.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function getMarkClassName(): string
4242
->__toString();
4343
}
4444

45-
public static function add(Model $markable, Model $user, string $value = null, array $metadata = []): self
45+
public static function add(Model $markable, Model $user, ?string $value = null, array $metadata = []): self
4646
{
4747
static::validMarkable($markable);
4848

@@ -68,7 +68,7 @@ public static function add(Model $markable, Model $user, string $value = null, a
6868
return static::firstOrCreate($attributes, $values);
6969
}
7070

71-
public static function remove(Model $markable, Model $user, string $value = null)
71+
public static function remove(Model $markable, Model $user, ?string $value = null)
7272
{
7373
static::validMarkable($markable);
7474

@@ -80,7 +80,7 @@ public static function remove(Model $markable, Model $user, string $value = null
8080
])->get()->each->delete();
8181
}
8282

83-
public static function count(Model $markable, string $value = null): int
83+
public static function count(Model $markable, ?string $value = null): int
8484
{
8585
static::validMarkable($markable);
8686

@@ -91,7 +91,7 @@ public static function count(Model $markable, string $value = null): int
9191
])->count();
9292
}
9393

94-
public static function has(Model $markable, Model $user, string $value = null): bool
94+
public static function has(Model $markable, Model $user, ?string $value = null): bool
9595
{
9696
return static::where([
9797
app(static::class)->getUserIdColumn() => $user->getKey(),
@@ -101,7 +101,7 @@ public static function has(Model $markable, Model $user, string $value = null):
101101
])->exists();
102102
}
103103

104-
public static function toggle(Model $markable, Model $user, string $value = null, array $metadata = [])
104+
public static function toggle(Model $markable, Model $user, ?string $value = null, array $metadata = [])
105105
{
106106
return static::has($markable, $user, $value)
107107
? static::remove($markable, $user, $value)

src/Markable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function marks(): array
2525
return static::$marks ?? [];
2626
}
2727

28-
public function scopeWhereHasMark(Builder $builder, Mark $mark, Model $user, string $value = null): Builder
28+
public function scopeWhereHasMark(Builder $builder, Mark $mark, Model $user, ?string $value = null): Builder
2929
{
3030
return $builder->whereHas(
3131
$mark->markableRelationName(),

src/Scopes/MarkableScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function addWhereHasMark(Builder $builder, Mark $mark): void
2727
{
2828
$builder->macro(
2929
"whereHas{$mark::getMarkClassName()}",
30-
fn (Builder $b, $user, string $value = null) => $b->whereHasMark($mark, $user, $value)
30+
fn (Builder $b, $user, ?string $value = null) => $b->whereHasMark($mark, $user, $value)
3131
);
3232
}
3333
}

tests/Models/Article.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
class Article extends Model
1414
{
15-
use Markable;
1615
use HasFactory;
16+
use Markable;
1717

1818
protected static $marks = [
1919
Like::class,

tests/Models/Post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
class Post extends Model
1111
{
12-
use Markable;
1312
use HasFactory;
13+
use Markable;
1414

1515
protected static $marks = [
1616
Like::class,

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class TestCase extends Orchestra
1313
{
14-
public function setUp(): void
14+
protected function setUp(): void
1515
{
1616
parent::setUp();
1717

0 commit comments

Comments
 (0)