@@ -318,6 +318,8 @@ private function isReadable(string $filename): bool
318
318
*/
319
319
public function symlink ($ originDir , $ targetDir , $ copyOnWindows = false )
320
320
{
321
+ self ::assertFunctionExists ('symlink ' );
322
+
321
323
if ('\\' === \DIRECTORY_SEPARATOR ) {
322
324
$ originDir = strtr ($ originDir , '/ ' , '\\' );
323
325
$ targetDir = strtr ($ targetDir , '/ ' , '\\' );
@@ -354,6 +356,8 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
354
356
*/
355
357
public function hardlink ($ originFile , $ targetFiles )
356
358
{
359
+ self ::assertFunctionExists ('link ' );
360
+
357
361
if (!$ this ->exists ($ originFile )) {
358
362
throw new FileNotFoundException (null , 0 , null , $ originFile );
359
363
}
@@ -737,13 +741,22 @@ private function getSchemeAndHierarchy(string $filename): array
737
741
return 2 === \count ($ components ) ? [$ components [0 ], $ components [1 ]] : [null , $ components [0 ]];
738
742
}
739
743
744
+ private static function assertFunctionExists (string $ func ): void
745
+ {
746
+ if (!\function_exists ($ func )) {
747
+ throw new IOException (sprintf ('Unable to perform filesystem operation because the "%s()" function has been disabled. ' , $ func ));
748
+ }
749
+ }
750
+
740
751
/**
741
752
* @param mixed ...$args
742
753
*
743
754
* @return mixed
744
755
*/
745
- private static function box (callable $ func , ...$ args )
756
+ private static function box (string $ func , ...$ args )
746
757
{
758
+ self ::assertFunctionExists ($ func );
759
+
747
760
self ::$ lastError = null ;
748
761
set_error_handler (__CLASS__ .'::handleError ' );
749
762
try {
0 commit comments