Skip to content

Commit 491bb99

Browse files
author
fureev
committed
fix
1 parent de18e35 commit 491bb99

File tree

13 files changed

+36
-31
lines changed

13 files changed

+36
-31
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
],
1818
"require": {
1919
"php": "^8.2",
20-
"efureev/support": "^4.27|^5.0",
20+
"efureev/support": "^4.27 || ^5.0",
2121
"illuminate/database": "^11.0"
2222
},
2323
"require-dev": {
2424
"ergebnis/composer-normalize": "^2.42",
2525
"fakerphp/faker": "^1.23",
2626
"marcocesarato/php-conventional-changelog": "^1.17",
2727
"orchestra/testbench": "^9.0",
28+
"phpstan/phpstan": "^2.0",
2829
"phpunit/phpunit": "^11.5",
2930
"squizlabs/php_codesniffer": "^3.9"
3031
},
@@ -65,6 +66,7 @@
6566
"scripts": {
6667
"cs-fix": "@php ./vendor/bin/phpcbf",
6768
"phpcs": "@php ./vendor/bin/phpcs",
69+
"phpstan": "@php ./vendor/bin/phpstan analyze -c phpstan.neon --no-progress --ansi",
6870
"phpunit": "@php ./vendor/bin/phpunit --no-coverage --testdox --colors=always",
6971
"phpunit-cover": "@php ./vendor/bin/phpunit --coverage-text",
7072
"postversion": "git push && git push --tag",

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
level: '2'
3+
paths:
4+
- src
5+
# - tests
6+
# ignoreErrors:
7+
# -
8+
# identifier: trait.unused

src/Caster/AbstractCasting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected static function dataFromJson($json): array
130130
abstract public function toArray(): array;
131131

132132
/**
133-
* @param static|array $value
133+
* @param static|array|null $value
134134
*
135135
* @return string|null
136136
*/

src/Rules/HasValidate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected static function validateValue(
3030
mixed $value,
3131
string $rules,
3232
string $attributeName = 'value',
33-
string $message = null
33+
?string $message = null
3434
): mixed {
3535
Validator::make(
3636
[$attributeName => $value],
@@ -64,7 +64,7 @@ protected static function validateValues(
6464
protected static function gainIntValue(
6565
Request $request,
6666
string $name,
67-
int $default = null
67+
?int $default = null
6868
): ?int {
6969
$value = $request->get($name, $default);
7070
return $value === null ? null : (((int)$value) ?: $default);
@@ -73,7 +73,7 @@ protected static function gainIntValue(
7373
protected static function gainBoolValue(
7474
Request $request,
7575
string $name,
76-
bool $default = null
76+
?bool $default = null
7777
): ?bool {
7878
$value = $request->get($name, $default);
7979
return $value === null ? null : isTrue($value);
@@ -82,7 +82,7 @@ protected static function gainBoolValue(
8282
protected static function gainStringValue(
8383
Request $request,
8484
string $name,
85-
string $default = null
85+
?string $default = null
8686
): ?string {
8787
$value = (string)$request->get($name, $default);
8888
return $value ?: null;

src/ServiceProviders/HasCommands.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
trait HasCommands
1616
{
17-
/** @var array <Command::class> $commands */
17+
/** @var class-string[] */
1818
protected static array $commands = [];
1919

2020
protected function registerCommands(): static
@@ -23,9 +23,7 @@ protected function registerCommands(): static
2323
}
2424

2525
/**
26-
* @param array <Command::class> $policies
27-
*
28-
* @return $this
26+
* @param class-string[] $commands
2927
*/
3028
protected function registerCommandsForce(array $commands): static
3129
{

src/ServiceProviders/HasPathHelpers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function getDatabaseSeedersPath(string $path): ?string
7272
*
7373
* @return string|null
7474
*/
75-
public static function getConfigPath(string $path = null): ?string
75+
public static function getConfigPath(?string $path = null): ?string
7676
{
7777
if (!$cPath = static::packagePath('config')) {
7878
return null;
@@ -81,7 +81,7 @@ public static function getConfigPath(string $path = null): ?string
8181
return $cPath . ($path ? '/' . trim($path, '/') : '');
8282
}
8383

84-
public static function getRoutesPath(string $path = null): ?string
84+
public static function getRoutesPath(?string $path = null): ?string
8585
{
8686
if (!$cPath = static::packagePath('routes')) {
8787
return null;
@@ -90,7 +90,7 @@ public static function getRoutesPath(string $path = null): ?string
9090
return $cPath . ($path ? '/' . trim($path, '/') : '');
9191
}
9292

93-
public static function getResourcesPath(string $path = null): ?string
93+
public static function getResourcesPath(?string $path = null): ?string
9494
{
9595
if (!$cPath = static::packagePath('resources')) {
9696
return null;

src/ServiceProviders/HasPolicies.php

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

99
trait HasPolicies
1010
{
11-
/** @var array <Model::class => Policy::class> $policies */
11+
/** @var array<class-string,class-string> Model::class => Policy::class> */
1212
protected static array $policies = [];
1313

1414
protected function registerPolicies(): static
@@ -17,9 +17,7 @@ protected function registerPolicies(): static
1717
}
1818

1919
/**
20-
* @param array <Model::class => Policy::class> $policies
21-
*
22-
* @return $this
20+
* @param array<class-string,class-string> $policies Model::class => Policy::class
2321
*/
2422
protected function registerPoliciesForce(array $policies): static
2523
{

src/ServiceProviders/HasRegisters.php

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

1212
/**
1313
* Trait HasRegisters
14-
* @package Php\Support\Laravel\ServiceProviders
1514
* @mixin ServiceProvider
1615
*/
1716
trait HasRegisters
@@ -147,9 +146,9 @@ protected function registerViews(string $namespace): static
147146
*/
148147
protected function registerService(
149148
string $serviceClass,
150-
Closure|string $serviceName = null,
149+
Closure|string|null $serviceName = null,
151150
bool $singleton = false,
152-
string $alias = null
151+
?string $alias = null
153152
): static {
154153
if (is_string($serviceName)) {
155154
if (class_exists($serviceName)) {
@@ -175,7 +174,7 @@ protected function registerService(
175174
}
176175

177176

178-
protected function registerInstance(string $abstract, mixed $instance, string $alias = null): static
177+
protected function registerInstance(string $abstract, mixed $instance, ?string $alias = null): static
179178
{
180179
$this->app->instance($abstract, $instance);
181180

src/Traits/Models/AllowToExecute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function checkPossibilityAndExecute(string $method, ...$arguments): mi
4848
throw new MethodNotAllowedException($text ?? 'You don\'t allow to execute this method!');
4949
}
5050

51-
protected static function addMethodToDisallowMap(string $method, string|\Closure $hint = null): void
51+
protected static function addMethodToDisallowMap(string $method, string|\Closure|null $hint = null): void
5252
{
5353
static::$disallowMethodsMap[$method] = $hint;
5454
}

src/Traits/Models/Cachers/CacherContract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
interface CacherContract
88
{
9-
public function prefixKey(string $key = null, string $prefix = null): string;
9+
public function prefixKey(?string $key = null, ?string $prefix = null): string;
1010

11-
public function cacheForgetCollection(string $key = null): bool;
11+
public function cacheForgetCollection(?string $key = null): bool;
1212

1313
public function forgetByKey(string $key): bool;
1414
}

0 commit comments

Comments
 (0)