Skip to content

Commit

Permalink
Merge pull request #1041 from oat-sa/feature/ADF-1440/psr-12-apply
Browse files Browse the repository at this point in the history
chore: apply PSR-12
  • Loading branch information
shpran authored May 30, 2023
2 parents 984ae70 + 700d6e0 commit ad97fb8
Show file tree
Hide file tree
Showing 453 changed files with 4,530 additions and 2,815 deletions.
9 changes: 7 additions & 2 deletions common/cache/class.Exception.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -14,8 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER); 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
*
*/

Expand Down
9 changes: 6 additions & 3 deletions common/cache/class.FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2010-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2010-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
*
*/

Expand Down
22 changes: 14 additions & 8 deletions common/cache/class.KeyValueCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2010-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2010-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
*
*/

Expand All @@ -33,18 +36,21 @@
*/
class common_cache_KeyValueCache extends ConfigurableService implements common_cache_Cache
{
const OPTION_PERSISTENCE = 'persistence';
public const OPTION_PERSISTENCE = 'persistence';


/**
* @var common_persistence_KeyValuePersistence
*/
private $persistence;

protected function getPersistence()
{
if (is_null($this->persistence)) {
$this->persistence = $this->getServiceLocator()->get('generis/persistences')->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE));
$this->persistence = $this
->getServiceLocator()
->get('generis/persistences')
->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE));
}
return $this->persistence;
}
Expand Down
3 changes: 1 addition & 2 deletions common/cache/class.NoCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
class common_cache_NoCache extends ConfigurableService implements common_cache_Cache
{

public function has($key)
{
return false;
Expand All @@ -47,7 +46,7 @@ public function remove($serial)
{
return true;
}

public function get($serial)
{
throw new common_cache_NotFoundException();
Expand Down
9 changes: 7 additions & 2 deletions common/cache/class.NotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -14,8 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER); 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
*
*/

Expand Down
46 changes: 28 additions & 18 deletions common/cache/class.PartitionedCachable.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -14,9 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
*
*/

Expand Down Expand Up @@ -65,12 +69,12 @@ public function getSerial()
{
$returnValue = (string) '';


if (empty($this->serial)) {
$this->serial = $this->buildSerial();
}
$returnValue = $this->serial;


return (string) $returnValue;
}
Expand All @@ -84,7 +88,7 @@ public function getSerial()
*/
public function __construct()
{

if (!is_null($this->getCache())) {
$this->getCache()->put($this);
}
Expand All @@ -101,7 +105,7 @@ public function __sleep()
{
$returnValue = [];


$this->serializedProperties = [];
$reflection = new ReflectionClass($this);
foreach ($reflection->getProperties() as $property) {
Expand All @@ -122,7 +126,10 @@ public function __sleep()
}
}
if ($containsNonSerializable && $containsSerializable) {
throw new common_exception_Error('Serializable ' . $this->getSerial() . ' mixed serializable and non serializable values in property ' . $propertyName);
throw new common_exception_Error(
'Serializable ' . $this->getSerial()
. ' mixed serializable and non serializable values in property ' . $propertyName
);
}
} else {
if (is_object($value) && $value instanceof self) {
Expand All @@ -137,7 +144,7 @@ public function __sleep()
}
}
}


return (array) $returnValue;
}
Expand All @@ -151,7 +158,7 @@ public function __sleep()
*/
public function __wakeup()
{

foreach ($this->serializedProperties as $key => $value) {
if (is_array($value)) {
$restored = [];
Expand All @@ -172,16 +179,19 @@ public function __wakeup()
* @access public
* @author Jerome Bogaerts, <[email protected]>
* @return mixed
*
* phpcs:disable PSR2.Methods.MethodDeclaration
*/
public function _remove()
{

//usefull only when persistance is enabled
if (!is_null($this->getCache())) {
//clean session
$this->getCache()->remove($this->getSerial());
}
}
// phpcs:enable PSR2.Methods.MethodDeclaration

/**
* Short description of method getSuccessors
Expand All @@ -194,7 +204,7 @@ public function getSuccessors()
{
$returnValue = [];


$reflection = new ReflectionClass($this);
foreach ($reflection->getProperties() as $property) {
if (!$property->isStatic() && !$property->isPrivate()) {
Expand All @@ -203,15 +213,15 @@ public function getSuccessors()
if (is_array($value)) {
foreach ($value as $key => $subvalue) {
if (is_object($subvalue) && $subvalue instanceof self) {
$returnValue[] = $subvalue;
$returnValue[] = $subvalue;
}
}
} elseif (is_object($value) && $value instanceof self) {
$returnValue[] = $value;
$returnValue[] = $value;
}
}
}


return (array) $returnValue;
}
Expand All @@ -228,7 +238,7 @@ public function getPredecessors($classFilter = null)
{
$returnValue = [];


foreach ($this->getCache()->getAll() as $serial => $instance) {
if (
($classFilter == null || $instance instanceof $classFilter)
Expand All @@ -238,7 +248,7 @@ public function getPredecessors($classFilter = null)
break;
}
}


return (array) $returnValue;
}
Expand All @@ -262,4 +272,4 @@ abstract protected function buildSerial();
* @return common_cache_Cache
*/
abstract public function getCache();
} /* end of abstract class common_cache_PartitionedCachable */
}
3 changes: 1 addition & 2 deletions common/cache/class.PsrWrapperCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
class common_cache_PsrWrapperCache extends ConfigurableService implements common_cache_Cache
{

/**
* puts "something" into the cache,
* * If this is an object and implements Serializable,
Expand Down Expand Up @@ -112,7 +111,7 @@ public function purge()
return $this->getPsrSimpleCache()->clear();
}

protected function getPsrSimpleCache() : CacheInterface
protected function getPsrSimpleCache(): CacheInterface
{
return $this->getServiceLocator()->get(SimpleCache::SERVICE_ID);
}
Expand Down
3 changes: 2 additions & 1 deletion common/cache/class.SingletonCache.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -112,4 +113,4 @@ public static function getCached($function)
private function __construct()
{
}
} /* end of abstract class common_cache_SingletonCache */
}
12 changes: 8 additions & 4 deletions common/cache/interface.Cache.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -14,9 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
* 2013-2014 (update and modification) Open Assessment Technologies SA;
*/

Expand All @@ -29,7 +33,7 @@ interface common_cache_Cache
/**
* Service manager id.
*/
const SERVICE_ID = 'generis/cache';
public const SERVICE_ID = 'generis/cache';

// --- OPERATIONS ---

Expand Down
24 changes: 14 additions & 10 deletions common/class.AjaxResponse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -14,9 +15,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg
* (under the project TAO & TAO2);
* 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung
* (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
*
*/

Expand Down Expand Up @@ -51,12 +55,12 @@ class common_AjaxResponse
public function __construct(array $options = [])
{

$success = isset($options['success']) ? $options['success'] : true;
$type = isset($options['type']) ? $options['type'] : 'json';
$data = isset($options['data']) ? $options['data'] : null;
$message = isset($options['message']) ? $options['message'] : '';

$success = isset($options['success']) ? $options['success'] : true;
$type = isset($options['type']) ? $options['type'] : 'json';
$data = isset($options['data']) ? $options['data'] : null;
$message = isset($options['message']) ? $options['message'] : '';

//position the header of the response
$context = Context::getInstance();
$context->getResponse()->setContentHeader('application/json');
Expand All @@ -67,7 +71,7 @@ public function __construct(array $options = [])
, 'message' => $message
, 'data' => $data
];

//write the response
echo json_encode($response);
}
Expand Down
Loading

0 comments on commit ad97fb8

Please sign in to comment.