16
16
use CleverAge \ProcessBundle \Model \AbstractConfigurableTask ;
17
17
use CleverAge \ProcessBundle \Model \IterableTaskInterface ;
18
18
use CleverAge \ProcessBundle \Model \ProcessState ;
19
- use League \Flysystem \Filesystem ;
20
19
use League \Flysystem \FilesystemException ;
21
20
use League \Flysystem \FilesystemOperator ;
22
21
use Symfony \Component \DependencyInjection \ServiceLocator ;
@@ -32,6 +31,9 @@ class FileFetchTask extends AbstractConfigurableTask implements IterableTaskInte
32
31
33
32
protected FilesystemOperator $ destinationFS ;
34
33
34
+ /**
35
+ * @var array<int, string>
36
+ */
35
37
protected array $ matchingFiles = [];
36
38
37
39
/**
@@ -49,8 +51,12 @@ public function initialize(ProcessState $state): void
49
51
// Configure options
50
52
parent ::initialize ($ state );
51
53
52
- $ this ->sourceFS = $ this ->storages ->get ($ this ->getOption ($ state , 'source_filesystem ' ));
53
- $ 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 );
54
60
}
55
61
56
62
/**
@@ -69,7 +75,9 @@ public function execute(ProcessState $state): void
69
75
return ;
70
76
}
71
77
72
- $ 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 );
73
81
$ state ->setOutput ($ file );
74
82
}
75
83
@@ -92,16 +100,19 @@ public function next(ProcessState $state): bool
92
100
*/
93
101
protected function findMatchingFiles (ProcessState $ state ): void
94
102
{
103
+ /** @var ?string $filePattern */
95
104
$ filePattern = $ this ->getOption ($ state , 'file_pattern ' );
96
105
if ($ filePattern ) {
97
106
foreach ($ this ->sourceFS ->listContents ('/ ' ) as $ file ) {
98
- if ('file ' === $ file ['type ' ]
99
- && preg_match ($ filePattern , (string ) $ file ['path ' ])
100
- && !\in_array ($ file ['path ' ], $ this ->matchingFiles , true )) {
101
- $ 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 ();
102
112
}
103
113
}
104
114
} else {
115
+ /** @var array<string>|string|null $input */
105
116
$ input = $ state ->getInput ();
106
117
if (!$ input ) {
107
118
throw new \UnexpectedValueException ('No pattern neither input provided for the Task ' );
0 commit comments