From 72bb675f5fa700f123f0990f501a9e3e038b6f7a Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 6 Feb 2024 14:14:18 +0800 Subject: [PATCH] patches for laravel 10x compatability --- composer.json | 2 +- src/Eloquent/SpatialExpression.php | 3 ++- src/SpatialServiceProvider.php | 5 +++++ tests/Integration/IntegrationBaseTestCase.php | 7 ++++--- tests/Unit/BaseTestCase.php | 2 +- tests/Unit/Eloquent/SpatialTraitTest.php | 6 ++++-- tests/Unit/MysqlConnectionTest.php | 2 +- tests/Unit/Schema/BlueprintTest.php | 2 +- tests/Unit/Types/LineStringTest.php | 2 +- tests/Unit/Types/PolygonTest.php | 2 +- 10 files changed, 21 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 6ae9c57..e8c97b5 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "fleetbase/laravel-mysql-spatial", "description": "MySQL spatial data types extension for Laravel x Fleetbase.", - "version": "1.0.1", + "version": "1.0.2", "scripts": { "test": "phpunit -c phpunit.xml.dist", "test:unit": "phpunit -c phpunit.xml.dist --testsuite unit", diff --git a/src/Eloquent/SpatialExpression.php b/src/Eloquent/SpatialExpression.php index 4c8ce74..02d6d48 100644 --- a/src/Eloquent/SpatialExpression.php +++ b/src/Eloquent/SpatialExpression.php @@ -6,7 +6,8 @@ class SpatialExpression extends Expression { - public function getValue() + #[\ReturnTypeWillChange] + public function getValue($grammar) { return "ST_GeomFromText(?, ?, 'axis-order=long-lat')"; } diff --git a/src/SpatialServiceProvider.php b/src/SpatialServiceProvider.php index 85ec42d..7a0e176 100644 --- a/src/SpatialServiceProvider.php +++ b/src/SpatialServiceProvider.php @@ -41,6 +41,11 @@ public function register() return new DatabaseManager($app, $app['db.factory']); }); + // Bind for database schema + $this->app->bind('db.schema', function ($app) { + return $app['db']->connection()->getSchemaBuilder(); + }); + if (class_exists(DoctrineType::class)) { // Prevent geometry type fields from throwing a 'type not found' error when changing them $geometries = [ diff --git a/tests/Integration/IntegrationBaseTestCase.php b/tests/Integration/IntegrationBaseTestCase.php index f30dad6..35e7176 100644 --- a/tests/Integration/IntegrationBaseTestCase.php +++ b/tests/Integration/IntegrationBaseTestCase.php @@ -44,7 +44,7 @@ public function createApplication() * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -59,7 +59,7 @@ public function setUp() //}); } - public function tearDown() + public function tearDown(): void { $this->onMigrations(function ($migrationClass) { (new $migrationClass())->down(); @@ -71,7 +71,8 @@ public function tearDown() // MySQL 8.0.4 fixed bug #26941370 and bug #88031 private function isMySQL8AfterFix() { - $results = DB::select(DB::raw('select version()')); + $expression = DB::raw('select version()'); + $results = DB::select($expression->getValue(DB::connection()->getQueryGrammar())); $mysql_version = $results[0]->{'version()'}; return version_compare($mysql_version, '8.0.4', '>='); diff --git a/tests/Unit/BaseTestCase.php b/tests/Unit/BaseTestCase.php index 219f737..215690e 100644 --- a/tests/Unit/BaseTestCase.php +++ b/tests/Unit/BaseTestCase.php @@ -4,7 +4,7 @@ abstract class BaseTestCase extends TestCase { - public function tearDown() + public function tearDown(): void { Mockery::close(); } diff --git a/tests/Unit/Eloquent/SpatialTraitTest.php b/tests/Unit/Eloquent/SpatialTraitTest.php index 4085779..dd702ec 100644 --- a/tests/Unit/Eloquent/SpatialTraitTest.php +++ b/tests/Unit/Eloquent/SpatialTraitTest.php @@ -21,13 +21,13 @@ class SpatialTraitTest extends BaseTestCase */ protected $queries; - public function setUp() + public function setUp(): void { $this->model = new TestModel(); $this->queries = &$this->model->getConnection()->getPdo()->queries; } - public function tearDown() + public function tearDown(): void { $this->model->getConnection()->getPdo()->resetQueries(); } @@ -580,6 +580,7 @@ class TestPDO extends PDO public $counter = 1; + #[\ReturnTypeWillChange] public function prepare($statement, $driver_options = []) { $this->queries[] = $statement; @@ -593,6 +594,7 @@ public function prepare($statement, $driver_options = []) return $stmt; } + #[\ReturnTypeWillChange] public function lastInsertId($name = null) { return $this->counter++; diff --git a/tests/Unit/MysqlConnectionTest.php b/tests/Unit/MysqlConnectionTest.php index fa1b428..652b10f 100644 --- a/tests/Unit/MysqlConnectionTest.php +++ b/tests/Unit/MysqlConnectionTest.php @@ -9,7 +9,7 @@ class MysqlConnectionTest extends TestCase { private $mysqlConnection; - protected function setUp() + protected function setUp(): void { $mysqlConfig = ['driver' => 'mysql', 'prefix' => 'prefix', 'database' => 'database', 'name' => 'foo']; $this->mysqlConnection = new MysqlConnection(new PDOStub(), 'database', 'prefix', $mysqlConfig); diff --git a/tests/Unit/Schema/BlueprintTest.php b/tests/Unit/Schema/BlueprintTest.php index 4bf79a5..b926ce0 100644 --- a/tests/Unit/Schema/BlueprintTest.php +++ b/tests/Unit/Schema/BlueprintTest.php @@ -14,7 +14,7 @@ class BlueprintTest extends BaseTestCase */ protected $blueprint; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Unit/Types/LineStringTest.php b/tests/Unit/Types/LineStringTest.php index 8e64b5c..e0324b6 100644 --- a/tests/Unit/Types/LineStringTest.php +++ b/tests/Unit/Types/LineStringTest.php @@ -7,7 +7,7 @@ class LineStringTest extends BaseTestCase { private $points; - protected function setUp() + protected function setUp(): void { $this->points = [new Point(0, 0), new Point(1, 1), new Point(2, 2)]; } diff --git a/tests/Unit/Types/PolygonTest.php b/tests/Unit/Types/PolygonTest.php index 833beca..e788a93 100644 --- a/tests/Unit/Types/PolygonTest.php +++ b/tests/Unit/Types/PolygonTest.php @@ -8,7 +8,7 @@ class PolygonTest extends BaseTestCase { private $polygon; - protected function setUp() + protected function setUp(): void { $collection = new LineString( [