Skip to content

Commit

Permalink
Apply phpcbf to all PHP (#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
lindner committed Mar 4, 2021
1 parent 566d2f0 commit 32c1f1c
Show file tree
Hide file tree
Showing 248 changed files with 3,923 additions and 2,603 deletions.
7 changes: 4 additions & 3 deletions Idno/Caching/APCuCache.php
Expand Up @@ -3,15 +3,16 @@
namespace Idno\Caching {

use Symfony\Component\Cache\Adapter\ApcuAdapter;

/**
* Implement a persistent cache using APC User caching.
*/
class APCuCache extends PersistentCache
{
public function __construct() {
public function __construct()
{
parent::__construct();

$this->setCacheEngine(new ApcuAdapter());
}

Expand Down
7 changes: 4 additions & 3 deletions Idno/Caching/ArrayCache.php
@@ -1,7 +1,7 @@
<?php

namespace Idno\Caching {

use Symfony\Component\Cache\Adapter\ArrayAdapter;

/**
Expand All @@ -10,9 +10,10 @@
class ArrayCache
extends EphemeralCache
{
public function __construct() {
public function __construct()
{
parent::__construct();

$this->setCacheEngine(new ArrayAdapter());
}
}
Expand Down
71 changes: 41 additions & 30 deletions Idno/Caching/Cache.php
Expand Up @@ -3,89 +3,100 @@
namespace Idno\Caching {

use Symfony\Component\Cache\Adapter\AbstractAdapter;

abstract class Cache
extends \Idno\Common\Component
implements \ArrayAccess
{
/// This is the cache engine underlaying the engine
private $cache;

/**
* Set the cache engine used by this.
*
* @param AbstractAdapter $adapter
*/
protected function setCacheEngine(AbstractAdapter $adapter) {
protected function setCacheEngine(AbstractAdapter $adapter)
{
$this->cache = $adapter;
}

/**
* Get the current cache engine.
*
* @return AbstractAdapter
*/
public function getCacheEngine() : AbstractAdapter {
public function getCacheEngine() : AbstractAdapter
{
return $this->cache;
}


/**
* Return the number of keys currently stored.
*
* @deprecated
*/
public function size() {

public function size()
{

$engine = $this->getCacheEngine();

return count($engine->getItems());
}


/**
* Retrieve a value from the store.
* @param $key Key to retrieve
*
* @param $key Key to retrieve
* @return mixed|false
*/
public function load($key) {

public function load($key)
{

$engine = $this->getCacheEngine();

$item = $engine->getItem($key);
if ($item->isHit()) {
return $item->get();
}

return false;
}

/**
* Store or replace a value in the cache.
*
* @param $key string Identifier for this value
* @param $value mixed Value to store
* @param $key string Identifier for this value
* @param $value mixed Value to store
* @return bool
*/
public function store($key, $value) {

public function store($key, $value)
{

$engine = $this->getCacheEngine();

$item = $engine->getItem($key);
$item->set($value);

return $engine->save($item);
}

/**
* Remove a key from the cache.
* @param The key
*
* @param The key
* @return bool
*/
public function delete($key) {

public function delete($key)
{

$engine = $this->getCacheEngine();

return $engine->delete($key);
}

/* Object interface */

public function __isset($key)
Expand All @@ -97,9 +108,9 @@ public function __unset($key)
{
return $this->delete($key);
}

/* Candy */

public function __get($key)
{
return $this->load($key);
Expand All @@ -109,7 +120,7 @@ public function __set($key, $value)
{
return $this->store($key, $value);
}


/* Array access interface */

Expand Down
15 changes: 9 additions & 6 deletions Idno/Caching/FilesystemCache.php
Expand Up @@ -3,7 +3,7 @@
namespace Idno\Caching {

use Symfony\Component\Cache\Adapter\FilesystemAdapter;

/**
* Implement a persistent cache using the local filesystem.
*
Expand All @@ -15,19 +15,22 @@ class FilesystemCache extends PersistentCache
public function __construct()
{
$domain = md5(\Idno\Core\Idno::site()->config()->host);
if (empty($domain))
if (empty($domain)) {
throw new \RuntimeException(\Idno\Core\Idno::site()->language()->_("No domain specified for cache"));
}

$pathbase = \Idno\Core\Idno::site()->config()->cachepath;
if (empty($pathbase))
if (empty($pathbase)) {
$pathbase = \Idno\Core\Idno::site()->config()->uploadpath;
if (empty($pathbase))
}
if (empty($pathbase)) {
$pathbase = \Idno\Core\Idno::site()->config()->getTempDir();
}

$engine = new FilesystemAdapter($domain, 0, $pathbase);

$this->setCacheEngine($engine);

}

}
Expand Down
1 change: 1 addition & 0 deletions Idno/Caching/StaticArrayCache.php
Expand Up @@ -5,6 +5,7 @@
/**
* A version of ArrayCache which uses a shared array, this means it's safe to use "$foo = new StaticArrayCache()" and still have access
* to values set elsewhere in the system.
*
* @deprecated
*/
class StaticArrayCache extends ArrayCache
Expand Down
25 changes: 17 additions & 8 deletions Idno/Common/Component.php
Expand Up @@ -3,7 +3,7 @@
/**
* All idno components inherit this base class
*
* @package idno
* @package idno
* @subpackage core
*/

Expand All @@ -20,11 +20,11 @@ function __construct()
$this->registerPages();
$this->registerTranslations();
}

/**
* Register any autoloaders here.
*/
function registerLibraries()
function registerLibraries()
{
}

Expand Down Expand Up @@ -70,6 +70,7 @@ function registerTranslations()

/**
* Helper function that gets the full class name of this entity
*
* @return string
*/
function getClass()
Expand All @@ -80,6 +81,7 @@ function getClass()
/**
* Helper method to retrieve the filename of the current component
* (works with inheritance).
*
* @return string
*/
function getFilename()
Expand All @@ -91,6 +93,7 @@ function getFilename()

/**
* Returns a camelCase version of the object title, suitable for use in element IDs
*
* @return string
*/
function getIDSelector()
Expand All @@ -100,21 +103,25 @@ function getIDSelector()

/**
* Returns the camelCased version of a given string
* @param $string
*
* @param $string
* @return $string
*/
function camelCase($string)
{
$string = preg_replace_callback('/\s([a-z])/', function ($matches) {
return strtoupper($matches[0]);
}, strtolower($string));
$string = preg_replace_callback(
'/\s([a-z])/', function ($matches) {
return strtoupper($matches[0]);
}, strtolower($string)
);
$string = preg_replace('/\s/', '', $string);

return $string;
}

/**
* Returns a camelCase version of the object class, suitable for use in element IDs
*
* @return string
*/
function getClassSelector()
Expand All @@ -124,6 +131,7 @@ function getClassSelector()

/**
* Get the name of this class without its namespace
*
* @return string
*/
function getClassName()
Expand All @@ -144,7 +152,8 @@ function getNamespace()

/**
* Gets the name of this class including its namespace
* @param bool $convert_slashes If set to true, converts \ slashes to / (false by default)
*
* @param bool $convert_slashes If set to true, converts \ slashes to / (false by default)
* @return string
*/
function getFullClassName($convert_slashes = false)
Expand Down
2 changes: 1 addition & 1 deletion Idno/Common/ConsolePlugin.php
Expand Up @@ -3,7 +3,7 @@
/**
* All known console plugins should extend this component.
*
* @package idno
* @package idno
* @subpackage core
*/

Expand Down

0 comments on commit 32c1f1c

Please sign in to comment.