Skip to content

Commit

Permalink
Merge pull request #1142 from kinow/typos
Browse files Browse the repository at this point in the history
Fix typos in comments, add phpdocs, replace NBSP by space, simplify phpunit
  • Loading branch information
kouralex authored Mar 23, 2021
2 parents c84dc97 + 4774577 commit d904172
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function setLanguageProperties($lang)
* As a side effect, set the HTTP Vary header if a choice was made based on
* the Accept header.
* @param array $choices possible MIME types as strings
* @param string $accept HTTP Accept header value
* @param string $accept HTTP Accept header value
* @param string $format proposed format
* @return string selected format, or null if negotiation failed
*/
Expand Down
2 changes: 1 addition & 1 deletion controller/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function transformSearchResults($request, $results, $parameters)
if ($request->getQueryParam('labellang')) {
$ret['@context']['@language'] = $request->getQueryParam('labellang');
} elseif ($request->getQueryParam('lang')) {
$ret['@context']['@language'] = $request->getQueryParam('lang');;
$ret['@context']['@language'] = $request->getQueryParam('lang');
}
return $ret;
}
Expand Down
10 changes: 5 additions & 5 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public function invokeVocabularyConcept(Request $request)
return;
}
$pluginParameters = $vocab->getConfig()->getPluginParameters();
/** @var \Twig\Template $template */
$template = (in_array('skos:Concept', $results[0]->getType()) || in_array('skos:ConceptScheme', $results[0]->getType())) ? $this->twig->loadTemplate('concept-info.twig') : $this->twig->loadTemplate('group-contents.twig');

$crumbs = $vocab->getBreadCrumbs($request->getContentLang(), $uri);
Expand Down Expand Up @@ -588,10 +587,11 @@ public function getChangeList($request, $prop, $offset=0, $limit=200)
}

/**
* Formats the list of concepts as labels arranged by modification month
* @param Array $changeList
* @param string $lang the language for displaying dates in the change list
*/
* Formats the list of concepts as labels arranged by modification month
* @param Array $changeList
* @param string $lang the language for displaying dates in the change list
* @return array list of concepts as labels by month
*/
public function formatChangeList($changeList, $lang)
{
$formatByDate = array();
Expand Down
6 changes: 4 additions & 2 deletions model/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ abstract class BaseConfig extends DataObject
* Returns a boolean value based on a literal value from the config.ttl configuration.
* @param string $property the property to query
* @param boolean $default the default value if the value is not set in configuration
* @return boolean the boolean value for the given property, or the default value if not found
*/
protected function getBoolean($property, $default = false)
{
Expand All @@ -37,14 +38,15 @@ protected function getResources($property)
}

/**
* Returns a boolean value based on a literal value from the config.ttl configuration.
* Returns a string value based on a literal value from the config.ttl configuration.
* @param string $property the property to query
* @param string $default default value
* @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)
{
if (!isset($lang)) {;
if (!isset($lang)) {
$lang = $this->getEnvLang();
}

Expand Down
17 changes: 9 additions & 8 deletions model/Concept.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ public function getMappingProperties(array $whitelist = null)
}

if ($response) {
$ret[$prop]->addValue(new ConceptMappingPropertyValue($this->model, $this->vocab, $response, $this->resource, $prop), $this->clang);
$ret[$prop]->addValue(new ConceptMappingPropertyValue($this->model, $this->vocab, $response, $this->resource, $prop));

$this->processExternalResource($response);

continue;
}
}
$ret[$prop]->addValue(new ConceptMappingPropertyValue($this->model, $this->vocab, $val, $this->resource, $prop, $this->clang), $this->clang);
$ret[$prop]->addValue(new ConceptMappingPropertyValue($this->model, $this->vocab, $val, $this->resource, $prop, $this->clang));
}
}
}
Expand Down Expand Up @@ -604,7 +604,7 @@ public function getProperties()
if (isset($ret[$prop])) {
// create a ConceptPropertyValue first, assuming the resource exists in current vocabulary
$value = new ConceptPropertyValue($this->model, $this->vocab, $val, $prop, $this->clang);
$ret[$prop]->addValue($value, $this->clang);
$ret[$prop]->addValue($value);
}

}
Expand All @@ -613,22 +613,22 @@ public function getProperties()
// adding narrowers part of a collection
foreach ($properties as $prop => $values) {
foreach ($values as $value) {
$ret[$prop]->addValue($value, $this->clang);
$ret[$prop]->addValue($value);
}
}

$groupPropObj = new ConceptProperty('skosmos:memberOf', null);
foreach ($this->getGroupProperties() as $propVals) {
foreach ($propVals as $propVal) {
$groupPropObj->addValue($propVal, $this->clang);
$groupPropObj->addValue($propVal);
}
}
$ret['skosmos:memberOf'] = $groupPropObj;

$arrayPropObj = new ConceptProperty('skosmos:memberOfArray', null);
foreach ($this->getArrayProperties() as $propVals) {
foreach ($propVals as $propVal) {
$arrayPropObj->addValue($propVal, $this->clang);
$arrayPropObj->addValue($propVal);
}
}
$ret['skosmos:memberOfArray'] = $arrayPropObj;
Expand All @@ -646,8 +646,8 @@ public function getProperties()

/**
* Removes properties that have duplicate values.
* @param $ret the array of properties generated by getProperties
* @param $duplicates array of properties found are a subProperty of a another property
* @param array $ret the array of properties generated by getProperties
* @param array $duplicates array of properties found are a subProperty of a another property
* @return array of ConceptProperties
*/
public function removeDuplicatePropertyValues($ret, $duplicates)
Expand Down Expand Up @@ -907,6 +907,7 @@ public function getForeignLabels()
/**
* Gets the values for the property in question in all other languages than the ui language.
* @param string $property
* @return array array of labels for the values of the given property
*/
public function getAllLabels($property)
{
Expand Down
2 changes: 1 addition & 1 deletion model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function getRDF($vocid, $uri, $format)
* Makes a SPARQL-query to the endpoint that retrieves concept
* references as it's search results.
* @param ConceptSearchParameters $params an object that contains all the parameters needed for the search
* @return array search results
* @return array search results
*/
public function searchConcepts($params)
{
Expand Down
12 changes: 6 additions & 6 deletions model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function __construct($model)

/**
* Set a GET query parameter to mock it in tests.
* @param string $paramName parameter name
* @param string $value parameter value
* @param string $paramName parameter name
* @param string $value parameter value
*/
public function setQueryParam($paramName, $value)
{
Expand All @@ -59,8 +59,8 @@ public function setQueryParam($paramName, $value)

/**
* Set a SERVER constant to mock it in tests.
* @param string $paramName parameter name
* @param string $value parameter value
* @param string $paramName parameter name
* @param string $value parameter value
*/
public function setServerConstant($paramName, $value)
{
Expand All @@ -69,7 +69,7 @@ public function setServerConstant($paramName, $value)

/**
* Return the requested GET query parameter as a string. Backslashes are stripped for security reasons.
* @param string $paramName parameter name
* @param string $paramName parameter name
* @return string parameter content, or null if no parameter found
*/
public function getQueryParam($paramName)
Expand All @@ -81,7 +81,7 @@ public function getQueryParam($paramName)

/**
* Return the requested GET query parameter as a string, with no sanitizing.
* @param string $paramName parameter name
* @param string $paramName parameter name
* @return string parameter content, or null if no parameter found
*/
public function getQueryParamRaw($paramName)
Expand Down
4 changes: 2 additions & 2 deletions model/Vocabulary.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function getInfo($lang = null)
ksort($ret[$prop]);
}
}
if (isset($ret['owl:versionInfo'])) { // if version info availible for vocabulary convert it to a more readable format
if (isset($ret['owl:versionInfo'])) { // if version info available for vocabulary convert it to a more readable format
$ret['owl:versionInfo'][0] = $this->parseVersionInfo($ret['owl:versionInfo'][0]);
}
// remove duplicate values
Expand Down Expand Up @@ -303,7 +303,7 @@ private function parseVersionInfo($version)

/**
* Counts the statistics of the vocabulary.
* @return array of the concept/group counts
* @return Array containing the label counts
*/
public function getStatistics($lang = '', $array=null, $group=null)
{
Expand Down
4 changes: 2 additions & 2 deletions model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function getArrayClassURI()

/**
* Returns custom properties displayed on the search page if configured.
* @return string array class URI or null
* @return array array class URI or null
*/

public function getAdditionalSearchProperties()
Expand Down Expand Up @@ -441,7 +441,7 @@ public function getPlugins()

/**
* Returns the property/properties used for visualizing concept hierarchies.
* @return string array class URI or null
* @return array array class URI or null
*/

public function getHierarchyProperty()
Expand Down
1 change: 0 additions & 1 deletion model/resolver/WDQSResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class WDQSResource extends RemoteResource
const WDQS_ENDPOINT = "https://query.wikidata.org/sparql";

public function resolve(int $timeout) : ?EasyRdf\Resource {
$client = new EasyRdf\Sparql\Client(self::WDQS_ENDPOINT);
try {
// unregister the legacy "json" format as it causes problems with CONSTRUCT requests
EasyRdf\Format::unregister('json');
Expand Down
20 changes: 10 additions & 10 deletions model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class GenericSparql {
protected $client;
/**
* Graph uri.
* @property string $graph
* @property object $graph
*/
protected $graph;
/**
* A SPARQL query graph part template.
* @property string $graph
* @property string $graphClause
*/
protected $graphClause;
/**
Expand Down Expand Up @@ -82,8 +82,8 @@ protected function generateQueryPrefixes($query)

/**
* Execute the SPARQL query using the SPARQL client, logging it as well.
* @param string $query SPARQL query to perform
* @return Result|\EasyRdf\Graph query result
* @param string $query SPARQL query to perform
* @return \EasyRdf\Sparql\Result|\EasyRdf\Graph query result
*/
protected function query($query) {
$queryId = sprintf("%05d", rand(0, 99999));
Expand Down Expand Up @@ -216,7 +216,7 @@ private function transformCountConceptsResults($result, $lang) {
/**
* Used for counting number of concepts and collections in a vocabulary.
* @param string $lang language of labels
* @return int number of concepts in this vocabulary
* @return array with number of concepts in this vocabulary per label
*/
public function countConcepts($lang = null, $array = null, $group = null) {
$query = $this->generateCountConceptsQuery($array, $group);
Expand Down Expand Up @@ -608,7 +608,7 @@ private function generateQueryConceptSchemeQuery($conceptscheme) {
/**
* Retrieves conceptScheme information from the endpoint.
* @param string $conceptscheme concept scheme URI
* @return EasyRDF_Graph query result graph
* @return \EasyRdf\Sparql\Result|\EasyRdf\Graph query result graph
*/
public function queryConceptScheme($conceptscheme) {
$query = $this->generateQueryConceptSchemeQuery($conceptscheme);
Expand Down Expand Up @@ -818,7 +818,7 @@ private function formatPrefLabelCsvClause() {
/**
* @param string $lang language code of the returned labels
* @param array|null $fields extra fields to include in the result (array of strings). (default: null = none)
* @return string sparql query clause
* @return array sparql query clause
*/
protected function formatExtraFields($lang, $fields) {
// extra variable expressions to request and extra fields to query for
Expand Down Expand Up @@ -962,7 +962,7 @@ protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $p
return $query;
}
/**
* This function can be overwritten in other SPARQL dialects for the possibility of handling the differenc language clauses
* This function can be overwritten in other SPARQL dialects for the possibility of handling the different language clauses
* @param string $lang
* @return string formatted language clause
*/
Expand Down Expand Up @@ -1970,7 +1970,7 @@ private function generateParentListQuery($uri, $lang, $fallback, $props) {
* Transforms the result into an array.
* @param EasyRdf\Sparql\Result
* @param string $lang
* @return an array for the REST controller to encode.
* @return array|null an array for the REST controller to encode.
*/
private function transformParentListResults($result, $lang)
{
Expand All @@ -1989,7 +1989,7 @@ private function transformParentListResults($result, $lang)
}
if (isset($row->tops)) {
$topConceptsList=explode(" ", $row->tops->getValue());
// sort to garantee an alphabetical ordering of the URI
// sort to guarantee an alphabetical ordering of the URI
sort($topConceptsList);
$ret[$uri]['tops'] = $topConceptsList;
}
Expand Down
6 changes: 3 additions & 3 deletions resource/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {

.row > .property-value-column, .row > .property-value-column {
margin: 5px 0;
  }
}
#vocab-info .property-value-wrapper {
padding: 0;
}
Expand Down Expand Up @@ -2055,7 +2055,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {

.right-box {
left: 0;
  }
}

}

Expand Down Expand Up @@ -2196,7 +2196,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
.voclist-left > .right-box {
top: 0;
right: 0;
  }
}

h1 {
font-size: 20px;
Expand Down
2 changes: 1 addition & 1 deletion tests/ConceptPropertyValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,6 @@ public function testGetReifiedPropertyValues() {
$vals = $props['skos:definition']->getValues();
$val = reset($vals);
$reified_vals = $val->getReifiedPropertyValues();
$this->assertEquals(2, count($reified_vals));
$this->assertCount(2, $reified_vals);
}
}
14 changes: 7 additions & 7 deletions tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ public function testListConceptGroups()
$voc = $this->model->getVocabulary('groups');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$actual = $sparql->ListConceptGroups('http://www.w3.org/2004/02/skos/core#Collection', 'en', false);
$actual = $sparql->ListConceptGroups('http://www.w3.org/2004/02/skos/core#Collection', 'en');
$expected = array (0 => array ('prefLabel' => 'Fish', 'uri' => 'http://www.skosmos.skos/groups/fish', 'hasMembers' => true, 'childGroups' => array('http://www.skosmos.skos/groups/sub')), 1 => array ('prefLabel' => 'Freshwater fish', 'uri' => 'http://www.skosmos.skos/groups/fresh', 'hasMembers' => true), 2 => array ('prefLabel' => 'Saltwater fish', 'uri' => 'http://www.skosmos.skos/groups/salt', 'hasMembers' => true),3 => array ('prefLabel' => 'Submarine-like fish', 'uri' => 'http://www.skosmos.skos/groups/sub', 'hasMembers' => true));
$this->assertEquals($expected, $actual);
}
Expand Down Expand Up @@ -1206,13 +1206,13 @@ public function testQueryAllConceptLabels()

$actual = $sparql->queryAllConceptLabels('http://www.skosmos.skos/test/ta112', 'en');

$this->assertTrue(array_key_exists('prefLabel',$actual));
$this->assertArrayHasKey('prefLabel', $actual);
$this->assertEquals($actual['prefLabel'][0], "Carp");

$this->assertTrue(array_key_exists('altLabel',$actual));
$this->assertArrayHasKey('altLabel', $actual);
$this->assertEquals($actual['altLabel'][0], "Golden crucian");

$this->assertFalse(array_key_exists('hiddenLabel',$actual));
$this->assertArrayNotHasKey('hiddenLabel', $actual);
}

/**
Expand Down Expand Up @@ -1245,8 +1245,8 @@ public function testQueryAllConceptLabelsNoPrefLabel()
$actual = $sparql->queryAllConceptLabels('http://www.skosmos.skos/test/ta112', 'sv');

$this->assertTrue(is_array($actual));
$this->assertFalse(array_key_exists('prefLabel',$actual));
$this->assertFalse(array_key_exists('altLabel',$actual));
$this->assertFalse(array_key_exists('hiddenLabel',$actual));
$this->assertArrayNotHasKey('prefLabel', $actual);
$this->assertArrayNotHasKey('altLabel', $actual);
$this->assertArrayNotHasKey('hiddenLabel', $actual);
}
}
2 changes: 1 addition & 1 deletion tests/GlobalConfigTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Tests for GlobalConfig. Must cover all of its methods, and use at least one file configuratoin that contains
* Tests for GlobalConfig. Must cover all of its methods, and use at least one file configuration that contains
* different values than the default ones.
*/
class GlobalConfigTest extends PHPUnit\Framework\TestCase
Expand Down
Loading

0 comments on commit d904172

Please sign in to comment.