1 | <?php |
||
9 | class DirectoryConverter |
||
10 | { |
||
11 | /** @var string */ |
||
12 | protected $sourceDirectory; |
||
13 | /** @var string */ |
||
14 | protected $copyNonPhpFiles = true; |
||
15 | /** @var bool */ |
||
16 | protected $cleanDestinationDirectory = false; |
||
17 | /** @var string[] */ |
||
18 | protected $extensions; |
||
19 | /** @var null|string[] */ |
||
20 | protected $excludes; |
||
21 | protected $logger; |
||
22 | |||
23 | /** |
||
24 | * DirectoryConverter constructor. |
||
25 | * |
||
26 | * @param string $sourceDirectory |
||
27 | * @param string[] $extensions |
||
28 | * @param string[]|null $excludes |
||
29 | * |
||
30 | * @throws \Spatie\Php7to5\Exceptions\InvalidParameter |
||
31 | */ |
||
32 | public function __construct($sourceDirectory, array $extensions, array $excludes = null) |
||
42 | |||
43 | public function setLogger(OutputInterface $output) |
||
47 | |||
48 | public function log($sourceItem, $target) |
||
57 | |||
58 | /** |
||
59 | * @return $this |
||
60 | */ |
||
61 | public function alsoCopyNonPhpFiles() |
||
67 | |||
68 | /** |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function cleanDestinationDirectory() |
||
77 | |||
78 | /** |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function doNotCopyNonPhpFiles() |
||
87 | |||
88 | /** |
||
89 | * @param string $destinationDirectory |
||
90 | * |
||
91 | * @throws \Spatie\Php7to5\Exceptions\InvalidParameter |
||
92 | */ |
||
93 | public function savePhp5FilesTo($destinationDirectory) |
||
105 | |||
106 | /** |
||
107 | * @param string $sourceDirectory |
||
108 | * @param string $destinationDirectory |
||
109 | */ |
||
110 | protected function copyDirectory($sourceDirectory, $destinationDirectory) |
||
151 | |||
152 | /** |
||
153 | * @param string $path |
||
154 | */ |
||
155 | protected function removeDirectory($path) |
||
165 | |||
166 | /** |
||
167 | * @param string $filePath |
||
168 | */ |
||
169 | protected function convertToPhp5($filePath) |
||
175 | |||
176 | /** |
||
177 | * @param string $filePath |
||
178 | * |
||
179 | * @return bool |
||
180 | */ |
||
181 | protected function isPhpFile($filePath) |
||
185 | } |
||
186 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.