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;
    }