Skip to content

Commit 42cbdd4

Browse files
authored
[13.x] Use constructor promotion and typed properties in cache flush events (#59098)
1 parent 24a56c3 commit 42cbdd4

File tree

3 files changed

+15
-57
lines changed

3 files changed

+15
-57
lines changed

src/Illuminate/Cache/Events/CacheFlushFailed.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@
44

55
class CacheFlushFailed
66
{
7-
/**
8-
* The name of the cache store.
9-
*
10-
* @var string|null
11-
*/
12-
public $storeName;
13-
14-
/**
15-
* The tags that were assigned to the key.
16-
*
17-
* @var array
18-
*/
19-
public $tags;
20-
217
/**
228
* Create a new event instance.
239
*
2410
* @param string|null $storeName
2511
* @param array $tags
2612
*/
27-
public function __construct($storeName, array $tags = [])
28-
{
29-
$this->storeName = $storeName;
30-
$this->tags = $tags;
13+
public function __construct(
14+
public ?string $storeName,
15+
public array $tags = [],
16+
) {
3117
}
3218

3319
/**
@@ -36,7 +22,7 @@ public function __construct($storeName, array $tags = [])
3622
* @param array $tags
3723
* @return $this
3824
*/
39-
public function setTags($tags)
25+
public function setTags(array $tags)
4026
{
4127
$this->tags = $tags;
4228

src/Illuminate/Cache/Events/CacheFlushed.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@
44

55
class CacheFlushed
66
{
7-
/**
8-
* The name of the cache store.
9-
*
10-
* @var string|null
11-
*/
12-
public $storeName;
13-
14-
/**
15-
* The tags that were assigned to the key.
16-
*
17-
* @var array
18-
*/
19-
public $tags;
20-
217
/**
228
* Create a new event instance.
239
*
2410
* @param string|null $storeName
2511
* @param array $tags
2612
*/
27-
public function __construct($storeName, array $tags = [])
28-
{
29-
$this->storeName = $storeName;
30-
$this->tags = $tags;
13+
public function __construct(
14+
public ?string $storeName,
15+
public array $tags = [],
16+
) {
3117
}
3218

3319
/**
@@ -36,7 +22,7 @@ public function __construct($storeName, array $tags = [])
3622
* @param array $tags
3723
* @return $this
3824
*/
39-
public function setTags($tags)
25+
public function setTags(array $tags)
4026
{
4127
$this->tags = $tags;
4228

src/Illuminate/Cache/Events/CacheFlushing.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@
44

55
class CacheFlushing
66
{
7-
/**
8-
* The name of the cache store.
9-
*
10-
* @var string|null
11-
*/
12-
public $storeName;
13-
14-
/**
15-
* The tags that were assigned to the key.
16-
*
17-
* @var array
18-
*/
19-
public $tags;
20-
217
/**
228
* Create a new event instance.
239
*
2410
* @param string|null $storeName
2511
* @param array $tags
2612
*/
27-
public function __construct($storeName, array $tags = [])
28-
{
29-
$this->storeName = $storeName;
30-
$this->tags = $tags;
13+
public function __construct(
14+
public ?string $storeName,
15+
public array $tags = [],
16+
) {
3117
}
3218

3319
/**
@@ -36,7 +22,7 @@ public function __construct($storeName, array $tags = [])
3622
* @param array $tags
3723
* @return $this
3824
*/
39-
public function setTags($tags)
25+
public function setTags(array $tags)
4026
{
4127
$this->tags = $tags;
4228

0 commit comments

Comments
 (0)