16
16
* Controller to process the Discourse SSO request. There is a good bit of logic in here that almost feels like too
17
17
* much for a controller, but given that this is the only thing that this controller is doing, I am not going to break
18
18
* it out into a service class.
19
- *
20
- * @package Spinen\Discourse\Controllers
21
19
*/
22
20
class SsoController extends Controller
23
21
{
24
22
/**
25
23
* Package configuration
26
- *
27
- * @var Collection
28
24
*/
29
- protected $ config ;
25
+ protected Collection $ config ;
30
26
31
27
/**
32
28
* SSOHelper Instance
33
- *
34
- * @var SSOHelper
35
29
*/
36
- protected $ sso ;
30
+ protected SSOHelper $ sso ;
37
31
38
32
/**
39
33
* Authenticated user
40
- *
41
- * @var User
42
34
*/
43
- protected $ user ;
35
+ protected User $ user ;
44
36
45
37
/**
46
38
* SsoController constructor.
47
- *
48
- * @param Config $config
49
- * @param SSOHelper $sso
50
39
*/
51
40
public function __construct (Config $ config , SSOHelper $ sso )
52
41
{
@@ -57,10 +46,8 @@ public function __construct(Config $config, SSOHelper $sso)
57
46
58
47
/**
59
48
* Build out the extra parameters to send to Discourse
60
- *
61
- * @return array
62
49
*/
63
- protected function buildExtraParameters ()
50
+ protected function buildExtraParameters (): array
64
51
{
65
52
return $ this ->config ->get ('user ' )
66
53
->except (['access ' , 'email ' , 'external_id ' ])
@@ -75,12 +62,8 @@ protected function buildExtraParameters()
75
62
*
76
63
* The Discourse SSO API does not accept 0 or 1 for false or true. You must send
77
64
* "false" or "true", so convert any boolean property to the string version.
78
- *
79
- * @param $property
80
- *
81
- * @return string
82
65
*/
83
- public function castBooleansToString ($ property )
66
+ public function castBooleansToString (string | bool $ property ): string
84
67
{
85
68
if (! is_bool ($ property )) {
86
69
return $ property ;
@@ -93,10 +76,8 @@ public function castBooleansToString($property)
93
76
* Cache the configs on the object as a collection
94
77
*
95
78
* The 'user' property will be an array, so go ahead and convert it to a collection
96
- *
97
- * @param Config $config
98
79
*/
99
- protected function loadConfigs (Config $ config )
80
+ protected function loadConfigs (Config $ config ): void
100
81
{
101
82
$ this ->config = collect ($ config ->get ('services.discourse ' ));
102
83
$ this ->config ->put ('user ' , collect ($ this ->config ->get ('user ' )));
@@ -105,9 +86,6 @@ protected function loadConfigs(Config $config)
105
86
/**
106
87
* Process the SSO login request from Discourse
107
88
*
108
- * @param Request $request
109
- *
110
- * @return mixed
111
89
* @throws 403
112
90
*/
113
91
public function login (Request $ request )
@@ -138,11 +116,8 @@ public function login(Request $request)
138
116
139
117
/**
140
118
* Check to see if property is null
141
- *
142
- * @param string $property
143
- * @return bool
144
119
*/
145
- public function nullProperty ($ property )
120
+ public function nullProperty (? string $ property ): bool
146
121
{
147
122
return is_null ($ property );
148
123
}
@@ -151,9 +126,6 @@ public function nullProperty($property)
151
126
* Get the property from the user
152
127
*
153
128
* If a string is passed in, then get it from the user object, otherwise, return what was given
154
- *
155
- * @param mixed $property
156
- * @return mixed
157
129
*/
158
130
public function parseUserValue ($ property )
159
131
{
0 commit comments