Skip to content

Commit e3601d0

Browse files
committed
minor: phpstan 2.0
1 parent bf46c17 commit e3601d0

File tree

9 files changed

+20
-19
lines changed

9 files changed

+20
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"league/flysystem-ziparchive": "^3.12",
3030
"league/glide": "^2.2",
3131
"league/mime-type-detection": ">=1.8",
32-
"phpstan/phpstan": "^1.4",
32+
"phpstan/phpstan": "^2.0",
3333
"phpunit/phpunit": "^9.6.18",
3434
"srwiez/thumbhash": "^1.2",
3535
"symfony/browser-kit": "^6.4|^7.0",

src/Filesystem/Attribute/PendingUploadedFile.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121
/**
2222
* @author Jakub Caban <kuba.iluvatar@gmail.com>
23-
*
24-
* @phpstan-consistent-constructor
25-
* @readonly
2623
*/
2724
#[\Attribute(\Attribute::TARGET_PARAMETER | \Attribute::TARGET_PROPERTY)]
2825
class PendingUploadedFile
@@ -48,7 +45,7 @@ public static function forArgument(ArgumentMetadata $argument): self
4845
$attribute = $attributes[0];
4946
\assert($attribute instanceof self);
5047
} else {
51-
$attribute = new static();
48+
$attribute = new self();
5249
}
5350

5451
$attribute->path ??= $argument->getName();

src/Filesystem/Glide/GlideTransformUrlGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function transformUrl(string $path, array|string $filter, Config $config)
2828
{
2929
$filter = match (true) {
3030
\is_string($filter) => ['p' => $filter], // is glide "preset"
31-
\is_array($filter) && !\array_is_list($filter) => $filter, // is standard glide parameters
32-
\is_array($filter) => ['p' => \implode(',', $filter)], // is array of "presets"
31+
!\array_is_list($filter) => $filter, // is standard glide parameters
32+
default => ['p' => \implode(',', $filter)], // is array of "presets"
3333
};
3434

3535
return $this->urlBuilder->getUrl($path, $filter);

src/Filesystem/Node/Directory.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,35 @@
1919
/**
2020
* @author Kevin Bond <kevinbond@gmail.com>
2121
*
22-
* @extends \IteratorAggregate<Node|File|Directory>
22+
* @extends \IteratorAggregate<File|Directory> (required for intellisense)
23+
*
24+
* @phpstan-template T of Node = Node
25+
* @phpstan-extends \IteratorAggregate<T>
2326
*/
2427
interface Directory extends Node, \IteratorAggregate
2528
{
2629
public function recursive(): static;
2730

31+
/**
32+
* @return File|Directory
33+
* @phpstan-return T|null
34+
*/
2835
public function first(): ?Node;
2936

3037
/**
3138
* Filter nodes (return true = include, return false = exclude).
3239
*
33-
* @param callable(Node):bool|callable(File):bool|callable(Directory):bool $predicate
40+
* @param callable(T):bool $predicate
3441
*/
3542
public function filter(callable $predicate): static;
3643

3744
/**
38-
* @return $this<File>|File[]
45+
* @return static<File>
3946
*/
4047
public function files(): static;
4148

4249
/**
43-
* @return $this<Directory>|Directory[]
50+
* @return static<self>
4451
*/
4552
public function directories(): static;
4653

@@ -152,8 +159,6 @@ public function notMatchingPath(string|array $patterns): static;
152159
/**
153160
* @see FilesystemReader::listContents()
154161
*
155-
* @return Node[]|File[]|Directory[]|\Traversable<Node|File|Directory>
156-
*
157162
* @throws UnableToListContents
158163
* @throws FilesystemException
159164
*/

src/Filesystem/Node/Dsn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function create(string $filesystem, Path|string $path): self
5151
public static function normalize(string $value): array
5252
{
5353
if (2 === \count($parts = \explode('://', $value, 2))) {
54-
return $parts; // @phpstan-ignore return.type
54+
return $parts;
5555
}
5656

5757
return [null, $value];

src/Filesystem/Node/PathGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function generate(string|Namer|callable $namer, Node $node, array $contex
4242
$namer = new Namer($namer);
4343
}
4444

45-
if (!$namer instanceof Namer && \is_callable($namer)) {
45+
if (!$namer instanceof Namer) {
4646
return (new CallbackPathGenerator($namer))->generatePath($node, $context);
4747
}
4848

src/Filesystem/Symfony/Serializer/NodeNormalizer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Zenstruck\Filesystem\Node\File\Image\LazyImage;
2626
use Zenstruck\Filesystem\Node\File\LazyFile;
2727
use Zenstruck\Filesystem\Node\File\PendingFile;
28-
use Zenstruck\Filesystem\Node\LazyNode;
2928
use Zenstruck\Filesystem\Node\Mapping;
3029
use Zenstruck\Filesystem\Node\PathGenerator;
3130

@@ -72,7 +71,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
7271
$data = [Mapping::FILENAME => $data];
7372
}
7473

75-
/** @var LazyNode $node */
74+
/** @var LazyDirectory|LazyFile $node */
7675
$node = new (self::TYPE_MAP[$type])($data);
7776
$filesystem = $mapping->filesystem();
7877

src/Filesystem/Test/InteractsWithFilesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* @author Kevin Bond <kevinbond@gmail.com>
2828
*/
29-
trait InteractsWithFilesystem
29+
trait InteractsWithFilesystem // @phpstan-ignore trait.unused
3030
{
3131
private TestFilesystem $_testFilesystem;
3232

src/Filesystem/Test/ResetFilesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* @author Kevin Bond <kevinbond@gmail.com>
1919
*/
20-
trait ResetFilesystem
20+
trait ResetFilesystem // @phpstan-ignore trait.unused
2121
{
2222
/**
2323
* @before

0 commit comments

Comments
 (0)