@@ -329,6 +329,8 @@ private function isReadable(string $filename): bool
329
329
*/
330
330
public function symlink (string $ originDir , string $ targetDir , bool $ copyOnWindows = false )
331
331
{
332
+ self ::assertFunctionExists ('symlink ' );
333
+
332
334
if ('\\' === \DIRECTORY_SEPARATOR ) {
333
335
$ originDir = strtr ($ originDir , '/ ' , '\\' );
334
336
$ targetDir = strtr ($ targetDir , '/ ' , '\\' );
@@ -364,6 +366,8 @@ public function symlink(string $originDir, string $targetDir, bool $copyOnWindow
364
366
*/
365
367
public function hardlink (string $ originFile , $ targetFiles )
366
368
{
369
+ self ::assertFunctionExists ('link ' );
370
+
367
371
if (!$ this ->exists ($ originFile )) {
368
372
throw new FileNotFoundException (null , 0 , null , $ originFile );
369
373
}
@@ -730,13 +734,22 @@ private function getSchemeAndHierarchy(string $filename): array
730
734
return 2 === \count ($ components ) ? [$ components [0 ], $ components [1 ]] : [null , $ components [0 ]];
731
735
}
732
736
737
+ private static function assertFunctionExists (string $ func ): void
738
+ {
739
+ if (!\function_exists ($ func )) {
740
+ throw new IOException (sprintf ('Unable to perform filesystem operation because the "%s()" function has been disabled. ' , $ func ));
741
+ }
742
+ }
743
+
733
744
/**
734
745
* @param mixed ...$args
735
746
*
736
747
* @return mixed
737
748
*/
738
- private static function box (callable $ func , ...$ args )
749
+ private static function box (string $ func , ...$ args )
739
750
{
751
+ self ::assertFunctionExists ($ func );
752
+
740
753
self ::$ lastError = null ;
741
754
set_error_handler (__CLASS__ .'::handleError ' );
742
755
try {
0 commit comments