These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class DMSFilesystemTestHelper |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | /** |
||
6 | * Files that are added to the DMS asset directory by the DMS instance. They will be removed after running tests. |
||
7 | * |
||
8 | * @var array |
||
9 | */ |
||
10 | protected static $dmsFiles = array('.htaccess', 'web.config'); |
||
11 | |||
12 | /** |
||
13 | * Deletes a directory and all files within it, or a file. Will automatically prepend the base path. |
||
14 | * |
||
15 | * This only work while a unit test is running for safety reasons. |
||
16 | * |
||
17 | * @param string $path |
||
18 | */ |
||
19 | public static function delete($path) |
||
20 | { |
||
21 | if (!SapphireTest::is_running_test() || !file_exists($path)) { |
||
22 | return false; |
||
23 | } |
||
24 | |||
25 | $path = BASE_PATH . DIRECTORY_SEPARATOR . $path; |
||
26 | if (is_dir($path)) { |
||
27 | $files = new RecursiveIteratorIterator( |
||
28 | new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), |
||
29 | RecursiveIteratorIterator::CHILD_FIRST |
||
30 | ); |
||
31 | |||
32 | foreach ($files as $fileinfo) { |
||
33 | $action = $fileinfo->isDir() ? 'rmdir' : 'unlink'; |
||
34 | $action($fileinfo->getRealPath()); |
||
35 | } |
||
36 | |||
37 | rmdir($path); |
||
38 | } else { |
||
39 | unlink($path); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.