Skip to content

Commit

Permalink
chore: apply PSR-12 manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed May 30, 2023
1 parent 13ccdce commit b7b6a3b
Show file tree
Hide file tree
Showing 77 changed files with 1,265 additions and 395 deletions.
5 changes: 3 additions & 2 deletions common/class.Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,9 @@ public function handlePHPShutdown()

if ($error !== null && ($error['type'] & (E_COMPILE_ERROR | E_ERROR | E_PARSE | E_CORE_ERROR)) !== 0) {
$msg = (isset($error['file'], $error['line']))
? 'php error(' . $error['type'] . ') in ' . $error['file'] . '@' . $error['line'] . ': ' . $error['message']
: 'php error(' . $error['type'] . '): ' . $error['message'];
? 'php error(' . $error['type'] . ') in ' . $error['file'] . '@' . $error['line'] . ': '
. $error['message']
: 'php error(' . $error['type'] . '): ' . $error['message'];
self::singleton()->log(self::FATAL_LEVEL, $msg, ['PHPERROR']);
}
}
Expand Down
12 changes: 10 additions & 2 deletions common/log/class.Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ class common_log_Item
* @param int errorLine
* @return mixed
*/
public function __construct($description, $severity, $datetime, $backtrace = [], $tags = [], $request = "", $errorFile = '', $errorLine = 0)
{
public function __construct(
$description,
$severity,
$datetime,
$backtrace = [],
$tags = [],
$request = "",
$errorFile = '',
$errorLine = 0
) {
if (!is_string($description)) {
throw new InvalidArgumentException("The description must be a string, " . gettype($description) . " given");
}
Expand Down
7 changes: 4 additions & 3 deletions common/user/auth/class.Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ private function __construct()
*
* @access public
* @author Jerome Bogaerts, <[email protected]>
* @param string login The login of the user.
* @param string password the md5 hash of the password.
* @param allowedRoles A Role or an array of Roles that are allowed to be logged in. If the user has a Role that matches one or more Roles in this array, the login request will be accepted.
* @param string $login The login of the user.
* @param string $password the md5 hash of the password.
* @param $allowedRoles - A Role or an array of Roles that are allowed to be logged in. If the user has a Role that
* matches one or more Roles in this array, the login request will be accepted.
* @return boolean
*/
public function login(common_user_auth_Adapter $adapter, $allowedRoles = [])
Expand Down
6 changes: 5 additions & 1 deletion common/user/class.User.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public function getRoles()
// We use a Depth First Search approach to flatten the Roles Graph.
foreach ($this->getPropertyValues(GenerisRdf::PROPERTY_USER_ROLES) as $roleUri) {
$returnValue[] = $roleUri;
foreach (core_kernel_users_Service::singleton()->getIncludedRoles(new core_kernel_classes_Resource($roleUri)) as $role) {
$includedRoles = core_kernel_users_Service::singleton()->getIncludedRoles(
new core_kernel_classes_Resource($roleUri)
);

foreach ($includedRoles as $role) {
$returnValue[] = $role->getUri();
}
}
Expand Down
1 change: 1 addition & 0 deletions core/GenerisRdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
* Copyright (c) 2017 (original work) Open Assessment Technologies SA;
*
* phpcs:disable Generic.Files.LineLength
*/

namespace oat\generis\model;
Expand Down
23 changes: 17 additions & 6 deletions core/kernel/classes/class.Class.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,17 @@ public function countInstances($propertyFilters = [], $options = [])
* @param array options
* @return \core_kernel_classes_Resource[]
*/
public function getInstancesPropertyValues(core_kernel_classes_Property $property, $propertyFilters = [], $options = [])
{
return (array) $this->getImplementation()->getInstancesPropertyValues($this, $property, $propertyFilters, $options);
public function getInstancesPropertyValues(
core_kernel_classes_Property $property,
$propertyFilters = [],
$options = []
) {
return (array) $this->getImplementation()->getInstancesPropertyValues(
$this,
$property,
$propertyFilters,
$options
);
}

/**
Expand Down Expand Up @@ -394,7 +402,9 @@ public function createInstanceWithProperties($properties)

$additionalTypes = [];
if (isset($properties[OntologyRdf::RDF_TYPE])) {
$types = is_array($properties[OntologyRdf::RDF_TYPE]) ? $properties[OntologyRdf::RDF_TYPE] : [$properties[OntologyRdf::RDF_TYPE]];
$types = is_array($properties[OntologyRdf::RDF_TYPE])
? $properties[OntologyRdf::RDF_TYPE]
: [$properties[OntologyRdf::RDF_TYPE]];
foreach ($types as $type) {
$uri = is_object($type) ? $type->getUri() : $type;
if ($uri != $this->getUri()) {
Expand All @@ -418,8 +428,9 @@ public function createInstanceWithProperties($properties)
*
* @access public
* @author Jerome Bogaerts, <[email protected]>
* @param array resources An array of core_kernel_classes_Resource or URIs.
* @param boolean deleteReference If set to true, references about the resources will also be deleted from the database.
* @param array $resources An array of core_kernel_classes_Resource or URIs.
* @param boolean $deleteReference If set to true, references about the resources will also be deleted from the
* database.
* @return boolean
*/
public function deleteInstances($resources, $deleteReference = false)
Expand Down
9 changes: 7 additions & 2 deletions core/kernel/classes/class.ClassFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ public static function createInstance(core_kernel_classes_Class $clazz, $label =
* @param string uri
* @return core_kernel_classes_Property
*/
public static function createProperty(core_kernel_classes_Class $clazz, $label = '', $comment = '', $isLgDependent = false, $uri = '')
{
public static function createProperty(
core_kernel_classes_Class $clazz,
$label = '',
$comment = '',
$isLgDependent = false,
$uri = ''
) {
$returnValue = null;
$property = new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY);
$propertyInstance = self::createInstance($property, $label, $comment, $uri);
Expand Down
9 changes: 7 additions & 2 deletions core/kernel/classes/class.ClassIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function __construct($classes)
{
$classes = is_array($classes) ? $classes : [$classes];
foreach ($classes as $class) {
$this->todoClasses[] = (is_object($class) && $class instanceof core_kernel_classes_Class) ? $class->getUri() : $class;
$this->todoClasses[] = (is_object($class) && $class instanceof core_kernel_classes_Class)
? $class->getUri()
: $class;
}
$this->rewind();
}
Expand Down Expand Up @@ -92,7 +94,10 @@ public function next()
$this->classes[] = $newUri;
$class = new \core_kernel_classes_Class($newUri);
foreach ($class->getSubClasses(false) as $subClass) {
if (!in_array($subClass->getUri(), $this->classes) && !in_array($subClass->getUri(), $this->todoClasses)) {
if (
!in_array($subClass->getUri(), $this->classes)
&& !in_array($subClass->getUri(), $this->todoClasses)
) {
$this->todoClasses[] = $subClass->getUri();
}
}
Expand Down
6 changes: 5 additions & 1 deletion core/kernel/classes/class.ContainerCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ public function intersect(common_Collection $collection)


$returnValue = new core_kernel_classes_ContainerCollection(new common_Object(__METHOD__));
$returnValue->sequence = array_uintersect($this->sequence, $collection->sequence, 'core_kernel_classes_ContainerComparator::compare');
$returnValue->sequence = array_uintersect(
$this->sequence,
$collection->sequence,
'core_kernel_classes_ContainerComparator::compare'
);


return $returnValue;
Expand Down
8 changes: 5 additions & 3 deletions core/kernel/classes/class.DbWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,11 @@ public function getColumnNotFoundErrorCode()
* @abstract
* @access public
* @author Jerome Bogaerts, <[email protected]>
* @param string indexName The name of the index to create.
* @param string tableName A table name
* @param array columns An associative array that represents the columns on which the index applies. The keys of the array are the name of the columns, the values are the length of the data to index in the column. If there is no length limitation, set the value of the array cell to null.
* @param string $indexName The name of the index to create.
* @param string $tableName A table name
* @param array $columns An associative array that represents the columns on which the index applies. The keys of
* the array are the name of the columns, the values are the length of the data to index in
* the column. If there is no length limitation, set the value of the array cell to null.
* @return void
*/
public function createIndex($indexName, $tableName, $columns)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public function __construct(core_kernel_classes_Resource $resource, core_kernel_
$this->resource = $resource;
$this->property = $property;

parent::__construct('Property ( ' . $property->getUri() . ' ) of resource ' . ' ( ' . $resource->getUri() . ' ) has more than one value do not use getUniquePropertyValue but use getPropertyValue instead');
parent::__construct(
'Property ( ' . $property->getUri() . ' ) of resource ' . ' ( ' . $resource->getUri()
. ' ) has more than one value do not use getUniquePropertyValue but use getPropertyValue instead'
);
}

/**
Expand Down
28 changes: 20 additions & 8 deletions core/kernel/classes/class.Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,15 @@ private function getImplementation()
public function __construct($uri, $debug = '')
{
if (empty($uri)) {
throw new common_exception_Error('cannot construct the resource because the uri cannot be empty, debug: ' . $debug);
throw new common_exception_Error(
'cannot construct the resource because the uri cannot be empty, debug: ' . $debug
);
}
if (!is_string($uri) && !$uri instanceof self) {
throw new common_exception_Error('could not create resource from ' . (is_object($uri) ? get_class($uri) : gettype($uri)) . ' debug: ' . $debug);
throw new common_exception_Error(
'could not create resource from ' . (is_object($uri) ? get_class($uri) : gettype($uri))
. ' debug: ' . $debug
);
}
$this->uriResource = $uri instanceof self ? $uri->getUri() : $uri;
}
Expand All @@ -126,7 +131,9 @@ public function __construct($uri, $debug = '')
*/
public function __clone()
{
throw new common_exception_DeprecatedApiMethod('Use duplicated instead, because clone resource could not share same uri that original');
throw new common_exception_DeprecatedApiMethod(
'Use duplicated instead, because clone resource could not share same uri that original'
);
}

public function isCustom(): bool
Expand Down Expand Up @@ -196,7 +203,8 @@ public function isProperty()
* Returns all the types of this resource as core_kernel_classes_Class objects.
*
* @author Joel Bout <[email protected]>
* @return core_kernel_classes_Class[] An associative array where keys are class URIs and values are core_kernel_classes_Class objects.
* @return core_kernel_classes_Class[] An associative array where keys are class URIs and values are
* core_kernel_classes_Class objects.
*/
public function getTypes()
{
Expand Down Expand Up @@ -287,8 +295,9 @@ public function setComment($comment)
*
* @access public
* @author Joel Bout, <[email protected]>
* @param Property property uriProperty is string and may be short in the case of a locally defined property (module namespace), or long uri
* @param array options
* @param core_kernel_classes_Property $property uriProperty is string and may be short in the case of a locally
* defined property (module namespace), or long uri
* @param array $options
* @return array
*/
public function getPropertyValues(core_kernel_classes_Property $property, $options = [])
Expand Down Expand Up @@ -358,7 +367,9 @@ public function getOnePropertyValue(core_kernel_classes_Property $property, $las
{
$returnValue = null;
if ($last) {
throw new core_kernel_persistence_Exception('parameter \'last\' for getOnePropertyValue no longer supported');
throw new core_kernel_persistence_Exception(
'parameter \'last\' for getOnePropertyValue no longer supported'
);
};

$options = [
Expand Down Expand Up @@ -595,7 +606,8 @@ public function duplicate($excludedProperties = [])
*
* @author [email protected]
*
* @param bool deleteReference set deleteReference to true when you need that all reference to this resource are removed.
* @param bool $deleteReference set deleteReference to true when you need that all reference to this resource are
* removed.
*
* @return bool
*/
Expand Down
4 changes: 3 additions & 1 deletion core/kernel/classes/class.ResourceFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ private function propertiesValuestoStdClasses($propertiesValues = null)
foreach ($values as $value) {
$stdValue = new stdClass();
$stdValue->valueType = (get_class($value) == "core_kernel_classes_Literal") ? "literal" : "resource";
$stdValue->value = (get_class($value) == "core_kernel_classes_Literal") ? $value->__toString() : $value->getUri();
$stdValue->value = (get_class($value) == "core_kernel_classes_Literal")
? $value->__toString()
: $value->getUri();
$propStdClass->values[] = $stdValue;
}
$returnValue[] = $propStdClass;
Expand Down
3 changes: 2 additions & 1 deletion core/kernel/classes/class.ResourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public function next()
$this->currentInstance++;
if (!isset($this->instanceCache[$this->currentInstance])) {
// try to load next block (unless we know it's empty)
$remainingInstances = !$this->endOfClass && $this->load($this->classIterator->current(), $this->currentInstance);
$remainingInstances = !$this->endOfClass
&& $this->load($this->classIterator->current(), $this->currentInstance);

// endOfClass or failed loading
if (!$remainingInstances) {
Expand Down
4 changes: 3 additions & 1 deletion core/kernel/impl/class.ApiModelOO.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ public function setStatement($subject, $predicate, $object, $language)
]);
} catch (DBALException $e) {
if ($e->getCode() !== '00000') {
throw new common_Exception("Unable to setStatement (SPO) {$subject}, {$predicate}, {$object} : " . $e->getMessage());
throw new common_Exception(
"Unable to setStatement (SPO) {$subject}, {$predicate}, {$object} : " . $e->getMessage()
);
}
}

Expand Down
14 changes: 12 additions & 2 deletions core/kernel/persistence/interface.ClassInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ public function createSubClass(core_kernel_classes_Class $resource, $label = '',
* @param boolean isLgDependent
* @return core_kernel_classes_Property
*/
public function createProperty(core_kernel_classes_Class $resource, $label = '', $comment = '', $isLgDependent = false);
public function createProperty(
core_kernel_classes_Class $resource,
$label = '',
$comment = '',
$isLgDependent = false
);

/**
* Short description of method searchInstances
Expand Down Expand Up @@ -181,7 +186,12 @@ public function countInstances(core_kernel_classes_Class $resource, $propertyFil
* @param array options
* @return array
*/
public function getInstancesPropertyValues(core_kernel_classes_Class $resource, core_kernel_classes_Property $property, $propertyFilters = [], $options = []);
public function getInstancesPropertyValues(
core_kernel_classes_Class $resource,
core_kernel_classes_Property $property,
$propertyFilters = [],
$options = []
);

/**
* Should not be called by application code, please use
Expand Down
Loading

0 comments on commit b7b6a3b

Please sign in to comment.