Skip to content

Commit 6364060

Browse files
#12 Apply phpstan level 10
1 parent 2341a97 commit 6364060

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

Diff for: phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 6
2+
level: 10
33
paths:
44
- src
55
- tests

Diff for: src/Task/FileFetchTask.php

+16-7
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ public function initialize(ProcessState $state): void
5151
// Configure options
5252
parent::initialize($state);
5353

54-
$this->sourceFS = $this->storages->get($this->getOption($state, 'source_filesystem'));
55-
$this->destinationFS = $this->storages->get($this->getOption($state, 'destination_filesystem'));
54+
/** @var string $sourceFilesystemOption */
55+
$sourceFilesystemOption = $this->getOption($state, 'source_filesystem');
56+
$this->sourceFS = $this->storages->get($sourceFilesystemOption);
57+
/** @var string $destinationFilesystemOption */
58+
$destinationFilesystemOption = $this->getOption($state, 'destination_filesystem');
59+
$this->destinationFS = $this->storages->get($destinationFilesystemOption);
5660
}
5761

5862
/**
@@ -71,7 +75,9 @@ public function execute(ProcessState $state): void
7175
return;
7276
}
7377

74-
$this->doFileCopy($state, $file, $this->getOption($state, 'remove_source'));
78+
/** @var bool $removeSourceOption */
79+
$removeSourceOption = $this->getOption($state, 'remove_source');
80+
$this->doFileCopy($state, $file, $removeSourceOption);
7581
$state->setOutput($file);
7682
}
7783

@@ -94,16 +100,19 @@ public function next(ProcessState $state): bool
94100
*/
95101
protected function findMatchingFiles(ProcessState $state): void
96102
{
103+
/** @var ?string $filePattern */
97104
$filePattern = $this->getOption($state, 'file_pattern');
98105
if ($filePattern) {
99106
foreach ($this->sourceFS->listContents('/') as $file) {
100-
if ('file' === $file['type']
101-
&& preg_match($filePattern, (string) $file['path'])
102-
&& !\in_array($file['path'], $this->matchingFiles, true)) {
103-
$this->matchingFiles[] = $file['path'];
107+
if ('file' === $file->type()
108+
&& preg_match($filePattern, $file->path())
109+
&& !\in_array($file->path(), $this->matchingFiles, true)
110+
) {
111+
$this->matchingFiles[] = $file->path();
104112
}
105113
}
106114
} else {
115+
/** @var array<string>|string|null $input */
107116
$input = $state->getInput();
108117
if (!$input) {
109118
throw new \UnexpectedValueException('No pattern neither input provided for the Task');

Diff for: src/Task/ListContentTask.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ protected function configureOptions(OptionsResolver $resolver): void
5353
public function execute(ProcessState $state): void
5454
{
5555
if (null === $this->fsContent || null === key($this->fsContent)) {
56-
$filesystem = $this->storages->get($this->getOption($state, 'filesystem'));
57-
$pattern = $this->getOption($state, 'file_pattern');
56+
/** @var string $filesystemOption */
57+
$filesystemOption = $this->getOption($state, 'filesystem');
58+
$filesystem = $this->storages->get($filesystemOption);
59+
/** @var ?string $patternOption */
60+
$patternOption = $this->getOption($state, 'file_pattern');
5861

59-
$this->fsContent = $this->getFilteredFilesystemContents($filesystem, $pattern);
62+
$this->fsContent = $this->getFilteredFilesystemContents($filesystem, $patternOption);
6063
}
6164

6265
if (null === key($this->fsContent)) {
@@ -87,7 +90,7 @@ protected function getFilteredFilesystemContents(FilesystemOperator $filesystem,
8790
{
8891
$results = [];
8992
foreach ($filesystem->listContents('') as $item) {
90-
if (null === $pattern || preg_match($pattern, (string) $item['path'])) {
93+
if (null === $pattern || preg_match($pattern, $item->path())) {
9194
$results[] = $item;
9295
}
9396
}

Diff for: src/Task/RemoveFileTask.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ protected function configureOptions(OptionsResolver $resolver): void
4141

4242
public function execute(ProcessState $state): void
4343
{
44-
$filesystem = $this->storages->get($this->getOption($state, 'filesystem'));
44+
/** @var string $filesystemOption */
45+
$filesystemOption = $this->getOption($state, 'filesystem');
46+
$filesystem = $this->storages->get($filesystemOption);
47+
/** @var string $filePath */
4548
$filePath = $state->getInput();
4649

4750
try {

0 commit comments

Comments
 (0)