Skip to content

Commit c98df53

Browse files
committed
Implement PHPStan up to level 1
1 parent 8ae5647 commit c98df53

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"require-dev": {
2828
"spatie/ray": "^1.0",
29-
"pestphp/pest": "^2.0|^3.0"
29+
"pestphp/pest": "^2.0|^3.0",
30+
"phpstan/phpstan": "^2.1"
3031
},
3132
"autoload": {
3233
"psr-4": {

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 1
3+
paths:
4+
- src

src/Connection/ImapCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function compile(): array
8686
*/
8787
public function redacted(): ImapCommand
8888
{
89-
return new static($this->tag, $this->command, array_map(
89+
return new self($this->tag, $this->command, array_map(
9090
function (mixed $token) {
9191
return is_array($token)
9292
? array_map(fn () => '[redacted]', $token)

src/Connection/ImapConnection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function fake(array $responses = []): static
6161

6262
$stream->feed($responses);
6363

64-
return new static($stream);
64+
return new self($stream);
6565
}
6666

6767
/**
@@ -719,7 +719,7 @@ protected function assertTaggedResponse(string $tag, ?callable $exception = null
719719
*
720720
* @template T of Response
721721
*
722-
* @param callable(Response): bool $filter
722+
* @param callable(T): bool $filter
723723
* @return T
724724
*/
725725
protected function assertNextResponse(callable $filter, callable $assertion, callable $exception): Response
@@ -740,7 +740,7 @@ protected function assertNextResponse(callable $filter, callable $assertion, cal
740740
*
741741
* @template T of Response
742742
*
743-
* @param callable(Response): bool $filter
743+
* @param callable(T): bool $filter
744744
* @return T
745745
*/
746746
protected function nextResponse(callable $filter): Response

src/Connection/ImapQueryBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ public function toImap(): string
292292
/**
293293
* Create a new query instance (like Eloquent's newQuery).
294294
*/
295-
protected function newQuery(): static
295+
protected function newQuery(): self
296296
{
297-
return new static;
297+
return new self;
298298
}
299299

300300
/**

src/Exceptions/ImapCommandException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ImapCommandException extends Exception
2222
*/
2323
public static function make(ImapCommand $command, Response $response): static
2424
{
25-
$exception = new static(sprintf('IMAP command "%s" failed. Response: "%s"', $command, $response));
25+
$exception = new self(sprintf('IMAP command "%s" failed. Response: "%s"', $command, $response));
2626

2727
$exception->command = $command;
2828
$exception->response = $response;

src/Mailbox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __clone(): void
7171
*/
7272
public static function make(array $config = []): static
7373
{
74-
return new static($config);
74+
return new self($config);
7575
}
7676

7777
/**

src/Support/ForwardsCalls.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function forwardCallTo(object $object, string $method, array $paramete
3333
/**
3434
* Throw a bad method call exception for the given method.
3535
*/
36-
protected static function throwBadMethodCallException(string $method)
36+
protected static function throwBadMethodCallException(string $method): never
3737
{
3838
throw new BadMethodCallException(sprintf(
3939
'Call to undefined method %s::%s()', static::class, $method

0 commit comments

Comments
 (0)