Skip to content

Commit 95bc97d

Browse files
committed
Fix internal doc and type hinting (Ref #711)
1 parent ad1d277 commit 95bc97d

3 files changed

Lines changed: 52 additions & 27 deletions

File tree

app/sprinkles/core/src/Alert/CacheAlertStream.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,50 @@
77
*/
88
namespace UserFrosting\Sprinkle\Core\Alert;
99

10+
use Illuminate\Cache\TaggedCache;
11+
use UserFrosting\I18n\MessageTranslator;
12+
use UserFrosting\Support\Repository\Repository;
13+
1014
/**
11-
* CacheAlertStream Class
12-
*
13-
* Implements a message stream for use between HTTP requests, with i18n support via the MessageTranslator class
14-
* Using the cache system to store the alerts. Note that the tags are added each time instead of the constructor
15-
* since the session_id can change when the user logs in or out
15+
* CacheAlertStream Class
16+
* Implements a message stream for use between HTTP requests, with i18n
17+
* support via the MessageTranslator class using the cache system to store
18+
* the alerts. Note that the tags are added each time instead of the
19+
* constructor since the session_id can change when the user logs in or out
1620
*
17-
* @author Louis Charette
21+
* @author Louis Charette
1822
*/
1923
class CacheAlertStream extends AlertStream
2024
{
2125
/**
22-
* @var Illuminate\\Cache\\*Store Object We use the cache object so that added messages will automatically appear in the cache.
26+
* @var TaggedCache Object We use the cache object so that added messages will automatically appear in the cache.
2327
*/
2428
protected $cache;
2529

2630
/**
27-
* @var Illuminate\\Cache\\*Store Object We use the cache object so that added messages will automatically appear in the cache.
31+
* @var Repository Object We use the cache object so that added messages will automatically appear in the cache.
2832
*/
2933
protected $config;
3034

3135
/**
32-
* Create a new message stream.
36+
* Create a new message stream.
37+
*
38+
* @param string $messagesKey Store the messages under this key
39+
* @param MessageTranslator|null $translator
40+
* @param TaggedCache $cache
41+
* @param Repository $config
3342
*/
34-
public function __construct($messagesKey, $translator = null, $cache, $config)
43+
public function __construct($messagesKey, MessageTranslator $translator = null, TaggedCache $cache, Repository $config)
3544
{
3645
$this->cache = $cache;
3746
$this->config = $config;
3847
parent::__construct($messagesKey, $translator);
3948
}
4049

4150
/**
42-
* Get the messages from this message stream.
51+
* Get the messages from this message stream.
4352
*
44-
* @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
53+
* @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
4554
*/
4655
public function messages()
4756
{
@@ -53,15 +62,20 @@ public function messages()
5362
}
5463

5564
/**
56-
* Clear all messages from this message stream.
65+
* Clear all messages from this message stream.
66+
*
67+
* @return void
5768
*/
5869
public function resetMessageStream()
5970
{
6071
$this->cache->tags([$this->config['cache.prefix'], "_s".session_id()])->forget($this->messagesKey);
6172
}
6273

6374
/**
64-
* Save messages to the stream
75+
* Save messages to the stream
76+
*
77+
* @param string $messages The message
78+
* @return void
6579
*/
6680
protected function saveMessages($messages)
6781
{

app/sprinkles/core/src/Alert/SessionAlertStream.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,61 @@
77
*/
88
namespace UserFrosting\Sprinkle\Core\Alert;
99

10+
use UserFrosting\I18n\MessageTranslator;
11+
use UserFrosting\Session\Session;
12+
1013
/**
11-
* SessionAlertStream Class
12-
*
13-
* Implements a message stream for use between HTTP requests, with i18n support via the MessageTranslator class
14-
* Using the session storage to store the alerts
14+
* SessionAlertStream Class
15+
* Implements a message stream for use between HTTP requests, with i18n support via the MessageTranslator class
16+
* Using the session storage to store the alerts
1517
*
16-
* @author Alex Weissman (https://alexanderweissman.com)
18+
* @author Alex Weissman (https://alexanderweissman.com)
1719
*/
1820
class SessionAlertStream extends AlertStream
1921
{
2022
/**
21-
* @var UserFrosting\Session\Session We use the session object so that added messages will automatically appear in the session.
23+
* @var Session We use the session object so that added messages will automatically appear in the session.
2224
*/
2325
protected $session;
2426

2527
/**
26-
* Create a new message stream.
28+
* Create a new message stream.
29+
*
30+
* @param string $messagesKey Store the messages under this key
31+
* @param MessageTranslator|null $translator
32+
* @param Session $session
2733
*/
28-
public function __construct($messagesKey, $translator = null, $session)
34+
public function __construct($messagesKey, MessageTranslator $translator = null, Session $session)
2935
{
3036
$this->session = $session;
3137
parent::__construct($messagesKey, $translator);
3238
}
3339

3440
/**
35-
* Get the messages from this message stream.
41+
* Get the messages from this message stream.
3642
*
37-
* @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
43+
* @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
3844
*/
3945
public function messages()
4046
{
4147
return $this->session[$this->messagesKey] ?: [];
4248
}
4349

4450
/**
45-
* Clear all messages from this message stream.
51+
* Clear all messages from this message stream.
52+
*
53+
* @return void
4654
*/
4755
public function resetMessageStream()
4856
{
4957
$this->session[$this->messagesKey] = [];
5058
}
5159

5260
/**
53-
* Save messages to the stream
61+
* Save messages to the stream
62+
*
63+
* @param string $messages The message
64+
* @return void
5465
*/
5566
protected function saveMessages($messages)
5667
{

app/sprinkles/core/src/ServicesProvider/ServicesProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function register(ContainerInterface $container)
149149
/**
150150
* Cache service.
151151
*
152-
* @todo Create an option somewhere to flush the cache
152+
* @return \Illuminate\Cache\TaggedCache
153153
*/
154154
$container['cache'] = function ($c) {
155155

0 commit comments

Comments
 (0)