Install composer package cweagans/composer-patches

Now find the bug in the code and fix it directly. When you are finished and everything is working, open the local history in PhpStorm for this file (right click > Local History > Show History). Select the change you just made and choose "Create Patch" from the context menu. Save it to a folder such as "patches" in your project.

Add the path to your patch file to composer.json and update composer.

"extra": {
	"patches": {
        "package/tofix": {
            "Short description what you did": "patches/yourpatch.patch"
        }
    }
}