Skip to content

Commit fb716aa

Browse files
committed
refactor: updates for php 84 compatibilities
1 parent e409911 commit fb716aa

File tree

7 files changed

+22
-38
lines changed

7 files changed

+22
-38
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
],
2323
"require": {
2424
"ext-intl": "*",
25-
"php": "^8.2",
25+
"php": "^8.4",
2626
"guzzlehttp/guzzle": "^7.2",
2727
"illuminate/config": "^11.0",
2828
"illuminate/support": "^11.0",

src/Facades/Rules.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class Rules extends Facade
1212
{
1313
/**
1414
* Get the registered name of the component.
15-
*
16-
* @return string
1715
*/
1816
protected static function getFacadeAccessor(): string
1917
{

src/Helpers.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ function sanitizeDomainString(string $domain): string
2121
/**
2222
* Is a given string a valid domain
2323
*
24-
* @param string $domain
2524
*
26-
* @return bool
2725
*/
2826
function isDomain(string $domain): bool
2927
{
@@ -39,9 +37,7 @@ function isDomain(string $domain): bool
3937
/**
4038
* Is the given value a valid known TLD
4139
*
42-
* @param string $input
4340
*
44-
* @return bool
4541
*/
4642
function isTLD(string $input): bool
4743
{

src/ServiceProvider.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Myerscode\Laravel\DomainValidator;
44

5+
use Override;
56
use Closure;
67
use Illuminate\Support\Facades\Validator;
78
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
@@ -18,41 +19,30 @@ class ServiceProvider extends BaseServiceProvider
1819
{
1920
/**
2021
* Register any application services.
21-
*
22-
* @return void
2322
*/
23+
#[Override]
2424
public function register(): void
2525
{
2626
$this->registerConfig();
2727

2828
$this->registerLanguage();
2929

30-
$this->app->singleton('ldv.factory', function () {
31-
return new RulesFactory;
32-
});
30+
$this->app->singleton('ldv.factory', fn(): RulesFactory => new RulesFactory);
3331

34-
$this->app->singleton('ldv.rules', function ($app) {
35-
return $app->make('ldv.factory')->createPublicSuffixRules();
36-
});
32+
$this->app->singleton('ldv.rules', fn($app) => $app->make('ldv.factory')->createPublicSuffixRules());
3733

38-
$this->app->singleton('ldv.tld', function ($app) {
39-
return $app->make('ldv.factory')->createTopLevelDomains();
40-
});
34+
$this->app->singleton('ldv.tld', fn($app) => $app->make('ldv.factory')->createTopLevelDomains());
4135

42-
$this->app->singleton('ldv.suffix', function ($app) {
43-
return new class {
44-
public function __call($method, $parameters)
45-
{
46-
return Suffix::$method(...$parameters);
47-
}
48-
};
36+
$this->app->singleton('ldv.suffix', fn($app): object => new class {
37+
public function __call(string $method, array $parameters)
38+
{
39+
return Suffix::$method(...$parameters);
40+
}
4941
});
5042
}
5143

5244
/**
5345
* Bootstrap any application services.
54-
*
55-
* @return void
5646
*/
5747
public function boot(): void
5848
{

tests/DomainValidator/HelpersTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests\DomainValidator;
44

5+
use Exception;
56
use Myerscode\Laravel\DomainValidator\Facades\Rules;
67
use Myerscode\Laravel\DomainValidator\Facades\Suffix;
78
use Myerscode\Laravel\DomainValidator\Facades\TopLevelDomain;
@@ -18,9 +19,9 @@ class HelpersTest extends TestCase
1819
protected function makeFacadesFails(): void
1920
{
2021
$throwException = new class {
21-
public function __call($method, $parameters)
22+
public function __call(string $method, array $parameters)
2223
{
23-
throw new \Exception();
24+
throw new Exception();
2425
}
2526
};
2627

@@ -29,7 +30,7 @@ public function __call($method, $parameters)
2930
TopLevelDomain::swap($throwException);
3031
}
3132

32-
public function testRuleReturnsFalseIfException()
33+
public function testRuleReturnsFalseIfException(): void
3334
{
3435
$this->makeFacadesFails();
3536

tests/DomainValidator/Rules/RulesTestCase.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ abstract class RulesTestCase extends TestCase
1111
abstract public static function ruleTestProvider();
1212

1313
/**
14-
* @param string $attribute
15-
* @param string|array $inputs
16-
* @param array $constraints
17-
* @param bool $valid
1814
* @param ?string $message null
1915
*/
2016
#[DataProvider('ruleTestProvider')]

tests/TestCase.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Tests;
44

5+
use Override;
6+
use Illuminate\Foundation\Application;
57
use Illuminate\Support\Facades\Artisan;
68
use Illuminate\Contracts\Config\Repository;
79
use Illuminate\Support\Facades\Validator;
@@ -11,7 +13,8 @@
1113

1214
class TestCase extends OrchestraTestCase
1315
{
14-
public function setUp(): void
16+
#[Override]
17+
protected function setUp(): void
1518
{
1619
parent::setUp();
1720
Artisan::call('cache:clear');
@@ -21,7 +24,7 @@ public function setUp(): void
2124
protected function defineEnvironment($app): void
2225
{
2326
// Setup default database to use sqlite :memory:
24-
tap($app['config'], function (Repository $config) {
27+
tap($app['config'], function (Repository $config): void {
2528
$config->set('domain-validator.storage_driver', 'local');
2629
$config->set('domain-validator.cache_driver', 'array');
2730
$config->set('filesystems.disks.local.root', __DIR__ . '/storage');
@@ -31,7 +34,7 @@ protected function defineEnvironment($app): void
3134
/**
3235
* Get package providers.
3336
*
34-
* @param \Illuminate\Foundation\Application $app
37+
* @param Application $app
3538
*
3639
* @return array<int, class-string>
3740
*/
@@ -45,7 +48,7 @@ protected function getPackageProviders($app): array
4548
/**
4649
* Get package aliases.
4750
*
48-
* @param \Illuminate\Foundation\Application $app
51+
* @param Application $app
4952
*
5053
* @return array<string, class-string>
5154
*/

0 commit comments

Comments
 (0)