Skip to content

Commit

Permalink
Fix phpcs (#181)
Browse files Browse the repository at this point in the history
* Allow composer scripts

* Apply present day phpcs rules.
  • Loading branch information
markstory authored Aug 31, 2023
1 parent 4316f62 commit 2b7937a
Show file tree
Hide file tree
Showing 55 changed files with 282 additions and 379 deletions.
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@

}
},
"minimum-stability": "dev"
"minimum-stability": "dev",
"config": {
"allow-plugins": {
"cakephp/plugin-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
16 changes: 10 additions & 6 deletions src/AclExtras.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* Acl Extras.
Expand Down Expand Up @@ -34,7 +35,6 @@
*/
class AclExtras
{

/**
* Contains instance of AclComponent
*
Expand Down Expand Up @@ -91,10 +91,14 @@ class AclExtras
*/
protected $foundACOs = [];

/** @var \Cake\Controller\Controller */
/**
* @var \Cake\Controller\Controller
*/
protected $controller;

/** @var \Cake\Console\Shell */
/**
* @var \Cake\Console\Shell
*/
protected $Shell;

/**
Expand Down Expand Up @@ -178,7 +182,7 @@ public function acoUpdate($params = [])
} else {
$plugin = $params['plugin'];
if (!Plugin::loaded($plugin)) {
$this->err(__d('cake_acl', "<error>Plugin {0} not found or not activated.</error>", [$plugin]));
$this->err(__d('cake_acl', '<error>Plugin {0} not found or not activated.</error>', [$plugin]));

return false;
}
Expand Down Expand Up @@ -236,7 +240,7 @@ protected function _processPrefixes($root)
* @param string $plugin The name of the plugin to alias
* @return string
*/
protected function _pluginAlias(string $plugin) :string
protected function _pluginAlias(string $plugin): string
{
return preg_replace('/\//', '\\', Inflector::camelize($plugin));
}
Expand Down Expand Up @@ -355,7 +359,7 @@ public function getControllerList($plugin = null, $prefix = null)
$dir = new Folder($path[0]);
$controllers = $dir->find('.*Controller\.php');
} else {
$path = Plugin::classPath($plugin) . 'Controller' . DS. (empty($prefix) ? '' : DS . Inflector::camelize($prefix));
$path = Plugin::classPath($plugin) . 'Controller' . DS . (empty($prefix) ? '' : DS . Inflector::camelize($prefix));
$dir = new Folder($path);
$controllers = $dir->find('.*Controller\.php');
}
Expand Down
13 changes: 6 additions & 7 deletions src/AclInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
Expand All @@ -20,11 +21,9 @@
/**
* Access Control List interface.
* Implementing classes are used by AclComponent to perform ACL checks in Cake.
*
*/
interface AclInterface
{

/**
* Empty method to be overridden in subclasses
*
Expand All @@ -33,7 +32,7 @@ interface AclInterface
* @param string $action Action (defaults to *)
* @return bool Success
*/
public function check($aro, $aco, $action = "*");
public function check($aro, $aco, $action = '*');

/**
* Allow methods are used to grant an ARO access to an ACO.
Expand All @@ -43,7 +42,7 @@ public function check($aro, $aco, $action = "*");
* @param string $action Action (defaults to *)
* @return bool Success
*/
public function allow($aro, $aco, $action = "*");
public function allow($aro, $aco, $action = '*');

/**
* Deny methods are used to remove permission from an ARO to access an ACO.
Expand All @@ -53,7 +52,7 @@ public function allow($aro, $aco, $action = "*");
* @param string $action Action (defaults to *)
* @return bool Success
*/
public function deny($aro, $aco, $action = "*");
public function deny($aro, $aco, $action = '*');

/**
* Inherit methods modify the permission for an ARO to be that of its parent object.
Expand All @@ -63,12 +62,12 @@ public function deny($aro, $aco, $action = "*");
* @param string $action Action (defaults to *)
* @return bool Success
*/
public function inherit($aro, $aco, $action = "*");
public function inherit($aro, $aco, $action = '*');

/**
* Initialization method for the Acl implementation
*
* @param Component $component Component instance.
* @param \Cake\Controller\Component $component Component instance.
* @return void
*/
public function initialize(Component $component);
Expand Down
18 changes: 8 additions & 10 deletions src/Adapter/CachedDbAcl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
Expand All @@ -17,7 +18,6 @@

use Acl\AclInterface;
use Cake\Cache\Cache;
use Cake\Controller\Component;
use Cake\Core\Configure;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
Expand All @@ -31,12 +31,10 @@
*/
class CachedDbAcl extends DbAcl implements AclInterface
{

protected $_cacheConfig = 'default';

/**
* Constructor
*
*/
public function __construct()
{
Expand All @@ -50,7 +48,7 @@ public function __construct()
/**
* {{@inheritDoc}}
*/
public function check($aro, $aco, $action = "*")
public function check($aro, $aco, $action = '*')
{
$key = $this->_getCacheKey($aro, $aco, $action);

Expand All @@ -64,7 +62,7 @@ public function check($aro, $aco, $action = "*")
/**
* {{@inheritDoc}}
*/
public function allow($aro, $aco, $actions = "*", $value = 1)
public function allow($aro, $aco, $actions = '*', $value = 1)
{
Cache::clear($this->_cacheConfig);

Expand All @@ -74,8 +72,8 @@ public function allow($aro, $aco, $actions = "*", $value = 1)
/**
* Generates a string cache key for the ARO, ACO pair
*
* @param string|array|Entity $aro The requesting object identifier.
* @param string|array|Entity $aco The controlled object identifier.
* @param string|array|\Cake\ORM\Entity $aro The requesting object identifier.
* @param string|array|\Cake\ORM\Entity $aco The controlled object identifier.
* @param string $action Action
* @return string
*/
Expand All @@ -87,7 +85,7 @@ protected function _getCacheKey($aro, $aco, $action = '*')
/**
* Generates a key string to use for the cache
*
* @param string|array|Entity $ref Array with 'model' and 'foreign_key', model object, or string value
* @param string|array|\Cake\ORM\Entity $ref Array with 'model' and 'foreign_key', model object, or string value
* @return string
*/
protected function _getNodeCacheKey($ref)
Expand All @@ -100,7 +98,7 @@ protected function _getNodeCacheKey($ref)
return $ref->getSource() . '_' . $ref->id;
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
$name = key($ref);
list(, $alias) = pluginSplit($name);
[, $alias] = pluginSplit($name);

$bindTable = TableRegistry::getTableLocator()->get($name);
$entityClass = $bindTable->getEntityClass();
Expand All @@ -113,7 +111,7 @@ protected function _getNodeCacheKey($ref)
throw new Exception\Exception(
__d(
'cake_dev',
"Entity class {0} not found in CachedDbAcl::_getNodeCacheKey() when trying to bind {1} object",
'Entity class {0} not found in CachedDbAcl::_getNodeCacheKey() when trying to bind {1} object',
[$type, $this->alias()]
)
);
Expand Down
23 changes: 11 additions & 12 deletions src/Adapter/DbAcl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
Expand All @@ -16,12 +17,12 @@
namespace Acl\Adapter;

use Acl\AclInterface;
use Acl\Model\Table\AcosTable;
use Acl\Model\Table\ArosTable;
use Acl\Model\Table\PermissionsTable;
use Cake\Controller\Component;
use Cake\Core\App;
use Cake\ORM\TableRegistry;
use Acl\Model\Table\PermissionsTable;
use Acl\Model\Table\ArosTable;
use Acl\Model\Table\AcosTable;

/**
* DbAcl implements an ACL control system in the database. ARO's and ACO's are
Expand All @@ -39,7 +40,6 @@
* Users
* edit
* }}}
*
*/
class DbAcl implements AclInterface
{
Expand All @@ -49,7 +49,6 @@ class DbAcl implements AclInterface

/**
* Constructor
*
*/
public function __construct()
{
Expand All @@ -65,7 +64,7 @@ public function __construct()
/**
* Initializes the containing component and sets the Aro/Aco objects to it.
*
* @param AclComponent $component Component
* @param \Acl\Adapter\AclComponent $component Component
* @return void
*/
public function initialize(Component $component)
Expand All @@ -83,7 +82,7 @@ public function initialize(Component $component)
* @return bool Success (true if ARO has access to action in ACO, false otherwise)
* @link https://book.cakephp.org/2.0/en/core-libraries/components/access-control-lists.html#checking-permissions-the-acl-component
*/
public function check($aro, $aco, $action = "*")
public function check($aro, $aco, $action = '*')
{
return $this->Permission->check($aro, $aco, $action);
}
Expand All @@ -98,7 +97,7 @@ public function check($aro, $aco, $action = "*")
* @return bool Success
* @link https://book.cakephp.org/2.0/en/core-libraries/components/access-control-lists.html#assigning-permissions
*/
public function allow($aro, $aco, $actions = "*", $value = 1)
public function allow($aro, $aco, $actions = '*', $value = 1)
{
return $this->Permission->allow($aro, $aco, $actions, $value);
}
Expand All @@ -112,7 +111,7 @@ public function allow($aro, $aco, $actions = "*", $value = 1)
* @return bool Success
* @link https://book.cakephp.org/2.0/en/core-libraries/components/access-control-lists.html#assigning-permissions
*/
public function deny($aro, $aco, $action = "*")
public function deny($aro, $aco, $action = '*')
{
return $this->allow($aro, $aco, $action, -1);
}
Expand All @@ -125,7 +124,7 @@ public function deny($aro, $aco, $action = "*")
* @param string $action Action (defaults to *)
* @return bool Success
*/
public function inherit($aro, $aco, $action = "*")
public function inherit($aro, $aco, $action = '*')
{
return $this->allow($aro, $aco, $action, 0);
}
Expand All @@ -139,7 +138,7 @@ public function inherit($aro, $aco, $action = "*")
* @return bool Success
* @see allow()
*/
public function grant($aro, $aco, $action = "*")
public function grant($aro, $aco, $action = '*')
{
return $this->allow($aro, $aco, $action);
}
Expand All @@ -153,7 +152,7 @@ public function grant($aro, $aco, $action = "*")
* @return bool Success
* @see deny()
*/
public function revoke($aro, $aco, $action = "*")
public function revoke($aro, $aco, $action = '*')
{
return $this->deny($aro, $aco, $action);
}
Expand Down
Loading

0 comments on commit 2b7937a

Please sign in to comment.