public static function changePermissions(string $file, int $permissions)
    {
        if (!\is_file($file)) {
            throw new \InvalidArgumentException(\sprintf('No such file found: "%s"', $file));
        }
        
        if (DIRECTORY_SEPARATOR == '\\') {
            return $file;
        }
        
        $old = \umask(0);
        
        try {
            if (!@\chmod($file, $permissions)) {
                throw new \RuntimeException(\sprintf('Unable to change access permissions of file "%s"%s', $file, self::getErrorInfo()));
            }
        } finally {
            \umask($old);
        }
        
        \clearstatcache(true, $file);
        
        return $file;
    }
public static function changePermissions(string $file, int $permissions)
    {
        if (!\is_file($file)) {
            throw new \InvalidArgumentException(\sprintf('No such file found: "%s"', $file));
        }
        
        if (DIRECTORY_SEPARATOR == '\\') {
            return $file;
        }
        
        $old = \umask(0);
        
        try {
            if (!@\chmod($file, $permissions)) {
                throw new \RuntimeException(\sprintf('Unable to change access permissions of file "%s"%s', $file, self::getErrorInfo()));
            }
        } finally {
            \umask($old);
        }
        
        \clearstatcache(true, $file);
        
        return $file;
    }
public static function changePermissions ( string $ file , int $ permissions ) { if ( ! \ is_file ( $ file ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'No such file found: "%s"' , $ file ) ) ; } if ( DIRECTORY_SEPARATOR == '\\' ) { return $ file ; } $ old = \ umask ( 0 ) ; try { if ( ! @ \ chmod ( $ file , $ permissions ) ) { throw new \ RuntimeException ( \ sprintf ( 'Unable to change access permissions of file "%s"%s' , $ file , self :: getErrorInfo ( ) ) ) ; } } finally { \ umask ( $ old ) ; } \ clearstatcache ( true , $ file ) ; return $ file ; }
Change access permissions of the given file.

@param string $file
@param int $permissions Permissions to be set, needs to be an integer like 0777 (octal notation).
@return string The file's location.

@throws \InvalidArgumentException When no such file exists or permissions are invalid.
@throws \RuntimeException When access permissions could not be changed.
Change access permissions of the given file .