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 Maps\Semantic\ValueDescriptions; |
||
4 | |||
5 | use Maps\Semantic\DatabaseBase; |
||
6 | use Maps\Semantic\SMWDIGeoCoord; |
||
7 | use SMW\DataValueFactory; |
||
8 | use SMW\Query\Language\ValueDescription; |
||
9 | |||
10 | /** |
||
11 | * Description of one data value of type Geographical Coordinates. |
||
12 | * |
||
13 | * @author Jeroen De Dauw |
||
14 | */ |
||
15 | class CoordinateDescription extends ValueDescription { |
||
16 | |||
17 | /** |
||
18 | * @see SMWDescription::getQueryString |
||
19 | * |
||
20 | * @since 0.6 |
||
21 | * |
||
22 | * @param boolean $asValue |
||
23 | * @return string |
||
24 | */ |
||
25 | public function getQueryString( $asValue = false ) { |
||
26 | if ( $this->getDataItem() !== null ) { |
||
27 | $queryString = DataValueFactory::newDataItemValue( $this->getDataItem(), $this->getPropertyCompat() )->getWikiValue(); |
||
28 | return $asValue ? $queryString : "[[$queryString]]"; |
||
29 | } else { |
||
30 | return $asValue ? '+' : ''; |
||
31 | } |
||
32 | } |
||
33 | |||
34 | private function getPropertyCompat() { |
||
35 | return method_exists( $this, 'getProperty' ) ? $this->getProperty() : $this->m_property; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @see SMWDescription::getSQLCondition |
||
40 | * |
||
41 | * FIXME: store specific code should be in the store component |
||
42 | * |
||
43 | * @since 0.6 |
||
44 | * |
||
45 | * @param string $tableName |
||
46 | * @param array $fieldNames |
||
47 | * @param DatabaseBase $dbs |
||
48 | * |
||
49 | * @return boolean |
||
50 | */ |
||
51 | public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) { |
||
52 | $dataItem = $this->getDataItem(); |
||
53 | |||
54 | // Only execute the query when the description's type is geographical coordinates, |
||
55 | // the description is valid, and the near comparator is used. |
||
56 | if ( $dataItem instanceof SMWDIGeoCoord ) { |
||
0 ignored issues
–
show
|
|||
57 | switch ( $this->getComparator() ) { |
||
58 | case SMW_CMP_EQ: $comparator = '='; break; |
||
59 | case SMW_CMP_LEQ: $comparator = '<='; break; |
||
60 | case SMW_CMP_GEQ: $comparator = '>='; break; |
||
61 | case SMW_CMP_NEQ: $comparator = '!='; break; |
||
62 | default: return false; |
||
63 | } |
||
64 | |||
65 | $lat = $dbs->addQuotes( $dataItem->getLatitude() ); |
||
66 | $lon = $dbs->addQuotes( $dataItem->getLongitude() ); |
||
67 | |||
68 | $conditions = []; |
||
69 | |||
70 | $conditions[] = "{$tableName}.$fieldNames[1] $comparator $lat"; |
||
71 | $conditions[] = "{$tableName}.$fieldNames[2] $comparator $lon"; |
||
72 | |||
73 | return implode( ' AND ', $conditions ); |
||
74 | } |
||
75 | |||
76 | return false; |
||
77 | } |
||
78 | |||
79 | } |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.