Skip to content

Commit 158c481

Browse files
committed
phpstan
phpstan Fix styling Fix styling Fix styling
1 parent 1db05ca commit 158c481

28 files changed

+340
-385
lines changed

.github/workflows/phpstan.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@ jobs:
1212
phpstan:
1313
name: phpstan
1414
runs-on: ubuntu-latest
15+
16+
env:
17+
DB_DATABASE: "laravel"
18+
DB_HOST: "127.0.0.1"
19+
DB_PORT: "3306"
20+
DB_USERNAME: "root"
21+
DB_PASSWORD: "root"
22+
1523
steps:
24+
- name: Set up MySQL
25+
run: |
26+
sudo /etc/init.d/mysql start
27+
mysql -e 'CREATE DATABASE laravel' -uroot -proot
28+
1629
- uses: actions/checkout@v3
1730

1831
- name: Setup PHP

phpstan-baseline.neon

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Call to function is_null\\(\\) with Illuminate\\\\Database\\\\Schema\\\\Grammars\\\\Grammar will always evaluate to false\\.$#"
5+
count: 1
6+
path: src/MysqlConnection.php
7+
8+
-
9+
message: "#^Method Grimzy\\\\LaravelMysqlSpatial\\\\MysqlConnection\\:\\:getDefaultSchemaGrammar\\(\\) should return Illuminate\\\\Database\\\\Schema\\\\Grammars\\\\MySqlGrammar but returns Illuminate\\\\Database\\\\Grammar\\.$#"
10+
count: 1
11+
path: src/MysqlConnection.php
12+
13+
-
14+
message: "#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Schema\\\\Blueprint\\:\\:spatialIndex\\(\\) should return Illuminate\\\\Database\\\\Schema\\\\IndexDefinition but returns Illuminate\\\\Support\\\\Fluent\\.$#"
15+
count: 1
16+
path: src/Schema/Blueprint.php
17+
18+
-
19+
message: "#^Access to an undefined property Illuminate\\\\Support\\\\Fluent\\:\\:\\$srid\\.$#"
20+
count: 1
21+
path: src/Schema/Grammars/MySqlGrammar.php
22+
23+
-
24+
message: "#^Call to an undefined method GeoJson\\\\GeoJson\\:\\:getGeometry\\(\\)\\.$#"
25+
count: 1
26+
path: src/Types/Geometry.php
27+
28+
-
29+
message: "#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Geometry\\:\\:fromWKT\\(\\) should return static\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Geometry\\) but returns Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\.$#"
30+
count: 1
31+
path: src/Types/Geometry.php
32+
33+
-
34+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
35+
count: 2
36+
path: src/Types/GeometryCollection.php
37+
38+
-
39+
message: "#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\:\\:jsonSerialize\\(\\) has no return type specified\\.$#"
40+
count: 1
41+
path: src/Types/GeometryInterface.php
42+
43+
-
44+
message: "#^Return type \\(GeoJson\\\\Geometry\\\\LineString\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\LineString\\:\\:jsonSerialize\\(\\) should be compatible with return type \\(GeoJson\\\\Geometry\\\\GeometryCollection\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryCollection\\:\\:jsonSerialize\\(\\)$#"
45+
count: 1
46+
path: src/Types/LineString.php
47+
48+
-
49+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
50+
count: 1
51+
path: src/Types/LineString.php
52+
53+
-
54+
message: "#^Return type \\(GeoJson\\\\Geometry\\\\MultiLineString\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\MultiLineString\\:\\:jsonSerialize\\(\\) should be compatible with return type \\(GeoJson\\\\Geometry\\\\GeometryCollection\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryCollection\\:\\:jsonSerialize\\(\\)$#"
55+
count: 1
56+
path: src/Types/MultiLineString.php
57+
58+
-
59+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
60+
count: 1
61+
path: src/Types/MultiLineString.php
62+
63+
-
64+
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\)\\: mixed\\)\\|null, Closure\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Point\\)\\: non\\-falsy\\-string given\\.$#"
65+
count: 1
66+
path: src/Types/MultiPoint.php
67+
68+
-
69+
message: "#^Return type \\(GeoJson\\\\Geometry\\\\MultiPoint\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\MultiPoint\\:\\:jsonSerialize\\(\\) should be compatible with return type \\(GeoJson\\\\Geometry\\\\GeometryCollection\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryCollection\\:\\:jsonSerialize\\(\\)$#"
70+
count: 1
71+
path: src/Types/MultiPoint.php
72+
73+
-
74+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
75+
count: 1
76+
path: src/Types/MultiPoint.php
77+
78+
-
79+
message: "#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\MultiPolygon\\:\\:getPolygons\\(\\) should return array\\<Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Polygon\\> but returns array\\<Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\>\\.$#"
80+
count: 1
81+
path: src/Types/MultiPolygon.php
82+
83+
-
84+
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\)\\: mixed\\)\\|null, Closure\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Polygon\\)\\: non\\-falsy\\-string given\\.$#"
85+
count: 1
86+
path: src/Types/MultiPolygon.php
87+
88+
-
89+
message: "#^Return type \\(GeoJson\\\\Geometry\\\\MultiPolygon\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\MultiPolygon\\:\\:jsonSerialize\\(\\) should be compatible with return type \\(GeoJson\\\\Geometry\\\\GeometryCollection\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryCollection\\:\\:jsonSerialize\\(\\)$#"
90+
count: 1
91+
path: src/Types/MultiPolygon.php
92+
93+
-
94+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
95+
count: 1
96+
path: src/Types/MultiPolygon.php
97+
98+
-
99+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
100+
count: 1
101+
path: src/Types/Point.php
102+
103+
-
104+
message: "#^Method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\PointCollection\\:\\:getPoints\\(\\) should return array\\<Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Point\\> but returns array\\<Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\>\\.$#"
105+
count: 1
106+
path: src/Types/PointCollection.php
107+
108+
-
109+
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\)\\: mixed\\)\\|null, Closure\\(Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Point\\)\\: string given\\.$#"
110+
count: 1
111+
path: src/Types/PointCollection.php
112+
113+
-
114+
message: "#^Return type \\(GeoJson\\\\Geometry\\\\Polygon\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\Polygon\\:\\:jsonSerialize\\(\\) should be compatible with return type \\(GeoJson\\\\Geometry\\\\MultiLineString\\) of method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\MultiLineString\\:\\:jsonSerialize\\(\\)$#"
115+
count: 1
116+
path: src/Types/Polygon.php

phpstan.neon.dist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 4
5+
level: 6
66
paths:
77
- src
88
tmpDir: build/phpstan
9-
checkOctaneCompatibility: true
109
checkModelProperties: true
1110
checkMissingIterableValueType: false
12-
11+
checkGenericClassInNonGenericObjectType: false

pint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"use_arrow_functions": true
5+
}
6+
}

src/Eloquent/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function update(array $values)
1818
return parent::update($values);
1919
}
2020

21-
protected function asWKT(GeometryInterface $geometry)
21+
protected function asWKT(GeometryInterface $geometry): SpatialExpression
2222
{
2323
return new SpatialExpression($geometry);
2424
}

src/Eloquent/SpatialExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public function getValue()
1111
return "ST_GeomFromText(?, ?, 'axis-order=long-lat')";
1212
}
1313

14-
public function getSpatialValue()
14+
public function getSpatialValue(): string
1515
{
1616
return $this->value->toWkt();
1717
}
1818

19-
public function getSrid()
19+
public function getSrid(): int
2020
{
2121
return $this->value->getSrid();
2222
}

src/MysqlConnection.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,16 @@ public function __construct($pdo, $database = '', $tablePrefix = '', array $conf
3535

3636
/**
3737
* Get the default schema grammar instance.
38-
*
39-
* @return \Illuminate\Database\Grammar
4038
*/
41-
protected function getDefaultSchemaGrammar()
39+
protected function getDefaultSchemaGrammar(): \Illuminate\Database\Grammar
4240
{
4341
return $this->withTablePrefix(new MySqlGrammar());
4442
}
4543

4644
/**
4745
* Get a schema builder instance for the connection.
48-
*
49-
* @return \Illuminate\Database\Schema\MySqlBuilder
5046
*/
51-
public function getSchemaBuilder()
47+
public function getSchemaBuilder(): \Illuminate\Database\Schema\MySqlBuilder
5248
{
5349
if (is_null($this->schemaGrammar)) {
5450
$this->useDefaultSchemaGrammar();

src/Schema/Blueprint.php

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,96 +8,66 @@ class Blueprint extends IlluminateBlueprint
88
{
99
/**
1010
* Add a geometry column on the table.
11-
*
12-
* @param string $column
13-
* @param null|int $srid
14-
* @return \Illuminate\Support\Fluent
1511
*/
16-
public function geometry($column, $srid = null)
12+
public function geometry($column, ?int $srid = null): \Illuminate\Support\Fluent
1713
{
1814
return $this->addColumn('geometry', $column, compact('srid'));
1915
}
2016

2117
/**
2218
* Add a point column on the table.
2319
*
24-
* @param string $column
25-
* @param null|int $srid
26-
* @return \Illuminate\Support\Fluent
20+
* @param ?int $srid
2721
*/
28-
public function point($column, $srid = null)
22+
public function point($column, $srid = null): \Illuminate\Support\Fluent
2923
{
3024
return $this->addColumn('point', $column, compact('srid'));
3125
}
3226

3327
/**
3428
* Add a linestring column on the table.
35-
*
36-
* @param string $column
37-
* @param null|int $srid
38-
* @return \Illuminate\Support\Fluent
3929
*/
40-
public function lineString($column, $srid = null)
30+
public function lineString($column, ?int $srid = null): \Illuminate\Support\Fluent
4131
{
4232
return $this->addColumn('linestring', $column, compact('srid'));
4333
}
4434

4535
/**
4636
* Add a polygon column on the table.
47-
*
48-
* @param string $column
49-
* @param null|int $srid
50-
* @return \Illuminate\Support\Fluent
5137
*/
52-
public function polygon($column, $srid = null)
38+
public function polygon($column, ?int $srid = null): \Illuminate\Support\Fluent
5339
{
5440
return $this->addColumn('polygon', $column, compact('srid'));
5541
}
5642

5743
/**
5844
* Add a multipoint column on the table.
59-
*
60-
* @param string $column
61-
* @param null|int $srid
62-
* @return \Illuminate\Support\Fluent
6345
*/
64-
public function multiPoint($column, $srid = null)
46+
public function multiPoint($column, ?int $srid = null): \Illuminate\Support\Fluent
6547
{
6648
return $this->addColumn('multipoint', $column, compact('srid'));
6749
}
6850

6951
/**
7052
* Add a multilinestring column on the table.
71-
*
72-
* @param string $column
73-
* @param null|int $srid
74-
* @return \Illuminate\Support\Fluent
7553
*/
76-
public function multiLineString($column, $srid = null)
54+
public function multiLineString($column, ?int $srid = null): \Illuminate\Support\Fluent
7755
{
7856
return $this->addColumn('multilinestring', $column, compact('srid'));
7957
}
8058

8159
/**
8260
* Add a multipolygon column on the table.
83-
*
84-
* @param string $column
85-
* @param null|int $srid
86-
* @return \Illuminate\Support\Fluent
8761
*/
88-
public function multiPolygon($column, $srid = null)
62+
public function multiPolygon($column, ?int $srid = null): \Illuminate\Support\Fluent
8963
{
9064
return $this->addColumn('multipolygon', $column, compact('srid'));
9165
}
9266

9367
/**
9468
* Add a geometrycollection column on the table.
95-
*
96-
* @param string $column
97-
* @param null|int $srid
98-
* @return \Illuminate\Support\Fluent
9969
*/
100-
public function geometryCollection($column, $srid = null)
70+
public function geometryCollection($column, ?int $srid = null): \Illuminate\Support\Fluent
10171
{
10272
return $this->addColumn('geometrycollection', $column, compact('srid'));
10373
}
@@ -107,9 +77,8 @@ public function geometryCollection($column, $srid = null)
10777
*
10878
* @param string|array $columns
10979
* @param string $name
110-
* @return \Illuminate\Support\Fluent
11180
*/
112-
public function spatialIndex($columns, $name = null)
81+
public function spatialIndex($columns, $name = null): \Illuminate\Support\Fluent
11382
{
11483
return $this->indexCommand('spatial', $columns, $name);
11584
}
@@ -118,9 +87,8 @@ public function spatialIndex($columns, $name = null)
11887
* Indicate that the given index should be dropped.
11988
*
12089
* @param string|array $index
121-
* @return \Illuminate\Support\Fluent
12290
*/
123-
public function dropSpatialIndex($index)
91+
public function dropSpatialIndex($index): \Illuminate\Support\Fluent
12492
{
12593
return $this->dropIndexCommand('dropIndex', 'spatial', $index);
12694
}

0 commit comments

Comments
 (0)