Bit-Wasp /
bitcoind-server
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace BitWasp\Bitcoind\Utils; |
||||
| 4 | |||||
| 5 | use BitWasp\Bitcoind\Exception\BitcoindException; |
||||
| 6 | |||||
| 7 | class File |
||||
| 8 | { |
||||
| 9 | 1 | public static function recursiveDelete(string $src) |
|||
| 10 | { |
||||
| 11 | 1 | if (!is_dir($src)) { |
|||
| 12 | 1 | throw new BitcoindException("Parameter 1 for recursiveDelete should be a directory"); |
|||
| 13 | } |
||||
| 14 | |||||
| 15 | $dir = opendir($src); |
||||
| 16 | while (false !== ( $file = readdir($dir))) { |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 17 | if (( $file != '.' ) && ( $file != '..' )) { |
||||
| 18 | $full = $src . '/' . $file; |
||||
| 19 | if (is_dir($full)) { |
||||
| 20 | self::recursiveDelete($full); |
||||
| 21 | } else { |
||||
| 22 | unlink($full); |
||||
| 23 | } |
||||
| 24 | } |
||||
| 25 | } |
||||
| 26 | closedir($dir); |
||||
|
0 ignored issues
–
show
It seems like
$dir can also be of type false; however, parameter $dir_handle of closedir() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 27 | rmdir($src); |
||||
| 28 | } |
||||
| 29 | } |
||||
| 30 |