Skip to content

Commit

Permalink
add phpstan type coverage extension
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Dec 26, 2023
1 parent ceeecfc commit 20b10c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 41 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"saloonphp/saloon": "^3.0"
},
"require-dev": {
"larastan/larastan": "^2.0",
"orchestra/testbench": "^7.0 || ^8.0",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^9.0 || ^10.0"
"phpunit/phpunit": "^9.0 || ^10.0",
"tomasvotruba/type-coverage": "^0.2"
},
"minimum-stability": "dev",
"autoload": {
Expand Down
9 changes: 7 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# includes:
# - ./vendor/larastan/larastan/extension.neon
includes:
- vendor/tomasvotruba/type-coverage/config/extension.neon

parameters:

Expand All @@ -8,4 +8,9 @@ parameters:

level: "max"

type_coverage:
return_type: 100
param_type: 100
property_type: 100

checkMissingIterableValueType: false
17 changes: 2 additions & 15 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

namespace OpenSoutheners\CarboneSdk;

use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class ServiceProvider extends BaseServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->app->bind(Carbone::class, function () {
$this->app->bind(Carbone::class, function (): Carbone {
/** @var string $key */
$key = config('services.carbone.key', env('CARBONE_API_KEY', ''));
/** @var string|null $version */
Expand All @@ -25,14 +22,4 @@ public function boot()

$this->app->alias(Carbone::class, 'carbone');
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
17 changes: 17 additions & 0 deletions tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace OpenSoutheners\CarboneSdk\Tests;

use OpenSoutheners\CarboneSdk\Carbone;
use OpenSoutheners\CarboneSdk\ServiceProvider;
use Orchestra\Testbench\TestCase;

/**
* @group integration
Expand All @@ -11,8 +13,23 @@
*/
class ServiceProviderTest extends TestCase
{
/**
* Get package providers.
*
* @param \Illuminate\Foundation\Application $app
* @return array<int, class-string>
*/
protected function getPackageProviders($app)
{
return [
ServiceProvider::class,
];
}

public function testCarboneIsBoundWithCarboneInstance()
{
$this->withoutExceptionHandling();

$this->assertTrue($this->app->bound(Carbone::class));
$this->assertTrue($this->app->bound('carbone'));
$this->assertInstanceOf(Carbone::class, $this->app->get('carbone'));
Expand Down
22 changes: 0 additions & 22 deletions tests/TestCase.php

This file was deleted.

0 comments on commit 20b10c3

Please sign in to comment.