Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
phpcs and doc block fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
burzum committed Jul 17, 2017
1 parent cbcd4ce commit 04b6de7
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 129 deletions.
18 changes: 9 additions & 9 deletions src/Auth/DefaultAuthSetupTrait.php
Expand Up @@ -8,20 +8,20 @@
*/
namespace Burzum\UserTools\Auth;

trait DefaultAuthSetupTrait
{
trait DefaultAuthSetupTrait {

/**
* Sets the default authentication settings up.
*
* Call this in your beforeFilter().
*
* @return void
*/
/**
* Sets the default authentication settings up.
*
* Call this in your beforeFilter().
*
* @return void
*/
public function setupAuthentication() {
if (!in_array('Auth', $this->components()->loaded())) {
$this->components()->load('Auth');
}

$this->components()->Auth->config('authenticate', [
'Form' => [
'userModel' => 'Users',
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/FlashAndRedirectTrait.php
Expand Up @@ -60,7 +60,7 @@ protected function _handleRedirect($type, $options) {
*
* @param string $type Prefix for the array key, mostly "success" or "error"
* @param array $options Options
* @return boolean
* @return bool
*/
protected function _handleFlash($type, $options) {
if (isset($options[$type . 'Message']) && $options[$type . 'Message'] !== false) {
Expand Down
80 changes: 46 additions & 34 deletions src/Controller/Component/UserToolComponent.php
Expand Up @@ -8,13 +8,13 @@
*/
namespace Burzum\UserTools\Controller\Component;

use Cake\Core\Configure;
use Cake\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Event\EventDispatcherTrait;
use Cake\Event\Event;
use Cake\Event\EventDispatcherTrait;
use Cake\Http\Response;
use Cake\Network\Exception\NotFoundException;
use Cake\ORM\Table;
Expand Down Expand Up @@ -224,10 +224,20 @@ public function __construct(ComponentRegistry $registry, $config = []) {
parent::__construct($registry, $config);
}

/**
* Gets the request from the controller
*
* @return \Cake\Http\ServerRequest
*/
protected function _getRequest() {
return $this->getController()->request;
}

/**
* Gets the response from the controller
*
* @return \Cake\Http\Response
*/
protected function _getResponse() {
return $this->getController()->response;
}
Expand Down Expand Up @@ -289,7 +299,7 @@ public function initialize(array $config) {
* User listing with pagination.
*
* @param array $options Pagination options
* @return \Cake\ORM\Query
* @return void
*/
public function listing($options = []) {
$this->getController()->set('users', $this->getController()->paginate($this->UserTable, $options));
Expand All @@ -314,7 +324,7 @@ public function loadUserBehaviour() {
/**
* Sets or instantiates the user model class.
*
* @param mixed $table
* @param null|string|\Cake\ORM\Table $table Table name or a table object
* @throws \RuntimeException
* @return void
*/
Expand All @@ -338,9 +348,9 @@ public function setUserTable($table = null) {
/**
* Start up
*
* @param Event $Event
* @link https://github.com/cakephp/cakephp/issues/4530
* @return Response|null
* @param Event $Event Event object
* @return null|\Cake\Http\Response
*/
public function startup(Event $Event) {
if ($this->getConfig('actionMapping') === true) {
Expand All @@ -366,7 +376,9 @@ public function mapAction() {
}

/**
* @param string $action
* Direct Mapping
*
* @param string $action Action name
* @return \Cake\Http\Response|bool A response object containing the rendered view.
*/
protected function _directMapping($action) {
Expand All @@ -387,7 +399,7 @@ protected function _directMapping($action) {
/**
* Maps an action of the controller to the component
*
* @param string $action
* @param string $action Action name
* @return bool|\Cake\Network\Response
*/
protected function _mapAction($action) {
Expand Down Expand Up @@ -421,10 +433,10 @@ protected function _mapAction($action) {
* and flash message if configured for that.
*
* @see UserToolComponent::login()
* @param array $options
* @param array $options Options
* @return void
*/
public function _handleUserBeingAlreadyLoggedIn(array $options) {
protected function _handleUserBeingAlreadyLoggedIn(array $options) {
$Auth = $this->_getAuthObject();
if ((bool)$Auth->user()) {
if ($options['alreadyLoggedInRedirectUrl'] === null) {
Expand All @@ -437,8 +449,8 @@ public function _handleUserBeingAlreadyLoggedIn(array $options) {
/**
* Internal callback to prepare the credentials for the login.
*
* @param \Cake\Datasource\EntityInterface
* @param array $options
* @param \Cake\Datasource\EntityInterface $entity User entity
* @param array $options Options
* @return mixed
*/
protected function _beforeLogin(EntityInterface $entity, array $options) {
Expand All @@ -459,8 +471,8 @@ protected function _beforeLogin(EntityInterface $entity, array $options) {
/**
* Internal callback to handle the after login procedure.
*
* @param array $user
* @param array $options
* @param array $user User data
* @param array $options Options
* @return mixed
*/
protected function _afterLogin($user, array $options) {
Expand All @@ -487,7 +499,7 @@ protected function _afterLogin($user, array $options) {
/**
* Login
*
* @var array
* @param array $options Options
* @return bool
*/
public function login($options = []) {
Expand Down Expand Up @@ -541,9 +553,9 @@ public function getUser($userId = null, $options = []) {
/**
* Deletes an user record
*
* @param mixed $userId
* @param array $options
* @return boolean
* @param mixed $userId User ID
* @param array $options Options
* @return bool
*/
public function deleteUser($userId = null, $options = []) {
$entity = $this->_getUserEntity($userId);
Expand All @@ -561,7 +573,7 @@ public function deleteUser($userId = null, $options = []) {
/**
* Gets or constructs an user entity with a given id.
*
* @paramx mixed array|int|string $userId
* @param mixed array|int|string $userId User ID
* @return \Cake\Datasource\EntityInterface
*/
protected function _getUserEntity($userId) {
Expand Down Expand Up @@ -614,8 +626,8 @@ public function logout($options = []) {
* - `setEntity` Set the entity to the view or not, default is true.
*
* @throws \Cake\Error\NotFoundException
* @param array $options
* @return boolean|null
* @param array $options Options
* @return bool|null
*/
public function register($options = []) {
$options = Hash::merge($this->getConfig('registration'), $options);
Expand Down Expand Up @@ -647,9 +659,9 @@ public function register($options = []) {
}

/**
* verifyEmailToken
* Verifies an email token
*
* @param array $options
* @param array $options Options
* @return mixed
*/
public function verifyEmailToken($options = []) {
Expand All @@ -665,9 +677,9 @@ public function verifyEmailToken($options = []) {
/**
* The user can request a new password reset token, an email is send to him.
*
* @param array $options
* @param array $options Options
* @throws \Cake\Datasource\Exception\RecordNotFoundException
* @return boolean|null
* @return bool|null
*/
public function requestPassword($options = []) {
$options = Hash::merge($this->getConfig('requestPassword'), $options);
Expand Down Expand Up @@ -703,8 +715,8 @@ public function requestPassword($options = []) {
/**
* Initializes the password reset and handles a possible errors.
*
* @param \Cake\Datasource\EntityInterface
* @param array $options Options array
* @param \Cake\Datasource\EntityInterface $entity User entity
* @param array $options Options array Options
* @return bool
*/
protected function _initPasswordReset(EntityInterface $entity, $options) {
Expand All @@ -726,9 +738,9 @@ protected function _initPasswordReset(EntityInterface $entity, $options) {
/**
* Allows the user to enter a new password.
*
* @param string $token
* @param array $options
* @return void
* @param string|null $token Token
* @param array $options Options
* @return null|\Cake\Http\Response
*/
public function resetPassword($token = null, $options = []) {
$options = Hash::merge($this->getConfig('resetPassword'), $options);
Expand Down Expand Up @@ -785,7 +797,7 @@ public function resetPassword($token = null, $options = []) {
/**
* Let the logged in user change his password.
*
* @param array $options
* @param array $options Options
* @return void
*/
public function changePassword($options = []) {
Expand Down Expand Up @@ -820,7 +832,7 @@ public function changePassword($options = []) {
/**
* Verify Token
*
* @param array $options
* @param array $options Options
* @throws \Cake\Error\NotFoundException;
* @return mixed
*/
Expand Down Expand Up @@ -874,8 +886,8 @@ protected function _getAuthObject() {
/**
* Handles the optional setting of view vars within the component.
*
* @param bool $viewVar
* @param \Cake\Datesource\EntityInterface
* @param bool $viewVar Set the view var or not
* @param \Cake\Datasource\EntityInterface $entity User entity
* @return void
*/
protected function _setViewVar($viewVar, $entity) {
Expand Down

0 comments on commit 04b6de7

Please sign in to comment.