Skip to content

Commit

Permalink
Upgrade PHP-CS-Fixer to 3.64.* and change code style accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Oct 1, 2024
1 parent 23e0de7 commit a555e40
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"phpunit/phpunit": "9.5.*",
"symfony/dom-crawler": "5.4.*",
"mockery/mockery": "1.5.1",
"friendsofphp/php-cs-fixer": "3.16.*"
"friendsofphp/php-cs-fixer": "3.64.*"
},
"autoload": {
"classmap": ["src/controller/", "src/model/", "src/model/sparql/"]
Expand Down
4 changes: 2 additions & 2 deletions src/controller/EntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private function redirectREST($vocab, $uri, $targetFormat)
{
$baseurl = $this->getBaseHref();
$vocid = $vocab->getId();
$query = http_build_query(array('uri'=>$uri, 'format'=>$targetFormat));
$query = http_build_query(array('uri' => $uri, 'format' => $targetFormat));
$url = $baseurl . "rest/v1/$vocid/data?$query";
$this->redirect303($url);
}
Expand All @@ -35,7 +35,7 @@ private function redirectWeb($vocab, $uri)
$url = $baseurl . "$vocid/page/$localname";
} else {
// must use full URI
$query = http_build_query(array('uri'=>$uri));
$query = http_build_query(array('uri' => $uri));
$url = $baseurl . "$vocid/page/?" . $query;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/controller/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function parseLimit()
}


/** Global REST methods **/
/** Global REST methods **/

/**
* Returns all the vocabularies available on the server in a json object.
Expand Down Expand Up @@ -105,7 +105,7 @@ private function constructSearchParameters($request)
// convert to vocids array to support multi-vocabulary search
$vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : array();
$vocabObjects = array();
foreach($vocids as $vocid) {
foreach ($vocids as $vocid) {
$vocabObjects[] = $this->model->getVocabulary($vocid);
}
$parameters->setVocabularies($vocabObjects);
Expand Down Expand Up @@ -195,7 +195,7 @@ public function search(Request $request): void
$this->returnJson($ret);
}

/** Vocabulary-specific methods **/
/** Vocabulary-specific methods **/

/**
* Loads the vocabulary metadata. And wraps the result in a json-ld object.
Expand Down Expand Up @@ -985,7 +985,7 @@ public function hierarchy($request)
$topconcepts = $request->getVocab()->getTopConcepts(array_keys($schemes), $request->getLang());
foreach ($topconcepts as $top) {
if (!isset($results[$top['uri']])) {
$results[$top['uri']] = array('uri' => $top['uri'], 'top'=>$top['topConceptOf'], 'tops'=>array($top['topConceptOf']), 'prefLabel' => $top['label'], 'hasChildren' => $top['hasChildren']);
$results[$top['uri']] = array('uri' => $top['uri'], 'top' => $top['topConceptOf'], 'tops' => array($top['topConceptOf']), 'prefLabel' => $top['label'], 'hasChildren' => $top['hasChildren']);
if (isset($top['notation'])) {
$results[$top['uri']]['notation'] = $top['notation'];
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ private function changedConcepts($request, $prop, $offset, $limit)
$changeList = $request->getVocab()->getChangeList($prop, $request->getLang(), $offset, $limit);

$simpleChangeList = array();
foreach($changeList as $conceptInfo) {
foreach ($changeList as $conceptInfo) {
if (array_key_exists('date', $conceptInfo)) {
$concept = array(
'uri' => $conceptInfo['uri'],
Expand Down
6 changes: 3 additions & 3 deletions src/controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public function invokeGlobalSearch($request)
$vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null;
$vocabObjects = array();
if ($vocids) {
foreach($vocids as $vocid) {
foreach ($vocids as $vocid) {
try {
$vocabObjects[] = $this->model->getVocabulary($vocid);
} catch (ValueError $e) {
Expand Down Expand Up @@ -381,7 +381,7 @@ public function invokeGlobalSearch($request)
'search_count' => $counts,
'languages' => $this->languages,
'search_results' => $searchResults,
'rest' => $parameters->getOffset()>0,
'rest' => $parameters->getOffset() > 0,
'global_search' => true,
'search_failed' => $errored,
'term' => $request->getQueryParamRaw('q'),
Expand Down Expand Up @@ -453,7 +453,7 @@ public function invokeVocabularySearch($request)
'vocab' => $vocab,
'search_results' => $searchResults,
'search_count' => $counts,
'rest' => $parameters->getOffset()>0,
'rest' => $parameters->getOffset() > 0,
'limit_parent' => $parameters->getParentLimit(),
'limit_type' => $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null,
'limit_group' => $parameters->getGroupLimit(),
Expand Down
2 changes: 1 addition & 1 deletion src/model/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function getResources($property)
* @param string $lang preferred language for the literal
* @return string string value for the given property, or the default value if not found
*/
protected function getLiteral($property, $default=null, $lang=null)
protected function getLiteral($property, $default = null, $lang = null)
{
if (!isset($lang)) {
$lang = $this->getLang();
Expand Down
2 changes: 1 addition & 1 deletion src/model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function fetch($key)
/**
* Wraps apc_store() and apcu_store()
*/
public function store($key, $value, $ttl=3600)
public function store($key, $value, $ttl = 3600)
{
if (function_exists('apcu_store')) {
return apcu_store($key, $value, $ttl);
Expand Down
20 changes: 10 additions & 10 deletions src/model/Concept.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function getLabel()
return $this->resource->label($fallback);
}
// We need to check all the labels in case one of them matches a subtag of the current language
foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
foreach ($this->resource->allLiterals('skos:prefLabel') as $label) {
// the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) {
return EasyRdf\Literal::create($label, $fallback);
Expand Down Expand Up @@ -174,7 +174,7 @@ public function hasXlLabel()
public function getXlLabel()
{
$labels = $this->resource->allResources('skosxl:prefLabel');
foreach($labels as $labres) {
foreach ($labels as $labres) {
$label = $labres->getLiteral('skosxl:literalForm');
if ($label !== null && $label->getLang() == $this->clang) {
return new LabelSkosXL($this->model, $labres);
Expand Down Expand Up @@ -306,7 +306,7 @@ public function processExternalResource($res)
* @param string[] $seen Processed resources so far
* @param string[] $props (optional) limit to these property URIs
*/
private function addExternalTriplesToGraph($res, &$seen, $props=null)
private function addExternalTriplesToGraph($res, &$seen, $props = null)
{
if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) {
return;
Expand Down Expand Up @@ -531,15 +531,15 @@ public function getProperties()
// if not found in current vocabulary, look up in the default graph to be able
// to read an ontology loaded in a separate graph
// note that this imply that the property has an rdf:type declared for the query to work
if(!$is_well_known && !$proplabel) {
if (!$is_well_known && !$proplabel) {
$envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getLang());

$defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, '');

if($envLangLabels) {
if ($envLangLabels) {
$proplabel = $envLangLabels[$this->getLang()];
} else {
if($defaultPropLabel) {
if ($defaultPropLabel) {
$proplabel = $defaultPropLabel[''];
}
}
Expand All @@ -552,7 +552,7 @@ public function getProperties()
}

// also look up superprops in the default graph if not found in current vocabulary
if(!$is_well_known && (!$superprops || empty($superprops))) {
if (!$is_well_known && (!$superprops || empty($superprops))) {
$superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri);
}

Expand All @@ -570,7 +570,7 @@ public function getProperties()
}

// searching for subproperties of literals too
if($superprops) {
if ($superprops) {
foreach ($superprops as $subi) {
$suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi;
$duplicates[$suburi] = $prop;
Expand Down Expand Up @@ -827,7 +827,7 @@ private function getCollections($includeArrays)
$groups[$collLabel] = array($group);

$res = $collection;
while($super = $this->graph->resourcesMatching('skos:member', $res)) {
while ($super = $this->graph->resourcesMatching('skos:member', $res)) {
foreach ($super as $res) {
$superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang);
array_unshift($groups[$collLabel], $superprop);
Expand Down Expand Up @@ -937,7 +937,7 @@ public function dumpJsonLd()
'skos' => EasyRdf\RdfNamespace::get("skos"),
'isothes' => EasyRdf\RdfNamespace::get("isothes"),
'rdfs' => EasyRdf\RdfNamespace::get("rdfs"),
'owl' =>EasyRdf\RdfNamespace::get("owl"),
'owl' => EasyRdf\RdfNamespace::get("owl"),
'dct' => EasyRdf\RdfNamespace::get("dcterms"),
'dc11' => EasyRdf\RdfNamespace::get("dc11"),
'uri' => '@id',
Expand Down
2 changes: 1 addition & 1 deletion src/model/ConceptProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ConceptProperty
* @param string $super URI of superproperty
* @param boolean $sort_by_notation whether to sort the property values by their notation code
*/
public function __construct($model, $prop, $label, $tooltip=null, $super=null, $sort_by_notation=false)
public function __construct($model, $prop, $label, $tooltip = null, $super = null, $sort_by_notation = false)
{
$this->model = $model;
$this->prop = $prop;
Expand Down
4 changes: 2 additions & 2 deletions src/model/ConceptPropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getLabel($lang = '', $fallbackToUri = 'uri')
}
// We need to check all the labels in case one of them matches a subtag of the current language
if ($this->resource->allLiterals('skos:prefLabel')) {
foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
foreach ($this->resource->allLiterals('skos:prefLabel') as $label) {
// the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) {
return EasyRdf\Literal::create($label, $fallback);
Expand Down Expand Up @@ -164,7 +164,7 @@ public function getReifiedPropertyValues()
{
$ret = array();
$props = $this->resource->propertyUris();
foreach($props as $prop) {
foreach ($props as $prop) {
$prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop;
$propkey = str_starts_with($prop, 'dc11:') ?
str_replace('dc11:', 'dc:', $prop) : $prop;
Expand Down
2 changes: 1 addition & 1 deletion src/model/ConceptPropertyValueLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getXlLabel()
{
$graph = $this->resource->getGraph();
$labelResources = $graph->resourcesMatching('skosxl:literalForm', $this->literal);
foreach($labelResources as $labres) {
foreach ($labelResources as $labres) {
return new LabelSkosXL($this->model, $labres);
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/model/GlobalConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GlobalConfig extends BaseConfig
*/
private $configModifiedTime = null;

public function __construct(Model $model, string $config_name='../../config.ttl')
public function __construct(Model $model, string $config_name = '../../config.ttl')
{
$this->cache = new Cache();
$this->filePath = realpath(dirname(__FILE__) . "/" . $config_name);
Expand Down Expand Up @@ -78,7 +78,7 @@ private function initializeConfig(): EasyRdf\Resource
$this->cache->store($key, $this->graph);
$this->cache->store($nskey, $this->namespaces);
}
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else { // APC not available, parse on every request
$this->parseConfig($this->filePath);
}
Expand Down
4 changes: 2 additions & 2 deletions src/model/LabelSkosXL.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function getPrefLabel()
{
$label = null;
$labels = $this->resource->allResources('skosxl:prefLabel');
foreach($labels as $labres) {
foreach ($labels as $labres) {
$label = $labres->getLiteral('skosxl:literalForm');
if ($label->getLang() == $this->clang) {
return $label;
Expand All @@ -24,7 +24,7 @@ public function getProperties()
{
$ret = array();
$props = $this->resource->properties();
foreach($props as $prop) {
foreach ($props as $prop) {
if ($prop !== 'rdf:type' && $prop !== 'skosxl:literalForm') {
// make sure to use the correct gettext keys for DC namespace
$propkey = str_starts_with($prop, 'dc11:') ?
Expand Down
14 changes: 7 additions & 7 deletions src/model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Model
/**
* Initializes the Model object
*/
public function __construct(string $config_filename="../../config.ttl")
public function __construct(string $config_filename = "../../config.ttl")
{
$this->resolver = new Resolver($this);
$this->globalConfig = new GlobalConfig($this, $config_filename);
Expand Down Expand Up @@ -274,11 +274,11 @@ public function searchConcepts($params)
}

$vocabs = $params->getVocabs();
$showDeprecated=false;
$showDeprecated = false;
if (sizeof($vocabs) === 1) { // search within vocabulary
$voc = $vocabs[0];
$sparql = $voc->getSparql();
$showDeprecated=$voc->getConfig()->getShowDeprecated();
$showDeprecated = $voc->getConfig()->getShowDeprecated();
} else { // multi-vocabulary or global search
$voc = null;
$sparql = $this->getDefaultSparql();
Expand Down Expand Up @@ -439,7 +439,7 @@ public function getVocabulariesInCategory($cat)
public function getVocabularyCategories()
{
$cats = $this->globalConfig->getGraph()->allOfType('skos:Concept');
if(empty($cats)) {
if (empty($cats)) {
return array(new VocabularyCategory($this, null));
}

Expand Down Expand Up @@ -520,9 +520,9 @@ private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
}

// if there are multiple vocabularies and one is the preferred vocabulary, return it
if($preferredVocabId != null) {
if ($preferredVocabId != null) {
foreach ($vocabs as $vocab) {
if($vocab->getId() == $preferredVocabId) {
if ($vocab->getId() == $preferredVocabId) {
try {
// double check that a label exists in the preferred vocabulary
if ($vocab->getConceptLabel($uri, null) !== null) {
Expand Down Expand Up @@ -628,7 +628,7 @@ public function getResourceFromUri($uri)
$resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout());
$this->globalConfig->getCache()->store($key, $resource, self::URI_FETCH_TTL);
}
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd
} else { // APC not available, parse on every request
$resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout());
}
Expand Down
16 changes: 8 additions & 8 deletions src/model/PluginRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PluginRegister
private $requestedPlugins;
private $pluginOrder;

public function __construct($requestedPlugins=array())
public function __construct($requestedPlugins = array())
{
$this->requestedPlugins = $requestedPlugins;
$this->pluginOrder = array();
Expand Down Expand Up @@ -49,7 +49,7 @@ private function sortPlugins($plugins)
* @param boolean $raw interpret $type values as raw text instead of files
* @return array
*/
private function filterPlugins($type, $raw=false)
private function filterPlugins($type, $raw = false)
{
$plugins = $this->getPlugins();
$plugins = $this->sortPlugins($plugins);
Expand Down Expand Up @@ -94,7 +94,7 @@ private function filterPluginsByName($type, $names)
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginsJS($names=null)
public function getPluginsJS($names = null)
{
if ($names) {
$names = array_merge($this->requestedPlugins, $names);
Expand All @@ -108,7 +108,7 @@ public function getPluginsJS($names=null)
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginsCSS($names=null)
public function getPluginsCSS($names = null)
{
if ($names) {
$names = array_merge($this->requestedPlugins, $names);
Expand All @@ -122,7 +122,7 @@ public function getPluginsCSS($names=null)
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginsTemplates($names=null)
public function getPluginsTemplates($names = null)
{
if ($names) {
$names = array_merge($this->requestedPlugins, $names);
Expand All @@ -136,15 +136,15 @@ public function getPluginsTemplates($names=null)
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getTemplates($names=null)
public function getTemplates($names = null)
{
$templateStrings = array();
$plugins = $this->getPluginsTemplates($names);
foreach ($plugins as $folder => $templates) {
foreach ($templates as $path) {
if (file_exists($path)) {
$filename = explode('/', $path);
$filename = $filename[sizeof($filename)-1];
$filename = $filename[sizeof($filename) - 1];
$id = $folder . '-' . substr($filename, 0, (strrpos($filename, ".")));
$templateStrings[$id] = file_get_contents($path);
}
Expand All @@ -158,7 +158,7 @@ public function getTemplates($names=null)
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginCallbacks($names=null)
public function getPluginCallbacks($names = null)
{
if ($names) {
$names = array_merge($this->requestedPlugins, $names);
Expand Down
Loading

0 comments on commit a555e40

Please sign in to comment.