diff --git a/controller/Controller.php b/controller/Controller.php index ca50c0959..bb0e09485 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -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 */ diff --git a/controller/RestController.php b/controller/RestController.php index ab280adef..49d3fd251 100644 --- a/controller/RestController.php +++ b/controller/RestController.php @@ -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; } diff --git a/controller/WebController.php b/controller/WebController.php index afd972b56..fda5903d5 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -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); @@ -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(); diff --git a/model/BaseConfig.php b/model/BaseConfig.php index 745fb5ba0..befa2b8aa 100644 --- a/model/BaseConfig.php +++ b/model/BaseConfig.php @@ -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) { @@ -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(); } diff --git a/model/Concept.php b/model/Concept.php index eff6291fc..67c48759b 100644 --- a/model/Concept.php +++ b/model/Concept.php @@ -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)); } } } @@ -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); } } @@ -613,14 +613,14 @@ 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; @@ -628,7 +628,7 @@ public function getProperties() $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; @@ -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) @@ -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) { diff --git a/model/Model.php b/model/Model.php index 4230ec8e0..9b6b6d819 100644 --- a/model/Model.php +++ b/model/Model.php @@ -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) { diff --git a/model/Request.php b/model/Request.php index a8bee1558..000ce384f 100644 --- a/model/Request.php +++ b/model/Request.php @@ -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) { @@ -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) { @@ -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) @@ -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) diff --git a/model/Vocabulary.php b/model/Vocabulary.php index abd25df95..2aaf4de7a 100644 --- a/model/Vocabulary.php +++ b/model/Vocabulary.php @@ -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 @@ -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) { diff --git a/model/VocabularyConfig.php b/model/VocabularyConfig.php index d7d161da8..199107a44 100644 --- a/model/VocabularyConfig.php +++ b/model/VocabularyConfig.php @@ -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() @@ -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() diff --git a/model/resolver/WDQSResource.php b/model/resolver/WDQSResource.php index 4340ae0ac..0cfd65081 100644 --- a/model/resolver/WDQSResource.php +++ b/model/resolver/WDQSResource.php @@ -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'); diff --git a/model/sparql/GenericSparql.php b/model/sparql/GenericSparql.php index c302b70b8..561bb4c18 100644 --- a/model/sparql/GenericSparql.php +++ b/model/sparql/GenericSparql.php @@ -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; /** @@ -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)); @@ -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); @@ -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); @@ -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 @@ -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 */ @@ -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) { @@ -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; } diff --git a/resource/css/styles.css b/resource/css/styles.css index f62dee742..b7b082cb3 100644 --- a/resource/css/styles.css +++ b/resource/css/styles.css @@ -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; } @@ -2055,7 +2055,7 @@ body, .versal, h1, h2, h3, p, .versal-bold { .right-box { left: 0; -  } + } } @@ -2196,7 +2196,7 @@ body, .versal, h1, h2, h3, p, .versal-bold { .voclist-left > .right-box { top: 0; right: 0; -  } + } h1 { font-size: 20px; diff --git a/tests/ConceptPropertyValueTest.php b/tests/ConceptPropertyValueTest.php index 6c133e26d..21f4b577b 100644 --- a/tests/ConceptPropertyValueTest.php +++ b/tests/ConceptPropertyValueTest.php @@ -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); } } diff --git a/tests/GenericSparqlTest.php b/tests/GenericSparqlTest.php index 864051fa1..f5497d7ff 100644 --- a/tests/GenericSparqlTest.php +++ b/tests/GenericSparqlTest.php @@ -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); } @@ -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); } /** @@ -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); } } diff --git a/tests/GlobalConfigTest.php b/tests/GlobalConfigTest.php index a33fa2c3a..d23d2d05a 100644 --- a/tests/GlobalConfigTest.php +++ b/tests/GlobalConfigTest.php @@ -1,7 +1,7 @@ model->getVocabulary('cbd'); - $this->assertEquals(4 , count($vocab->getConfig()->getExtProperties())); + $this->assertCount(4, $vocab->getConfig()->getExtProperties()); } /** diff --git a/tests/VocabularyTest.php b/tests/VocabularyTest.php index 3e333fc1a..c9dbbbe21 100644 --- a/tests/VocabularyTest.php +++ b/tests/VocabularyTest.php @@ -161,7 +161,7 @@ public function testGetStatistics() { */ public function testListConceptGroups() { $vocab = $this->model->getVocabulary('groups'); - $cgroups = $vocab->listConceptGroups(false, 'en'); + $cgroups = $vocab->listConceptGroups('en'); $expected = array (0 => array ('uri' => 'http://www.skosmos.skos/groups/fish', 'hasMembers' => true, 'childGroups' => array('http://www.skosmos.skos/groups/sub'), 'prefLabel' => 'Fish'), 1 => array ('uri' => 'http://www.skosmos.skos/groups/fresh', 'hasMembers' => true, 'prefLabel' => 'Freshwater fish'), 2 => array ('uri' => 'http://www.skosmos.skos/groups/salt', 'hasMembers' => true, 'prefLabel' => 'Saltwater fish'),3 => array ('uri' => 'http://www.skosmos.skos/groups/sub', 'hasMembers' => true, 'prefLabel' => 'Submarine-like fish')); $this->assertEquals($expected, $cgroups); }