Skip to content

Commit 8032ce8

Browse files
committed
Laravel 10
Fix styling Fix styling Fix styling fixup! phpstan
1 parent 158c481 commit 8032ce8

36 files changed

+305
-215
lines changed

.github/workflows/run-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
matrix:
1515
os: [ubuntu-latest]
1616
php: [8.2, 8.1]
17-
laravel: [9.*]
17+
laravel: [10.*]
1818
stability: [prefer-lowest, prefer-stable]
1919
include:
20-
- laravel: 9.*
21-
testbench: 7.*
20+
- laravel: 10.*
21+
testbench: 8.*
2222
carbon: ^2.63
2323

2424
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ testbench.yaml
1010
vendor
1111
_db/
1212
node_modules
13+
.phpunit.cache

composer.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,32 @@
2121
"php": "^8.1",
2222
"ext-json": "*",
2323
"ext-pdo": "*",
24-
"doctrine/dbal": "^2.5",
24+
"doctrine/dbal": "^3.0",
2525
"geo-io/wkb-parser": "^1.0",
26-
"illuminate/contracts": "^9.0",
27-
"illuminate/database": "^9.0",
26+
"illuminate/contracts": "^10.0",
27+
"illuminate/database": "^10.0",
2828
"jmikola/geojson": "^1.0"
2929
},
30-
"conflict": {
31-
"doctrine/dbal": "2.13.*"
32-
},
30+
"conflict": {},
3331
"require-dev": {
3432
"laravel/pint": "^1.5",
35-
"laravel/laravel": "^9.5.2",
36-
"laravel/browser-kit-testing": "^6.4",
33+
"laravel/laravel": "^10.0.2",
34+
"laravel/browser-kit-testing": "^7.0",
3735
"mockery/mockery": "^1.5.1",
38-
"nunomaduro/collision": "^6.4",
36+
"nunomaduro/collision": "^7.0.4",
3937
"nunomaduro/larastan": "^2.4.1",
40-
"orchestra/testbench": "^7.22",
38+
"orchestra/testbench": "^8.0.1",
4139
"phpstan/extension-installer": "^1.2",
4240
"phpstan/phpstan-deprecation-rules": "^1.1.1",
4341
"phpstan/phpstan-phpunit": "^1.3.4",
44-
"phpunit/phpunit": "^9.6.3"
42+
"phpunit/phpunit": "^10.0.7"
4543
},
4644
"autoload": {
4745
"psr-4": {
4846
"Grimzy\\LaravelMysqlSpatial\\": "src"
4947
}
5048
},
5149
"autoload-dev": {
52-
"classmap": [
53-
"tests/Unit",
54-
"tests/Integration"
55-
],
5650
"psr-4": {
5751
"Grimzy\\LaravelMysqlSpatial\\Tests\\": "tests"
5852
}
@@ -71,6 +65,6 @@
7165
]
7266
}
7367
},
74-
"minimum-stability": "dev",
68+
"minimum-stability": "stable",
7569
"prefer-stable": true
7670
}

phpstan-baseline.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
parameters:
22
ignoreErrors:
3+
-
4+
message: "#^Call to an undefined method Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface\\:\\:getSrid\\(\\)\\.$#"
5+
count: 1
6+
path: src/Eloquent/SpatialExpression.php
7+
8+
-
9+
message: "#^PHPDoc type Grimzy\\\\LaravelMysqlSpatial\\\\Types\\\\GeometryInterface of property Grimzy\\\\LaravelMysqlSpatial\\\\Eloquent\\\\SpatialExpression\\:\\:\\$value is not covariant with PHPDoc type float\\|int\\|string of overridden property Illuminate\\\\Database\\\\Query\\\\Expression\\:\\:\\$value\\.$#"
10+
count: 1
11+
path: src/Eloquent/SpatialExpression.php
12+
313
-
414
message: "#^Call to function is_null\\(\\) with Illuminate\\\\Database\\\\Schema\\\\Grammars\\\\Grammar will always evaluate to false\\.$#"
515
count: 1

phpunit.xml.dist

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,34 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
bootstrap="vendor/autoload.php"
8-
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
processIsolation="false"
13-
stopOnFailure="false"
14-
verbose="true"
15-
>
16-
<testsuites>
17-
<testsuite name="unit">
18-
<directory suffix="Test.php">./tests/Unit</directory>
19-
</testsuite>
20-
<testsuite name="integration">
21-
<directory suffix="Test.php">./tests/Integration</directory>
22-
</testsuite>
23-
</testsuites>
24-
<listeners>
25-
<listener class="\Mockery\Adapter\Phpunit\TestListener"
26-
file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php">
27-
</listener>
28-
</listeners>
29-
<coverage>
30-
<include>
31-
<directory suffix=".php">./src</directory>
32-
</include>
33-
<report>
34-
<html outputDirectory="build/coverage"/>
35-
<text outputFile="build/coverage.txt"/>
36-
<clover outputFile="build/logs/clover.xml"/>
37-
</report>
38-
</coverage>
39-
<logging>
40-
<junit outputFile="build/report.junit.xml"/>
41-
</logging>
42-
<php>
43-
<env name="APP_ENV" value="testing"/>
44-
<env name="APP_DEBUG" value="true"/>
45-
<env name="APP_KEY" value="V4EYYl0MjI4Bin9GkFPUE3cpAARPCF27"/>
46-
<env name="CACHE_DRIVER" value="array"/>
47-
<env name="SESSION_DRIVER" value="array"/>
48-
<env name="QUEUE_DRIVER" value="sync"/>
49-
<env name="DB_DATABASE" value="laravel"/>
50-
<env name="DB_HOST" value="127.0.0.1"/>
51-
<env name="DB_PORT" value="3306"/>
52-
<env name="DB_USERNAME" value="root"/>
53-
<env name="DB_PASSWORD" value="root"/>
54-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Test Suite">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<coverage>
9+
<include>
10+
<directory suffix=".php">./src</directory>
11+
</include>
12+
<report>
13+
<html outputDirectory="build/coverage"/>
14+
<text outputFile="build/coverage.txt"/>
15+
<clover outputFile="build/logs/clover.xml"/>
16+
</report>
17+
</coverage>
18+
<logging>
19+
<junit outputFile="build/report.junit.xml"/>
20+
</logging>
21+
<php>
22+
<env name="APP_ENV" value="testing"/>
23+
<env name="APP_DEBUG" value="true"/>
24+
<env name="APP_KEY" value="V4EYYl0MjI4Bin9GkFPUE3cpAARPCF27"/>
25+
<env name="CACHE_DRIVER" value="array"/>
26+
<env name="SESSION_DRIVER" value="array"/>
27+
<env name="QUEUE_DRIVER" value="sync"/>
28+
<env name="DB_DATABASE" value="laravel"/>
29+
<env name="DB_HOST" value="127.0.0.1"/>
30+
<env name="DB_PORT" value="3306"/>
31+
<env name="DB_USERNAME" value="root"/>
32+
<env name="DB_PASSWORD" value="root"/>
33+
</php>
5534
</phpunit>

src/Eloquent/SpatialExpression.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,28 @@
22

33
namespace Grimzy\LaravelMysqlSpatial\Eloquent;
44

5+
use Grimzy\LaravelMysqlSpatial\Types\Geometry;
6+
use Grimzy\LaravelMysqlSpatial\Types\GeometryInterface;
7+
use Illuminate\Database\Grammar;
58
use Illuminate\Database\Query\Expression;
69

710
class SpatialExpression extends Expression
811
{
9-
public function getValue()
12+
/**
13+
* @var Geometry|GeometryInterface
14+
*/
15+
protected $value;
16+
17+
/**
18+
* @param Geometry|GeometryInterface $value
19+
* @return void
20+
*/
21+
public function __construct($value)
22+
{
23+
$this->value = $value;
24+
}
25+
26+
public function getValue(Grammar $grammar)
1027
{
1128
return "ST_GeomFromText(?, ?, 'axis-order=long-lat')";
1229
}
@@ -20,4 +37,9 @@ public function getSrid(): int
2037
{
2138
return $this->value->getSrid();
2239
}
40+
41+
public function toWkt(): string
42+
{
43+
return $this->value->toWkt();
44+
}
2345
}

src/MysqlConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct($pdo, $database = '', $tablePrefix = '', array $conf
2626
'geometrycollection',
2727
'geomcollection',
2828
];
29-
$dbPlatform = $this->getDoctrineSchemaManager()->getDatabasePlatform();
29+
$dbPlatform = $this->getDoctrineConnection()->getDatabasePlatform();
3030
foreach ($geometries as $type) {
3131
$dbPlatform->registerDoctrineTypeMapping($type, 'string');
3232
}

tests/Integration/IntegrationBaseTestCase.php renamed to tests/Integration/IntegrationBaseCase.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<?php
22

3+
namespace Grimzy\LaravelMysqlSpatial\Tests\Integration;
4+
35
use Grimzy\LaravelMysqlSpatial\SpatialServiceProvider;
6+
use Grimzy\LaravelMysqlSpatial\Tests\Integration\Migrations\CreateTables;
7+
use Grimzy\LaravelMysqlSpatial\Tests\Integration\Migrations\UpdateTables;
48
use Illuminate\Support\Facades\DB;
59
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
610

7-
abstract class IntegrationBaseTestCase extends BaseTestCase
11+
abstract class IntegrationBaseCase extends BaseTestCase
812
{
913
protected $after_fix = false;
1014

1115
protected $migrations = [];
1216

1317
/**
1418
* Boots the application.
15-
*
16-
* @return \Illuminate\Foundation\Application
1719
*/
18-
public function createApplication(): Illuminate\Foundation\Application
20+
public function createApplication(): \Illuminate\Foundation\Application
1921
{
2022
$app = require __DIR__.'/../../vendor/laravel/laravel/bootstrap/app.php';
2123
$app->register(SpatialServiceProvider::class);
@@ -49,9 +51,10 @@ public function setUp(): void
4951

5052
$this->after_fix = $this->isMySQL8AfterFix();
5153

52-
$this->onMigrations(function ($migrationClass) {
53-
(new $migrationClass())->up();
54-
});
54+
$this->artisan('migrate:fresh');
55+
56+
(new CreateTables)->up();
57+
(new UpdateTables)->up();
5558

5659
//\DB::listen(function($sql) {
5760
// var_dump($sql);
@@ -60,17 +63,16 @@ public function setUp(): void
6063

6164
public function tearDown(): void
6265
{
63-
$this->onMigrations(function ($migrationClass) {
64-
(new $migrationClass())->down();
65-
}, true);
66+
(new UpdateTables)->down();
67+
(new CreateTables)->down();
6668

6769
parent::tearDown();
6870
}
6971

7072
// MySQL 8.0.4 fixed bug #26941370 and bug #88031
7173
private function isMySQL8AfterFix()
7274
{
73-
$results = DB::select(DB::raw('select version()'));
75+
$results = DB::select(DB::raw('select version()')->getValue(DB::connection()->getQueryGrammar()));
7476
$mysql_version = $results[0]->{'version()'};
7577

7678
return version_compare($mysql_version, '8.0.4', '>=');

tests/Integration/MigrationTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?php
22

3+
namespace Grimzy\LaravelMysqlSpatial\Tests\Integration;
4+
5+
use Grimzy\LaravelMysqlSpatial\Tests\Integration\Migrations\CreateTables;
6+
use Grimzy\LaravelMysqlSpatial\Tests\Integration\Migrations\UpdateTables;
37
use Illuminate\Support\Facades\DB;
48

5-
class MigrationTest extends IntegrationBaseTestCase
9+
class MigrationTest extends IntegrationBaseCase
610
{
711
protected $migrations = [
8-
CreateLocationTable::class,
9-
UpdateLocationTable::class,
12+
CreateTables::class,
13+
UpdateTables::class,
1014
];
1115

1216
public function testTableWasCreatedWithRightTypes()

tests/Integration/Migrations/CreateTables.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3+
namespace Grimzy\LaravelMysqlSpatial\Tests\Integration\Migrations;
4+
35
use Grimzy\LaravelMysqlSpatial\Schema\Blueprint;
46
use Illuminate\Database\Migrations\Migration;
57
use Illuminate\Support\Facades\Schema;
68

7-
class CreateLocationTable extends Migration
9+
class CreateTables extends Migration
810
{
911
/**
1012
* Run the migrations.

0 commit comments

Comments
 (0)