Skip to content

Commit fcc2bfc

Browse files
committed
Added @return for all services for easier documentation, part of #711
1 parent 56cad27 commit fcc2bfc

File tree

4 files changed

+106
-19
lines changed

4 files changed

+106
-19
lines changed

app/sprinkles/account/src/ServicesProvider/ServicesProvider.php

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
*/
88
namespace UserFrosting\Sprinkle\Account\ServicesProvider;
99

10-
use Birke\Rememberme\Authenticator as RememberMe;
1110
use Illuminate\Database\Capsule\Manager as Capsule;
12-
use Monolog\Formatter\LineFormatter;
13-
use Monolog\Handler\ErrorLogHandler;
11+
use Interop\Container\ContainerInterface;
1412
use Monolog\Handler\StreamHandler;
1513
use Monolog\Logger;
1614
use Psr\Http\Message\ResponseInterface as Response;
@@ -25,7 +23,6 @@
2523
use UserFrosting\Sprinkle\Account\Repository\PasswordResetRepository;
2624
use UserFrosting\Sprinkle\Account\Repository\VerificationRepository;
2725
use UserFrosting\Sprinkle\Account\Twig\AccountExtension;
28-
use UserFrosting\Sprinkle\Core\Facades\Debug;
2926
use UserFrosting\Sprinkle\Core\Log\MixedFormatter;
3027

3128
/**
@@ -38,12 +35,14 @@ class ServicesProvider
3835
/**
3936
* Register UserFrosting's account services.
4037
*
41-
* @param Container $container A DI container implementing ArrayAccess and container-interop.
38+
* @param ContainerInterface $container A DI container implementing ArrayAccess and container-interop.
4239
*/
43-
public function register($container)
40+
public function register(ContainerInterface $container)
4441
{
4542
/**
4643
* Extend the asset manager service to see assets for the current user's theme.
44+
*
45+
* @return \UserFrosting\Assets\Assets
4746
*/
4847
$container->extend('assets', function ($assets, $c) {
4948

@@ -68,6 +67,8 @@ public function register($container)
6867
* Extend the 'classMapper' service to register model classes.
6968
*
7069
* Mappings added: User, Group, Role, Permission, Activity, PasswordReset, Verification
70+
*
71+
* @return \UserFrosting\Sprinkle\Core\Util\ClassMapper
7172
*/
7273
$container->extend('classMapper', function ($classMapper, $c) {
7374
$classMapper->setClassMapping('user', 'UserFrosting\Sprinkle\Account\Database\Models\User');
@@ -84,6 +85,8 @@ public function register($container)
8485
* Extends the 'errorHandler' service with custom exception handlers.
8586
*
8687
* Custom handlers added: ForbiddenExceptionHandler
88+
*
89+
* @return \UserFrosting\Sprinkle\Core\Error\ExceptionHandlerManager
8790
*/
8891
$container->extend('errorHandler', function ($handler, $c) {
8992
// Register the ForbiddenExceptionHandler.
@@ -98,6 +101,7 @@ public function register($container)
98101
/**
99102
* Extends the 'localePathBuilder' service, adding any locale files from the user theme.
100103
*
104+
* @return \UserFrosting\I18n\LocalePathBuilder
101105
*/
102106
$container->extend('localePathBuilder', function ($pathBuilder, $c) {
103107
// Add paths for user theme, if a user is logged in
@@ -125,6 +129,8 @@ public function register($container)
125129
* Extends the 'view' service with the AccountExtension for Twig.
126130
*
127131
* Adds account-specific functions, globals, filters, etc to Twig, and the path to templates for the user theme.
132+
*
133+
* @return \Slim\Views\Twig
128134
*/
129135
$container->extend('view', function ($view, $c) {
130136
$twig = $view->getEnvironment();
@@ -159,6 +165,8 @@ public function register($container)
159165
* Authentication service.
160166
*
161167
* Supports logging in users, remembering their sessions, etc.
168+
*
169+
* @return \UserFrosting\Sprinkle\Account\Authenticate\Authenticator
162170
*/
163171
$container['authenticator'] = function ($c) {
164172
$classMapper = $c->classMapper;
@@ -178,6 +186,8 @@ public function register($container)
178186

179187
/**
180188
* Sets up the AuthGuard middleware, used to limit access to authenticated users for certain routes.
189+
*
190+
* @return \UserFrosting\Sprinkle\Account\Authenticate\AuthGuard
181191
*/
182192
$container['authGuard'] = function ($c) {
183193
$authenticator = $c->authenticator;
@@ -188,6 +198,8 @@ public function register($container)
188198
* Authorization check logging with Monolog.
189199
*
190200
* Extend this service to push additional handlers onto the 'auth' log stack.
201+
*
202+
* @return \Monolog\Logger
191203
*/
192204
$container['authLogger'] = function ($c) {
193205
$logger = new Logger('auth');
@@ -208,6 +220,8 @@ public function register($container)
208220
* Authorization service.
209221
*
210222
* Determines permissions for user actions. Extend this service to add additional access condition callbacks.
223+
*
224+
* @return \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager
211225
*/
212226
$container['authorizer'] = function ($c) {
213227
$config = $c->config;
@@ -327,20 +341,29 @@ public function register($container)
327341

328342
/**
329343
* Loads the User object for the currently logged-in user.
344+
*
345+
* @return \UserFrosting\Sprinkle\Account\Database\Models\User
330346
*/
331347
$container['currentUser'] = function ($c) {
332348
$authenticator = $c->authenticator;
333349

334350
return $authenticator->user();
335351
};
336352

353+
/**
354+
* Password Hasher service
355+
*
356+
* @return \UserFrosting\Sprinkle\Account\Authenticate\Hasher
357+
*/
337358
$container['passwordHasher'] = function ($c) {
338359
$hasher = new Hasher();
339360
return $hasher;
340361
};
341362

342363
/**
343364
* Returns a callback that forwards to dashboard if user is already logged in.
365+
*
366+
* @return callable
344367
*/
345368
$container['redirect.onAlreadyLoggedIn'] = function ($c) {
346369
/**
@@ -361,6 +384,8 @@ public function register($container)
361384

362385
/**
363386
* Returns a callback that handles setting the `UF-Redirect` header after a successful login.
387+
*
388+
* @return callable
364389
*/
365390
$container['redirect.onLogin'] = function ($c) {
366391
/**
@@ -380,7 +405,7 @@ public function register($container)
380405
return $determineRedirectOnLogin($response)->withStatus(200);
381406
}
382407

383-
/** @var UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */
408+
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */
384409
$authorizer = $c->authorizer;
385410

386411
$currentUser = $c->authenticator->user();
@@ -395,6 +420,8 @@ public function register($container)
395420

396421
/**
397422
* Repository for password reset requests.
423+
*
424+
* @return \UserFrosting\Sprinkle\Account\Repository\PasswordResetRepository
398425
*/
399426
$container['repoPasswordReset'] = function ($c) {
400427
$classMapper = $c->classMapper;
@@ -406,6 +433,8 @@ public function register($container)
406433

407434
/**
408435
* Repository for verification requests.
436+
*
437+
* @return \UserFrosting\Sprinkle\Account\Repository\VerificationRepository
409438
*/
410439
$container['repoVerification'] = function ($c) {
411440
$classMapper = $c->classMapper;
@@ -419,6 +448,8 @@ public function register($container)
419448
* Logger for logging the current user's activities to the database.
420449
*
421450
* Extend this service to push additional handlers onto the 'userActivity' log stack.
451+
*
452+
* @return \Monolog\Logger
422453
*/
423454
$container['userActivityLogger'] = function ($c) {
424455
$classMapper = $c->classMapper;

app/sprinkles/admin/src/ServicesProvider/ServicesProvider.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
*/
88
namespace UserFrosting\Sprinkle\Admin\ServicesProvider;
99

10+
use Interop\Container\ContainerInterface;
1011
use Psr\Http\Message\ResponseInterface as Response;
1112
use Psr\Http\Message\ServerRequestInterface as Request;
12-
use UserFrosting\Sprinkle\Account\Authenticate\Authenticator;
13-
use UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager;
14-
use UserFrosting\Sprinkle\Core\Facades\Debug;
1513

1614
/**
1715
* Registers services for the admin sprinkle.
@@ -23,14 +21,16 @@ class ServicesProvider
2321
/**
2422
* Register UserFrosting's admin services.
2523
*
26-
* @param Container $container A DI container implementing ArrayAccess and container-interop.
24+
* @param ContainerInterface $container A DI container implementing ArrayAccess and container-interop.
2725
*/
28-
public function register($container)
26+
public function register(ContainerInterface $container)
2927
{
3028
/**
3129
* Extend the 'classMapper' service to register sprunje classes.
3230
*
3331
* Mappings added: 'activity_sprunje', 'group_sprunje', 'permission_sprunje', 'role_sprunje', 'user_sprunje'
32+
*
33+
* @return \UserFrosting\Sprinkle\Core\Util\ClassMapper
3434
*/
3535
$container->extend('classMapper', function ($classMapper, $c) {
3636
$classMapper->setClassMapping('activity_sprunje', 'UserFrosting\Sprinkle\Admin\Sprunje\ActivitySprunje');
@@ -47,6 +47,8 @@ public function register($container)
4747
* Returns a callback that handles setting the `UF-Redirect` header after a successful login.
4848
*
4949
* Overrides the service definition in the account Sprinkle.
50+
*
51+
* @return callable
5052
*/
5153
$container['redirect.onLogin'] = function ($c) {
5254
/**
@@ -62,11 +64,11 @@ public function register($container)
6264
// Backwards compatibility for the deprecated determineRedirectOnLogin service
6365
if ($c->has('determineRedirectOnLogin')) {
6466
$determineRedirectOnLogin = $c->determineRedirectOnLogin;
65-
67+
6668
return $determineRedirectOnLogin($response)->withStatus(200);
6769
}
6870

69-
/** @var UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */
71+
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */
7072
$authorizer = $c->authorizer;
7173

7274
$currentUser = $c->authenticator->user();

0 commit comments

Comments
 (0)