1616use CleverAge \ProcessBundle \Model \AbstractConfigurableTask ;
1717use CleverAge \ProcessBundle \Model \IterableTaskInterface ;
1818use CleverAge \ProcessBundle \Model \ProcessState ;
19- use League \Flysystem \Filesystem ;
2019use League \Flysystem \FilesystemException ;
2120use League \Flysystem \FilesystemOperator ;
2221use Symfony \Component \DependencyInjection \ServiceLocator ;
@@ -32,6 +31,9 @@ class FileFetchTask extends AbstractConfigurableTask implements IterableTaskInte
3231
3332 protected FilesystemOperator $ destinationFS ;
3433
34+ /**
35+ * @var array<int, string>
36+ */
3537 protected array $ matchingFiles = [];
3638
3739 /**
@@ -49,8 +51,12 @@ public function initialize(ProcessState $state): void
4951 // Configure options
5052 parent ::initialize ($ state );
5153
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 );
5460 }
5561
5662 /**
@@ -69,7 +75,9 @@ public function execute(ProcessState $state): void
6975 return ;
7076 }
7177
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 );
7381 $ state ->setOutput ($ file );
7482 }
7583
@@ -92,16 +100,19 @@ public function next(ProcessState $state): bool
92100 */
93101 protected function findMatchingFiles (ProcessState $ state ): void
94102 {
103+ /** @var ?string $filePattern */
95104 $ filePattern = $ this ->getOption ($ state , 'file_pattern ' );
96105 if ($ filePattern ) {
97106 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 ();
102112 }
103113 }
104114 } else {
115+ /** @var array<string>|string|null $input */
105116 $ input = $ state ->getInput ();
106117 if (!$ input ) {
107118 throw new \UnexpectedValueException ('No pattern neither input provided for the Task ' );
0 commit comments