Skip to content

Commit 1cb4b22

Browse files
authored
chore: resolve phpstan issues (#825)
1 parent 52f200a commit 1cb4b22

File tree

59 files changed

+221
-738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+221
-738
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 486 deletions
Large diffs are not rendered by default.

phpstan.neon.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ includes:
55
parameters:
66
level: 5
77
tmpDir: .cache/phpstan
8+
tips:
9+
treatPhpDocTypesAsCertain: false
810
excludePaths:
911
- tests/Integration/View/blade/cache/**.php
1012
paths:
1113
- src
1214
- tests
1315
ignoreErrors:
14-
16+
-
17+
identifier: argument.named
1518
-
1619
message: '#.*#'
1720
path: src/Tempest/Router/src/Exceptions/exception.php

src/Tempest/Console/src/Actions/ExecuteConsoleCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __invoke(string|array $command, string|array $arguments = []): E
2929
[$commandName, $arguments] = $this->resolveCommandAndArguments($command, $arguments);
3030

3131
$consoleCommand = $this->resolveConsoleCommand($command) ?? $this->resolveConsoleCommand($commandName);
32-
$callable = $this->getCallable($consoleCommand?->middleware ?? []);
32+
$callable = $this->getCallable($consoleCommand->middleware ?? []);
3333

3434
$this->argumentBag->setCommandName($consoleCommand?->getName() ?? $commandName);
3535
$this->argumentBag->addMany($arguments);

src/Tempest/Console/src/Components/Concerns/OpensInEditor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ trait OpensInEditor
1717
{
1818
private function supportsOpeningInEditor(): bool
1919
{
20+
// @phpstan-ignore function.alreadyNarrowedType
2021
return is_subclass_of(static::class, CanOpenInEditor::class) && (bool) $this->getEditorCommand();
2122
}
2223

src/Tempest/Console/src/Input/ConsoleArgumentBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private function resolveArgumentValue(
120120
);
121121
}
122122

123-
public function findArrayFor(ConsoleArgumentDefinition $argumentDefinition): ?ConsoleInputArgument
123+
public function findArrayFor(ConsoleArgumentDefinition $argumentDefinition): ConsoleInputArgument
124124
{
125125
$values = [];
126126

src/Tempest/Console/src/Input/ConsoleArgumentDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function fromParameter(ParameterReflector $parameter): ConsoleArgu
3131
$boolean = $type->getName() === 'bool' || is_bool($default);
3232

3333
return new ConsoleArgumentDefinition(
34-
name: static::normalizeName($attribute?->name ?? $parameter->getName(), boolean: $boolean),
34+
name: static::normalizeName($attribute->name ?? $parameter->getName(), boolean: $boolean),
3535
type: $type->getName(),
3636
default: $default,
3737
hasDefault: $parameter->isDefaultValueAvailable(),

src/Tempest/Container/src/Container.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public function config(object $config): self;
1919
/**
2020
* @template TClassName of object
2121
* @param class-string<TClassName> $className
22-
* @return TClassName
22+
* @return null|TClassName
2323
*/
24-
public function get(string $className, ?string $tag = null, mixed ...$params): object;
24+
public function get(string $className, ?string $tag = null, mixed ...$params): mixed;
2525

2626
public function invoke(MethodReflector|FunctionReflector|callable|string $method, mixed ...$params): mixed;
2727

src/Tempest/Container/src/GenericContainer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function config(object $config): self
9797
return $this;
9898
}
9999

100-
public function get(string $className, ?string $tag = null, mixed ...$params): object
100+
public function get(string $className, ?string $tag = null, mixed ...$params): null|object
101101
{
102102
$this->resolveChain();
103103

@@ -213,7 +213,7 @@ public function addInitializer(ClassReflector|string $initializerClass): Contain
213213
return $this;
214214
}
215215

216-
private function resolve(string $className, ?string $tag = null, mixed ...$params): object
216+
private function resolve(string $className, ?string $tag = null, mixed ...$params): null|object
217217
{
218218
$class = new ClassReflector($className);
219219

src/Tempest/Container/tests/ContainerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ public function test_arrays_are_automatically_created(): void
138138
*/
139139
$class = $container->get(BuiltinArrayClass::class);
140140

141-
$this->assertIsArray($class->anArray);
142141
$this->assertEmpty($class->anArray);
143142
}
144143

src/Tempest/Core/src/HandlesDiscoveryCache.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)