This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Wikibase\Repo\Rdf; |
||
| 4 | |||
| 5 | use DataValues\DataValue; |
||
| 6 | use OutOfBoundsException; |
||
| 7 | use Wikibase\DataAccess\EntitySourceDefinitions; |
||
| 8 | use Wikibase\DataModel\Assert\RepositoryNameAssert; |
||
| 9 | use Wikibase\DataModel\Entity\EntityId; |
||
| 10 | use Wikibase\DataModel\Entity\Property; |
||
| 11 | use Wikibase\DataModel\Statement\Statement; |
||
| 12 | use Wikimedia\Assert\Assert; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * RDF vocabulary for use in mapping for wikibase data model. |
||
| 16 | * |
||
| 17 | * @license GPL-2.0-or-later |
||
| 18 | */ |
||
| 19 | class RdfVocabulary { |
||
| 20 | |||
| 21 | // Change this when changing data format! |
||
| 22 | const FORMAT_VERSION = '1.0.0'; |
||
| 23 | const ONTOLOGY_VERSION = '1.0'; |
||
| 24 | |||
| 25 | const ONTOLOGY_BASE_URI = 'http://wikiba.se/ontology'; |
||
| 26 | const NS_ONTOLOGY = 'wikibase'; // wikibase ontology (shared) |
||
| 27 | // Nodes |
||
| 28 | const NS_ENTITY = ''; // concept uris |
||
| 29 | const NS_DATA = 'data'; // document uris |
||
| 30 | const NS_STATEMENT = 's'; // statement |
||
| 31 | const NS_REFERENCE = 'ref'; // reference |
||
| 32 | const NS_VALUE = 'v'; // value |
||
| 33 | // Predicates |
||
| 34 | const NSP_DIRECT_CLAIM = 't'; // direct assertion entity -> value |
||
| 35 | const NSP_DIRECT_CLAIM_NORM = 'tn'; // direct assertion entity -> value, normalized |
||
| 36 | const NSP_CLAIM = 'p'; // entity -> statement |
||
| 37 | const NSP_CLAIM_STATEMENT = 'ps'; // statement -> simple value |
||
| 38 | const NSP_CLAIM_VALUE = 'psv'; // statement -> deep value |
||
| 39 | const NSP_CLAIM_VALUE_NORM = 'psn'; // statement -> deep value, normalized |
||
| 40 | const NSP_QUALIFIER = 'pq'; // statement -> qualifier |
||
| 41 | const NSP_QUALIFIER_VALUE = 'pqv'; // statement -> qualifier deep value |
||
| 42 | const NSP_QUALIFIER_VALUE_NORM = 'pqn'; // statement -> qualifier deep value, normalized |
||
| 43 | const NSP_REFERENCE = 'pr'; // reference -> simple value |
||
| 44 | const NSP_REFERENCE_VALUE = 'prv'; // reference -> deep value |
||
| 45 | const NSP_REFERENCE_VALUE_NORM = 'prn'; // reference -> deep value, normalized |
||
| 46 | const NSP_NOVALUE = 'no'; // novalue class |
||
| 47 | // other prefixes |
||
| 48 | const NS_SKOS = 'skos'; // SKOS vocabulary |
||
| 49 | const NS_SCHEMA_ORG = 'schema'; // schema.org vocabulary |
||
| 50 | const NS_CC = 'cc'; // Creative Commons |
||
| 51 | const NS_GEO = 'geo'; // prefix for geolocations |
||
| 52 | const NS_PROV = 'prov'; // for provenance |
||
| 53 | const SKOS_URI = 'http://www.w3.org/2004/02/skos/core#'; |
||
| 54 | const SCHEMA_ORG_URI = 'http://schema.org/'; |
||
| 55 | const CC_URI = 'http://creativecommons.org/ns#'; |
||
| 56 | // External URIs |
||
| 57 | //FIXME: get from config |
||
| 58 | const MEDIA_URI = 'http://commons.wikimedia.org/wiki/Special:FilePath/'; |
||
| 59 | //FIXME: get from config |
||
| 60 | const COMMONS_DATA_URI = 'http://commons.wikimedia.org/data/main/'; |
||
| 61 | const GEO_URI = 'http://www.opengis.net/ont/geosparql#'; |
||
| 62 | const PROV_URI = 'http://www.w3.org/ns/prov#'; |
||
| 63 | |||
| 64 | // Gregorian calendar link. |
||
| 65 | // I'm not very happy about hardcoding it here but see no better way so far. |
||
| 66 | // See also DataValues\TimeValue\TimeFormatter::XXX_CALENDAR constants. |
||
| 67 | const GREGORIAN_CALENDAR = 'http://www.wikidata.org/entity/Q1985727'; |
||
| 68 | const JULIAN_CALENDAR = 'http://www.wikidata.org/entity/Q1985786'; |
||
| 69 | /** |
||
| 70 | * URI for unit "1" |
||
| 71 | * See: https://phabricator.wikimedia.org/T105432 |
||
| 72 | */ |
||
| 73 | const ONE_ENTITY = 'http://www.wikidata.org/entity/Q199'; |
||
| 74 | // Ranks |
||
| 75 | const WIKIBASE_RANK_BEST = 'BestRank'; |
||
| 76 | |||
| 77 | public static $rankMap = [ |
||
| 78 | Statement::RANK_DEPRECATED => 'DeprecatedRank', |
||
| 79 | Statement::RANK_NORMAL => 'NormalRank', |
||
| 80 | Statement::RANK_PREFERRED => 'PreferredRank', |
||
| 81 | ]; |
||
| 82 | // Value properties |
||
| 83 | public $claimToValue = []; |
||
| 84 | // Value properties for normalized values |
||
| 85 | public $claimToValueNormalized = []; |
||
| 86 | // Value properties for normalized values, including for direct claims |
||
| 87 | public $normalizedPropertyValueNamespace = []; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var string[] Mapping of namespace names to URIs. |
||
| 91 | */ |
||
| 92 | private $namespaces = []; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var array Associative array mapping repository names to names specific to the particular repository |
||
| 96 | * (ie. containing repository suffix). |
||
| 97 | */ |
||
| 98 | public $entityNamespaceNames = []; |
||
| 99 | |||
| 100 | public $dataNamespaceNames = []; |
||
| 101 | |||
| 102 | public $statementNamespaceNames = []; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var array[] Associative array mapping repository names to maps, each mapping the "general" property |
||
| 106 | * namespace name to the name specific to the particular repository (ie. containing repository suffix). |
||
| 107 | */ |
||
| 108 | public $propertyNamespaceNames = []; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @var string[] Mapping of non-standard to canonical language codes. |
||
| 112 | */ |
||
| 113 | private $canonicalLanguageCodes; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @var string[] |
||
| 117 | */ |
||
| 118 | private $dataTypeUris; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @var string[] |
||
| 122 | */ |
||
| 123 | private static $canonicalLanguageCodeCache = []; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Map of the configured page properties. |
||
| 127 | * @var string[][] |
||
| 128 | */ |
||
| 129 | private $pagePropertyDefs; |
||
| 130 | |||
| 131 | private $licenseUrl; |
||
| 132 | |||
| 133 | private $sourceNameByEntityType; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @param string[] $conceptUris Associative array mapping repository names to base URIs for entity concept URIs. |
||
| 137 | * @param string[] $dataUris Associative array mapping source/repository names to base URIs for entity description URIs. |
||
| 138 | * @param EntitySourceDefinitions $entitySourceDefinitions |
||
| 139 | * @param string $localEntitySourceName |
||
| 140 | * @param string[] $rdfTurtleNodePrefixes |
||
| 141 | * @param string[] $rdfTurtlePredicatePrefixes |
||
| 142 | * @param string[] $canonicalLanguageCodes Mapping of non-standard to canonical language codes. |
||
| 143 | * @param string[] $dataTypeUris Mapping of property data type IDs to their URIs, |
||
| 144 | * if different from the default mapping. |
||
| 145 | * @param string[][] $pagePropertyDefs Mapping of page props: pageProp => wikibase predicate |
||
| 146 | * All predicates will be prefixed with wikibase: |
||
| 147 | * @param string $licenseUrl |
||
| 148 | */ |
||
| 149 | public function __construct( |
||
| 150 | array $conceptUris, |
||
| 151 | array $dataUris, |
||
| 152 | EntitySourceDefinitions $entitySourceDefinitions, |
||
| 153 | $localEntitySourceName, |
||
| 154 | array $rdfTurtleNodePrefixes, |
||
| 155 | array $rdfTurtlePredicatePrefixes, |
||
| 156 | array $canonicalLanguageCodes = [], |
||
| 157 | array $dataTypeUris = [], |
||
| 158 | array $pagePropertyDefs = [], |
||
| 159 | $licenseUrl = 'http://creativecommons.org/publicdomain/zero/1.0/' |
||
| 160 | ) { |
||
| 161 | Assert::parameter( |
||
| 162 | array_key_exists( $localEntitySourceName, $conceptUris ), |
||
| 163 | '$conceptUris', |
||
| 164 | 'must contain entry for the local repository, ie. ' . $localEntitySourceName |
||
| 165 | ); |
||
| 166 | Assert::parameterElementType( 'string', $conceptUris, '$conceptUris' ); |
||
| 167 | RepositoryNameAssert::assertParameterKeysAreValidRepositoryNames( $conceptUris, '$conceptUris' ); |
||
| 168 | |||
| 169 | Assert::parameterElementType( 'string', $dataUris, '$dataUris' ); |
||
| 170 | Assert::parameter( |
||
| 171 | array_key_exists( $localEntitySourceName, $dataUris ), |
||
| 172 | '$dataUris', |
||
| 173 | 'must contain entry for the local entity source, ie. ' . $localEntitySourceName |
||
| 174 | ); |
||
| 175 | |||
| 176 | Assert::parameter( |
||
| 177 | array_keys( $conceptUris ) === array_keys( $dataUris ), |
||
| 178 | '$dataUris', |
||
| 179 | 'must have values defined for all keys that $conceptUris' |
||
| 180 | ); |
||
| 181 | |||
| 182 | $this->canonicalLanguageCodes = $canonicalLanguageCodes; |
||
| 183 | $this->dataTypeUris = $dataTypeUris; |
||
| 184 | $this->pagePropertyDefs = $pagePropertyDefs; |
||
| 185 | |||
| 186 | $this->namespaces = [ |
||
|
0 ignored issues
–
show
|
|||
| 187 | 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', |
||
| 188 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', |
||
| 189 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#', |
||
| 190 | 'owl' => 'http://www.w3.org/2002/07/owl#', |
||
| 191 | self::NS_ONTOLOGY => self::ONTOLOGY_BASE_URI . "#", |
||
| 192 | |||
| 193 | // external |
||
| 194 | self::NS_SKOS => self::SKOS_URI, |
||
| 195 | self::NS_SCHEMA_ORG => self::SCHEMA_ORG_URI, |
||
| 196 | self::NS_CC => self::CC_URI, |
||
| 197 | self::NS_GEO => self::GEO_URI, |
||
| 198 | self::NS_PROV => self::PROV_URI, |
||
| 199 | ]; |
||
| 200 | |||
| 201 | $propertyNamespaces = [ |
||
| 202 | self::NSP_CLAIM, |
||
| 203 | self::NSP_CLAIM_STATEMENT, |
||
| 204 | self::NSP_CLAIM_VALUE, |
||
| 205 | self::NSP_CLAIM_VALUE_NORM, |
||
| 206 | self::NSP_QUALIFIER, |
||
| 207 | self::NSP_QUALIFIER_VALUE, |
||
| 208 | self::NSP_QUALIFIER_VALUE_NORM, |
||
| 209 | self::NSP_REFERENCE, |
||
| 210 | self::NSP_REFERENCE_VALUE, |
||
| 211 | self::NSP_REFERENCE_VALUE_NORM, |
||
| 212 | ]; |
||
| 213 | $propertyNamespacesUseNodePrefix = [ |
||
| 214 | self::NSP_DIRECT_CLAIM, |
||
| 215 | self::NSP_DIRECT_CLAIM_NORM, |
||
| 216 | self::NSP_NOVALUE, |
||
| 217 | ]; |
||
| 218 | |||
| 219 | foreach ( $conceptUris as $repositoryOrSourceName => $baseUri ) { |
||
| 220 | $nodeNamespacePrefix = $rdfTurtleNodePrefixes[$repositoryOrSourceName]; |
||
| 221 | $predicateNamespacePrefix = $rdfTurtlePredicatePrefixes[$repositoryOrSourceName]; |
||
| 222 | |||
| 223 | $this->entityNamespaceNames[$repositoryOrSourceName] = $nodeNamespacePrefix . self::NS_ENTITY; |
||
| 224 | $this->dataNamespaceNames[$repositoryOrSourceName] = $predicateNamespacePrefix . self::NS_DATA; |
||
| 225 | $this->statementNamespaceNames[$repositoryOrSourceName] = [ |
||
| 226 | self::NS_STATEMENT => $predicateNamespacePrefix . self::NS_STATEMENT, |
||
| 227 | self::NS_REFERENCE => $predicateNamespacePrefix . self::NS_REFERENCE, |
||
| 228 | self::NS_VALUE => $predicateNamespacePrefix . self::NS_VALUE, |
||
| 229 | ]; |
||
| 230 | |||
| 231 | $this->propertyNamespaceNames[$repositoryOrSourceName] = array_combine( |
||
| 232 | $propertyNamespaces, |
||
| 233 | array_map( |
||
| 234 | function ( $ns ) use ( $predicateNamespacePrefix ) { |
||
| 235 | return $predicateNamespacePrefix . $ns; |
||
| 236 | }, |
||
| 237 | $propertyNamespaces |
||
| 238 | ) |
||
| 239 | ); |
||
| 240 | $this->propertyNamespaceNames[$repositoryOrSourceName] += array_combine( |
||
| 241 | $propertyNamespacesUseNodePrefix, |
||
| 242 | array_map( |
||
| 243 | function ( $ns ) use ( $nodeNamespacePrefix ) { |
||
| 244 | return $nodeNamespacePrefix . $ns; |
||
| 245 | }, |
||
| 246 | $propertyNamespacesUseNodePrefix |
||
| 247 | ) |
||
| 248 | ); |
||
| 249 | |||
| 250 | $dataUri = $dataUris[$repositoryOrSourceName]; |
||
| 251 | $this->namespaces = array_merge( |
||
|
0 ignored issues
–
show
It seems like
array_merge($this->names...x, $baseUri, $dataUri)) of type array<string,string,{"rd...tring","owl":"string"}> is incompatible with the declared type array<integer,string> of property $namespaces.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 252 | $this->namespaces, |
||
| 253 | $this->getConceptNamespaces( $nodeNamespacePrefix, $predicateNamespacePrefix, $baseUri, $dataUri ) |
||
| 254 | ); |
||
| 255 | |||
| 256 | $this->claimToValue = array_merge( |
||
| 257 | $this->claimToValue, |
||
| 258 | [ |
||
| 259 | $predicateNamespacePrefix . self::NSP_CLAIM_STATEMENT => $predicateNamespacePrefix . self::NSP_CLAIM_VALUE, |
||
| 260 | $predicateNamespacePrefix . self::NSP_QUALIFIER => $predicateNamespacePrefix . self::NSP_QUALIFIER_VALUE, |
||
| 261 | $predicateNamespacePrefix . self::NSP_REFERENCE => $predicateNamespacePrefix . self::NSP_REFERENCE_VALUE, |
||
| 262 | ] |
||
| 263 | ); |
||
| 264 | $this->claimToValueNormalized = array_merge( |
||
| 265 | $this->claimToValueNormalized, |
||
| 266 | [ |
||
| 267 | $predicateNamespacePrefix . self::NSP_CLAIM_STATEMENT => $predicateNamespacePrefix . self::NSP_CLAIM_VALUE_NORM, |
||
| 268 | $predicateNamespacePrefix . self::NSP_QUALIFIER => $predicateNamespacePrefix . self::NSP_QUALIFIER_VALUE_NORM, |
||
| 269 | $predicateNamespacePrefix . self::NSP_REFERENCE => $predicateNamespacePrefix . self::NSP_REFERENCE_VALUE_NORM, |
||
| 270 | ] |
||
| 271 | ); |
||
| 272 | $this->normalizedPropertyValueNamespace = array_merge( |
||
| 273 | $this->normalizedPropertyValueNamespace, |
||
| 274 | [ |
||
| 275 | $nodeNamespacePrefix . self::NSP_DIRECT_CLAIM => $nodeNamespacePrefix . self::NSP_DIRECT_CLAIM_NORM, |
||
| 276 | $predicateNamespacePrefix . self::NSP_CLAIM_STATEMENT => $predicateNamespacePrefix . self::NSP_CLAIM_VALUE_NORM, |
||
| 277 | $predicateNamespacePrefix . self::NSP_QUALIFIER => $predicateNamespacePrefix . self::NSP_QUALIFIER_VALUE_NORM, |
||
| 278 | $predicateNamespacePrefix . self::NSP_REFERENCE => $predicateNamespacePrefix . self::NSP_REFERENCE_VALUE_NORM, |
||
| 279 | ] |
||
| 280 | ); |
||
| 281 | } |
||
| 282 | |||
| 283 | $this->sourceNameByEntityType = []; |
||
| 284 | foreach ( $entitySourceDefinitions->getEntityTypeToSourceMapping() as $entityType => $source ) { |
||
|
0 ignored issues
–
show
The expression
$entitySourceDefinitions...tyTypeToSourceMapping() of type null|array<integer,objec...taAccess\EntitySource>> is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
Loading history...
|
|||
| 285 | $this->sourceNameByEntityType[$entityType] = $source->getSourceName(); |
||
| 286 | } |
||
| 287 | |||
| 288 | $this->licenseUrl = $licenseUrl; |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Generates mapping of concept namespaces (including the prefix) to URIs |
||
| 293 | * using the given URI base. |
||
| 294 | * |
||
| 295 | * @param string $nodeNamespacePrefix |
||
| 296 | * @param string $predicateNamespacePrefix |
||
| 297 | * @param string $baseUri |
||
| 298 | * @param string $dataUri |
||
| 299 | * @return string[] |
||
| 300 | */ |
||
| 301 | private function getConceptNamespaces( $nodeNamespacePrefix, $predicateNamespacePrefix, $baseUri, $dataUri ) { |
||
| 302 | $topUri = $this->getConceptUriBase( $baseUri ); |
||
| 303 | |||
| 304 | $propUri = $topUri . 'prop/'; |
||
| 305 | |||
| 306 | return [ |
||
| 307 | $nodeNamespacePrefix . self::NS_ENTITY => $baseUri, |
||
| 308 | $predicateNamespacePrefix . self::NS_DATA => $dataUri, |
||
| 309 | $predicateNamespacePrefix . self::NS_STATEMENT => $baseUri . 'statement/', |
||
| 310 | $predicateNamespacePrefix . self::NS_REFERENCE => $topUri . 'reference/', |
||
| 311 | $predicateNamespacePrefix . self::NS_VALUE => $topUri . 'value/', |
||
| 312 | // predicates |
||
| 313 | $nodeNamespacePrefix . self::NSP_DIRECT_CLAIM => $propUri . 'direct/', |
||
| 314 | $nodeNamespacePrefix . self::NSP_DIRECT_CLAIM_NORM => $propUri . 'direct-normalized/', |
||
| 315 | $predicateNamespacePrefix . self::NSP_CLAIM => $propUri, |
||
| 316 | $predicateNamespacePrefix . self::NSP_CLAIM_STATEMENT => $propUri . 'statement/', |
||
| 317 | $predicateNamespacePrefix . self::NSP_CLAIM_VALUE => $propUri . 'statement/value/', |
||
| 318 | $predicateNamespacePrefix . self::NSP_CLAIM_VALUE_NORM => $propUri . 'statement/value-normalized/', |
||
| 319 | $predicateNamespacePrefix . self::NSP_QUALIFIER => $propUri . 'qualifier/', |
||
| 320 | $predicateNamespacePrefix . self::NSP_QUALIFIER_VALUE => $propUri . 'qualifier/value/', |
||
| 321 | $predicateNamespacePrefix . self::NSP_QUALIFIER_VALUE_NORM => $propUri . 'qualifier/value-normalized/', |
||
| 322 | $predicateNamespacePrefix . self::NSP_REFERENCE => $propUri . 'reference/', |
||
| 323 | $predicateNamespacePrefix . self::NSP_REFERENCE_VALUE => $propUri . 'reference/value/', |
||
| 324 | $predicateNamespacePrefix . self::NSP_REFERENCE_VALUE_NORM => $propUri . 'reference/value-normalized/', |
||
| 325 | $nodeNamespacePrefix . self::NSP_NOVALUE => $propUri . 'novalue/', |
||
| 326 | ]; |
||
| 327 | } |
||
| 328 | |||
| 329 | /** |
||
| 330 | * Returns the base part of concept URIs |
||
| 331 | * |
||
| 332 | * @param string $baseUri |
||
| 333 | * @return string |
||
| 334 | */ |
||
| 335 | private function getConceptUriBase( $baseUri ) { |
||
| 336 | if ( substr( $baseUri, -7 ) === 'entity/' ) { |
||
| 337 | return substr( $baseUri, 0, -7 ); |
||
| 338 | } |
||
| 339 | return $baseUri; |
||
| 340 | } |
||
| 341 | |||
| 342 | /** |
||
| 343 | * Returns a map of namespace names (prefixes) to URIs |
||
| 344 | * |
||
| 345 | * @return string[] |
||
| 346 | */ |
||
| 347 | public function getNamespaces() { |
||
| 348 | return $this->namespaces; |
||
| 349 | } |
||
| 350 | |||
| 351 | /** |
||
| 352 | * Returns the base URI for a given namespace (aka prefix). |
||
| 353 | * |
||
| 354 | * @param string $ns The namespace name |
||
| 355 | * |
||
| 356 | * @throws OutOfBoundsException if $ns is not a known namespace |
||
| 357 | * @return string the URI for the given namespace |
||
| 358 | */ |
||
| 359 | public function getNamespaceURI( $ns ) { |
||
| 360 | if ( !isset( $this->namespaces[$ns] ) ) { |
||
| 361 | throw new OutOfBoundsException(); |
||
| 362 | } |
||
| 363 | |||
| 364 | return $this->namespaces[$ns]; |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Returns a local name for the given entity using the given prefix. |
||
| 369 | * |
||
| 370 | * @param EntityId $entityId |
||
| 371 | * |
||
| 372 | * @return string |
||
| 373 | */ |
||
| 374 | public function getEntityLName( EntityId $entityId ) { |
||
| 375 | $id = $entityId->getSerialization(); |
||
|
0 ignored issues
–
show
$id is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 376 | |||
| 377 | $localIdPart = $entityId->getLocalPart(); |
||
| 378 | // If local ID part (ID excluding repository prefix) contains a colon, ie. the ID contains |
||
| 379 | // "chained" repository prefixes, replace all colons with periods in the local ID part. |
||
| 380 | return str_replace( ':', '.', $localIdPart ); |
||
| 381 | } |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @param EntityId $entityId |
||
| 385 | * @return string |
||
| 386 | */ |
||
| 387 | public function getEntityRepositoryName( EntityId $entityId ) { |
||
| 388 | return $this->sourceNameByEntityType[$entityId->getEntityType()]; |
||
| 389 | } |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Returns a qname for the given statement using the given prefix. |
||
| 393 | * |
||
| 394 | * @param Statement $statement |
||
| 395 | * |
||
| 396 | * @return string |
||
| 397 | */ |
||
| 398 | public function getStatementLName( Statement $statement ) { |
||
| 399 | return preg_replace( '/[^\w-]/', '-', $statement->getGuid() ); |
||
| 400 | } |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Returns a qname for the given entity type. |
||
| 404 | * For well known types, these qnames refer to classes from the Wikibase ontology. |
||
| 405 | * |
||
| 406 | * @param string $type |
||
| 407 | * |
||
| 408 | * @return string |
||
| 409 | */ |
||
| 410 | public function getEntityTypeName( $type ) { |
||
| 411 | return ucfirst( $type ); |
||
| 412 | } |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Get Wikibase property data type Uri for ontology |
||
| 416 | * |
||
| 417 | * @param Property $prop |
||
| 418 | * |
||
| 419 | * @return string |
||
| 420 | */ |
||
| 421 | public function getDataTypeURI( Property $prop ) { |
||
| 422 | $type = $prop->getDataTypeId(); |
||
| 423 | |||
| 424 | if ( !isset( $this->dataTypeUris[$type] ) ) { |
||
| 425 | // if the requested type has no URI in $this->dataTypeUris, add a generic one |
||
| 426 | $name = preg_replace( '/\W+/', '', ucwords( strtr( $type, '-', ' ' ) ) ); |
||
| 427 | $this->dataTypeUris[$type] = $this->namespaces[self::NS_ONTOLOGY] . $name; |
||
| 428 | } |
||
| 429 | |||
| 430 | return $this->dataTypeUris[$type]; |
||
| 431 | } |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Get Wikibase value type name for ontology |
||
| 435 | * |
||
| 436 | * @param DataValue $val |
||
| 437 | * |
||
| 438 | * @return string |
||
| 439 | */ |
||
| 440 | public function getValueTypeName( DataValue $val ) { |
||
| 441 | return ucfirst( $val->getType() ) . 'Value'; |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Create Commons URL from filename value |
||
| 446 | * |
||
| 447 | * @param string $file |
||
| 448 | * |
||
| 449 | * @return string |
||
| 450 | */ |
||
| 451 | public function getMediaFileURI( $file ) { |
||
| 452 | return self::MEDIA_URI . rawurlencode( $file ); |
||
| 453 | } |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Create data entry point URL for geo shapes |
||
| 457 | * |
||
| 458 | * @param string $file |
||
| 459 | * |
||
| 460 | * @return string |
||
| 461 | */ |
||
| 462 | public function getGeoShapeURI( $file ) { |
||
| 463 | return self::COMMONS_DATA_URI . wfUrlencode( $file ); |
||
| 464 | } |
||
| 465 | |||
| 466 | /** |
||
| 467 | * Create data entry point URL for tabular data |
||
| 468 | * |
||
| 469 | * @param string $file |
||
| 470 | * |
||
| 471 | * @return string |
||
| 472 | */ |
||
| 473 | public function getTabularDataURI( $file ) { |
||
| 474 | return self::COMMONS_DATA_URI . wfUrlencode( $file ); |
||
| 475 | } |
||
| 476 | |||
| 477 | /** |
||
| 478 | * @param string $languageCode Any non-standard or canonical language code |
||
| 479 | * |
||
| 480 | * @return string Canonical language code |
||
| 481 | */ |
||
| 482 | public function getCanonicalLanguageCode( $languageCode ) { |
||
| 483 | // First we check the case since most languages will be cached very quickly |
||
| 484 | if ( isset( self::$canonicalLanguageCodeCache[$languageCode] ) ) { |
||
| 485 | return self::$canonicalLanguageCodeCache[$languageCode]; |
||
| 486 | } |
||
| 487 | |||
| 488 | // Wikibase list goes first in case we want to override |
||
| 489 | // Like "simple" goes to en-simple not en |
||
| 490 | if ( isset( $this->canonicalLanguageCodes[$languageCode] ) ) { |
||
| 491 | return $this->canonicalLanguageCodes[$languageCode]; |
||
| 492 | } |
||
| 493 | |||
| 494 | self::$canonicalLanguageCodeCache[$languageCode] = \LanguageCode::bcp47( $languageCode ); |
||
| 495 | return self::$canonicalLanguageCodeCache[$languageCode]; |
||
| 496 | } |
||
| 497 | |||
| 498 | /** |
||
| 499 | * Return current ontology version URI |
||
| 500 | * @return string |
||
| 501 | */ |
||
| 502 | public static function getOntologyURI() { |
||
| 503 | return self::ONTOLOGY_BASE_URI . "-" . self::ONTOLOGY_VERSION . ".owl"; |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * Get the map of configured page properties |
||
| 508 | * @return string[][] |
||
| 509 | */ |
||
| 510 | public function getPageProperties() { |
||
| 511 | return $this->pagePropertyDefs; |
||
| 512 | } |
||
| 513 | |||
| 514 | /** |
||
| 515 | * @return string |
||
| 516 | */ |
||
| 517 | public function getLicenseUrl() { |
||
| 518 | return $this->licenseUrl; |
||
| 519 | } |
||
| 520 | |||
| 521 | } |
||
| 522 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..