Skip to content

Commit

Permalink
Merge pull request #1 from fleetbase/dev-v1.0.2
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
roncodes authored Feb 15, 2024
2 parents 72bb675 + 66c96cf commit 3dd0c72
Show file tree
Hide file tree
Showing 49 changed files with 374 additions and 336 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PHP CI

on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, gd, zip, pdo_mysql, sockets, intl, bcmath, gmp
coverage: xdebug

- name: Update and Install additional packages
run: |
sudo apt-get update
sudo apt-get install -y libzip-dev libgd-dev libfreetype6-dev libjpeg-dev libpng-dev imagemagick libmagickwand-dev libmemcached-dev libgeos-dev libgmp-dev default-mysql-client libicu-dev
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run Lint
run: composer lint

# - name: Run Tests -- Will add tests back after phppest issue https://github.com/pestphp/pest/issues/920 is fixed
# run: composer test:unit
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
vendor/
composer.lock
_db/
build/
build/
.idea/*
.idea/codeStyleSettings.xml
server_vendor/
.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
*.swp
*.swo
.DS_Store
29 changes: 29 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
->append(['.php-cs-fixer.php']);

$rules = [
'@Symfony' => true,
'phpdoc_no_empty_return' => false,
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => false,
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align',
'=' => 'align',
],
],
'concat_space' => ['spacing' => 'one'],
'not_operator_with_space' => false,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'single_quote' => true,
];

return (new PhpCsFixer\Config())
->setUsingCache(true)
->setRules($rules)
->setFinder($finder);
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"description": "MySQL spatial data types extension for Laravel x Fleetbase.",
"version": "1.0.2",
"scripts": {
"lint": "php-cs-fixer fix -v",
"test": "phpunit -c phpunit.xml.dist",
"test:lint": "php-cs-fixer fix -v --dry-run",
"test:types": "phpstan analyse --ansi --memory-limit=4G",
"test:unit": "phpunit -c phpunit.xml.dist --testsuite unit",
"test:integration": "phpunit -c phpunit.xml.dist --testsuite integration"
},
Expand All @@ -23,16 +26,19 @@
"php": "^8.0",
"ext-pdo": "*",
"ext-json": "*",
"doctrine/dbal": "^3.5",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"geo-io/wkb-parser": "^1.0",
"jmikola/geojson": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"laravel/laravel": "^8.0",
"doctrine/dbal": "^3.4",
"phpunit/phpunit": "^10.0.15",
"laravel/laravel": "^10.0.4",
"laravel/browser-kit-testing": "^7.0",
"mockery/mockery": "^1.5"
"mockery/mockery": "^1.5",
"friendsofphp/php-cs-fixer": "^3.34.1",
"phpstan/phpstan": "^1.10.38"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 8 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: max
paths:
- src

checkMissingIterableValueType: true
checkGenericClassInNonGenericObjectType: false
reportUnmatchedIgnoredErrors: true
10 changes: 4 additions & 6 deletions src/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

use Fleetbase\LaravelMysqlSpatial\MysqlConnection;
use Illuminate\Database\Connectors\ConnectionFactory as IlluminateConnectionFactory;
use PDO;

class ConnectionFactory extends IlluminateConnectionFactory
{
/**
* @param string $driver
* @param \Closure|PDO $connection
* @param string $database
* @param string $prefix
* @param array $config
* @param string $driver
* @param \Closure|\PDO $connection
* @param string $database
* @param string $prefix
*
* @return \Illuminate\Database\ConnectionInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Geometry extends Type
{
const GEOMETRY = 'geometry';
public const GEOMETRY = 'geometry';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/GeometryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class GeometryCollection extends Type
{
const GEOMETRYCOLLECTION = 'geometrycollection';
public const GEOMETRYCOLLECTION = 'geometrycollection';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/LineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class LineString extends Type
{
const LINESTRING = 'linestring';
public const LINESTRING = 'linestring';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/MultiLineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MultiLineString extends Type
{
const MULTILINESTRING = 'multilinestring';
public const MULTILINESTRING = 'multilinestring';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/MultiPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MultiPoint extends Type
{
const MULTIPOINT = 'multipoint';
public const MULTIPOINT = 'multipoint';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/MultiPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MultiPolygon extends Type
{
const MULTIPOLYGON = 'multipolygon';
public const MULTIPOLYGON = 'multipolygon';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Point extends Type
{
const POINT = 'point';
public const POINT = 'point';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Polygon extends Type
{
const POLYGON = 'polygon';
public const POLYGON = 'polygon';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Eloquent/SpatialTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait SpatialTrait
*
* @param \Illuminate\Database\Query\Builder $query
*
* @return \Fleetbase\LaravelMysqlSpatial\Eloquent\Builder
* @return Builder
*/
public function newEloquentBuilder($query)
{
Expand All @@ -85,18 +85,18 @@ protected function performInsert(EloquentBuilder $query, array $options = [])
{
foreach ($this->attributes as $key => $value) {
if ($value instanceof GeometryInterface) {
$this->geometries[$key] = $value; //Preserve the geometry objects prior to the insert
$this->geometries[$key] = $value; // Preserve the geometry objects prior to the insert
$this->attributes[$key] = new SpatialExpression($value);
}
}

$insert = parent::performInsert($query, $options);

foreach ($this->geometries as $key => $value) {
$this->attributes[$key] = $value; //Retrieve the geometry objects so they can be used in the model
$this->attributes[$key] = $value; // Retrieve the geometry objects so they can be used in the model
}

return $insert; //Return the result of the parent insert
return $insert; // Return the result of the parent insert
}

public function setRawAttributes(array $attributes, $sync = false)
Expand All @@ -117,7 +117,7 @@ public function getSpatialFields()
if (property_exists($this, 'spatialFields')) {
return $this->spatialFields;
} else {
throw new SpatialFieldsNotDefinedException(__CLASS__.' has to define $spatialFields');
throw new SpatialFieldsNotDefinedException(__CLASS__ . ' has to define $spatialFields');
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Blueprint extends IlluminateBlueprint
* Add a geometry column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -23,7 +23,7 @@ public function geometry($column, $srid = null)
* Add a point column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -36,7 +36,7 @@ public function point($column, $srid = null)
* Add a linestring column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -49,7 +49,7 @@ public function lineString($column, $srid = null)
* Add a polygon column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -62,7 +62,7 @@ public function polygon($column, $srid = null)
* Add a multipoint column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -75,7 +75,7 @@ public function multiPoint($column, $srid = null)
* Add a multilinestring column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -88,7 +88,7 @@ public function multiLineString($column, $srid = null)
* Add a multipolygon column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand All @@ -101,7 +101,7 @@ public function multiPolygon($column, $srid = null)
* Add a geometrycollection column on the table.
*
* @param string $column
* @param null|int $srid
* @param int|null $srid
*
* @return \Illuminate\Support\Fluent
*/
Expand Down
5 changes: 2 additions & 3 deletions src/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ class Builder extends MySqlBuilder
/**
* Create a new command set with a Closure.
*
* @param string $table
* @param Closure $callback
* @param string $table
*
* @return Blueprint
*/
protected function createBlueprint($table, Closure $callback = null)
protected function createBlueprint($table, ?\Closure $callback = null)
{
return new Blueprint($table, $callback);
}
Expand Down
Loading

0 comments on commit 3dd0c72

Please sign in to comment.