Skip to content

Commit 6de72a1

Browse files
committed
feat: upgrade installation package
1 parent 5f0f887 commit 6de72a1

File tree

10 files changed

+67
-69
lines changed

10 files changed

+67
-69
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":{"CustomD\\Addressable\\Tests\\Feature\\ServiceProviderTest::it_has_provides_method":4,"CustomD\\Addressable\\Tests\\Feature\\ServiceProviderTest::it_is_a_service_provider":4},"times":{"CustomD\\Addressable\\Tests\\Feature\\ServiceProviderTest::it_has_provides_method":0.233,"CustomD\\Addressable\\Tests\\Feature\\ServiceProviderTest::it_is_a_service_provider":0.016}}

composer.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,21 @@
3737
],
3838
"require": {
3939
"php": "^8.0.0",
40-
"illuminate/console": "^9.0.0 || ^10.0.0",
41-
"illuminate/database": "^9.0.0 || ^10.0.0",
42-
"illuminate/support": "^9.0.0 || ^10.0.0",
40+
"illuminate/console": "^9.0.0",
41+
"illuminate/database": "^9.0.0",
42+
"illuminate/support": "^9.0.0",
4343
"jackpopp/geodistance": "^1.2.0",
44-
"rinvex/countries": "^8.0.0"
44+
"rinvex/countries": "^8.0.0",
45+
"spatie/laravel-package-tools": "^1.9.2"
4546
},
4647
"require-dev": {
47-
"codedungeon/phpunit-result-printer": "^0.31.0",
48-
"illuminate/container": "^9.0.0 || ^10.0.0",
48+
"illuminate/container": "^9.0.0",
49+
"nunomaduro/collision": "^6.0",
50+
"nunomaduro/larastan": "^2.0.1",
51+
"orchestra/testbench": "^7.0",
52+
"phpstan/extension-installer": "^1.1",
53+
"phpstan/phpstan-deprecation-rules": "^1.0",
54+
"phpstan/phpstan-phpunit": "^1.0",
4955
"phpunit/phpunit": "^9.5.0"
5056
},
5157
"autoload": {
@@ -59,12 +65,16 @@
5965
}
6066
},
6167
"scripts": {
68+
"analyse": "vendor/bin/phpstan analyse",
6269
"test": "vendor/bin/phpunit"
6370
},
6471
"config": {
6572
"sort-packages": true,
6673
"preferred-install": "dist",
67-
"optimize-autoloader": true
74+
"optimize-autoloader": true,
75+
"allow-plugins": {
76+
"phpstan/extension-installer": true
77+
}
6878
},
6979
"extra": {
7080
"laravel": {
File renamed without changes.

database/migrations/2020_01_01_000001_create_addresses_table.php renamed to database/migrations/create_addresses_table.php.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Database\Migrations\Migration;
88

9-
class CreateAddressesTable extends Migration
9+
return new class extends Migration
1010
{
1111
public function up()
1212
{
@@ -35,4 +35,4 @@ public function down()
3535
{
3636
Schema::dropIfExists(config('addressable.tables.addresses'));
3737
}
38-
}
38+
};

phpstan-baseline.neon

Whitespace-only changes.

phpstan.neon.dist

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
includes:
2-
- ./vendor/nunomaduro/larastan/extension.neon
2+
- phpstan-baseline.neon
3+
34
parameters:
4-
level: 5
5-
paths:
6-
- src
5+
level: 5
6+
paths:
7+
- src
8+
- config
9+
- database
10+
tmpDir: build/phpstan
11+
checkOctaneCompatibility: true
12+
checkModelProperties: true
13+
checkMissingIterableValueType: false

phpunit.xml.dist

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false"
12-
beStrictAboutTestsThatDoNotTestAnything="true"
13-
beStrictAboutChangesToGlobalState="true"
14-
beStrictAboutCoversAnnotation="true"
15-
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" verbose="true">
3+
164
<testsuites>
175
<testsuite name="Custom D Addresssable Unit Test Suite">
186
<directory suffix="Test.php">./tests/Unit</directory>

src/AddressesServiceProvider.php

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,27 @@
55
namespace CustomD\Addressable;
66

77
use CustomD\Addressable\Models\Address;
8-
use Illuminate\Support\ServiceProvider;
8+
use Spatie\LaravelPackageTools\Package;
9+
use Spatie\LaravelPackageTools\PackageServiceProvider;
910

10-
class AddressesServiceProvider extends ServiceProvider
11+
class AddressesServiceProvider extends PackageServiceProvider
1112
{
12-
/**
13-
* {@inheritdoc}
14-
*/
15-
public function register()
13+
public function configurePackage(Package $package): void
1614
{
17-
// Merge config
18-
$this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'addressable');
1915

20-
$this->app->singleton('addressable.addresss', config('addressable.models.address'));
21-
22-
if(config('addressable.models.address') !== Address::class) {
23-
$this->app->alias('addressable.models.address', Address::class);
24-
}
16+
$package
17+
->name('addressable')
18+
->hasConfigFile()
19+
->hasMigration('create_addresses_table.php');
2520
}
2621

27-
/**
28-
* {@inheritdoc}
29-
*/
30-
public function boot()
22+
public function packageRegistered()
3123
{
32-
$this->publishes([
33-
__DIR__.'/../config/config.php' => config_path('addressable.php')
34-
], 'config');
3524

36-
$this->publishes([
37-
__DIR__.'/../database/migrations/' => database_path('migrations')
38-
], 'migrations');
25+
$this->app->singleton('addressable.addresss', config('addressable.models.address'));
26+
27+
if (config('addressable.models.address') !== Address::class) {
28+
$this->app->alias('addressable.models.address', Address::class);
29+
}
3930
}
4031
}

src/Models/Address.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ class Address extends Model
7070
use SoftDeletes;
7171
use GeoDistanceTrait;
7272

73-
protected $latColumn = 'latitude';
74-
75-
protected $lngColumn = 'longitude';
7673

7774
/**
7875
* {@inheritdoc}
@@ -98,21 +95,21 @@ class Address extends Model
9895
* {@inheritdoc}
9996
*/
10097
protected $casts = [
101-
'addressable_id' => 'integer',
98+
'addressable_id' => 'integer',
10299
'addressable_type' => 'string',
103-
'label' => 'string',
104-
'given_name' => 'string',
105-
'family_name' => 'string',
106-
'organization' => 'string',
107-
'country_code' => 'string',
108-
'street' => 'string',
109-
'state' => 'string',
110-
'city' => 'string',
111-
'postal_code' => 'string',
112-
'latitude' => 'float',
113-
'longitude' => 'float',
114-
'is_primary' => 'boolean',
115-
'deleted_at' => 'datetime',
100+
'label' => 'string',
101+
'given_name' => 'string',
102+
'family_name' => 'string',
103+
'organization' => 'string',
104+
'country_code' => 'string',
105+
'street' => 'string',
106+
'state' => 'string',
107+
'city' => 'string',
108+
'postal_code' => 'string',
109+
'latitude' => 'float',
110+
'longitude' => 'float',
111+
'is_primary' => 'boolean',
112+
'deleted_at' => 'datetime',
116113
];
117114

118115
/**
@@ -139,6 +136,10 @@ public function __construct(array $attributes = [])
139136
{
140137
$this->setTable(config('addressable.tables.addresses'));
141138

139+
$this->latColumn = 'latitude';
140+
141+
$this->lngColumn = 'longitude';
142+
142143
parent::__construct($attributes);
143144
}
144145

tests/Feature/ServiceProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace CustomD\Addressable\Tests\Feature;
66

77
use ReflectionClass;
8-
use PHPUnit\Framework\TestCase;
8+
use Orchestra\Testbench\TestCase;
99
use Illuminate\Container\Container;
1010
use Illuminate\Support\ServiceProvider;
11-
use CustomD\Addressable\Providers\AddressesServiceProvider;
11+
use CustomD\Addressable\AddressesServiceProvider;
1212

1313
class ServiceProviderTest extends TestCase
1414
{

0 commit comments

Comments
 (0)