Issues (52)

src/ORM/SQLite3GISSchemaManager.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace Smindel\GIS\ORM;
4
5
use SilverStripe\SQLite\SQLite3SchemaManager;
0 ignored issues
show
The type SilverStripe\SQLite\SQLite3SchemaManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\ORM\DB;
7
use Smindel\GIS\GIS;
8
9
if (!class_exists(SQLite3SchemaManager::class)) return;
10
11
class SQLite3GISSchemaManager extends SQLite3SchemaManager
12
{
13
    use GISSchemaManager;
14
15
    protected static $is_initialised = false;
16
17
    public function initialise()
18
    {
19
        if (!self::$is_initialised) {
20
            $connector = DB::get_connector()->getRawConnector();
0 ignored issues
show
The method getRawConnector() does not exist on SilverStripe\ORM\Connect\DBConnector. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
            $connector = DB::get_connector()->/** @scrutinizer ignore-call */ getRawConnector();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
            $connector->loadExtension('mod_spatialite.so');
22
            $connector->exec("SELECT InitSpatialMetadata()");
23
            self::$is_initialised = true;
24
        }
25
    }
26
27
    public function geography($values)
28
    {
29
        // ATTENTION: GEOGRAPHY IS NOT SUPPORTED BY MYSQL. THIS IS STRICTLY FOR COMPATIBILITY
30
        return 'geometry';
31
    }
32
33
    public function translateStGeometryTypeFilter($field, $value, $inclusive)
34
    {
35
        $null = $inclusive ? '' : ' OR ' . DB::get_conn()->nullCheckClause($field, true);
36
        $fragment = sprintf(
37
            '%sLOWER(ST_GeometryType(%s)) = ?%s',
38
            $inclusive ? '' : 'NOT ',
39
            $field,
40
            $null
41
        );
42
        return [$fragment => strtolower($value)];
43
    }
44
45
    public function translateBasicSelectGeo()
46
    {
47
        DB::get_schema()->initialise();
0 ignored issues
show
The method initialise() does not exist on SilverStripe\ORM\Connect\DBSchemaManager. It seems like you code against a sub-type of SilverStripe\ORM\Connect\DBSchemaManager such as Smindel\GIS\ORM\MySQLGISSchemaManager. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        DB::get_schema()->/** @scrutinizer ignore-call */ initialise();
Loading history...
48
        return 'CASE WHEN %s IS NULL THEN NULL ELSE \'SRID=\' || ST_SRID(%s) || \';\' || ST_AsText(%s) END AS "%s"';
49
    }
50
}
51