@@ -31,9 +31,9 @@ trait FilesManagement
3131 public static function createFolder ($ folder )
3232 {
3333 try {
34- if (!is_dir ($ folder )) {
35- if (!is_dir ($ folder ) && !mkdir ($ folder ) && !is_dir ($ folder )) {
36- throw new \RuntimeException (sprintf ('Unable to create the %s directory ' , $ folder ));
34+ if (!\ is_dir ($ folder )) {
35+ if (!\ is_dir ($ folder ) && !\ mkdir ($ folder ) && !\ is_dir ($ folder )) {
36+ throw new \RuntimeException (\ sprintf ('Unable to create the %s directory ' , $ folder ));
3737 }
3838
3939 file_put_contents ($ folder . '/index.html ' , '<script>history.go(-1);</script> ' );
@@ -50,7 +50,7 @@ public static function createFolder($folder)
5050 */
5151 public static function copyFile ($ file , $ folder )
5252 {
53- return copy ($ file , $ folder );
53+ return \ copy ($ file , $ folder );
5454 }
5555
5656 /**
@@ -59,21 +59,21 @@ public static function copyFile($file, $folder)
5959 */
6060 public static function recurseCopy ($ src , $ dst )
6161 {
62- $ dir = opendir ($ src );
62+ $ dir = \ opendir ($ src );
6363 // @mkdir($dst);
64- if (!@mkdir ($ dst ) && !is_dir ($ dst )) {
64+ if (!@\ mkdir ($ dst ) && !\ is_dir ($ dst )) {
6565 throw new \RuntimeException ('The directory ' . $ dst . ' could not be created. ' );
6666 }
67- while (false !== ($ file = readdir ($ dir ))) {
67+ while (false !== ($ file = \ readdir ($ dir ))) {
6868 if (('. ' !== $ file ) && ('.. ' !== $ file )) {
69- if (is_dir ($ src . '/ ' . $ file )) {
69+ if (\ is_dir ($ src . '/ ' . $ file )) {
7070 self ::recurseCopy ($ src . '/ ' . $ file , $ dst . '/ ' . $ file );
7171 } else {
72- copy ($ src . '/ ' . $ file , $ dst . '/ ' . $ file );
72+ \ copy ($ src . '/ ' . $ file , $ dst . '/ ' . $ file );
7373 }
7474 }
7575 }
76- closedir ($ dir );
76+ \ closedir ($ dir );
7777 }
7878
7979 /**
@@ -98,21 +98,21 @@ public static function deleteDirectory($src)
9898 $ dirInfo = new \SplFileInfo ($ src );
9999 // validate is a directory
100100 if ($ dirInfo ->isDir ()) {
101- $ fileList = array_diff (scandir ($ src , SCANDIR_SORT_NONE ), ['.. ' , '. ' ]);
101+ $ fileList = \ array_diff (\ scandir ($ src , \ SCANDIR_SORT_NONE ), ['.. ' , '. ' ]);
102102 foreach ($ fileList as $ k => $ v ) {
103103 $ fileInfo = new \SplFileInfo ("{$ src }/ {$ v }" );
104104 if ($ fileInfo ->isDir ()) {
105105 // recursively handle subdirectories
106106 if (!$ success = self ::deleteDirectory ($ fileInfo ->getRealPath ())) {
107107 break ;
108108 }
109- } elseif (!($ success = unlink ($ fileInfo ->getRealPath ()))) {
109+ } elseif (!($ success = \ unlink ($ fileInfo ->getRealPath ()))) {
110110 break ;
111111 }
112112 }
113113 // now delete this (sub)directory if all the files are gone
114114 if ($ success ) {
115- $ success = rmdir ($ dirInfo ->getRealPath ());
115+ $ success = \ rmdir ($ dirInfo ->getRealPath ());
116116 }
117117 } else {
118118 // input is not a valid directory
@@ -139,7 +139,7 @@ public static function rrmdir($src)
139139 }
140140
141141 // If source is not a directory stop processing
142- if (!is_dir ($ src )) {
142+ if (!\ is_dir ($ src )) {
143143 return false ;
144144 }
145145
@@ -151,7 +151,7 @@ public static function rrmdir($src)
151151 if ($ fObj ->isFile ()) {
152152 $ filename = $ fObj ->getPathname ();
153153 $ fObj = null ; // clear this iterator object to close the file
154- if (!unlink ($ filename )) {
154+ if (!\ unlink ($ filename )) {
155155 return false ; // couldn't delete the file
156156 }
157157 } elseif (!$ fObj ->isDot () && $ fObj ->isDir ()) {
@@ -160,7 +160,7 @@ public static function rrmdir($src)
160160 }
161161 }
162162 $ iterator = null ; // clear iterator Obj to close file/directory
163- return rmdir ($ src ); // remove the directory & return results
163+ return \ rmdir ($ src ); // remove the directory & return results
164164 }
165165
166166 /**
@@ -179,28 +179,28 @@ public static function rmove($src, $dest)
179179 }
180180
181181 // If source is not a directory stop processing
182- if (!is_dir ($ src )) {
182+ if (!\ is_dir ($ src )) {
183183 return false ;
184184 }
185185
186186 // If the destination directory does not exist and could not be created stop processing
187- if (!is_dir ($ dest ) && !mkdir ($ dest ) && !is_dir ($ dest )) {
187+ if (!\ is_dir ($ dest ) && !\ mkdir ($ dest ) && !\ is_dir ($ dest )) {
188188 return false ;
189189 }
190190
191191 // Open the source directory to read in files
192192 $ iterator = new \DirectoryIterator ($ src );
193193 foreach ($ iterator as $ fObj ) {
194194 if ($ fObj ->isFile ()) {
195- rename ($ fObj ->getPathname (), "{$ dest }/ " . $ fObj ->getFilename ());
195+ \ rename ($ fObj ->getPathname (), "{$ dest }/ " . $ fObj ->getFilename ());
196196 } elseif (!$ fObj ->isDot () && $ fObj ->isDir ()) {
197197 // Try recursively on directory
198198 self ::rmove ($ fObj ->getPathname (), "{$ dest }/ " . $ fObj ->getFilename ());
199199 // rmdir($fObj->getPath()); // now delete the directory
200200 }
201201 }
202202 $ iterator = null ; // clear iterator Obj to close file/directory
203- return rmdir ($ src ); // remove the directory & return results
203+ return \ rmdir ($ src ); // remove the directory & return results
204204 }
205205
206206 /**
@@ -222,20 +222,20 @@ public static function rcopy($src, $dest)
222222 }
223223
224224 // If source is not a directory stop processing
225- if (!is_dir ($ src )) {
225+ if (!\ is_dir ($ src )) {
226226 return false ;
227227 }
228228
229229 // If the destination directory does not exist and could not be created stop processing
230- if (!is_dir ($ dest ) && !mkdir ($ dest ) && !is_dir ($ dest )) {
230+ if (!\ is_dir ($ dest ) && !\ mkdir ($ dest ) && !\ is_dir ($ dest )) {
231231 return false ;
232232 }
233233
234234 // Open the source directory to read in files
235235 $ iterator = new \DirectoryIterator ($ src );
236236 foreach ($ iterator as $ fObj ) {
237237 if ($ fObj ->isFile ()) {
238- copy ($ fObj ->getPathname (), "{$ dest }/ " . $ fObj ->getFilename ());
238+ \ copy ($ fObj ->getPathname (), "{$ dest }/ " . $ fObj ->getFilename ());
239239 } elseif (!$ fObj ->isDot () && $ fObj ->isDir ()) {
240240 self ::rcopy ($ fObj ->getPathname (), "{$ dest }/ " . $ fObj ->getFilename ());
241241 }
0 commit comments